[Mesa-dev] [Mesa-stable] [PATCH 4/5] glsl: Optionally lower TCS gl_PatchVerticesIn to a uniform.

Kenneth Graunke kenneth at whitecape.org
Fri Jun 3 05:21:13 UTC 2016


On Thursday, June 2, 2016 5:00:51 PM PDT Ian Romanick wrote:
> On 06/02/2016 02:09 PM, Kenneth Graunke wrote:
> > i965 has no special hardware for this, so the best way to implement
> > this is to pass it in via a uniform.
> > 
> > Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> > Cc: mesa-stable at lists.freedesktop.org
> > ---
> >  src/compiler/glsl/builtin_variables.cpp | 13 ++++++++++++-
> >  src/mesa/main/mtypes.h                  |  1 +
> >  src/mesa/program/prog_statevars.c       |  4 ++++
> >  src/mesa/program/prog_statevars.h       |  1 +
> >  4 files changed, 18 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
> > index 05b3b0b..35a11bb 100644
> > --- a/src/compiler/glsl/builtin_variables.cpp
> > +++ b/src/compiler/glsl/builtin_variables.cpp
> > @@ -37,6 +37,11 @@ static const struct gl_builtin_uniform_element gl_NumSamples_elements[] = {
> >     {NULL, {STATE_NUM_SAMPLES, 0, 0}, SWIZZLE_XXXX}
> >  };
> >  
> > +/* only for TCS */
> > +static const struct gl_builtin_uniform_element gl_PatchVerticesIn_elements[] = {
> > +   {NULL, {STATE_INTERNAL, STATE_TCS_PATCH_VERTICES_IN}, SWIZZLE_XXXX}
> > +};
> > +
> >  static const struct gl_builtin_uniform_element gl_DepthRange_elements[] = {
> >     {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX},
> >     {"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY},
> > @@ -234,6 +239,7 @@ static const struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = {
> >  #define STATEVAR(name) {#name, name ## _elements, ARRAY_SIZE(name ## _elements)}
> >  
> >  static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = {
> > +   STATEVAR(gl_PatchVerticesIn),
> >     STATEVAR(gl_NumSamples),
> >     STATEVAR(gl_DepthRange),
> >     STATEVAR(gl_ClipPlane),
> > @@ -1029,9 +1035,14 @@ void
> >  builtin_variable_generator::generate_tcs_special_vars()
> >  {
> >     add_system_value(SYSTEM_VALUE_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
> > -   add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
> >     add_system_value(SYSTEM_VALUE_INVOCATION_ID, int_t, "gl_InvocationID");
> >  
> > +   if (state->ctx->Const.LowerTCSPatchVerticesIn) {
> > +      add_uniform(int_t, "gl_PatchVerticesIn");
> > +   } else {
> > +      add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
> > +   }
> > +
> 
> There are some built-in shader inputs that can be redeclared to add
> qualifiers.  If gl_PatchVerticesIn is one of those (and I have no idea
> whether or not it is), I think this will cause problems.

I don't think it is...it's just a single integer telling you how many
vertices are in the patch primitive being drawn.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160602/f592c1c5/attachment.sig>


More information about the mesa-dev mailing list