diff options
| author | 2016-12-17 16:16:02 -0800 | |
|---|---|---|
| committer | 2017-01-25 18:53:25 -0800 | |
| commit | 0e9081b97348c65029c96697443acb0dbbc58756 (patch) | |
| tree | 58091caadcd6a11a96b48713c41ebf54716e1cc3 /src | |
| parent | VideoCore/Shader: Move per-batch ShaderEngine state into ShaderSetup (diff) | |
| download | yuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar.gz yuzu-0e9081b97348c65029c96697443acb0dbbc58756.tar.xz yuzu-0e9081b97348c65029c96697443acb0dbbc58756.zip | |
VideoCore/Shader: Move entry_point to SetupBatch
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/command_processor.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/shader/shader.h | 6 | ||||
| -rw-r--r-- | src/video_core/shader/shader_interpreter.cpp | 19 | ||||
| -rw-r--r-- | src/video_core/shader/shader_interpreter.h | 6 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64.h | 4 |
7 files changed, 29 insertions, 29 deletions
diff --git a/src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp index 616b34d56..f37524190 100644 --- a/src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp +++ b/src/citra_qt/debugger/graphics/graphics_vertex_shader.cpp | |||
| @@ -521,9 +521,8 @@ void GraphicsVertexShaderWidget::Reload(bool replace_vertex_data, void* vertex_d | |||
| 521 | 521 | ||
| 522 | // Generate debug information | 522 | // Generate debug information |
| 523 | Pica::Shader::InterpreterEngine shader_engine; | 523 | Pica::Shader::InterpreterEngine shader_engine; |
| 524 | shader_engine.SetupBatch(shader_setup); | 524 | shader_engine.SetupBatch(shader_setup, entry_point); |
| 525 | debug_data = | 525 | debug_data = shader_engine.ProduceDebugInfo(shader_setup, input_vertex, num_attributes); |
| 526 | shader_engine.ProduceDebugInfo(shader_setup, input_vertex, num_attributes, entry_point); | ||
| 527 | 526 | ||
| 528 | // Reload widget state | 527 | // Reload widget state |
| 529 | for (int attr = 0; attr < num_attributes; ++attr) { | 528 | for (int attr = 0; attr < num_attributes; ++attr) { |
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index c3872d06c..eb79974a8 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -143,7 +143,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 143 | immediate_attribute_id = 0; | 143 | immediate_attribute_id = 0; |
| 144 | 144 | ||
| 145 | auto* shader_engine = Shader::GetEngine(); | 145 | auto* shader_engine = Shader::GetEngine(); |
| 146 | shader_engine->SetupBatch(g_state.vs); | 146 | shader_engine->SetupBatch(g_state.vs, regs.vs.main_offset); |
| 147 | 147 | ||
| 148 | // Send to vertex shader | 148 | // Send to vertex shader |
| 149 | if (g_debug_context) | 149 | if (g_debug_context) |
| @@ -151,7 +151,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 151 | static_cast<void*>(&immediate_input)); | 151 | static_cast<void*>(&immediate_input)); |
| 152 | Shader::UnitState shader_unit; | 152 | Shader::UnitState shader_unit; |
| 153 | shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); | 153 | shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); |
| 154 | shader_engine->Run(g_state.vs, shader_unit, regs.vs.main_offset); | 154 | shader_engine->Run(g_state.vs, shader_unit); |
| 155 | auto output_vertex = Shader::OutputVertex::FromRegisters( | 155 | auto output_vertex = Shader::OutputVertex::FromRegisters( |
| 156 | shader_unit.registers.output, regs, regs.vs.output_mask); | 156 | shader_unit.registers.output, regs, regs.vs.output_mask); |
| 157 | 157 | ||
| @@ -248,7 +248,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 248 | auto* shader_engine = Shader::GetEngine(); | 248 | auto* shader_engine = Shader::GetEngine(); |
| 249 | Shader::UnitState shader_unit; | 249 | Shader::UnitState shader_unit; |
| 250 | 250 | ||
| 251 | shader_engine->SetupBatch(g_state.vs); | 251 | shader_engine->SetupBatch(g_state.vs, regs.vs.main_offset); |
| 252 | 252 | ||
| 253 | for (unsigned int index = 0; index < regs.num_vertices; ++index) { | 253 | for (unsigned int index = 0; index < regs.num_vertices; ++index) { |
| 254 | // Indexed rendering doesn't use the start offset | 254 | // Indexed rendering doesn't use the start offset |
| @@ -288,7 +288,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 288 | g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, | 288 | g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, |
| 289 | (void*)&input); | 289 | (void*)&input); |
| 290 | shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); | 290 | shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); |
| 291 | shader_engine->Run(g_state.vs, shader_unit, regs.vs.main_offset); | 291 | shader_engine->Run(g_state.vs, shader_unit); |
| 292 | 292 | ||
| 293 | // Retrieve vertex from register data | 293 | // Retrieve vertex from register data |
| 294 | output_vertex = Shader::OutputVertex::FromRegisters(shader_unit.registers.output, | 294 | output_vertex = Shader::OutputVertex::FromRegisters(shader_unit.registers.output, |
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index f26d2ba4f..44d9f76c3 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h | |||
| @@ -170,6 +170,7 @@ struct ShaderSetup { | |||
| 170 | 170 | ||
| 171 | /// Data private to ShaderEngines | 171 | /// Data private to ShaderEngines |
| 172 | struct EngineData { | 172 | struct EngineData { |
| 173 | unsigned int entry_point; | ||
| 173 | /// Used by the JIT, points to a compiled shader object. | 174 | /// Used by the JIT, points to a compiled shader object. |
| 174 | const void* cached_shader = nullptr; | 175 | const void* cached_shader = nullptr; |
| 175 | } engine_data; | 176 | } engine_data; |
| @@ -183,7 +184,7 @@ public: | |||
| 183 | * Performs any shader unit setup that only needs to happen once per shader (as opposed to once | 184 | * Performs any shader unit setup that only needs to happen once per shader (as opposed to once |
| 184 | * per vertex, which would happen within the `Run` function). | 185 | * per vertex, which would happen within the `Run` function). |
| 185 | */ | 186 | */ |
| 186 | virtual void SetupBatch(ShaderSetup& setup) = 0; | 187 | virtual void SetupBatch(ShaderSetup& setup, unsigned int entry_point) = 0; |
| 187 | 188 | ||
| 188 | /** | 189 | /** |
| 189 | * Runs the currently setup shader. | 190 | * Runs the currently setup shader. |
| @@ -191,8 +192,7 @@ public: | |||
| 191 | * @param setup Shader engine state, must be setup with SetupBatch on each shader change. | 192 | * @param setup Shader engine state, must be setup with SetupBatch on each shader change. |
| 192 | * @param state Shader unit state, must be setup with input data before each shader invocation. | 193 | * @param state Shader unit state, must be setup with input data before each shader invocation. |
| 193 | */ | 194 | */ |
| 194 | virtual void Run(const ShaderSetup& setup, UnitState& state, | 195 | virtual void Run(const ShaderSetup& setup, UnitState& state) const = 0; |
| 195 | unsigned int entry_point) const = 0; | ||
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | // TODO(yuriks): Remove and make it non-global state somewhere | 198 | // TODO(yuriks): Remove and make it non-global state somewhere |
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index e44abbf1d..c0c89b857 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp | |||
| @@ -652,32 +652,31 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData | |||
| 652 | } | 652 | } |
| 653 | } | 653 | } |
| 654 | 654 | ||
| 655 | void InterpreterEngine::SetupBatch(ShaderSetup& setup) {} | 655 | void InterpreterEngine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { |
| 656 | ASSERT(entry_point < 1024); | ||
| 657 | setup.engine_data.entry_point = entry_point; | ||
| 658 | } | ||
| 656 | 659 | ||
| 657 | MICROPROFILE_DECLARE(GPU_Shader); | 660 | MICROPROFILE_DECLARE(GPU_Shader); |
| 658 | 661 | ||
| 659 | void InterpreterEngine::Run(const ShaderSetup& setup, UnitState& state, | 662 | void InterpreterEngine::Run(const ShaderSetup& setup, UnitState& state) const { |
| 660 | unsigned int entry_point) const { | ||
| 661 | ASSERT(entry_point < 1024); | ||
| 662 | 663 | ||
| 663 | MICROPROFILE_SCOPE(GPU_Shader); | 664 | MICROPROFILE_SCOPE(GPU_Shader); |
| 664 | 665 | ||
| 665 | DebugData<false> dummy_debug_data; | 666 | DebugData<false> dummy_debug_data; |
| 666 | RunInterpreter(setup, state, dummy_debug_data, entry_point); | 667 | RunInterpreter(setup, state, dummy_debug_data, setup.engine_data.entry_point); |
| 667 | } | 668 | } |
| 668 | 669 | ||
| 669 | DebugData<true> InterpreterEngine::ProduceDebugInfo(const ShaderSetup& setup, | 670 | DebugData<true> InterpreterEngine::ProduceDebugInfo(const ShaderSetup& setup, |
| 670 | const InputVertex& input, int num_attributes, | 671 | const InputVertex& input, |
| 671 | unsigned int entry_point) const { | 672 | int num_attributes) const { |
| 672 | ASSERT(entry_point < 1024); | ||
| 673 | |||
| 674 | UnitState state; | 673 | UnitState state; |
| 675 | DebugData<true> debug_data; | 674 | DebugData<true> debug_data; |
| 676 | 675 | ||
| 677 | // Setup input register table | 676 | // Setup input register table |
| 678 | boost::fill(state.registers.input, Math::Vec4<float24>::AssignToAll(float24::Zero())); | 677 | boost::fill(state.registers.input, Math::Vec4<float24>::AssignToAll(float24::Zero())); |
| 679 | state.LoadInputVertex(input, num_attributes); | 678 | state.LoadInputVertex(input, num_attributes); |
| 680 | RunInterpreter(setup, state, debug_data, entry_point); | 679 | RunInterpreter(setup, state, debug_data, setup.engine_data.entry_point); |
| 681 | return debug_data; | 680 | return debug_data; |
| 682 | } | 681 | } |
| 683 | 682 | ||
diff --git a/src/video_core/shader/shader_interpreter.h b/src/video_core/shader/shader_interpreter.h index 7f94d405f..d6c0e2d8c 100644 --- a/src/video_core/shader/shader_interpreter.h +++ b/src/video_core/shader/shader_interpreter.h | |||
| @@ -13,8 +13,8 @@ namespace Shader { | |||
| 13 | 13 | ||
| 14 | class InterpreterEngine final : public ShaderEngine { | 14 | class InterpreterEngine final : public ShaderEngine { |
| 15 | public: | 15 | public: |
| 16 | void SetupBatch(ShaderSetup& setup) override; | 16 | void SetupBatch(ShaderSetup& setup, unsigned int entry_point) override; |
| 17 | void Run(const ShaderSetup& setup, UnitState& state, unsigned int entry_point) const override; | 17 | void Run(const ShaderSetup& setup, UnitState& state) const override; |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * Produce debug information based on the given shader and input vertex | 20 | * Produce debug information based on the given shader and input vertex |
| @@ -24,7 +24,7 @@ public: | |||
| 24 | * @return Debug information for this shader with regards to the given vertex | 24 | * @return Debug information for this shader with regards to the given vertex |
| 25 | */ | 25 | */ |
| 26 | DebugData<true> ProduceDebugInfo(const ShaderSetup& setup, const InputVertex& input, | 26 | DebugData<true> ProduceDebugInfo(const ShaderSetup& setup, const InputVertex& input, |
| 27 | int num_attributes, unsigned int entry_point) const; | 27 | int num_attributes) const; |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | } // namespace | 30 | } // namespace |
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index 15c1d60b5..0ee0dd9ef 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp | |||
| @@ -14,7 +14,10 @@ namespace Shader { | |||
| 14 | JitX64Engine::JitX64Engine() = default; | 14 | JitX64Engine::JitX64Engine() = default; |
| 15 | JitX64Engine::~JitX64Engine() = default; | 15 | JitX64Engine::~JitX64Engine() = default; |
| 16 | 16 | ||
| 17 | void JitX64Engine::SetupBatch(ShaderSetup& setup) { | 17 | void JitX64Engine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { |
| 18 | ASSERT(entry_point < 1024); | ||
| 19 | setup.engine_data.entry_point = entry_point; | ||
| 20 | |||
| 18 | u64 code_hash = Common::ComputeHash64(&setup.program_code, sizeof(setup.program_code)); | 21 | u64 code_hash = Common::ComputeHash64(&setup.program_code, sizeof(setup.program_code)); |
| 19 | u64 swizzle_hash = Common::ComputeHash64(&setup.swizzle_data, sizeof(setup.swizzle_data)); | 22 | u64 swizzle_hash = Common::ComputeHash64(&setup.swizzle_data, sizeof(setup.swizzle_data)); |
| 20 | 23 | ||
| @@ -32,14 +35,13 @@ void JitX64Engine::SetupBatch(ShaderSetup& setup) { | |||
| 32 | 35 | ||
| 33 | MICROPROFILE_DECLARE(GPU_Shader); | 36 | MICROPROFILE_DECLARE(GPU_Shader); |
| 34 | 37 | ||
| 35 | void JitX64Engine::Run(const ShaderSetup& setup, UnitState& state, unsigned int entry_point) const { | 38 | void JitX64Engine::Run(const ShaderSetup& setup, UnitState& state) const { |
| 36 | ASSERT(setup.engine_data.cached_shader != nullptr); | 39 | ASSERT(setup.engine_data.cached_shader != nullptr); |
| 37 | ASSERT(entry_point < 1024); | ||
| 38 | 40 | ||
| 39 | MICROPROFILE_SCOPE(GPU_Shader); | 41 | MICROPROFILE_SCOPE(GPU_Shader); |
| 40 | 42 | ||
| 41 | const JitShader* shader = static_cast<const JitShader*>(setup.engine_data.cached_shader); | 43 | const JitShader* shader = static_cast<const JitShader*>(setup.engine_data.cached_shader); |
| 42 | shader->Run(setup, state, entry_point); | 44 | shader->Run(setup, state, setup.engine_data.entry_point); |
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | } // namespace Shader | 47 | } // namespace Shader |
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h index bd30f51e2..078b2cba5 100644 --- a/src/video_core/shader/shader_jit_x64.h +++ b/src/video_core/shader/shader_jit_x64.h | |||
| @@ -19,8 +19,8 @@ public: | |||
| 19 | JitX64Engine(); | 19 | JitX64Engine(); |
| 20 | ~JitX64Engine() override; | 20 | ~JitX64Engine() override; |
| 21 | 21 | ||
| 22 | void SetupBatch(ShaderSetup& setup) override; | 22 | void SetupBatch(ShaderSetup& setup, unsigned int entry_point) override; |
| 23 | void Run(const ShaderSetup& setup, UnitState& state, unsigned int entry_point) const override; | 23 | void Run(const ShaderSetup& setup, UnitState& state) const override; |
| 24 | 24 | ||
| 25 | private: | 25 | private: |
| 26 | std::unordered_map<u64, std::unique_ptr<JitShader>> cache; | 26 | std::unordered_map<u64, std::unique_ptr<JitShader>> cache; |