[Mesa-dev] [PATCH 22/25] mesa/glsl/i965: set and get tes layouts directly to and from shader_info

Timothy Arceri timothy.arceri at collabora.com
Tue Jan 10 02:06:35 UTC 2017


On Mon, 2017-01-09 at 16:13 +1100, Timothy Arceri wrote:
> ---
>  src/compiler/glsl/linker.cpp        | 63 +++++++++++++++++++------
> ------------
>  src/mesa/drivers/dri/i965/brw_tcs.c |  6 ++--
>  src/mesa/main/shaderapi.c           | 15 +++------
>  3 files changed, 39 insertions(+), 45 deletions(-)
> 
> diff --git a/src/compiler/glsl/linker.cpp
> b/src/compiler/glsl/linker.cpp
> index 36e1e86..41a566a 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -1712,18 +1712,19 @@ link_tcs_out_layout_qualifiers(struct
> gl_shader_program *prog,
>   */
>  static void
>  link_tes_in_layout_qualifiers(struct gl_shader_program *prog,
> -                              struct gl_linked_shader
> *linked_shader,
> +                              struct gl_program *gl_prog,
>                                struct gl_shader **shader_list,
>                                unsigned num_shaders)
>  {
> -   linked_shader->info.TessEval.PrimitiveMode = PRIM_UNKNOWN;
> -   linked_shader->info.TessEval.Spacing = TESS_SPACING_UNSPECIFIED;
> -   linked_shader->info.TessEval.VertexOrder = 0;
> -   linked_shader->info.TessEval.PointMode = -1;
> -
> -   if (linked_shader->Stage != MESA_SHADER_TESS_EVAL)
> +   if (gl_prog->info.stage != MESA_SHADER_TESS_EVAL)
>        return;
>  
> +   int point_mode = -1;
> +   unsigned vertex_order = 0;
> +
> +   gl_prog->info.tes.primitive_mode = PRIM_UNKNOWN;
> +   gl_prog->info.tes.spacing = TESS_SPACING_UNSPECIFIED;
> +
>     /* From the GLSL 4.0 spec (chapter 4.3.8.1):
>      *
>      *     "At least one tessellation evaluation shader (compilation
> unit) in
> @@ -1742,49 +1743,44 @@ link_tes_in_layout_qualifiers(struct
> gl_shader_program *prog,
>        struct gl_shader *shader = shader_list[i];
>  
>        if (shader->info.TessEval.PrimitiveMode != PRIM_UNKNOWN) {
> -         if (linked_shader->info.TessEval.PrimitiveMode !=
> PRIM_UNKNOWN &&
> -             linked_shader->info.TessEval.PrimitiveMode !=
> +         if (gl_prog->info.tes.primitive_mode != PRIM_UNKNOWN &&
> +             gl_prog->info.tes.primitive_mode !=
>               shader->info.TessEval.PrimitiveMode) {
>              linker_error(prog, "tessellation evaluation shader
> defined with "
>                           "conflicting input primitive modes.\n");
>              return;
>           }
> -         linked_shader->info.TessEval.PrimitiveMode = shader-
> >info.TessEval.PrimitiveMode;
> +         gl_prog->info.tes.primitive_mode = shader-
> >info.TessEval.PrimitiveMode;
>        }
>  
>        if (shader->info.TessEval.Spacing != 0) {
> -         if (linked_shader->info.TessEval.Spacing != 0 &&
> -             linked_shader->info.TessEval.Spacing !=
> +         if (gl_prog->info.tes.spacing != 0 && gl_prog-
> >info.tes.spacing !=
>               shader->info.TessEval.Spacing) {
>              linker_error(prog, "tessellation evaluation shader
> defined with "
>                           "conflicting vertex spacing.\n");
>              return;
>           }
> -         linked_shader->info.TessEval.Spacing = shader-
> >info.TessEval.Spacing;
> +         gl_prog->info.tes.spacing = shader->info.TessEval.Spacing;
>        }
>  
>        if (shader->info.TessEval.VertexOrder != 0) {
> -         if (linked_shader->info.TessEval.VertexOrder != 0 &&
> -             linked_shader->info.TessEval.VertexOrder !=
> -             shader->info.TessEval.VertexOrder) {
> +         if (vertex_order != 0 &&
> +             vertex_order != shader->info.TessEval.VertexOrder) {
>              linker_error(prog, "tessellation evaluation shader
> defined with "
>                           "conflicting ordering.\n");
>              return;
>           }
> -         linked_shader->info.TessEval.VertexOrder =
> -            shader->info.TessEval.VertexOrder;
> +         vertex_order = shader->info.TessEval.VertexOrder;
>        }
>  
>        if (shader->info.TessEval.PointMode != -1) {
> -         if (linked_shader->info.TessEval.PointMode != -1 &&
> -             linked_shader->info.TessEval.PointMode !=
> -             shader->info.TessEval.PointMode) {
> +         if (point_mode != -1 &&
> +             point_mode != shader->info.TessEval.PointMode) {
>              linker_error(prog, "tessellation evaluation shader
> defined with "
>                           "conflicting point modes.\n");
>              return;
>           }
> -         linked_shader->info.TessEval.PointMode =
> -            shader->info.TessEval.PointMode;
> +         point_mode = shader->info.TessEval.PointMode;
>        }
>  
>     }
> @@ -1793,21 +1789,26 @@ link_tes_in_layout_qualifiers(struct
> gl_shader_program *prog,
>      * since we already know we're in the right type of shader
> program
>      * for doing it.
>      */
> -   if (linked_shader->info.TessEval.PrimitiveMode == PRIM_UNKNOWN) {
> +   if (gl_prog->info.tes.primitive_mode == PRIM_UNKNOWN) {
>        linker_error(prog,
>                     "tessellation evaluation shader didn't declare
> input "
>                     "primitive modes.\n");
>        return;
>     }
>  
> -   if (linked_shader->info.TessEval.Spacing ==
> TESS_SPACING_UNSPECIFIED)
> -      linked_shader->info.TessEval.Spacing = TESS_SPACING_EQUAL;
> +   if (gl_prog->info.tes.spacing == TESS_SPACING_UNSPECIFIED)
> +      gl_prog->info.tes.spacing = TESS_SPACING_EQUAL;
>  
> -   if (linked_shader->info.TessEval.VertexOrder == 0)
> -      linked_shader->info.TessEval.VertexOrder = GL_CCW;
> +   if (vertex_order == 0)

Small rebasing issue here. This should be:

   if (vertex_order == 0 || vertex_order == GL_CCW)

> +      gl_prog->info.tes.ccw = true;
> +   else
> +      gl_prog->info.tes.ccw = false;
> +   
>  
> -   if (linked_shader->info.TessEval.PointMode == -1)
> -      linked_shader->info.TessEval.PointMode = GL_FALSE;
> +   if (point_mode == -1)

And this:

  if (point_mode == -1 || point_mode == GL_FALSE)


I've fixed these locally.

> +      gl_prog->info.tes.point_mode = false;
> +   else
> +      gl_prog->info.tes.point_mode = true;
>  }
>  
>  
> @@ -2203,7 +2204,7 @@ link_intrastage_shaders(void *mem_ctx,
>  
>     link_fs_inout_layout_qualifiers(prog, linked, shader_list,
> num_shaders);
>     link_tcs_out_layout_qualifiers(prog, gl_prog, shader_list,
> num_shaders);
> -   link_tes_in_layout_qualifiers(prog, linked, shader_list,
> num_shaders);
> +   link_tes_in_layout_qualifiers(prog, gl_prog, shader_list,
> num_shaders);
>     link_gs_inout_layout_qualifiers(prog, linked, shader_list,
> num_shaders);
>     link_cs_input_layout_qualifiers(prog, linked, shader_list,
> num_shaders);
>     link_xfb_stride_layout_qualifiers(ctx, prog, linked, shader_list,
> diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c
> b/src/mesa/drivers/dri/i965/brw_tcs.c
> index 27a53e3..9a3eb1d 100644
> --- a/src/mesa/drivers/dri/i965/brw_tcs.c
> +++ b/src/mesa/drivers/dri/i965/brw_tcs.c
> @@ -398,10 +398,10 @@ brw_tcs_precompile(struct gl_context *ctx,
>     struct brw_program *btep;
>     if (tes) {
>        btep = brw_program(tes->Program);
> -      key.tes_primitive_mode = tes->info.TessEval.PrimitiveMode;
> +      key.tes_primitive_mode = tes->Program-
> >info.tes.primitive_mode;
>        key.quads_workaround = brw->gen < 9 &&
> -                             tes->info.TessEval.PrimitiveMode ==
> GL_QUADS &&
> -                             tes->info.TessEval.Spacing ==
> TESS_SPACING_EQUAL;
> +                             tes->Program->info.tes.primitive_mode
> == GL_QUADS &&
> +                             tes->Program->info.tes.spacing ==
> TESS_SPACING_EQUAL;
>     } else {
>        btep = NULL;
>        key.tes_primitive_mode = GL_TRIANGLES;
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 53a29e5..f68ef51 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -829,7 +829,7 @@ get_programiv(struct gl_context *ctx, GLuint
> program, GLenum pname,
>           break;
>        if (check_tes_query(ctx, shProg)) {
>           *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
> -            info.TessEval.PrimitiveMode;
> +            Program->info.tes.primitive_mode;
>        }
>        return;
>     case GL_TESS_GEN_SPACING:
> @@ -838,7 +838,7 @@ get_programiv(struct gl_context *ctx, GLuint
> program, GLenum pname,
>        if (check_tes_query(ctx, shProg)) {
>           const struct gl_linked_shader *tes =
>              shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL];
> -         switch (tes->info.TessEval.Spacing) {
> +         switch (tes->Program->info.tes.spacing) {
>           case TESS_SPACING_EQUAL:
>              *params = GL_EQUAL;
>              break;
> @@ -859,7 +859,7 @@ get_programiv(struct gl_context *ctx, GLuint
> program, GLenum pname,
>           break;
>        if (check_tes_query(ctx, shProg)) {
>           *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
> -            info.TessEval.VertexOrder;
> +            Program->info.tes.ccw ? GL_CCW : GL_CW;
>           }
>        return;
>     case GL_TESS_GEN_POINT_MODE:
> @@ -867,7 +867,7 @@ get_programiv(struct gl_context *ctx, GLuint
> program, GLenum pname,
>           break;
>        if (check_tes_query(ctx, shProg)) {
>           *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
> -            info.TessEval.PointMode;
> +            Program->info.tes.point_mode ? GL_TRUE : GL_FALSE;
>        }
>        return;
>     default:
> @@ -2203,13 +2203,6 @@ _mesa_copy_linked_program_data(const struct
> gl_shader_program *src,
>     dst->info.separate_shader = src->SeparateShader;
>  
>     switch (dst_sh->Stage) {
> -   case MESA_SHADER_TESS_EVAL: {
> -      dst->info.tes.primitive_mode = dst_sh-
> >info.TessEval.PrimitiveMode;
> -      dst->info.tes.spacing = dst_sh->info.TessEval.Spacing;
> -      dst->info.tes.ccw = dst_sh->info.TessEval.VertexOrder ==
> GL_CCW;
> -      dst->info.tes.point_mode = dst_sh->info.TessEval.PointMode;
> -      break;
> -   }
>     case MESA_SHADER_GEOMETRY: {
>        dst->info.gs.vertices_in = src->Geom.VerticesIn;
>        dst->info.gs.vertices_out = dst_sh->info.Geom.VerticesOut;


More information about the mesa-dev mailing list