shader_recompiler: Few fixes for buffer number conversions. (#2869)

* liverpool: Pass correct color buffer number type for conversion mapping.

* shader_recompiler: Apply number conversion to vertex inputs.
This commit is contained in:
squidbus 2025-04-30 20:46:16 -07:00 committed by GitHub
parent 10b24d04bc
commit 5fd5b62539
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View file

@ -517,7 +517,9 @@ void Translator::EmitFetch(const GcnInst& inst) {
const auto values =
ir.CompositeConstruct(ir.GetAttribute(attr, 0), ir.GetAttribute(attr, 1),
ir.GetAttribute(attr, 2), ir.GetAttribute(attr, 3));
const auto swizzled = ApplySwizzle(ir, values, buffer.DstSelect());
const auto converted =
IR::ApplyReadNumberConversionVec4(ir, values, buffer.GetNumberConversion());
const auto swizzled = ApplySwizzle(ir, converted, buffer.DstSelect());
for (u32 i = 0; i < 4; i++) {
ir.SetVectorReg(dst_reg++, IR::F32{ir.CompositeExtract(swizzled, i)});
}

View file

@ -924,15 +924,11 @@ struct Liverpool {
}
[[nodiscard]] NumberFormat GetNumberFmt() const {
// There is a small difference between T# and CB number types, account for it.
return RemapNumberFormat(info.number_type == NumberFormat::SnormNz
? NumberFormat::Srgb
: info.number_type.Value(),
info.format);
return RemapNumberFormat(GetFixedNumberFormat(), info.format);
}
[[nodiscard]] NumberConversion GetNumberConversion() const {
return MapNumberConversion(info.number_type);
return MapNumberConversion(GetFixedNumberFormat());
}
[[nodiscard]] CompMapping Swizzle() const {
@ -973,6 +969,13 @@ struct Liverpool {
const auto mrt_swizzle = mrt_swizzles[swap_idx][components_idx];
return RemapSwizzle(info.format, mrt_swizzle);
}
private:
[[nodiscard]] NumberFormat GetFixedNumberFormat() const {
// There is a small difference between T# and CB number types, account for it.
return info.number_type == NumberFormat::SnormNz ? NumberFormat::Srgb
: info.number_type.Value();
}
};
enum ContextRegs : u32 {