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: 701cb9d60c "nir/vtn: Handle integer sampling coordinates"

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7069>
This commit is contained in:
Jason Ekstrand 2020-08-31 19:33:51 -05:00 committed by Karol Herbst
parent 2015a109ff
commit 589d918a4f
1 changed files with 3 additions and 1 deletions

View File

@ -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;