gl_shader_decompiler: some small fixes
- remove unnecessary ";" - use std::tie for lexicographical ordering - simplify loop condition The offset always has step +1 on each iteration, so it would just hit one of the two boundary anyway
This commit is contained in:
parent
f8a292f920
commit
4991b15ee5
|
@ -42,10 +42,7 @@ struct Subroutine {
|
||||||
std::set<u32> labels; ///< Addresses refereced by JMP instructions.
|
std::set<u32> labels; ///< Addresses refereced by JMP instructions.
|
||||||
|
|
||||||
bool operator<(const Subroutine& rhs) const {
|
bool operator<(const Subroutine& rhs) const {
|
||||||
if (begin == rhs.begin) {
|
return std::tie(begin, end) < std::tie(rhs.begin, rhs.end);
|
||||||
return end < rhs.end;
|
|
||||||
}
|
|
||||||
return begin < rhs.begin;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,8 +119,7 @@ private:
|
||||||
if (!inserted)
|
if (!inserted)
|
||||||
return exit_method;
|
return exit_method;
|
||||||
|
|
||||||
u32 offset = begin;
|
for (u32 offset = begin; offset != end && offset != PROGRAM_END; ++offset) {
|
||||||
for (u32 offset = begin; offset < (begin > end ? PROGRAM_END : end); ++offset) {
|
|
||||||
const Instruction instr = {program_code[offset]};
|
const Instruction instr = {program_code[offset]};
|
||||||
switch (instr.opcode.Value()) {
|
switch (instr.opcode.Value()) {
|
||||||
case OpCode::Id::END: {
|
case OpCode::Id::END: {
|
||||||
|
@ -294,7 +290,7 @@ private:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/// Generates code representing a source register.
|
/// Generates code representing a source register.
|
||||||
std::string GetSourceRegister(const SourceRegister& source_reg,
|
std::string GetSourceRegister(const SourceRegister& source_reg,
|
||||||
|
@ -317,7 +313,7 @@ private:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/// Generates code representing a destination register.
|
/// Generates code representing a destination register.
|
||||||
std::string GetDestRegister(const DestRegister& dest_reg) const {
|
std::string GetDestRegister(const DestRegister& dest_reg) const {
|
||||||
|
@ -332,7 +328,7 @@ private:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/// Generates code representing a bool uniform
|
/// Generates code representing a bool uniform
|
||||||
std::string GetUniformBool(u32 index) const {
|
std::string GetUniformBool(u32 index) const {
|
||||||
|
@ -341,7 +337,7 @@ private:
|
||||||
return "((gl_PrimitiveIDIn == 0) || uniforms.b[15])";
|
return "((gl_PrimitiveIDIn == 0) || uniforms.b[15])";
|
||||||
}
|
}
|
||||||
return "uniforms.b[" + std::to_string(index) + "]";
|
return "uniforms.b[" + std::to_string(index) + "]";
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds code that calls a subroutine.
|
* Adds code that calls a subroutine.
|
||||||
|
@ -356,7 +352,7 @@ private:
|
||||||
} else {
|
} else {
|
||||||
shader.AddLine(subroutine.GetName() + "();");
|
shader.AddLine(subroutine.GetName() + "();");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes code that does an assignment operation.
|
* Writes code that does an assignment operation.
|
||||||
|
@ -395,7 +391,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
shader.AddLine(dest + " = " + src + ";");
|
shader.AddLine(dest + " = " + src + ";");
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles a single instruction from PICA to GLSL.
|
* Compiles a single instruction from PICA to GLSL.
|
||||||
|
@ -769,7 +765,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return offset + 1;
|
return offset + 1;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles a range of instructions from PICA to GLSL.
|
* Compiles a range of instructions from PICA to GLSL.
|
||||||
|
@ -783,7 +779,7 @@ private:
|
||||||
program_counter = CompileInstr(program_counter);
|
program_counter = CompileInstr(program_counter);
|
||||||
}
|
}
|
||||||
return program_counter;
|
return program_counter;
|
||||||
};
|
}
|
||||||
|
|
||||||
void Generate() {
|
void Generate() {
|
||||||
if (sanitize_mul) {
|
if (sanitize_mul) {
|
||||||
|
|
Loading…
Reference in New Issue