From f93677b95371a83db695151341d4629e133d2203 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Sat, 14 Dec 2024 12:46:35 -0800 Subject: [PATCH] resource_tracking_pass: Fix converting dimensions to float for normalization. (#1790) --- .../ir/passes/resource_tracking_pass.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp index f436db07..a5939895 100644 --- a/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp +++ b/src/shader_recompiler/ir/passes/resource_tracking_pass.cpp @@ -586,12 +586,13 @@ void PatchImageSampleInstruction(IR::Block& block, IR::Inst& inst, Info& info, const auto dimensions = unnormalized ? ir.ImageQueryDimension(ir.Imm32(image_binding), ir.Imm32(0u), ir.Imm1(false)) : IR::Value{}; - const auto get_coord = [&](u32 idx, u32 dim_idx) -> IR::Value { - const auto coord = get_addr_reg(idx); + const auto get_coord = [&](u32 coord_idx, u32 dim_idx) -> IR::Value { + const auto coord = get_addr_reg(coord_idx); if (unnormalized) { // Normalize the coordinate for sampling, dividing by its corresponding dimension. - return ir.FPDiv(coord, - ir.BitCast(IR::U32{ir.CompositeExtract(dimensions, dim_idx)})); + const auto dim = + ir.ConvertUToF(32, 32, IR::U32{ir.CompositeExtract(dimensions, dim_idx)}); + return ir.FPDiv(coord, dim); } return coord; };