[Mesa-dev] [PATCH] llvmpipe: fix primitive input to geom shaders

Zack Rusin zackr at vmware.com
Tue Jan 7 17:51:32 PST 2014


Yea, this sucks. Geometry shaders can take primitive id (system value) for passed in primitives and generate one (semantic) for primitives generated in the geometry shader. TBH, I thought we already handled it... Maybe wlk doesn't test it, we'll see if it regresses.

z

----- Original Message -----
> Well we were using a system value for prim id in gs, hence this was not
> necessary. I'm always confused though about system value / normal
> semantic usage though, Zack might know better.
> 
> Roland
> 
> Am 07.01.2014 09:55, schrieb Dave Airlie:
> > Not sure this is 100% the correct way to do this, since it may be a change
> > at the glsl->tgsi level that is required, either way open discussions!
> > 
> > fixes piglit
> > tests/spec/glsl-1.50/execution/geometry/primitive-id-in.shader_test
> > with llvmpipe with fake MSAA
> > 
> > Signed-off-by: Dave Airlie <airlied at redhat.com>
> > ---
> >  src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 5 +++++
> >  src/gallium/auxiliary/tgsi/tgsi_scan.c          | 3 +++
> >  2 files changed, 8 insertions(+)
> > 
> > diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> > b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> > index 6d8dc8c..de2c64f 100644
> > --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> > +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
> > @@ -1173,6 +1173,10 @@ emit_fetch_gs_input(
> >     LLVMValueRef swizzle_index = lp_build_const_int32(gallivm, swizzle);
> >     LLVMValueRef res;
> >  
> > +   if (bld_base->info->input_semantic_name[reg->Register.Index] ==
> > TGSI_SEMANTIC_PRIMID) {
> > +      res = bld->system_values.prim_id;
> > +      goto out;
> > +   }
> >     if (reg->Register.Indirect) {
> >        attrib_index = get_indirect_index(bld,
> >                                          reg->Register.File,
> > @@ -1200,6 +1204,7 @@ emit_fetch_gs_input(
> >  
> >     assert(res);
> >  
> > + out:
> >     if (stype == TGSI_TYPE_UNSIGNED) {
> >        res = LLVMBuildBitCast(builder, res, bld_base->uint_bld.vec_type,
> >        "");
> >     } else if (stype == TGSI_TYPE_SIGNED) {
> > diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c
> > b/src/gallium/auxiliary/tgsi/tgsi_scan.c
> > index 0f10556..ce1f7b6 100644
> > --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
> > +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
> > @@ -198,6 +198,9 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
> >                          info->uses_primid = TRUE;
> >                       else if (semName == TGSI_SEMANTIC_FACE)
> >                          info->uses_frontface = TRUE;
> > +                  } else if (procType == TGSI_PROCESSOR_GEOMETRY) {
> > +                     if (semName == TGSI_SEMANTIC_PRIMID)
> > +                        info->uses_primid = TRUE;
> >                    }
> >                 }
> >                 else if (file == TGSI_FILE_SYSTEM_VALUE) {
> > 
> 


More information about the mesa-dev mailing list