diff options
| author | 2014-12-16 01:20:29 +0100 | |
|---|---|---|
| committer | 2014-12-20 18:06:55 +0100 | |
| commit | b85524c760989f3d053d05df6b244b28252b2f4e (patch) | |
| tree | 00055a16904c3f20791e39e98b3e906280b3d384 /src/video_core/vertex_shader.cpp | |
| parent | Pica/VertexShader: Support negating src2. (diff) | |
| download | yuzu-b85524c760989f3d053d05df6b244b28252b2f4e.tar.gz yuzu-b85524c760989f3d053d05df6b244b28252b2f4e.tar.xz yuzu-b85524c760989f3d053d05df6b244b28252b2f4e.zip | |
Pica/VertexShader: Some cleanups using std::array.
Diffstat (limited to 'src/video_core/vertex_shader.cpp')
| -rw-r--r-- | src/video_core/vertex_shader.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp index c5c5261fe..c98c625c2 100644 --- a/src/video_core/vertex_shader.cpp +++ b/src/video_core/vertex_shader.cpp | |||
| @@ -31,8 +31,8 @@ static struct { | |||
| 31 | 31 | ||
| 32 | // TODO: Not sure where the shader binary and swizzle patterns are supposed to be loaded to! | 32 | // TODO: Not sure where the shader binary and swizzle patterns are supposed to be loaded to! |
| 33 | // For now, we just keep these local arrays around. | 33 | // For now, we just keep these local arrays around. |
| 34 | static u32 shader_memory[1024]; | 34 | static std::array<u32, 1024> shader_memory; |
| 35 | static u32 swizzle_data[1024]; | 35 | static std::array<u32, 1024> swizzle_data; |
| 36 | 36 | ||
| 37 | void SubmitShaderMemoryChange(u32 addr, u32 value) | 37 | void SubmitShaderMemoryChange(u32 addr, u32 value) |
| 38 | { | 38 | { |
| @@ -49,6 +49,17 @@ Math::Vec4<float24>& GetFloatUniform(u32 index) | |||
| 49 | return shader_uniforms.f[index]; | 49 | return shader_uniforms.f[index]; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | const std::array<u32, 1024>& GetShaderBinary() | ||
| 53 | { | ||
| 54 | return shader_memory; | ||
| 55 | } | ||
| 56 | |||
| 57 | const std::array<u32, 1024>& GetSwizzlePatterns() | ||
| 58 | { | ||
| 59 | return swizzle_data; | ||
| 60 | } | ||
| 61 | |||
| 62 | |||
| 52 | struct VertexShaderState { | 63 | struct VertexShaderState { |
| 53 | u32* program_counter; | 64 | u32* program_counter; |
| 54 | 65 | ||
| @@ -75,7 +86,7 @@ static void ProcessShaderCode(VertexShaderState& state) { | |||
| 75 | bool increment_pc = true; | 86 | bool increment_pc = true; |
| 76 | bool exit_loop = false; | 87 | bool exit_loop = false; |
| 77 | const Instruction& instr = *(const Instruction*)state.program_counter; | 88 | const Instruction& instr = *(const Instruction*)state.program_counter; |
| 78 | state.debug.max_offset = std::max<u32>(state.debug.max_offset, 1 + (state.program_counter - shader_memory)); | 89 | state.debug.max_offset = std::max<u32>(state.debug.max_offset, 1 + (state.program_counter - shader_memory.data())); |
| 79 | 90 | ||
| 80 | auto LookupSourceRegister = [&](const SourceRegister& source_reg) -> const float24* { | 91 | auto LookupSourceRegister = [&](const SourceRegister& source_reg) -> const float24* { |
| 81 | switch (source_reg.GetRegisterType()) { | 92 | switch (source_reg.GetRegisterType()) { |
| @@ -233,7 +244,7 @@ static void ProcessShaderCode(VertexShaderState& state) { | |||
| 233 | 244 | ||
| 234 | _dbg_assert_(HW_GPU, state.call_stack_pointer - state.call_stack < sizeof(state.call_stack)); | 245 | _dbg_assert_(HW_GPU, state.call_stack_pointer - state.call_stack < sizeof(state.call_stack)); |
| 235 | 246 | ||
| 236 | *++state.call_stack_pointer = state.program_counter - shader_memory; | 247 | *++state.call_stack_pointer = state.program_counter - shader_memory.data(); |
| 237 | state.program_counter = &shader_memory[instr.flow_control.dest_offset]; | 248 | state.program_counter = &shader_memory[instr.flow_control.dest_offset]; |
| 238 | break; | 249 | break; |
| 239 | 250 | ||
| @@ -305,7 +316,7 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes) | |||
| 305 | state.call_stack_pointer = &state.call_stack[0]; | 316 | state.call_stack_pointer = &state.call_stack[0]; |
| 306 | 317 | ||
| 307 | ProcessShaderCode(state); | 318 | ProcessShaderCode(state); |
| 308 | DebugUtils::DumpShader(shader_memory, state.debug.max_offset, swizzle_data, | 319 | DebugUtils::DumpShader(shader_memory.data(), state.debug.max_offset, swizzle_data.data(), |
| 309 | state.debug.max_opdesc_id, registers.vs_main_offset, | 320 | state.debug.max_opdesc_id, registers.vs_main_offset, |
| 310 | registers.vs_output_attributes); | 321 | registers.vs_output_attributes); |
| 311 | 322 | ||