From fa552f11ef1f96afab715c9653c705e3fbbe2a74 Mon Sep 17 00:00:00 2001 From: aroulin Date: Sun, 23 Aug 2015 15:13:36 +0200 Subject: Shader: RCP and RSQ computes only the 1st component --- src/video_core/shader/shader_interpreter.cpp | 10 ++++------ src/video_core/shader/shader_jit_x64.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 063cc38f0..51fee6f97 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -221,13 +221,12 @@ void RunInterpreter(UnitState& state) { { Record(state.debug, iteration, src1); Record(state.debug, iteration, dest); + float24 rcp_res = float24::FromFloat32(1.0f / src1[0].ToFloat32()); for (int i = 0; i < 4; ++i) { if (!swizzle.DestComponentEnabled(i)) continue; - // TODO: Be stable against division by zero! - // TODO: I think this might be wrong... we should only use one component here - dest[i] = float24::FromFloat32(1.0f / src1[i].ToFloat32()); + dest[i] = rcp_res; } Record(state.debug, iteration, dest); break; @@ -238,13 +237,12 @@ void RunInterpreter(UnitState& state) { { Record(state.debug, iteration, src1); Record(state.debug, iteration, dest); + float24 rsq_res = float24::FromFloat32(1.0f / sqrt(src1[0].ToFloat32())); for (int i = 0; i < 4; ++i) { if (!swizzle.DestComponentEnabled(i)) continue; - // TODO: Be stable against division by zero! - // TODO: I think this might be wrong... we should only use one component here - dest[i] = float24::FromFloat32(1.0f / sqrt(src1[i].ToFloat32())); + dest[i] = rsq_res; } Record(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 a1bdd8456..e52fe43fb 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp @@ -496,9 +496,10 @@ void JitCompiler::Compile_MOV(Instruction instr) { void JitCompiler::Compile_RCP(Instruction instr) { Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); - // TODO(bunnei): RCPPS is a pretty rough approximation, this might cause problems if Pica + // TODO(bunnei): RCPSS is a pretty rough approximation, this might cause problems if Pica // performs this operation more accurately. This should be checked on hardware. - RCPPS(SRC1, R(SRC1)); + RCPSS(SRC1, R(SRC1)); + SHUFPS(SRC1, R(SRC1), _MM_SHUFFLE(0, 0, 0, 0)); // XYWZ -> XXXX Compile_DestEnable(instr, SRC1); } @@ -506,9 +507,10 @@ void JitCompiler::Compile_RCP(Instruction instr) { void JitCompiler::Compile_RSQ(Instruction instr) { Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); - // TODO(bunnei): RSQRTPS is a pretty rough approximation, this might cause problems if Pica + // TODO(bunnei): RSQRTSS is a pretty rough approximation, this might cause problems if Pica // performs this operation more accurately. This should be checked on hardware. - RSQRTPS(SRC1, R(SRC1)); + RSQRTSS(SRC1, R(SRC1)); + SHUFPS(SRC1, R(SRC1), _MM_SHUFFLE(0, 0, 0, 0)); // XYWZ -> XXXX Compile_DestEnable(instr, SRC1); } -- cgit v1.2.3 From 03c5cfead4a6ad75097e736062b25f9a7e6082cd Mon Sep 17 00:00:00 2001 From: aroulin Date: Sun, 23 Aug 2015 22:03:07 +0200 Subject: Shader: Use std::sqrt for float instead of sqrt --- src/video_core/shader/shader_interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/video_core') diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 51fee6f97..76fda95f3 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -237,7 +237,7 @@ void RunInterpreter(UnitState& state) { { Record(state.debug, iteration, src1); Record(state.debug, iteration, dest); - float24 rsq_res = float24::FromFloat32(1.0f / sqrt(src1[0].ToFloat32())); + float24 rsq_res = float24::FromFloat32(1.0f / std::sqrt(src1[0].ToFloat32())); for (int i = 0; i < 4; ++i) { if (!swizzle.DestComponentEnabled(i)) continue; -- cgit v1.2.3