summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2015-08-24 06:46:58 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2015-08-24 06:46:58 +0200
commit082b74fa241ba71f27b2e3fdf756824a0467f7f4 (patch)
tree4bc4da888d196924e300d4f853855ac6d55fafa9
parentShader JIT: Add name to second scratch register (XMM4) (diff)
downloadyuzu-082b74fa241ba71f27b2e3fdf756824a0467f7f4.tar
yuzu-082b74fa241ba71f27b2e3fdf756824a0467f7f4.tar.gz
yuzu-082b74fa241ba71f27b2e3fdf756824a0467f7f4.tar.bz2
yuzu-082b74fa241ba71f27b2e3fdf756824a0467f7f4.tar.lz
yuzu-082b74fa241ba71f27b2e3fdf756824a0467f7f4.tar.xz
yuzu-082b74fa241ba71f27b2e3fdf756824a0467f7f4.tar.zst
yuzu-082b74fa241ba71f27b2e3fdf756824a0467f7f4.zip
-rw-r--r--src/video_core/shader/shader_interpreter.cpp10
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp2
2 files changed, 10 insertions, 2 deletions
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp
index ae5a30441..69e4efa68 100644
--- a/src/video_core/shader/shader_interpreter.cpp
+++ b/src/video_core/shader/shader_interpreter.cpp
@@ -177,7 +177,10 @@ void RunInterpreter(UnitState<Debug>& state) {
if (!swizzle.DestComponentEnabled(i))
continue;
- dest[i] = std::max(src1[i], src2[i]);
+ // NOTE: Exact form required to match NaN semantics to hardware:
+ // max(0, NaN) -> NaN
+ // max(NaN, 0) -> 0
+ dest[i] = (src1[i] > src2[i]) ? src1[i] : src2[i];
}
Record<DebugDataRecord::DEST_OUT>(state.debug, iteration, dest);
break;
@@ -190,7 +193,10 @@ void RunInterpreter(UnitState<Debug>& state) {
if (!swizzle.DestComponentEnabled(i))
continue;
- dest[i] = std::min(src1[i], src2[i]);
+ // NOTE: Exact form required to match NaN semantics to hardware:
+ // min(0, NaN) -> NaN
+ // min(NaN, 0) -> 0
+ dest[i] = (src1[i] < src2[i]) ? src1[i] : src2[i];
}
Record<DebugDataRecord::DEST_OUT>(state.debug, iteration, dest);
break;
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index e56bff2b8..456c8567d 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -467,6 +467,7 @@ void JitCompiler::Compile_FLR(Instruction instr) {
void JitCompiler::Compile_MAX(Instruction instr) {
Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
+ // SSE semantics match PICA200 ones: In case of NaN, SRC2 is returned.
MAXPS(SRC1, R(SRC2));
Compile_DestEnable(instr, SRC1);
}
@@ -474,6 +475,7 @@ void JitCompiler::Compile_MAX(Instruction instr) {
void JitCompiler::Compile_MIN(Instruction instr) {
Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
+ // SSE semantics match PICA200 ones: In case of NaN, SRC2 is returned.
MINPS(SRC1, R(SRC2));
Compile_DestEnable(instr, SRC1);
}