glsl/i965: move per stage AtomicBuffers list to gl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Fri, 11 Nov 2016 00:45:54 +0000 (11:45 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 18 Nov 2016 22:35:58 +0000 (09:35 +1100)
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/compiler/glsl/link_atomics.cpp
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_gs_surface_state.c
src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
src/mesa/drivers/dri/i965/brw_tes_surface_state.c
src/mesa/drivers/dri/i965/brw_vs_surface_state.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 053e7a433e0f630ce2087608cee1e3f91658b55f..46a8843d2cbe0cedd7137951e159b110240c9c9f 100644 (file)
@@ -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 =
index 7604d26b082009a8d56875954ccef48dd7180e90..be59e3b0d16549d258b08cabe313e9b7c5fa67bb 100644 (file)
@@ -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);
index f9cd18989f7bf100def58819fb3446cf0b27608b..cf56acfd99a758cdde190fbf5659f48f76d8a7a2 100644 (file)
@@ -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);
    }
 }
 
index 775c7350ec5e0c84c66a420db5488254a0843119..b2d075fe6bf9cbc18267be317aa565d5fd82211f 100644 (file)
@@ -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);
    }
 }
 
index a9b3dfaaaff7f405cfc236045938b8f18ba1213f..a3516834ce4277e2c28457f797604f4fa5c71698 100644 (file)
@@ -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);
    }
 }
 
index 514f26569cc58344b1a9b96e9855b944e760b4a1..7bc7b77e9cfc1a3f42c979ef80548ce30112dd33 100644 (file)
@@ -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);
    }
 }
 
index 300eff926e4a707e13b05292de6fbe6c20cf3b36..d40ccbf926d55b7fb4be720e250a84a183c63411 100644 (file)
@@ -1484,7 +1484,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)
@@ -1494,10 +1493,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(
@@ -1515,15 +1513,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);
    }
 }
 
@@ -1541,16 +1536,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);
    }
 }
 
index d2c1e58300455460abff49f8f07d49974a51b7d3..440bbb4b7627e039c31db4f10948a38a52a79600 100644 (file)
@@ -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.
      */
index cedcfa3a04cb9a9b696d73d276b6aa6bdfd1de5d..aebd81214e7cd2a3ae2c7b7689d03002a03dac74 100644 (file)
@@ -2152,7 +2152,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) {
index 2c2bbb6c26b5926168ff60f7e55906e930f97a37..0cea32b764bd25d87927147a8fbb5a7c6dd95c48 100644 (file)
@@ -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;
 }