Skip to content

Commit

Permalink
hotfix: Fix cube instructions nvidia Gpus atm #3125
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolix29 committed Jan 11, 2025
1 parent d72562c commit 6806e20
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/shader_recompiler/frontend/translate/vector_alu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,9 +1069,9 @@ void Translator::V_CUBEID_F32(const GcnInst& inst) {
const auto x_neg_cond{ir.FPLessThan(x, ir.Imm32(0.f))};
const auto y_neg_cond{ir.FPLessThan(y, ir.Imm32(0.f))};
const auto z_neg_cond{ir.FPLessThan(z, ir.Imm32(0.f))};
const IR::F32 x_face{ir.Select(x_neg_cond, ir.Imm32(5.f), ir.Imm32(4.f))};
const IR::F32 x_face{ir.Select(x_neg_cond, ir.Imm32(1.f), ir.Imm32(0.f))};
const IR::F32 y_face{ir.Select(y_neg_cond, ir.Imm32(3.f), ir.Imm32(2.f))};
const IR::F32 z_face{ir.Select(z_neg_cond, ir.Imm32(1.f), ir.Imm32(0.f))};
const IR::F32 z_face{ir.Select(z_neg_cond, ir.Imm32(5.f), ir.Imm32(4.f))};

result = SelectCubeResult(x, y, z, x_face, y_face, z_face);
}
Expand All @@ -1090,10 +1090,11 @@ void Translator::V_CUBESC_F32(const GcnInst& inst) {
} else {
const auto x_neg_cond{ir.FPLessThan(x, ir.Imm32(0.f))};
const auto z_neg_cond{ir.FPLessThan(z, ir.Imm32(0.f))};
const IR::F32 x_sc{ir.Select(x_neg_cond, ir.FPNeg(x), x)};
const IR::F32 z_sc{ir.Select(z_neg_cond, z, ir.FPNeg(z))};
const IR::F32 x_sc{ir.Select(x_neg_cond, z, ir.FPNeg(z))};
const IR::F32 y_sc{x};
const IR::F32 z_sc{ir.Select(z_neg_cond, ir.FPNeg(x), x)};

result = SelectCubeResult(x, y, z, x_sc, x, z_sc);
result = SelectCubeResult(x, y, z, x_sc, y_sc, z_sc);
}
SetDst(inst.dst[0], result);
}
Expand All @@ -1109,10 +1110,10 @@ void Translator::V_CUBETC_F32(const GcnInst& inst) {
result = IR::F32{ir.CompositeExtract(coords, 1)};
} else {
const auto y_neg_cond{ir.FPLessThan(y, ir.Imm32(0.f))};
const IR::F32 x_z_sc{ir.FPNeg(y)};
const IR::F32 y_sc{ir.Select(y_neg_cond, ir.FPNeg(z), z)};
const IR::F32 x_z_tc{ir.FPNeg(y)};
const IR::F32 y_tc{ir.Select(y_neg_cond, ir.FPNeg(z), z)};

result = SelectCubeResult(x, y, z, x_z_sc, y_sc, x_z_sc);
result = SelectCubeResult(x, y, z, x_z_tc, y_tc, x_z_tc);
}
SetDst(inst.dst[0], result);
}
Expand All @@ -1122,7 +1123,7 @@ void Translator::V_CUBEMA_F32(const GcnInst& inst) {
const auto y = GetSrc<IR::F32>(inst.src[1]);
const auto z = GetSrc<IR::F32>(inst.src[2]);

const auto two{ir.Imm32(4.f)};
const auto two{ir.Imm32(2.f)};
const IR::F32 x_major_axis{ir.FPMul(x, two)};
const IR::F32 y_major_axis{ir.FPMul(y, two)};
const IR::F32 z_major_axis{ir.FPMul(z, two)};
Expand Down Expand Up @@ -1385,4 +1386,4 @@ void Translator::VMovRelDHelper(u32 dst_vgprno, const IR::U32 src_val, const IR:
}
}

} // namespace Shader::Gcn
} // namespace Shader::Gcn

0 comments on commit 6806e20

Please sign in to comment.