On Mon, Sep 25, 2017 at 7:36 PM, Dave Airlie <airl...@gmail.com> wrote:
> From: Dave Airlie <airl...@redhat.com> > > %9903 = OpImageSampleDrefExplicitLod %float %14616 %14315 %16081 Lod > %float_0 > %14616 = OpSampledImage %510 %8499 %13137 > > %278 = OpTypeImage %float 2D 1 0 0 1 Unknown > %510 = OpTypeSampledImage %278 > > %8499 = OpLoad %150 %4159 > %150 = OpTypeImage %float 2D 0 0 0 1 Unknown > > Is being generated by a hlsl->spirv convertor. > > So it appears that the 510 return type from sampledimage is a shadow > sampler, > however the descriptor it's loading is for a 2D non-shadow image, which > makes it seems like OpSampledImage should cast appropriately. > > Now I'm not sure enough to know if this is valid spir-v in the first place, > and I don't think this patch is good enough to fix it even if it is, but > let's use it to open discussions. > Yeah, that's not a thing.... From the SPIR-V spec for OpLoad: *Pointer* is the pointer to load through. Its type must be an *OpTypePointer* whose *Type* operand is the same as *Result Type*. 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... 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. --Jason --- > src/compiler/spirv/spirv_to_nir.c | 6 +++++- > src/compiler/spirv/vtn_private.h | 1 + > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/compiler/spirv/spirv_to_nir.c > b/src/compiler/spirv/spirv_to_nir.c > index 6ce9d1a..d962e93 100644 > --- a/src/compiler/spirv/spirv_to_nir.c > +++ b/src/compiler/spirv/spirv_to_nir.c > @@ -1490,6 +1490,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp > opcode, > struct vtn_value *val = > vtn_push_value(b, w[2], vtn_value_type_sampled_image); > val->sampled_image = ralloc(b, struct vtn_sampled_image); > + val->sampled_image->ret_type = > + vtn_value(b, w[1], vtn_value_type_type)->type; > val->sampled_image->image = > vtn_value(b, w[3], vtn_value_type_pointer)->pointer; > val->sampled_image->sampler = > @@ -1521,7 +1523,9 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp > opcode, > } > > const struct glsl_type *image_type; > - if (sampled.image) { > + if (sampled.ret_type) { > + image_type = sampled.ret_type->type; > + } else if (sampled.image) { > image_type = sampled.image->var->var->interface_type; > } else { > image_type = sampled.sampler->var->var->interface_type; > diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_ > private.h > index 8458462..ce26326 100644 > --- a/src/compiler/spirv/vtn_private.h > +++ b/src/compiler/spirv/vtn_private.h > @@ -413,6 +413,7 @@ struct vtn_image_pointer { > struct vtn_sampled_image { > struct vtn_pointer *image; /* Image or array of images */ > struct vtn_pointer *sampler; /* Sampler */ > + struct vtn_type *ret_type; > }; > > struct vtn_value { > -- > 2.9.5 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev >
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev