<div dir="ltr">Thanks Jason. Can someone push this?</div><div class="gmail_extra"><br><div class="gmail_quote">On 6 November 2017 at 16:21, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Nov 6, 2017 at 2:37 AM, Alex Smith <span dir="ltr"><<a href="mailto:asmith@feralinteractive.com" target="_blank">asmith@feralinteractive.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We should use the result type of the OpSampledImage opcode, rather than<br>
the type of the underlying image/samplers.<br>
<br>
This resolves an issue when using separate images and shadow samplers<br>
with glslang. Example:<br>
<br>
layout (...) uniform samplerShadow s0;<br>
layout (...) uniform texture2D res0;<br>
...<br>
float result = textureLod(sampler2DShadow(res<wbr>0, s0), uv, 0);<br>
<br>
For this, for the combined OpSampledImage, the type of the base image<br>
was being used (which does not have the Depth flag set, whereas the<br>
result type does), therefore it was not being recognised as a shadow<br>
sampler. This led to the wrong LLVM intrinsics being emitted by RADV.<br></blockquote><div><br></div></span><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>><br></div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Alex Smith <<a href="mailto:asmith@feralinteractive.com" target="_blank">asmith@feralinteractive.com</a>><br>
Cc: "17.2 17.3" <<a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop<wbr>.org</a>><br>
---<br>
src/compiler/spirv/spirv_to_n<wbr>ir.c | 10 ++++------<br>
src/compiler/spirv/vtn_privat<wbr>e.h | 1 +<br>
src/compiler/spirv/vtn_variab<wbr>les.c | 1 +<br>
3 files changed, 6 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
index 6825e0d6a8..93a515d731 100644<br>
--- a/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
+++ b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
@@ -1490,6 +1490,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,<br>
struct vtn_value *val =<br>
vtn_push_value(b, w[2], vtn_value_type_sampled_image);<br>
val->sampled_image = ralloc(b, struct vtn_sampled_image);<br>
+ val->sampled_image->type =<br>
+ vtn_value(b, w[1], vtn_value_type_type)->type;<br>
val->sampled_image->image =<br>
vtn_value(b, w[3], vtn_value_type_pointer)->point<wbr>er;<br>
val->sampled_image->sampler =<br>
@@ -1516,16 +1518,12 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,<br>
sampled = *sampled_val->sampled_image;<br>
} else {<br>
assert(sampled_val->value_<wbr>type == vtn_value_type_pointer);<br>
+ sampled.type = sampled_val->pointer->type;<br>
sampled.image = NULL;<br>
sampled.sampler = sampled_val->pointer;<br>
}<br>
<br>
- const struct glsl_type *image_type;<br>
- if (sampled.image) {<br>
- image_type = sampled.image->var->var->inter<wbr>face_type;<br>
- } else {<br>
- image_type = sampled.sampler->var->var->int<wbr>erface_type;<br>
- }<br>
+ const struct glsl_type *image_type = sampled.type->type;<br>
const enum glsl_sampler_dim sampler_dim = glsl_get_sampler_dim(image_typ<wbr>e);<br>
const bool is_array = glsl_sampler_type_is_array(ima<wbr>ge_type);<br>
const bool is_shadow = glsl_sampler_type_is_shadow(im<wbr>age_type);<br>
diff --git a/src/compiler/spirv/vtn_priva<wbr>te.h b/src/compiler/spirv/vtn_priva<wbr>te.h<br>
index 84584620fc..6b4645acc8 100644<br>
--- a/src/compiler/spirv/vtn_priva<wbr>te.h<br>
+++ b/src/compiler/spirv/vtn_priva<wbr>te.h<br>
@@ -411,6 +411,7 @@ struct vtn_image_pointer {<br>
};<br>
<br>
struct vtn_sampled_image {<br>
+ struct vtn_type *type;<br>
struct vtn_pointer *image; /* Image or array of images */<br>
struct vtn_pointer *sampler; /* Sampler */<br>
};<br>
diff --git a/src/compiler/spirv/vtn_varia<wbr>bles.c b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
index 1cf9d597cf..9a69b4f6fc 100644<br>
--- a/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
+++ b/src/compiler/spirv/vtn_varia<wbr>bles.c<br>
@@ -1805,6 +1805,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,<br>
struct vtn_value *val =<br>
vtn_push_value(b, w[2], vtn_value_type_sampled_image);<br>
val->sampled_image = ralloc(b, struct vtn_sampled_image);<br>
+ val->sampled_image->type = base_val->sampled_image->type;<br>
val->sampled_image->image =<br>
vtn_pointer_dereference(b, base_val->sampled_image->image<wbr>, chain);<br>
val->sampled_image->sampler = base_val->sampled_image->sampl<wbr>er;<br>
<span class="m_369980367741172356HOEnZb"><font color="#888888">--<br>
2.13.6<br>
<br>
</font></span></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>