summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Tony Wasserka2014-12-16 01:20:29 +0100
committerGravatar Tony Wasserka2014-12-20 18:06:55 +0100
commitb85524c760989f3d053d05df6b244b28252b2f4e (patch)
tree00055a16904c3f20791e39e98b3e906280b3d384 /src
parentPica/VertexShader: Support negating src2. (diff)
downloadyuzu-b85524c760989f3d053d05df6b244b28252b2f4e.tar.gz
yuzu-b85524c760989f3d053d05df6b244b28252b2f4e.tar.xz
yuzu-b85524c760989f3d053d05df6b244b28252b2f4e.zip
Pica/VertexShader: Some cleanups using std::array.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/vertex_shader.cpp21
-rw-r--r--src/video_core/vertex_shader.h3
2 files changed, 19 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.
34static u32 shader_memory[1024]; 34static std::array<u32, 1024> shader_memory;
35static u32 swizzle_data[1024]; 35static std::array<u32, 1024> swizzle_data;
36 36
37void SubmitShaderMemoryChange(u32 addr, u32 value) 37void 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
52const std::array<u32, 1024>& GetShaderBinary()
53{
54 return shader_memory;
55}
56
57const std::array<u32, 1024>& GetSwizzlePatterns()
58{
59 return swizzle_data;
60}
61
62
52struct VertexShaderState { 63struct 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
diff --git a/src/video_core/vertex_shader.h b/src/video_core/vertex_shader.h
index 2f6ff5904..be01b24d7 100644
--- a/src/video_core/vertex_shader.h
+++ b/src/video_core/vertex_shader.h
@@ -73,6 +73,9 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes);
73 73
74Math::Vec4<float24>& GetFloatUniform(u32 index); 74Math::Vec4<float24>& GetFloatUniform(u32 index);
75 75
76const std::array<u32, 1024>& GetShaderBinary();
77const std::array<u32, 1024>& GetSwizzlePatterns();
78
76} // namespace 79} // namespace
77 80
78} // namespace 81} // namespace