Fix shader-interpreter RCP/RSQ output

Handle the `-0.0` special-case
This commit is contained in:
Wunkolo 2024-03-11 18:30:33 -07:00
parent 01b2ac7555
commit 123252592b
No known key found for this signature in database

View file

@ -382,7 +382,11 @@ void PICAShader::rcp(u32 instruction) {
vec4f srcVec1 = getSourceSwizzled<1>(src1, operandDescriptor);
vec4f& destVector = getDest(dest);
f24 res = f24::fromFloat32(1.0f) / srcVec1[0];
float input = srcVec1[0].toFloat32();
if (input == -0.0f) {
input = 0.0f;
}
const f24 res = f24::fromFloat32(1.0f / input);
u32 componentMask = operandDescriptor & 0xf;
for (int i = 0; i < 4; i++) {
@ -402,7 +406,11 @@ void PICAShader::rsq(u32 instruction) {
vec4f srcVec1 = getSourceSwizzled<1>(src1, operandDescriptor);
vec4f& destVector = getDest(dest);
f24 res = f24::fromFloat32(1.0f / std::sqrt(srcVec1[0].toFloat32()));
float input = srcVec1[0].toFloat32();
if (input == -0.0f) {
input = 0.0f;
}
const f24 res = f24::fromFloat32(1.0f / std::sqrt(input));
u32 componentMask = operandDescriptor & 0xf;
for (int i = 0; i < 4; i++) {