yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

ShaderGen: Ignore the 'sched' instruction when generating shaders.

The 'sched' instruction has a very convoluted encoding, but fortunately it seems to only appear on a fixed interval (once every 4 instructions).
This commit is contained in:
Subv 2018-04-20 09:02:28 -05:00
parent 326b044c19
commit 2e0a9f66a0
1 changed files with 16 additions and 0 deletions

View File

@ -276,6 +276,18 @@ private:
shader.AddLine(dest + " = " + src + ";"); shader.AddLine(dest + " = " + src + ";");
} }
/*
* Returns whether the instruction at the specified offset is a 'sched' instruction.
* Sched instructions always appear before a sequence of 3 instructions.
*/
bool IsSchedInstruction(u32 offset) const {
// sched instructions appear once every 4 instructions.
static constexpr size_t SchedPeriod = 4;
u32 absolute_offset = offset - main_offset;
return (absolute_offset % SchedPeriod) == 0;
}
/** /**
* Compiles a single instruction from Tegra to GLSL. * Compiles a single instruction from Tegra to GLSL.
* @param offset the offset of the Tegra shader instruction. * @param offset the offset of the Tegra shader instruction.
@ -283,6 +295,10 @@ private:
* + 1. If the current instruction always terminates the program, returns PROGRAM_END. * + 1. If the current instruction always terminates the program, returns PROGRAM_END.
*/ */
u32 CompileInstr(u32 offset) { u32 CompileInstr(u32 offset) {
// Ignore sched instructions when generating code.
if (IsSchedInstruction(offset))
return offset + 1;
const Instruction instr = {program_code[offset]}; const Instruction instr = {program_code[offset]};
shader.AddLine("// " + std::to_string(offset) + ": " + OpCode::GetInfo(instr.opcode).name); shader.AddLine("// " + std::to_string(offset) + ": " + OpCode::GetInfo(instr.opcode).name);