[Mesa-dev] [PATCH] spirv: Add more asserts in vtn_vector_construct

Samuel Iglesias Gonsálvez siglesias at igalia.com
Tue Feb 7 07:05:14 UTC 2017


Reviewed-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>

On Mon, 2017-02-06 at 21:20 -0800, Jason Ekstrand wrote:
> On Mon, Feb 6, 2017 at 9:18 PM, Jason Ekstrand <jason at jlekstrand.net>
> wrote:
> > These are currently getting hit by the Skia Vulkan back-end
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99465
>  
> > ---
> >  src/compiler/spirv/spirv_to_nir.c | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> > 
> > diff --git a/src/compiler/spirv/spirv_to_nir.c
> > b/src/compiler/spirv/spirv_to_nir.c
> > index 9f0b8fd..416e12a 100644
> > --- a/src/compiler/spirv/spirv_to_nir.c
> > +++ b/src/compiler/spirv/spirv_to_nir.c
> > @@ -2334,9 +2334,17 @@ vtn_vector_construct(struct vtn_builder *b,
> > unsigned num_components,
> >     nir_alu_instr *vec = create_vec(b->shader, num_components,
> >                                     srcs[0]->bit_size);
> > 
> > +   /* From the SPIR-V 1.1 spec for OpCompositeConstruct:
> > +    *
> > +    *    "When constructing a vector, there must be at least two
> > Constituent
> > +    *    operands."
> > +    */
> > +   assert(num_srcs >= 2);
> > +
> >     unsigned dest_idx = 0;
> >     for (unsigned i = 0; i < num_srcs; i++) {
> >        nir_ssa_def *src = srcs[i];
> > +      assert(dest_idx + src->num_components <= num_components);
> >        for (unsigned j = 0; j < src->num_components; j++) {
> >           vec->src[dest_idx].src = nir_src_for_ssa(src);
> >           vec->src[dest_idx].swizzle[0] = j;
> > @@ -2344,6 +2352,13 @@ vtn_vector_construct(struct vtn_builder *b,
> > unsigned num_components,
> >        }
> >     }
> > 
> > +   /* From the SPIR-V 1.1 spec for OpCompositeConstruct:
> > +    *
> > +    *    "When constructing a vector, the total number of
> > components in all
> > +    *    the operands must equal the number of components in
> > Result Type."
> > +    */
> > +   assert(dest_idx == num_components);
> > +
> >     nir_builder_instr_insert(&b->nb, &vec->instr);
> > 
> >     return &vec->dest.dest.ssa;
> > --
> > 2.5.0.400.gff86faf
> > 
> > 
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170207/c5156d2f/attachment-0001.sig>


More information about the mesa-dev mailing list