Module: Mesa Branch: master Commit: 589d918a4f9da83e3ae441aa674372a141d23349 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=589d918a4f9da83e3ae441aa674372a141d23349
Author: Jason Ekstrand <[email protected]> Date: Mon Aug 31 19:33:51 2020 -0500 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 <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069> --- 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; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
