From b85524c760989f3d053d05df6b244b28252b2f4e Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Tue, 16 Dec 2014 01:20:29 +0100 Subject: Pica/VertexShader: Some cleanups using std::array. --- src/video_core/vertex_shader.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/video_core/vertex_shader.cpp') diff --git a/src/video_core/vertex_shader.cpp b/src/video_core/vertex_shader.cpp index c5c5261f..c98c625c 100644 --- a/src/video_core/vertex_shader.cpp +++ b/src/video_core/vertex_shader.cpp @@ -31,8 +31,8 @@ static struct { // TODO: Not sure where the shader binary and swizzle patterns are supposed to be loaded to! // For now, we just keep these local arrays around. -static u32 shader_memory[1024]; -static u32 swizzle_data[1024]; +static std::array shader_memory; +static std::array swizzle_data; void SubmitShaderMemoryChange(u32 addr, u32 value) { @@ -49,6 +49,17 @@ Math::Vec4& GetFloatUniform(u32 index) return shader_uniforms.f[index]; } +const std::array& GetShaderBinary() +{ + return shader_memory; +} + +const std::array& GetSwizzlePatterns() +{ + return swizzle_data; +} + + struct VertexShaderState { u32* program_counter; @@ -75,7 +86,7 @@ static void ProcessShaderCode(VertexShaderState& state) { bool increment_pc = true; bool exit_loop = false; const Instruction& instr = *(const Instruction*)state.program_counter; - state.debug.max_offset = std::max(state.debug.max_offset, 1 + (state.program_counter - shader_memory)); + state.debug.max_offset = std::max(state.debug.max_offset, 1 + (state.program_counter - shader_memory.data())); auto LookupSourceRegister = [&](const SourceRegister& source_reg) -> const float24* { switch (source_reg.GetRegisterType()) { @@ -233,7 +244,7 @@ static void ProcessShaderCode(VertexShaderState& state) { _dbg_assert_(HW_GPU, state.call_stack_pointer - state.call_stack < sizeof(state.call_stack)); - *++state.call_stack_pointer = state.program_counter - shader_memory; + *++state.call_stack_pointer = state.program_counter - shader_memory.data(); state.program_counter = &shader_memory[instr.flow_control.dest_offset]; break; @@ -305,7 +316,7 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes) state.call_stack_pointer = &state.call_stack[0]; ProcessShaderCode(state); - DebugUtils::DumpShader(shader_memory, state.debug.max_offset, swizzle_data, + DebugUtils::DumpShader(shader_memory.data(), state.debug.max_offset, swizzle_data.data(), state.debug.max_opdesc_id, registers.vs_main_offset, registers.vs_output_attributes); -- cgit v1.2.3