diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index e537185fa..b89e424fe 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -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(); - 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); } diff --git a/src/shader_recompiler/ir/reinterpret.h b/src/shader_recompiler/ir/reinterpret.h index 73d587a56..388e69187 100644 --- a/src/shader_recompiler/ir/reinterpret.h +++ b/src/shader_recompiler/ir/reinterpret.h @@ -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),