diff options
| author | 2018-01-11 20:07:44 -0700 | |
|---|---|---|
| committer | 2018-01-12 19:11:03 -0700 | |
| commit | 1d28b2e142f845773e2b90e267d9632e196a99b9 (patch) | |
| tree | 027a3586a0fc927731afb3711c328c6dafc8551f /src/video_core/shader/shader.cpp | |
| parent | Massive removal of unused modules (diff) | |
| download | yuzu-1d28b2e142f845773e2b90e267d9632e196a99b9.tar.gz yuzu-1d28b2e142f845773e2b90e267d9632e196a99b9.tar.xz yuzu-1d28b2e142f845773e2b90e267d9632e196a99b9.zip | |
Remove references to PICA and rasterizers in video_core
Diffstat (limited to 'src/video_core/shader/shader.cpp')
| -rw-r--r-- | src/video_core/shader/shader.cpp | 154 |
1 files changed, 0 insertions, 154 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp deleted file mode 100644 index 2857d2829..000000000 --- a/src/video_core/shader/shader.cpp +++ /dev/null | |||
| @@ -1,154 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cmath> | ||
| 6 | #include <cstring> | ||
| 7 | #include "common/bit_set.h" | ||
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "common/microprofile.h" | ||
| 10 | #include "video_core/pica_state.h" | ||
| 11 | #include "video_core/regs_rasterizer.h" | ||
| 12 | #include "video_core/regs_shader.h" | ||
| 13 | #include "video_core/shader/shader.h" | ||
| 14 | #include "video_core/shader/shader_interpreter.h" | ||
| 15 | #ifdef ARCHITECTURE_x86_64 | ||
| 16 | #include "video_core/shader/shader_jit_x64.h" | ||
| 17 | #endif // ARCHITECTURE_x86_64 | ||
| 18 | #include "video_core/video_core.h" | ||
| 19 | |||
| 20 | namespace Pica { | ||
| 21 | |||
| 22 | namespace Shader { | ||
| 23 | |||
| 24 | OutputVertex OutputVertex::FromAttributeBuffer(const RasterizerRegs& regs, | ||
| 25 | const AttributeBuffer& input) { | ||
| 26 | // Setup output data | ||
| 27 | union { | ||
| 28 | OutputVertex ret{}; | ||
| 29 | std::array<float24, 24> vertex_slots; | ||
| 30 | }; | ||
| 31 | static_assert(sizeof(vertex_slots) == sizeof(ret), "Struct and array have different sizes."); | ||
| 32 | |||
| 33 | unsigned int num_attributes = regs.vs_output_total; | ||
| 34 | ASSERT(num_attributes <= 7); | ||
| 35 | for (unsigned int i = 0; i < num_attributes; ++i) { | ||
| 36 | const auto& output_register_map = regs.vs_output_attributes[i]; | ||
| 37 | |||
| 38 | RasterizerRegs::VSOutputAttributes::Semantic semantics[4] = { | ||
| 39 | output_register_map.map_x, output_register_map.map_y, output_register_map.map_z, | ||
| 40 | output_register_map.map_w}; | ||
| 41 | |||
| 42 | for (unsigned comp = 0; comp < 4; ++comp) { | ||
| 43 | RasterizerRegs::VSOutputAttributes::Semantic semantic = semantics[comp]; | ||
| 44 | if (semantic < vertex_slots.size()) { | ||
| 45 | vertex_slots[semantic] = input.attr[i][comp]; | ||
| 46 | } else if (semantic != RasterizerRegs::VSOutputAttributes::INVALID) { | ||
| 47 | LOG_ERROR(HW_GPU, "Invalid/unknown semantic id: %u", (unsigned int)semantic); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | // The hardware takes the absolute and saturates vertex colors like this, *before* doing | ||
| 53 | // interpolation | ||
| 54 | for (unsigned i = 0; i < 4; ++i) { | ||
| 55 | float c = std::fabs(ret.color[i].ToFloat32()); | ||
| 56 | ret.color[i] = float24::FromFloat32(c < 1.0f ? c : 1.0f); | ||
| 57 | } | ||
| 58 | |||
| 59 | LOG_TRACE(HW_GPU, "Output vertex: pos(%.2f, %.2f, %.2f, %.2f), quat(%.2f, %.2f, %.2f, %.2f), " | ||
| 60 | "col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f), view(%.2f, %.2f, %.2f)", | ||
| 61 | ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), | ||
| 62 | ret.pos.w.ToFloat32(), ret.quat.x.ToFloat32(), ret.quat.y.ToFloat32(), | ||
| 63 | ret.quat.z.ToFloat32(), ret.quat.w.ToFloat32(), ret.color.x.ToFloat32(), | ||
| 64 | ret.color.y.ToFloat32(), ret.color.z.ToFloat32(), ret.color.w.ToFloat32(), | ||
| 65 | ret.tc0.u().ToFloat32(), ret.tc0.v().ToFloat32(), ret.view.x.ToFloat32(), | ||
| 66 | ret.view.y.ToFloat32(), ret.view.z.ToFloat32()); | ||
| 67 | |||
| 68 | return ret; | ||
| 69 | } | ||
| 70 | |||
| 71 | void UnitState::LoadInput(const ShaderRegs& config, const AttributeBuffer& input) { | ||
| 72 | const unsigned max_attribute = config.max_input_attribute_index; | ||
| 73 | |||
| 74 | for (unsigned attr = 0; attr <= max_attribute; ++attr) { | ||
| 75 | unsigned reg = config.GetRegisterForAttribute(attr); | ||
| 76 | registers.input[reg] = input.attr[attr]; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | void UnitState::WriteOutput(const ShaderRegs& config, AttributeBuffer& output) { | ||
| 81 | unsigned int output_i = 0; | ||
| 82 | for (unsigned int reg : Common::BitSet<u32>(config.output_mask)) { | ||
| 83 | output.attr[output_i++] = registers.output[reg]; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | UnitState::UnitState(GSEmitter* emitter) : emitter_ptr(emitter) {} | ||
| 88 | |||
| 89 | GSEmitter::GSEmitter() { | ||
| 90 | handlers = new Handlers; | ||
| 91 | } | ||
| 92 | |||
| 93 | GSEmitter::~GSEmitter() { | ||
| 94 | delete handlers; | ||
| 95 | } | ||
| 96 | |||
| 97 | void GSEmitter::Emit(Math::Vec4<float24> (&vertex)[16]) { | ||
| 98 | ASSERT(vertex_id < 3); | ||
| 99 | std::copy(std::begin(vertex), std::end(vertex), buffer[vertex_id].begin()); | ||
| 100 | if (prim_emit) { | ||
| 101 | if (winding) | ||
| 102 | handlers->winding_setter(); | ||
| 103 | for (size_t i = 0; i < buffer.size(); ++i) { | ||
| 104 | AttributeBuffer output; | ||
| 105 | unsigned int output_i = 0; | ||
| 106 | for (unsigned int reg : Common::BitSet<u32>(output_mask)) { | ||
| 107 | output.attr[output_i++] = buffer[i][reg]; | ||
| 108 | } | ||
| 109 | handlers->vertex_handler(output); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | GSUnitState::GSUnitState() : UnitState(&emitter) {} | ||
| 115 | |||
| 116 | void GSUnitState::SetVertexHandler(VertexHandler vertex_handler, WindingSetter winding_setter) { | ||
| 117 | emitter.handlers->vertex_handler = std::move(vertex_handler); | ||
| 118 | emitter.handlers->winding_setter = std::move(winding_setter); | ||
| 119 | } | ||
| 120 | |||
| 121 | void GSUnitState::ConfigOutput(const ShaderRegs& config) { | ||
| 122 | emitter.output_mask = config.output_mask; | ||
| 123 | } | ||
| 124 | |||
| 125 | MICROPROFILE_DEFINE(GPU_Shader, "GPU", "Shader", MP_RGB(50, 50, 240)); | ||
| 126 | |||
| 127 | #ifdef ARCHITECTURE_x86_64 | ||
| 128 | static std::unique_ptr<JitX64Engine> jit_engine; | ||
| 129 | #endif // ARCHITECTURE_x86_64 | ||
| 130 | static InterpreterEngine interpreter_engine; | ||
| 131 | |||
| 132 | ShaderEngine* GetEngine() { | ||
| 133 | #ifdef ARCHITECTURE_x86_64 | ||
| 134 | // TODO(yuriks): Re-initialize on each change rather than being persistent | ||
| 135 | if (VideoCore::g_shader_jit_enabled) { | ||
| 136 | if (jit_engine == nullptr) { | ||
| 137 | jit_engine = std::make_unique<JitX64Engine>(); | ||
| 138 | } | ||
| 139 | return jit_engine.get(); | ||
| 140 | } | ||
| 141 | #endif // ARCHITECTURE_x86_64 | ||
| 142 | |||
| 143 | return &interpreter_engine; | ||
| 144 | } | ||
| 145 | |||
| 146 | void Shutdown() { | ||
| 147 | #ifdef ARCHITECTURE_x86_64 | ||
| 148 | jit_engine = nullptr; | ||
| 149 | #endif // ARCHITECTURE_x86_64 | ||
| 150 | } | ||
| 151 | |||
| 152 | } // namespace Shader | ||
| 153 | |||
| 154 | } // namespace Pica | ||