shader_jit_x64: Execute certain asserts at runtime.
- This is because we compile the full shader code space, and therefore its common to compile malformed instructions.
This commit is contained in:
parent
ffcf7ecee9
commit
f3afe24594
|
@ -146,6 +146,16 @@ static Instruction GetVertexShaderInstruction(size_t offset) {
|
||||||
return { g_state.vs.program_code[offset] };
|
return { g_state.vs.program_code[offset] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void LogCritical(const char* msg) {
|
||||||
|
LOG_CRITICAL(HW_GPU, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JitCompiler::RuntimeAssert(bool condition, const char* msg) {
|
||||||
|
if (!condition) {
|
||||||
|
ABI_CallFunctionP(reinterpret_cast<const void*>(LogCritical), const_cast<char*>(msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads and swizzles a source register into the specified XMM register.
|
* Loads and swizzles a source register into the specified XMM register.
|
||||||
* @param instr VS instruction, used for determining how to load the source register
|
* @param instr VS instruction, used for determining how to load the source register
|
||||||
|
@ -667,8 +677,7 @@ void JitCompiler::Compile_MAD(Instruction instr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void JitCompiler::Compile_IF(Instruction instr) {
|
void JitCompiler::Compile_IF(Instruction instr) {
|
||||||
ASSERT_MSG(instr.flow_control.dest_offset > last_program_counter, "Backwards if-statements (%d -> %d) not supported",
|
RuntimeAssert(instr.flow_control.dest_offset > last_program_counter, "Backwards if-statements not supported");
|
||||||
last_program_counter, instr.flow_control.dest_offset.Value());
|
|
||||||
|
|
||||||
// Evaluate the "IF" condition
|
// Evaluate the "IF" condition
|
||||||
if (instr.opcode.Value() == OpCode::Id::IFU) {
|
if (instr.opcode.Value() == OpCode::Id::IFU) {
|
||||||
|
@ -699,9 +708,8 @@ void JitCompiler::Compile_IF(Instruction instr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void JitCompiler::Compile_LOOP(Instruction instr) {
|
void JitCompiler::Compile_LOOP(Instruction instr) {
|
||||||
ASSERT_MSG(instr.flow_control.dest_offset > last_program_counter, "Backwards loops (%d -> %d) not supported",
|
RuntimeAssert(instr.flow_control.dest_offset > last_program_counter, "Backwards loops not supported");
|
||||||
last_program_counter, instr.flow_control.dest_offset.Value());
|
RuntimeAssert(!looping, "Nested loops not supported");
|
||||||
ASSERT_MSG(!looping, "Nested loops not supported");
|
|
||||||
|
|
||||||
looping = true;
|
looping = true;
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,12 @@ private:
|
||||||
|
|
||||||
BitSet32 PersistentCallerSavedRegs();
|
BitSet32 PersistentCallerSavedRegs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assertion evaluated at compile-time, but only triggered if executed at runtime.
|
||||||
|
* @param msg Message to be logged if the assertion fails.
|
||||||
|
*/
|
||||||
|
void RuntimeAssert(bool condition, const char* msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyzes the entire shader program for `CALL` instructions before emitting any code,
|
* Analyzes the entire shader program for `CALL` instructions before emitting any code,
|
||||||
* identifying the locations where a return needs to be inserted.
|
* identifying the locations where a return needs to be inserted.
|
||||||
|
|
Loading…
Reference in New Issue