From 589d918a4f9da83e3ae441aa674372a141d23349 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 31 Aug 2020 19:33:51 -0500 Subject: [PATCH] spirv: Add 0.5 to integer coordinates for OpImageSampleExplicitLod Just casting to a float is insufficient because that gives us the upper-left corner of the texel rather than the center. Fixes: 701cb9d60c03 "nir/vtn: Handle integer sampling coordinates" Reviewed-by: Karol Herbst Reviewed-by: Dave Airlie Part-of: --- src/compiler/spirv/spirv_to_nir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index d88ae4cd7aa..ec976c49506 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2661,7 +2661,9 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, "Unless the Kernel capability is being used, the coordinate parameter " "OpImageSampleExplicitLod must be floating point."); - p->src = nir_src_for_ssa(nir_i2f32(&b->nb, p->src.ssa)); + p->src = nir_src_for_ssa( + nir_fadd(&b->nb, nir_i2f32(&b->nb, p->src.ssa), + nir_imm_float(&b->nb, 0.5))); } p->src_type = nir_tex_src_coord;