spirv: Use correct type for sampled images
authorAlex Smith <asmith@feralinteractive.com>
Mon, 6 Nov 2017 10:37:05 +0000 (10:37 +0000)
committerAlex Smith <asmith@feralinteractive.com>
Mon, 13 Nov 2017 13:37:50 +0000 (13:37 +0000)
commite9eb3c4753e4f56b03d16d8d6f71d49f1e7b97db
treedaa795242e8c15d981fbacc23dd51aedf3c29888
parent157c9a13414b524ce98ea0ea07fce819efc1ba65
spirv: Use correct type for sampled images

We should use the result type of the OpSampledImage opcode, rather than
the type of the underlying image/samplers.

This resolves an issue when using separate images and shadow samplers
with glslang. Example:

    layout (...) uniform samplerShadow s0;
    layout (...) uniform texture2D res0;
    ...
    float result = textureLod(sampler2DShadow(res0, s0), uv, 0);

For this, for the combined OpSampledImage, the type of the base image
was being used (which does not have the Depth flag set, whereas the
result type does), therefore it was not being recognised as a shadow
sampler. This led to the wrong LLVM intrinsics being emitted by RADV.

Signed-off-by: Alex Smith <asmith@feralinteractive.com>
Cc: "17.2 17.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c