st/mesa/glsl: change xfb_program field to last_vert_prog
authorTimothy Arceri <timothy.arceri@collabora.com>
Sun, 20 Nov 2016 10:44:29 +0000 (21:44 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Mon, 23 Jan 2017 03:48:04 +0000 (14:48 +1100)
Now that the i965 backend doesn't depend on this field we can
make it more generic and short circuit a bunch of code paths.

The new field will be used in a following patch for another
clean-up.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/compiler/glsl/link_varyings.cpp
src/compiler/glsl/linker.cpp
src/mesa/main/mtypes.h
src/mesa/main/shader_query.cpp
src/mesa/main/transformfeedback.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp
src/mesa/state_tracker/st_program.c

index 8cd364441d3fc4960bc5cc29201038e441005118..eef215dfda767e6cee7ab32edaa6245b45cbc330 100644 (file)
@@ -1076,6 +1076,9 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
                      unsigned num_tfeedback_decls,
                      tfeedback_decl *tfeedback_decls, bool has_xfb_qualifiers)
 {
+   if (!prog->last_vert_prog)
+      return true;
+
    /* Make sure MaxTransformFeedbackBuffers is less than 32 so the bitmask for
     * tracking the number of buffers doesn't overflow.
     */
@@ -1084,7 +1087,7 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
    bool separate_attribs_mode =
       prog->TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS;
 
-   struct gl_program *xfb_prog = prog->xfb_program;
+   struct gl_program *xfb_prog = prog->last_vert_prog;
    xfb_prog->sh.LinkedTransformFeedback =
       rzalloc(xfb_prog, struct gl_transform_feedback_info);
 
index fb26be489509a77b5d213c431a15731c42b3528a..846f77f4c7d447efacddff324b743ebf0bd740d4 100644 (file)
@@ -4235,27 +4235,29 @@ build_program_resource_list(struct gl_context *ctx,
                                 output_stage, GL_PROGRAM_OUTPUT))
       return;
 
