summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2016-12-15 23:04:44 -0800
committerGravatar Yuri Kunde Schlesner2016-12-15 23:08:05 -0800
commit960578f4e12fbd958d06a476e900e4939cc7a648 (patch)
tree6dac011c2436bda59e441a81a3bfbb02fa8f57c3 /src
parentVideoCore/Shader: Remove dynamic control flow in (Get)UniformOffset (diff)
downloadyuzu-960578f4e12fbd958d06a476e900e4939cc7a648.tar.gz
yuzu-960578f4e12fbd958d06a476e900e4939cc7a648.tar.xz
yuzu-960578f4e12fbd958d06a476e900e4939cc7a648.zip
VideoCore/Shader: Extract call lambda up a scope and remove unused param
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader_interpreter.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp
index 167f9edc3..46e997f9f 100644
--- a/src/video_core/shader/shader_interpreter.cpp
+++ b/src/video_core/shader/shader_interpreter.cpp
@@ -42,9 +42,17 @@ template <bool Debug>
42void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned offset) { 42void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned offset) {
43 // TODO: Is there a maximal size for this? 43 // TODO: Is there a maximal size for this?
44 boost::container::static_vector<CallStackElement, 16> call_stack; 44 boost::container::static_vector<CallStackElement, 16> call_stack;
45
46 u32 program_counter = offset; 45 u32 program_counter = offset;
47 46
47 auto call = [&program_counter, &call_stack](u32 offset, u32 num_instructions, u32 return_offset,
48 u8 repeat_count, u8 loop_increment) {
49 // -1 to make sure when incrementing the PC we end up at the correct offset
50 program_counter = offset - 1;
51 ASSERT(call_stack.size() < call_stack.capacity());
52 call_stack.push_back(
53 {offset + num_instructions, return_offset, repeat_count, loop_increment, offset});
54 };
55
48 const auto& uniforms = g_state.vs.uniforms; 56 const auto& uniforms = g_state.vs.uniforms;
49 const auto& swizzle_data = g_state.vs.swizzle_data; 57 const auto& swizzle_data = g_state.vs.swizzle_data;
50 const auto& program_code = g_state.vs.program_code; 58 const auto& program_code = g_state.vs.program_code;
@@ -75,15 +83,6 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
75 const Instruction instr = {program_code[program_counter]}; 83 const Instruction instr = {program_code[program_counter]};
76 const SwizzlePattern swizzle = {swizzle_data[instr.common.operand_desc_id]}; 84 const SwizzlePattern swizzle = {swizzle_data[instr.common.operand_desc_id]};
77 85
78 auto call = [&program_counter, &call_stack](UnitState<Debug>& state, u32 offset,
79 u32 num_instructions, u32 return_offset,
80 u8 repeat_count, u8 loop_increment) {
81 // -1 to make sure when incrementing the PC we end up at the correct offset
82 program_counter = offset - 1;
83 ASSERT(call_stack.size() < call_stack.capacity());
84 call_stack.push_back(
85 {offset + num_instructions, return_offset, repeat_count, loop_increment, offset});
86 };
87 Record<DebugDataRecord::CUR_INSTR>(state.debug, iteration, program_counter); 86 Record<DebugDataRecord::CUR_INSTR>(state.debug, iteration, program_counter);
88 if (iteration > 0) 87 if (iteration > 0)
89 Record<DebugDataRecord::NEXT_INSTR>(state.debug, iteration - 1, program_counter); 88 Record<DebugDataRecord::NEXT_INSTR>(state.debug, iteration - 1, program_counter);
@@ -565,7 +564,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
565 break; 564 break;
566 565
567 case OpCode::Id::CALL: 566 case OpCode::Id::CALL:
568 call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions, 567 call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
569 program_counter + 1, 0, 0); 568 program_counter + 1, 0, 0);
570 break; 569 break;
571 570
@@ -573,7 +572,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
573 Record<DebugDataRecord::COND_BOOL_IN>( 572 Record<DebugDataRecord::COND_BOOL_IN>(
574 state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]); 573 state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]);
575 if (uniforms.b[instr.flow_control.bool_uniform_id]) { 574 if (uniforms.b[instr.flow_control.bool_uniform_id]) {
576 call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions, 575 call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
577 program_counter + 1, 0, 0); 576 program_counter + 1, 0, 0);
578 } 577 }
579 break; 578 break;
@@ -583,7 +582,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
583 state.conditional_code); 582 state.conditional_code);
584 if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy, 583 if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy,
585 instr.flow_control)) { 584 instr.flow_control)) {
586 call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions, 585 call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
587 program_counter + 1, 0, 0); 586 program_counter + 1, 0, 0);
588 } 587 }
589 break; 588 break;
@@ -595,12 +594,11 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
595 Record<DebugDataRecord::COND_BOOL_IN>( 594 Record<DebugDataRecord::COND_BOOL_IN>(
596 state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]); 595 state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]);
597 if (uniforms.b[instr.flow_control.bool_uniform_id]) { 596 if (uniforms.b[instr.flow_control.bool_uniform_id]) {
598 call(state, program_counter + 1, 597 call(program_counter + 1, instr.flow_control.dest_offset - program_counter - 1,
599 instr.flow_control.dest_offset - program_counter - 1,
600 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0, 598 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
601 0); 599 0);
602 } else { 600 } else {
603 call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions, 601 call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
604 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0, 602 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
605 0); 603 0);
606 } 604 }
@@ -614,12 +612,11 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
614 state.conditional_code); 612 state.conditional_code);
615 if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy, 613 if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy,
616 instr.flow_control)) { 614 instr.flow_control)) {
617 call(state, program_counter + 1, 615 call(program_counter + 1, instr.flow_control.dest_offset - program_counter - 1,
618 instr.flow_control.dest_offset - program_counter - 1,
619 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0, 616 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
620 0); 617 0);
621 } else { 618 } else {
622 call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions, 619 call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
623 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0, 620 instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
624 0); 621 0);
625 } 622 }
@@ -635,8 +632,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
635 state.address_registers[2] = loop_param.y; 632 state.address_registers[2] = loop_param.y;
636 633
637 Record<DebugDataRecord::LOOP_INT_IN>(state.debug, iteration, loop_param); 634 Record<DebugDataRecord::LOOP_INT_IN>(state.debug, iteration, loop_param);
638 call(state, program_counter + 1, 635 call(program_counter + 1, instr.flow_control.dest_offset - program_counter + 1,
639 instr.flow_control.dest_offset - program_counter + 1,
640 instr.flow_control.dest_offset + 1, loop_param.x, loop_param.z); 636 instr.flow_control.dest_offset + 1, loop_param.x, loop_param.z);
641 break; 637 break;
642 } 638 }