shader_recompiler: Fix type errors

This commit is contained in:
squidbus 2024-12-25 14:54:28 -08:00
parent 070c4af208
commit 0fe50e281d
2 changed files with 7 additions and 4 deletions

View File

@ -776,8 +776,11 @@ void PatchImageInterpretation(IR::Block& block, IR::Inst& inst, Info& info) {
inst.SetArg(4, ApplySwizzle(ir, inst.Arg(4), image.DstSelect()));
} else if (inst.GetOpcode() == IR::Opcode::ImageRead) {
const auto inst_info = inst.Flags<IR::TextureInstInfo>();
const auto texel = ir.ImageRead(inst.Arg(0), inst.Arg(1), IR::U32{inst.Arg(2)},
IR::U32{inst.Arg(3)}, inst_info);
const auto lod = inst.Arg(2);
const auto ms = inst.Arg(3);
const auto texel =
ir.ImageRead(inst.Arg(0), inst.Arg(1), lod.IsEmpty() ? IR::U32{} : IR::U32{lod},
ms.IsEmpty() ? IR::U32{} : IR::U32{ms}, inst_info);
const auto swizzled = ApplySwizzle(ir, texel, image.DstSelect());
inst.ReplaceUsesWith(swizzled);
}

View File

@ -12,8 +12,8 @@ namespace Shader::IR {
inline Value ApplySwizzle(IREmitter& ir, const Value& vector, const AmdGpu::CompMapping& swizzle) {
// Constants are indexed as 0 and 1, and components are 4-7. Thus we can apply a swizzle
// using two vectors and a shuffle, using one vector of constants and one of the components.
const auto zero = ir.Imm32(0.f);
const auto one = ir.Imm32(1.f);
const auto zero = vector.Type() == Type::U32x4 ? Value{ir.Imm32(0u)} : Value{ir.Imm32(0.f)};
const auto one = vector.Type() == Type::U32x4 ? Value{ir.Imm32(1u)} : Value{ir.Imm32(1.f)};
const auto constants_vec = ir.CompositeConstruct(zero, one, zero, zero);
const auto swizzled =
ir.CompositeShuffle(constants_vec, vector, size_t(swizzle.r), size_t(swizzle.g),