mesa: store gl_program in gl_transform_feedback_object rather than gl_shader_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Thu, 3 Nov 2016 03:35:08 +0000 (14:35 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Thu, 29 Dec 2016 23:57:16 +0000 (10:57 +1100)
This will allow us to make the CurrentProgram array store gl_program which allows
us to do a bunch of simplifications.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/gen6_sol.c
src/mesa/drivers/dri/i965/gen7_sol_state.c
src/mesa/main/mtypes.h
src/mesa/main/transformfeedback.c
src/mesa/state_tracker/st_cb_xformfb.c

index f6a183ad169e12aabf9e609854b73d0e97fe1d64..656d042769e2cc8d20a0291fb20be4197b563774 100644 (file)
@@ -45,8 +45,7 @@ gen6_update_sol_surfaces(struct brw_context *brw)
    if (xfb_active) {
       /* BRW_NEW_TRANSFORM_FEEDBACK */
       xfb_obj = ctx->TransformFeedback.CurrentObject;
-      linked_xfb_info =
-         xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+      linked_xfb_info = xfb_obj->program->sh.LinkedTransformFeedback;
    }
 
    for (int i = 0; i < BRW_MAX_SOL_BINDINGS; ++i) {
index 5170f6a16ea25aba63549c0962fe7a780ffe44af..c9f9f1f731dfd7d5498f03ef471e15dd31e77995 100644 (file)
@@ -43,7 +43,7 @@ upload_3dstate_so_buffers(struct brw_context *brw)
    struct gl_transform_feedback_object *xfb_obj =
       ctx->TransformFeedback.CurrentObject;
    const struct gl_transform_feedback_info *linked_xfb_info =
-      xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+      xfb_obj->program->sh.LinkedTransformFeedback;
    int i;
 
    /* Set up the up to 4 output buffers.  These are the ranges defined in the
@@ -103,7 +103,7 @@ gen7_upload_3dstate_so_decl_list(struct brw_context *brw,
    struct gl_transform_feedback_object *xfb_obj =
       ctx->TransformFeedback.CurrentObject;
    const struct gl_transform_feedback_info *linked_xfb_info =
-      xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+      xfb_obj->program->sh.LinkedTransformFeedback;
    uint16_t so_decl[MAX_VERTEX_STREAMS][128];
    int buffer_mask[MAX_VERTEX_STREAMS] = {0, 0, 0, 0};
    int next_offset[MAX_VERTEX_STREAMS] = {0, 0, 0, 0};
@@ -229,7 +229,7 @@ upload_3dstate_streamout(struct brw_context *brw, bool active,
    struct gl_transform_feedback_object *xfb_obj =
       ctx->TransformFeedback.CurrentObject;
    const struct gl_transform_feedback_info *linked_xfb_info =
-      xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+      xfb_obj->program->sh.LinkedTransformFeedback;
    uint32_t dw1 = 0, dw2 = 0, dw3 = 0, dw4 = 0;
    int i;
 
index 9b736bb9a3ff2d1105818e9a2cdaa8c2a3884681..35dd8135f26d749f8b5777b5740d90dc7dc10d9d 100644 (file)
@@ -1730,12 +1730,12 @@ struct gl_transform_feedback_object
    unsigned GlesRemainingPrims;
 
    /**
-    * The shader program active when BeginTransformFeedback() was called.
+    * The program active when BeginTransformFeedback() was called.
     * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
     * where stage is the pipeline stage that is the source of data for
     * transform feedback.
     */
-   struct gl_shader_program *shader_program;
+   struct gl_program *program;
 
    /** The feedback buffers */
    GLuint BufferNames[MAX_FEEDBACK_BUFFERS];
index 2088c76e5ea2bf391bf1b11dc74c9d172c0e7b38..771223aff994c7b31aed2922f10ec56e453ff0ff 100644 (file)
@@ -45,7 +45,7 @@
 
 struct using_program_tuple
 {
-   struct gl_shader_program *shProg;
+   struct gl_program *prog;
    bool found;
 };
 
@@ -54,7 +54,7 @@ active_xfb_object_references_program(GLuint key, void *data, void *user_data)
 {
    struct using_program_tuple *callback_data = user_data;
    struct gl_transform_feedback_object *obj = data;
-   if (obj->Active && obj->shader_program == callback_data->shProg)
+   if (obj->Active && obj->program == callback_data->prog)
       callback_data->found = true;
 }
 
@@ -66,8 +66,8 @@ _mesa_transform_feedback_is_using_program(struct gl_context *ctx,
                                           struct gl_shader_program *shProg)
 {
    struct using_program_tuple callback_data;
-   callback_data.shProg = shProg;
    callback_data.found = false;
+   callback_data.prog = shProg->xfb_program;
 
    _mesa_HashWalk(ctx->TransformFeedback.Objects,
                   active_xfb_object_references_program, &callback_data);
@@ -379,18 +379,18 @@ _mesa_compute_max_transform_feedback_vertices(struct gl_context *ctx,
 
 /**
  * Figure out which stage of the pipeline is the source of transform feedback
- * data given the current context state, and return its gl_shader_program.
+ * data given the current context state, and return its gl_program.
  *
  * If no active program can generate transform feedback data (i.e. no vertex
  * shader is active), returns NULL.
  */
-static struct gl_shader_program *
+static struct gl_program *
 get_xfb_source(struct gl_context *ctx)
 {
    int i;
    for (i = MESA_SHADER_GEOMETRY; i >= MESA_SHADER_VERTEX; i--) {
       if (ctx->_Shader->CurrentProgram[i] != NULL)
-         return ctx->_Shader->CurrentProgram[i];
+         return ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i]->Program;
    }
    return NULL;
 }
@@ -401,7 +401,6 @@ _mesa_BeginTransformFeedback(GLenum mode)
 {
    struct gl_transform_feedback_object *obj;
    struct gl_transform_feedback_info *info = NULL;
-   struct gl_shader_program *source;
    GLuint i;
    unsigned vertices_per_prim;
    GET_CURRENT_CONTEXT(ctx);
@@ -411,14 +410,14 @@ _mesa_BeginTransformFeedback(GLenum mode)
    /* Figure out what pipeline stage is the source of data for transform
     * feedback.
     */
-   source = get_xfb_source(ctx);
+   struct gl_program *source = get_xfb_source(ctx);
    if (source == NULL) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glBeginTransformFeedback(no program active)");
       return;
    }
 
-   info = source->xfb_program->sh.LinkedTransformFeedback;
+   info = source->sh.LinkedTransformFeedback;
 
    if (info->NumOutputs == 0) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -478,9 +477,9 @@ _mesa_BeginTransformFeedback(GLenum mode)
       obj->GlesRemainingPrims = max_vertices / vertices_per_prim;
    }
 
-   if (obj->shader_program != source) {
+   if (obj->program != source) {
       ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedbackProg;
-      obj->shader_program = source;
+      obj->program = source;
    }
 
    assert(ctx->Driver.BeginTransformFeedback);
@@ -1199,7 +1198,7 @@ _mesa_ResumeTransformFeedback(void)
     *  the program object being used by the current transform feedback object
     *  is not active."
     */
-   if (obj->shader_program != get_xfb_source(ctx)) {
+   if (obj->program != get_xfb_source(ctx)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glResumeTransformFeedback(wrong program bound)");
       return;
index bbc9e03dd0796b6407061ac8adf417b92534e899..4be9a7f659ebe3970462d887fbca15365e9e86b8 100644 (file)
@@ -124,8 +124,8 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
       struct st_buffer_object *bo = st_buffer_object(sobj->base.Buffers[i]);
 
       if (bo && bo->buffer) {
-         unsigned stream = obj->shader_program->xfb_program->
-            sh.LinkedTransformFeedback->Buffers[i].Stream;
+         unsigned stream = obj->program->sh.LinkedTransformFeedback->
+            Buffers[i].Stream;
 
          /* Check whether we need to recreate the target. */
          if (!sobj->targets[i] ||
@@ -203,8 +203,8 @@ st_end_transform_feedback(struct gl_context *ctx,
       pipe_so_target_reference(&sobj->draw_count[i], NULL);
 
    for (i = 0; i < ARRAY_SIZE(sobj->targets); i++) {
-      unsigned stream = obj->shader_program->xfb_program->
-         sh.LinkedTransformFeedback->Buffers[i].Stream;
+      unsigned stream = obj->program->sh.LinkedTransformFeedback->
+         Buffers[i].Stream;
 
       /* Is it not bound or already set for this stream? */
       if (!sobj->targets[i] || sobj->draw_count[stream])