[Mesa-dev] [PATCH 12/70] glsl/i965: move per stage AtomicBuffers list to gl_program

Timothy Arceri timothy.arceri at collabora.com
Fri Nov 11 00:45:54 UTC 2016


---
 src/compiler/glsl/link_atomics.cpp                |  8 ++++----
 src/mesa/drivers/dri/i965/brw_context.h           |  1 -
 src/mesa/drivers/dri/i965/brw_gs_surface_state.c  |  8 ++------
 src/mesa/drivers/dri/i965/brw_tcs_surface_state.c |  9 +++------
 src/mesa/drivers/dri/i965/brw_tes_surface_state.c |  9 +++------
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c  |  8 ++------
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  | 19 +++++--------------
 src/mesa/main/mtypes.h                            |  8 +++++---
 src/mesa/main/shaderapi.c                         |  1 -
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp        |  2 +-
 10 files changed, 25 insertions(+), 48 deletions(-)

diff --git a/src/compiler/glsl/link_atomics.cpp b/src/compiler/glsl/link_atomics.cpp
index 053e7a4..46a8843 100644
--- a/src/compiler/glsl/link_atomics.cpp
+++ b/src/compiler/glsl/link_atomics.cpp
@@ -267,8 +267,9 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
     */
    for (unsigned j = 0; j < MESA_SHADER_STAGES; ++j) {
       if (prog->_LinkedShaders[j] && num_atomic_buffers[j] > 0) {
-         prog->_LinkedShaders[j]->NumAtomicBuffers = num_atomic_buffers[j];
-         prog->_LinkedShaders[j]->AtomicBuffers =
+         struct gl_program *gl_prog = prog->_LinkedShaders[j]->Program;
+         gl_prog->info.num_abos = num_atomic_buffers[j];
+         gl_prog->sh.AtomicBuffers =
             rzalloc_array(prog, gl_active_atomic_buffer *,
                           num_atomic_buffers[j]);
 
@@ -277,8 +278,7 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
             struct gl_active_atomic_buffer *atomic_buffer =
                &prog->AtomicBuffers[i];
             if (atomic_buffer->StageReferences[j]) {
-               prog->_LinkedShaders[j]->AtomicBuffers[intra_stage_idx] =
-                  atomic_buffer;
+               gl_prog->sh.AtomicBuffers[intra_stage_idx] = atomic_buffer;
 
                for (unsigned u = 0; u < atomic_buffer->NumUniforms; u++) {
                   prog->UniformStorage[atomic_buffer->Uniforms[u]].opaque[j].index =
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 047cf1b..09e9f42 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1510,7 +1510,6 @@ void brw_upload_ubo_surfaces(struct brw_context *brw,
                              struct brw_stage_state *stage_state,
                              struct brw_stage_prog_data *prog_data);
 void brw_upload_abo_surfaces(struct brw_context *brw,
-                             struct gl_linked_shader *shader,
                              const struct gl_program *prog,
                              struct brw_stage_state *stage_state,
                              struct brw_stage_prog_data *prog_data);
diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
index f9cd189..cf56acf 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
@@ -99,16 +99,12 @@ const struct brw_tracked_state brw_gs_ubo_surfaces = {
 static void
 brw_upload_gs_abo_surfaces(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog =
-      ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
    const struct gl_program *gp = brw->geometry_program;
 
-   if (gp && prog) {
+   if (gp) {
       /* BRW_NEW_GS_PROG_DATA */
-      brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_GEOMETRY],
-                              gp, &brw->gs.base, brw->gs.base.prog_data);
+      brw_upload_abo_surfaces(brw, gp, &brw->gs.base, brw->gs.base.prog_data);
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
index 775c735..b2d075f 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
@@ -99,16 +99,13 @@ const struct brw_tracked_state brw_tcs_ubo_surfaces = {
 static void
 brw_upload_tcs_abo_surfaces(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog =
-      ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
    const struct gl_program *tcp = brw->tess_ctrl_program;
 
-   if (tcp && prog) {
+   if (tcp) {
       /* BRW_NEW_TCS_PROG_DATA */
-      brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL],
-                              tcp, &brw->tcs.base, brw->tcs.base.prog_data);
+      brw_upload_abo_surfaces(brw, tcp, &brw->tcs.base,
+                              brw->tcs.base.prog_data);
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
index a9b3dfa..a351683 100644
--- a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
@@ -99,16 +99,13 @@ const struct brw_tracked_state brw_tes_ubo_surfaces = {
 static void
 brw_upload_tes_abo_surfaces(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog =
-      ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
    const struct gl_program *tep = brw->tess_eval_program;
 
-   if (tep && prog) {
+   if (tep) {
       /* BRW_NEW_TES_PROG_DATA */
-      brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL],
-                              tep, &brw->tes.base, brw->tes.base.prog_data);
+      brw_upload_abo_surfaces(brw, tep, &brw->tes.base,
+                              brw->tes.base.prog_data);
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
index 514f265..7bc7b77 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -165,16 +165,12 @@ const struct brw_tracked_state brw_vs_ubo_surfaces = {
 static void
 brw_upload_vs_abo_surfaces(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog =
-      ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
    const struct gl_program *vp = brw->vertex_program;
 
-   if (vp && prog) {
+   if (vp) {
       /* BRW_NEW_VS_PROG_DATA */
-      brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_VERTEX],
-                              vp, &brw->vs.base, brw->vs.base.prog_data);
+      brw_upload_abo_surfaces(brw, vp, &brw->vs.base, brw->vs.base.prog_data);
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 94fcfb1..0787bf1 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1490,7 +1490,6 @@ const struct brw_tracked_state brw_cs_ubo_surfaces = {
 
 void
 brw_upload_abo_surfaces(struct brw_context *brw,
-                        struct gl_linked_shader *shader,
                         const struct gl_program *prog,
                         struct brw_stage_state *stage_state,
                         struct brw_stage_prog_data *prog_data)
@@ -1500,10 +1499,9 @@ brw_upload_abo_surfaces(struct brw_context *brw,
       &stage_state->surf_offset[prog_data->binding_table.abo_start];
 
    if (prog->info.num_abos) {
-      assert(shader);
       for (unsigned i = 0; i < prog->info.num_abos; i++) {
          struct gl_atomic_buffer_binding *binding =
-            &ctx->AtomicBufferBindings[shader->AtomicBuffers[i]->Binding];
+            &ctx->AtomicBufferBindings[prog->sh.AtomicBuffers[i]->Binding];
          struct intel_buffer_object *intel_bo =
             intel_buffer_object(binding->BufferObject);
          drm_intel_bo *bo = intel_bufferobj_buffer(
@@ -1521,15 +1519,12 @@ brw_upload_abo_surfaces(struct brw_context *brw,
 static void
 brw_upload_wm_abo_surfaces(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog = ctx->_Shader->_CurrentFragmentProgram;
    const struct gl_program *wm = brw->fragment_program;
 
-   if (prog) {
+   if (wm) {
       /* BRW_NEW_FS_PROG_DATA */
-      brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
-                              wm, &brw->wm.base, brw->wm.base.prog_data);
+      brw_upload_abo_surfaces(brw, wm, &brw->wm.base, brw->wm.base.prog_data);
    }
 }
 
@@ -1547,16 +1542,12 @@ const struct brw_tracked_state brw_wm_abo_surfaces = {
 static void
 brw_upload_cs_abo_surfaces(struct brw_context *brw)
 {
-   struct gl_context *ctx = &brw->ctx;
    /* _NEW_PROGRAM */
-   struct gl_shader_program *prog =
-      ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
    const struct gl_program *cp = brw->compute_program;
 
-   if (cp && prog) {
+   if (cp) {
       /* BRW_NEW_CS_PROG_DATA */
-      brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_COMPUTE],
-                              cp, &brw->cs.base, brw->cs.base.prog_data);
+      brw_upload_abo_surfaces(brw, cp, &brw->cs.base, brw->cs.base.prog_data);
    }
 }
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7312179..600b1da 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1944,6 +1944,11 @@ struct gl_program
    GLubyte SamplerUnits[MAX_SAMPLERS];
 
    union {
+      /** Fields used by GLSL programs */
+      struct {
+         struct gl_active_atomic_buffer **AtomicBuffers;
+      } sh;
+
       /** ARB assembly-style program fields */
       struct {
          struct prog_instruction *Instructions;
@@ -2354,9 +2359,6 @@ struct gl_linked_shader
     */
    GLuint NumImages;
 
-   struct gl_active_atomic_buffer **AtomicBuffers;
-   unsigned NumAtomicBuffers;
-
    /**
      * Number of types for subroutine uniforms.
      */
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 5db4137..4d64ae5 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2165,7 +2165,6 @@ _mesa_copy_linked_program_data(const struct gl_shader_program *src,
 
    struct gl_program *dst = dst_sh->Program;
 
-   dst->info.num_abos = dst_sh->NumAtomicBuffers;
    dst->info.num_images = dst_sh->NumImages;
 
    switch (dst_sh->Stage) {
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index c430e1a..e0e6fc5 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6607,7 +6607,7 @@ set_affected_state_flags(uint64_t *states,
    if (shader->NumShaderStorageBlocks)
       *states |= new_ssbos;
 
-   if (shader->NumAtomicBuffers)
+   if (prog->info.num_abos)
       *states |= new_atomics;
 }
 
-- 
2.7.4



More information about the mesa-dev mailing list