[Mesa-dev] [PATCH 3/5] glsl: Mark gl_ViewportIndex and gl_Layer varyings as flat.
Kenneth Graunke
kenneth at whitecape.org
Mon Oct 26 16:36:48 PDT 2015
On Monday, October 26, 2015 02:10:29 PM Ilia Mirkin wrote:
> On Mon, Oct 26, 2015 at 2:03 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> > Integer varyings need to be flat qualified - all others were already.
> > I think we just missed this. Presumably some hardware passes this via
> > sideband and ignores attribute interpolation, so no one has noticed.
> >
> > Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> > Cc: Chris Forbes <chrisf at ijw.co.nz>
> > ---
> > src/glsl/builtin_variables.cpp | 39 ++++++++++++++++++++++++++-------------
> > 1 file changed, 26 insertions(+), 13 deletions(-)
> >
> > diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
> > index a6ad105..07aacd4 100644
> > --- a/src/glsl/builtin_variables.cpp
> > +++ b/src/glsl/builtin_variables.cpp
> > @@ -887,16 +887,22 @@ builtin_variable_generator::generate_uniforms()
> > void
> > builtin_variable_generator::generate_vs_special_vars()
> > {
> > + ir_variable *var;
> > +
> > if (state->is_version(130, 300))
> > add_system_value(SYSTEM_VALUE_VERTEX_ID, int_t, "gl_VertexID");
> > if (state->ARB_draw_instanced_enable)
> > add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceIDARB");
> > if (state->ARB_draw_instanced_enable || state->is_version(140, 300))
> > add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceID");
> > - if (state->AMD_vertex_shader_layer_enable)
> > - add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
> > - if (state->AMD_vertex_shader_viewport_index_enable)
> > - add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex");
> > + if (state->AMD_vertex_shader_layer_enable) {
> > + var = add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
> > + var->data.interpolation = INTERP_QUALIFIER_FLAT;
>
> Not that I *strongly* prefer this, but what we'd do in nouveau/codegen
> code (and is IMHO more concise):
>
> add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer")
> ->data.interpolation = INTERP_QUALIFIER_FLAT;
>
> Alternatively, you could just solve this in add_output which should
> automatically set the flat interpolation for int types...
>
> FTR I don't strongly prefer either of the above to your solution, just
> wanted to point out some alternatives in case you like them more.
Yeah, I've never been a huge fan of using -> on pointers directly
returned by function calls...but that's mostly just personal preference.
I considered having add_input/add_output automatically detect ivec*
types and automatically set things to FLAT. The nice thing about that
is that would prevent future mistakes. However, I think ivec* typed
VS inputs/FS outputs shouldn't be marked FLAT, so we might need a
parameter (or special vs_input/fs_output functions)...which seemed
potentially ugly.
I suppose adding a non-optional interp qualifier parameter would also
prevent future mistakes, at the cost of making the common case wordy.
In the end I figured I'd do this for now and let somebody more
inspired tidy it up...
-------------- 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: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151026/785bb070/attachment.sig>
More information about the mesa-dev
mailing list