mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-02 08:25:07 +01:00
VideoCore/Shader: Extract call lambda up a scope and remove unused param
This commit is contained in:
parent
e4e962bc7c
commit
960578f4e1
@ -42,9 +42,17 @@ template <bool Debug>
|
|||||||
void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned offset) {
|
void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned offset) {
|
||||||
// TODO: Is there a maximal size for this?
|
// TODO: Is there a maximal size for this?
|
||||||
boost::container::static_vector<CallStackElement, 16> call_stack;
|
boost::container::static_vector<CallStackElement, 16> call_stack;
|
||||||
|
|
||||||
u32 program_counter = offset;
|
u32 program_counter = offset;
|
||||||
|
|
||||||
|
auto call = [&program_counter, &call_stack](u32 offset, u32 num_instructions, u32 return_offset,
|
||||||
|
u8 repeat_count, u8 loop_increment) {
|
||||||
|
// -1 to make sure when incrementing the PC we end up at the correct offset
|
||||||
|
program_counter = offset - 1;
|
||||||
|
ASSERT(call_stack.size() < call_stack.capacity());
|
||||||
|
call_stack.push_back(
|
||||||
|
{offset + num_instructions, return_offset, repeat_count, loop_increment, offset});
|
||||||
|
};
|
||||||
|
|
||||||
const auto& uniforms = g_state.vs.uniforms;
|
const auto& uniforms = g_state.vs.uniforms;
|
||||||
const auto& swizzle_data = g_state.vs.swizzle_data;
|
const auto& swizzle_data = g_state.vs.swizzle_data;
|
||||||
const auto& program_code = g_state.vs.program_code;
|
const auto& program_code = g_state.vs.program_code;
|
||||||
@ -75,15 +83,6 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
|
|||||||
const Instruction instr = {program_code[program_counter]};
|
const Instruction instr = {program_code[program_counter]};
|
||||||
const SwizzlePattern swizzle = {swizzle_data[instr.common.operand_desc_id]};
|
const SwizzlePattern swizzle = {swizzle_data[instr.common.operand_desc_id]};
|
||||||
|
|
||||||
auto call = [&program_counter, &call_stack](UnitState<Debug>& state, u32 offset,
|
|
||||||
u32 num_instructions, u32 return_offset,
|
|
||||||
u8 repeat_count, u8 loop_increment) {
|
|
||||||
// -1 to make sure when incrementing the PC we end up at the correct offset
|
|
||||||
program_counter = offset - 1;
|
|
||||||
ASSERT(call_stack.size() < call_stack.capacity());
|
|
||||||
call_stack.push_back(
|
|
||||||
{offset + num_instructions, return_offset, repeat_count, loop_increment, offset});
|
|
||||||
};
|
|
||||||
Record<DebugDataRecord::CUR_INSTR>(state.debug, iteration, program_counter);
|
Record<DebugDataRecord::CUR_INSTR>(state.debug, iteration, program_counter);
|
||||||
if (iteration > 0)
|
if (iteration > 0)
|
||||||
Record<DebugDataRecord::NEXT_INSTR>(state.debug, iteration - 1, program_counter);
|
Record<DebugDataRecord::NEXT_INSTR>(state.debug, iteration - 1, program_counter);
|
||||||
@ -565,7 +564,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode::Id::CALL:
|
case OpCode::Id::CALL:
|
||||||
call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
||||||
program_counter + 1, 0, 0);
|
program_counter + 1, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -573,7 +572,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
|
|||||||
Record<DebugDataRecord::COND_BOOL_IN>(
|
Record<DebugDataRecord::COND_BOOL_IN>(
|
||||||
state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]);
|
state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]);
|
||||||
if (uniforms.b[instr.flow_control.bool_uniform_id]) {
|
if (uniforms.b[instr.flow_control.bool_uniform_id]) {
|
||||||
call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
||||||
program_counter + 1, 0, 0);
|
program_counter + 1, 0, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -583,7 +582,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
|
|||||||
state.conditional_code);
|
state.conditional_code);
|
||||||
if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy,
|
if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy,
|
||||||
instr.flow_control)) {
|
instr.flow_control)) {
|
||||||
call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
||||||
program_counter + 1, 0, 0);
|
program_counter + 1, 0, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -595,12 +594,11 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
|
|||||||
Record<DebugDataRecord::COND_BOOL_IN>(
|
Record<DebugDataRecord::COND_BOOL_IN>(
|
||||||
state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]);
|
state.debug, iteration, uniforms.b[instr.flow_control.bool_uniform_id]);
|
||||||
if (uniforms.b[instr.flow_control.bool_uniform_id]) {
|
if (uniforms.b[instr.flow_control.bool_uniform_id]) {
|
||||||
call(state, program_counter + 1,
|
call(program_counter + 1, instr.flow_control.dest_offset - program_counter - 1,
|
||||||
instr.flow_control.dest_offset - program_counter - 1,
|
|
||||||
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
||||||
0);
|
0);
|
||||||
} else {
|
} else {
|
||||||
call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
||||||
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
@ -614,12 +612,11 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
|
|||||||
state.conditional_code);
|
state.conditional_code);
|
||||||
if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy,
|
if (evaluate_condition(state, instr.flow_control.refx, instr.flow_control.refy,
|
||||||
instr.flow_control)) {
|
instr.flow_control)) {
|
||||||
call(state, program_counter + 1,
|
call(program_counter + 1, instr.flow_control.dest_offset - program_counter - 1,
|
||||||
instr.flow_control.dest_offset - program_counter - 1,
|
|
||||||
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
||||||
0);
|
0);
|
||||||
} else {
|
} else {
|
||||||
call(state, instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
call(instr.flow_control.dest_offset, instr.flow_control.num_instructions,
|
||||||
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
instr.flow_control.dest_offset + instr.flow_control.num_instructions, 0,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
@ -635,8 +632,7 @@ void RunInterpreter(const ShaderSetup& setup, UnitState<Debug>& state, unsigned
|
|||||||
state.address_registers[2] = loop_param.y;
|
state.address_registers[2] = loop_param.y;
|
||||||
|
|
||||||
Record<DebugDataRecord::LOOP_INT_IN>(state.debug, iteration, loop_param);
|
Record<DebugDataRecord::LOOP_INT_IN>(state.debug, iteration, loop_param);
|
||||||
call(state, program_counter + 1,
|
call(program_counter + 1, instr.flow_control.dest_offset - program_counter + 1,
|
||||||
instr.flow_control.dest_offset - program_counter + 1,
|
|
||||||
instr.flow_control.dest_offset + 1, loop_param.x, loop_param.z);
|
instr.flow_control.dest_offset + 1, loop_param.x, loop_param.z);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user