summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2016-04-02 00:02:03 -0400
committerGravatar bunnei2016-04-13 23:04:49 -0400
commitf3afe24594bad11d7e0fd28902d1ce1e6e22e3a2 (patch)
tree32a252926d4679f68fbae537a129a0dc92e96f58 /src
parentshader: Remove unused 'state' argument from 'Setup' function. (diff)
downloadyuzu-f3afe24594bad11d7e0fd28902d1ce1e6e22e3a2.tar.gz
yuzu-f3afe24594bad11d7e0fd28902d1ce1e6e22e3a2.tar.xz
yuzu-f3afe24594bad11d7e0fd28902d1ce1e6e22e3a2.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp18
-rw-r--r--src/video_core/shader/shader_jit_x64.h6
2 files changed, 19 insertions, 5 deletions
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index cbdc1e40f..dda9bcef7 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -146,6 +146,16 @@ static Instruction GetVertexShaderInstruction(size_t offset) {
146 return { g_state.vs.program_code[offset] }; 146 return { g_state.vs.program_code[offset] };
147} 147}
148 148
149static void LogCritical(const char* msg) {
150 LOG_CRITICAL(HW_GPU, msg);
151}
152
153void JitCompiler::RuntimeAssert(bool condition, const char* msg) {
154 if (!condition) {
155 ABI_CallFunctionP(reinterpret_cast<const void*>(LogCritical), const_cast<char*>(msg));
156 }
157}
158
149/** 159/**
150 * Loads and swizzles a source register into the specified XMM register. 160 * Loads and swizzles a source register into the specified XMM register.
151 * @param instr VS instruction, used for determining how to load the source register 161 * @param instr VS instruction, used for determining how to load the source register
@@ -667,8 +677,7 @@ void JitCompiler::Compile_MAD(Instruction instr) {
667} 677}
668 678
669void JitCompiler::Compile_IF(Instruction instr) { 679void JitCompiler::Compile_IF(Instruction instr) {
670 ASSERT_MSG(instr.flow_control.dest_offset > last_program_counter, "Backwards if-statements (%d -> %d) not supported", 680 RuntimeAssert(instr.flow_control.dest_offset > last_program_counter, "Backwards if-statements not supported");
671 last_program_counter, instr.flow_control.dest_offset.Value());
672 681
673 // Evaluate the "IF" condition 682 // Evaluate the "IF" condition
674 if (instr.opcode.Value() == OpCode::Id::IFU) { 683 if (instr.opcode.Value() == OpCode::Id::IFU) {
@@ -699,9 +708,8 @@ void JitCompiler::Compile_IF(Instruction instr) {
699} 708}
700 709
701void JitCompiler::Compile_LOOP(Instruction instr) { 710void JitCompiler::Compile_LOOP(Instruction instr) {
702 ASSERT_MSG(instr.flow_control.dest_offset > last_program_counter, "Backwards loops (%d -> %d) not supported", 711 RuntimeAssert(instr.flow_control.dest_offset > last_program_counter, "Backwards loops not supported");
703 last_program_counter, instr.flow_control.dest_offset.Value()); 712 RuntimeAssert(!looping, "Nested loops not supported");
704 ASSERT_MSG(!looping, "Nested loops not supported");
705 713
706 looping = true; 714 looping = true;
707 715
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h
index 1501d13bf..159b902b2 100644
--- a/src/video_core/shader/shader_jit_x64.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -91,6 +91,12 @@ private:
91 BitSet32 PersistentCallerSavedRegs(); 91 BitSet32 PersistentCallerSavedRegs();
92 92
93 /** 93 /**
94 * Assertion evaluated at compile-time, but only triggered if executed at runtime.
95 * @param msg Message to be logged if the assertion fails.
96 */
97 void RuntimeAssert(bool condition, const char* msg);
98
99 /**
94 * Analyzes the entire shader program for `CALL` instructions before emitting any code, 100 * Analyzes the entire shader program for `CALL` instructions before emitting any code,
95 * identifying the locations where a return needs to be inserted. 101 * identifying the locations where a return needs to be inserted.
96 */ 102 */