-   struct gl_transform_feedback_info *linked_xfb =
-      shProg->xfb_program->sh.LinkedTransformFeedback;
-
-   /* Add transform feedback varyings. */
-   if (linked_xfb->NumVarying > 0) {
-      for (int i = 0; i < linked_xfb->NumVarying; i++) {
-         if (!add_program_resource(shProg, resource_set,
-                                   GL_TRANSFORM_FEEDBACK_VARYING,
-                                   &linked_xfb->Varyings[i], 0))
-         return;
+   if (shProg->last_vert_prog) {
+      struct gl_transform_feedback_info *linked_xfb =
+         shProg->last_vert_prog->sh.LinkedTransformFeedback;
+
+      /* Add transform feedback varyings. */
+      if (linked_xfb->NumVarying > 0) {
+         for (int i = 0; i < linked_xfb->NumVarying; i++) {
+            if (!add_program_resource(shProg, resource_set,
+                                      GL_TRANSFORM_FEEDBACK_VARYING,
+                                      &linked_xfb->Varyings[i], 0))
+            return;
+         }
       }
-   }
 
-   /* Add transform feedback buffers. */
-   for (unsigned i = 0; i < ctx->Const.MaxTransformFeedbackBuffers; i++) {
-      if ((linked_xfb->ActiveBuffers >> i) & 1) {
-         linked_xfb->Buffers[i].Binding = i;
-         if (!add_program_resource(shProg, resource_set,
-                                   GL_TRANSFORM_FEEDBACK_BUFFER,
-                                   &linked_xfb->Buffers[i], 0))
-         return;
+      /* Add transform feedback buffers. */
+      for (unsigned i = 0; i < ctx->Const.MaxTransformFeedbackBuffers; i++) {
+         if ((linked_xfb->ActiveBuffers >> i) & 1) {
+            linked_xfb->Buffers[i].Binding = i;
+            if (!add_program_resource(shProg, resource_set,
+                                      GL_TRANSFORM_FEEDBACK_BUFFER,
+                                      &linked_xfb->Buffers[i], 0))
+            return;
+         }
       }
    }
 
@@ -4566,15 +4568,12 @@ link_varyings_and_uniforms(unsigned first, unsigned last,
       return false;
    }
 
-   /* Find the program used for xfb. Even if we don't use xfb we still want to
-    * set this so we can fill the default values for program interface query.
-    */
-   prog->xfb_program = prog->_LinkedShaders[last]->Program;
+   prog->last_vert_prog = NULL;
    for (int i = MESA_SHADER_GEOMETRY; i >= MESA_SHADER_VERTEX; i--) {
       if (prog->_LinkedShaders[i] == NULL)
          continue;
 
-      prog->xfb_program = prog->_LinkedShaders[i]->Program;
+      prog->last_vert_prog = prog->_LinkedShaders[i]->Program;
       break;
    }
 
index c733911c47641a58c0282cef89194fa4dfe7856f..e8eddce0603794fef41f61e391b746b2010b38e0 100644 (file)
@@ -2742,7 +2742,7 @@ struct gl_shader_program
       GLchar **VaryingNames;  /**< Array [NumVarying] of char * */
    } TransformFeedback;
 
-   struct gl_program *xfb_program;
+   struct gl_program *last_vert_prog;
 
    /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
    enum gl_frag_depth_layout FragDepthLayout;
index f465b3959e50a6c46f15e6fc740f02bbea292f78..30e5b087abb6b8cd3b683e8a00637fb7d71df3b3 100644 (file)
@@ -1047,7 +1047,7 @@ get_buffer_property(struct gl_shader_program *shProg,
          return 1;
       case GL_ACTIVE_VARIABLES:
          struct gl_transform_feedback_info *linked_xfb =
-            shProg->xfb_program->sh.LinkedTransformFeedback;
+            shProg->last_vert_prog->sh.LinkedTransformFeedback;
          for (int i = 0; i < linked_xfb->NumVarying; i++) {
             unsigned index = linked_xfb->Varyings[i].BufferIndex;
             struct gl_program_resource *buf_res =
index 06fa56ab993f03c15d812b1877452074c908693d..96f3df1c961e2bb558bea7dd3ad1440475c3485a 100644 (file)
@@ -65,9 +65,12 @@ bool
 _mesa_transform_feedback_is_using_program(struct gl_context *ctx,
                                           struct gl_shader_program *shProg)
 {
+   if (!shProg->last_vert_prog)
+      return false;
+
    struct using_program_tuple callback_data;
    callback_data.found = false;
-   callback_data.prog = shProg->xfb_program;
+   callback_data.prog = shProg->last_vert_prog;
 
    _mesa_HashWalk(ctx->TransformFeedback.Objects,
                   active_xfb_object_references_program, &callback_data);
index a99e99178c67b1423b89a64e37ff442919d2556d..46952dcd3a2837c47d63a3b1741d9117e7198f75 100644 (file)
@@ -7003,8 +7003,11 @@ st_translate_stream_output_info(glsl_to_tgsi_visitor *glsl_to_tgsi,
                                 const GLuint outputMapping[],
                                 struct pipe_stream_output_info *so)
 {
+   if (!glsl_to_tgsi->shader_program->last_vert_prog)
+      return;
+
    struct gl_transform_feedback_info *info =
-      glsl_to_tgsi->shader_program->xfb_program->sh.LinkedTransformFeedback;
+      glsl_to_tgsi->shader_program->last_vert_prog->sh.LinkedTransformFeedback;
    st_translate_stream_output_info2(info, outputMapping, so);
 }
 
index e12427956707d2c939a270046426c06c9ea466d5..fb0a138c245c7b49de41ea87cc760ab556fe412b 100644 (file)
@@ -390,9 +390,13 @@ st_translate_vertex_program(struct st_context *st,
       stvp->tgsi.type = PIPE_SHADER_IR_NIR;
       stvp->tgsi.ir.nir = nir;
 
-      st_translate_stream_output_info2(stvp->shader_program->xfb_program->sh.LinkedTransformFeedback,
-                                       stvp->result_to_output,
-                                       &stvp->tgsi.stream_output);
+      struct gl_program *prog = stvp->shader_program->last_vert_prog;
+      if (prog) {
+         st_translate_stream_output_info2(prog->sh.LinkedTransformFeedback,
+                                          stvp->result_to_output,
+                                          &stvp->tgsi.stream_output);
+      }
+
       return true;
    }