diff options
| author | 2016-12-16 21:41:38 -0800 | |
|---|---|---|
| committer | 2017-01-25 18:53:20 -0800 | |
| commit | 34d581f2dcffa9f54e96af230a56cb01e8e2fccd (patch) | |
| tree | 5db8f302534297bf2ef9aa16e572da9866db93f1 /src | |
| parent | Merge pull request #2434 from mailwl/nfc-amiibo (diff) | |
| download | yuzu-34d581f2dcffa9f54e96af230a56cb01e8e2fccd.tar.gz yuzu-34d581f2dcffa9f54e96af230a56cb01e8e2fccd.tar.xz yuzu-34d581f2dcffa9f54e96af230a56cb01e8e2fccd.zip | |
VideoCore/Shader: Extract input vertex loading code into function
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/command_processor.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/shader/shader.cpp | 30 | ||||
| -rw-r--r-- | src/video_core/shader/shader.h | 12 |
3 files changed, 26 insertions, 22 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index ea58e9f54..36f72393b 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -149,7 +149,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 149 | if (g_debug_context) | 149 | if (g_debug_context) |
| 150 | g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, | 150 | g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, |
| 151 | static_cast<void*>(&immediate_input)); | 151 | static_cast<void*>(&immediate_input)); |
| 152 | g_state.vs.Run(shader_unit, immediate_input, regs.vs.num_input_attributes + 1); | 152 | shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); |
| 153 | g_state.vs.Run(shader_unit); | ||
| 153 | Shader::OutputVertex output_vertex = | 154 | Shader::OutputVertex output_vertex = |
| 154 | shader_unit.output_registers.ToVertex(regs.vs); | 155 | shader_unit.output_registers.ToVertex(regs.vs); |
| 155 | 156 | ||
| @@ -283,7 +284,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 283 | if (g_debug_context) | 284 | if (g_debug_context) |
| 284 | g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, | 285 | g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, |
| 285 | (void*)&input); | 286 | (void*)&input); |
| 286 | g_state.vs.Run(shader_unit, input, loader.GetNumTotalAttributes()); | 287 | shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); |
| 288 | g_state.vs.Run(shader_unit); | ||
| 287 | 289 | ||
| 288 | // Retrieve vertex from register data | 290 | // Retrieve vertex from register data |
| 289 | output_vertex = shader_unit.output_registers.ToVertex(regs.vs); | 291 | output_vertex = shader_unit.output_registers.ToVertex(regs.vs); |
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 7ae57e619..8dca9d0cb 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -76,6 +76,17 @@ OutputVertex OutputRegisters::ToVertex(const Regs::ShaderConfig& config) const { | |||
| 76 | return ret; | 76 | return ret; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | void UnitState::LoadInputVertex(const InputVertex& input, int num_attributes) { | ||
| 80 | // Setup input register table | ||
| 81 | const auto& attribute_register_map = g_state.regs.vs.input_register_map; | ||
| 82 | |||
| 83 | for (int i = 0; i < num_attributes; i++) | ||
| 84 | registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; | ||
| 85 | |||
| 86 | conditional_code[0] = false; | ||
| 87 | conditional_code[1] = false; | ||
| 88 | } | ||
| 89 | |||
| 79 | #ifdef ARCHITECTURE_x86_64 | 90 | #ifdef ARCHITECTURE_x86_64 |
| 80 | static std::unordered_map<u64, std::unique_ptr<JitShader>> shader_map; | 91 | static std::unordered_map<u64, std::unique_ptr<JitShader>> shader_map; |
| 81 | static const JitShader* jit_shader; | 92 | static const JitShader* jit_shader; |
| @@ -109,21 +120,12 @@ void ShaderSetup::Setup() { | |||
| 109 | 120 | ||
| 110 | MICROPROFILE_DEFINE(GPU_Shader, "GPU", "Shader", MP_RGB(50, 50, 240)); | 121 | MICROPROFILE_DEFINE(GPU_Shader, "GPU", "Shader", MP_RGB(50, 50, 240)); |
| 111 | 122 | ||
| 112 | void ShaderSetup::Run(UnitState& state, const InputVertex& input, int num_attributes) { | 123 | void ShaderSetup::Run(UnitState& state) { |
| 113 | auto& config = g_state.regs.vs; | 124 | auto& config = g_state.regs.vs; |
| 114 | auto& setup = g_state.vs; | 125 | auto& setup = g_state.vs; |
| 115 | 126 | ||
| 116 | MICROPROFILE_SCOPE(GPU_Shader); | 127 | MICROPROFILE_SCOPE(GPU_Shader); |
| 117 | 128 | ||
| 118 | // Setup input register table | ||
| 119 | const auto& attribute_register_map = config.input_register_map; | ||
| 120 | |||
| 121 | for (int i = 0; i < num_attributes; i++) | ||
| 122 | state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; | ||
| 123 | |||
| 124 | state.conditional_code[0] = false; | ||
| 125 | state.conditional_code[1] = false; | ||
| 126 | |||
| 127 | #ifdef ARCHITECTURE_x86_64 | 129 | #ifdef ARCHITECTURE_x86_64 |
| 128 | if (VideoCore::g_shader_jit_enabled) { | 130 | if (VideoCore::g_shader_jit_enabled) { |
| 129 | jit_shader->Run(setup, state, config.main_offset); | 131 | jit_shader->Run(setup, state, config.main_offset); |
| @@ -145,13 +147,7 @@ DebugData<true> ShaderSetup::ProduceDebugInfo(const InputVertex& input, int num_ | |||
| 145 | 147 | ||
| 146 | // Setup input register table | 148 | // Setup input register table |
| 147 | boost::fill(state.registers.input, Math::Vec4<float24>::AssignToAll(float24::Zero())); | 149 | boost::fill(state.registers.input, Math::Vec4<float24>::AssignToAll(float24::Zero())); |
| 148 | const auto& attribute_register_map = config.input_register_map; | 150 | state.LoadInputVertex(input, num_attributes); |
| 149 | for (int i = 0; i < num_attributes; i++) | ||
| 150 | state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; | ||
| 151 | |||
| 152 | state.conditional_code[0] = false; | ||
| 153 | state.conditional_code[1] = false; | ||
| 154 | |||
| 155 | RunInterpreter(setup, state, debug_data, config.main_offset); | 151 | RunInterpreter(setup, state, debug_data, config.main_offset); |
| 156 | return debug_data; | 152 | return debug_data; |
| 157 | } | 153 | } |
diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index 2b07759b9..c5d23e0ea 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h | |||
| @@ -142,6 +142,14 @@ struct UnitState { | |||
| 142 | return 0; | 142 | return 0; |
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | |||
| 146 | /** | ||
| 147 | * Loads the unit state with an input vertex. | ||
| 148 | * | ||
| 149 | * @param input Input vertex into the shader | ||
| 150 | * @param num_attributes The number of vertex shader attributes to load | ||
| 151 | */ | ||
| 152 | void LoadInputVertex(const InputVertex& input, int num_attributes); | ||
| 145 | }; | 153 | }; |
| 146 | 154 | ||
| 147 | /// Clears the shader cache | 155 | /// Clears the shader cache |
| @@ -182,10 +190,8 @@ struct ShaderSetup { | |||
| 182 | /** | 190 | /** |
| 183 | * Runs the currently setup shader | 191 | * Runs the currently setup shader |
| 184 | * @param state Shader unit state, must be setup per shader and per shader unit | 192 | * @param state Shader unit state, must be setup per shader and per shader unit |
| 185 | * @param input Input vertex into the shader | ||
| 186 | * @param num_attributes The number of vertex shader attributes | ||
| 187 | */ | 193 | */ |
| 188 | void Run(UnitState& state, const InputVertex& input, int num_attributes); | 194 | void Run(UnitState& state); |
| 189 | 195 | ||
| 190 | /** | 196 | /** |
| 191 | * Produce debug information based on the given shader and input vertex | 197 | * Produce debug information based on the given shader and input vertex |