<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 25, 2017 at 7:36 PM, Dave Airlie <span dir="ltr"><<a href="mailto:airlied@gmail.com" target="_blank">airlied@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
<br>
%9903 = OpImageSampleDrefExplicitLod %float %14616 %14315 %16081 Lod %float_0<br>
%14616 = OpSampledImage %510 %8499 %13137<br>
<br>
%278 = OpTypeImage %float 2D 1 0 0 1 Unknown<br>
%510 = OpTypeSampledImage %278<br>
<br>
%8499 = OpLoad %150 %4159<br>
%150 = OpTypeImage %float 2D 0 0 0 1 Unknown<br>
<br>
Is being generated by a hlsl->spirv convertor.<br>
<br>
So it appears that the 510 return type from sampledimage is a shadow sampler,<br>
however the descriptor it's loading is for a 2D non-shadow image, which<br>
makes it seems like OpSampledImage should cast appropriately.<br>
<br>
Now I'm not sure enough to know if this is valid spir-v in the first place,<br>
and I don't think this patch is good enough to fix it even if it is, but<br>
let's use it to open discussions.<br></blockquote><div><br></div><div>Yeah, that's not a thing.... From the SPIR-V spec for OpLoad:</div><div><br></div><div> <em>Pointer</em> is the pointer to load through. Its type must be an <a><strong>OpTypePointer</strong></a> whose <em>Type</em> operand is the same as <em>Result Type</em>.</div><div><br></div><div>You're not allowed to do an implicit cast in an OpLoad. My guess is that HLSL only makes a distinction between shadow and non-shadow sampling at the sample instruction and not at the interface point. GL, however, has lots of history encoded in these things...</div><div><br></div><div>Please file a bug against GLSLang. If it's too hard to fix there, I'm happy for John to kick it back to the SPIR-V working group and try to come up with a way to do this properly. I'm reluctant to just let it through because I have no idea what will happen in our hardware if you try to do a depth comparison on an RGBA8 image.</div><div><br></div><div>--Jason<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
src/compiler/spirv/spirv_to_<wbr>nir.c | 6 +++++-<br>
src/compiler/spirv/vtn_<wbr>private.h | 1 +<br>
2 files changed, 6 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/compiler/spirv/spirv_to_<wbr>nir.c b/src/compiler/spirv/spirv_to_<wbr>nir.c<br>
index 6ce9d1a..d962e93 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->ret_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)-><wbr>pointer;<br>
val->sampled_image->sampler =<br>
@@ -1521,7 +1523,9 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,<br>
}<br>
<br>
const struct glsl_type *image_type;<br>
- if (sampled.image) {<br>
+ if (sampled.ret_type) {<br>
+ image_type = sampled.ret_type->type;<br>
+ } else if (sampled.image) {<br>
image_type = sampled.image->var->var-><wbr>interface_type;<br>
} else {<br>
image_type = sampled.sampler->var->var-><wbr>interface_type;<br>
diff --git a/src/compiler/spirv/vtn_<wbr>private.h b/src/compiler/spirv/vtn_<wbr>private.h<br>
index 8458462..ce26326 100644<br>
--- a/src/compiler/spirv/vtn_<wbr>private.h<br>
+++ b/src/compiler/spirv/vtn_<wbr>private.h<br>
@@ -413,6 +413,7 @@ struct vtn_image_pointer {<br>
struct vtn_sampled_image {<br>
struct vtn_pointer *image; /* Image or array of images */<br>
struct vtn_pointer *sampler; /* Sampler */<br>
+ struct vtn_type *ret_type;<br>
};<br>
<br>
struct vtn_value {<br>
<span class="gmail-HOEnZb"><font color="#888888">--<br>
2.9.5<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>