i965: get num_abos from shader_info rather than gl_linked_shader
authorTimothy Arceri <timothy.arceri@collabora.com>
Thu, 27 Oct 2016 08:15:19 +0000 (19:15 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Thu, 17 Nov 2016 01:52:24 +0000 (12:52 +1100)
This is a step towards freeing gl_linked_shader after linking.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_gs_surface_state.c
src/mesa/drivers/dri/i965/brw_shader.cpp
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

index 799ae75742d27c42c88685f77e04a2055ecb4c54..7604d26b082009a8d56875954ccef48dd7180e90 100644 (file)
@@ -1511,6 +1511,7 @@ void brw_upload_ubo_surfaces(struct brw_context *brw,
                              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);
 void brw_upload_image_surfaces(struct brw_context *brw,
index dd43edfec85b19bff41e661d96e92645a96c4abb..f9cd18989f7bf100def58819fb3446cf0b27608b 100644 (file)
@@ -103,11 +103,12 @@ brw_upload_gs_abo_surfaces(struct brw_context *brw)
    /* _NEW_PROGRAM */
    struct gl_shader_program *prog =
       ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
+   const struct gl_program *gp = brw->geometry_program;
 
-   if (prog) {
+   if (gp && prog) {
       /* BRW_NEW_GS_PROG_DATA */
       brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_GEOMETRY],
-                              &brw->gs.base, brw->gs.base.prog_data);
+                              gp, &brw->gs.base, brw->gs.base.prog_data);
    }
 }
 
index db797184db526ea82f03c4c67e7b3aeb08709896..5ab8ada8bf02b26704c57d26415dd550018b97fb 100644 (file)
@@ -1224,9 +1224,9 @@ brw_assign_common_binding_table_offsets(gl_shader_stage stage,
       stage_prog_data->binding_table.gather_texture_start = 0xd0d0d0d0;
    }
 
-   if (shader && shader->NumAtomicBuffers) {
+   if (prog->info.num_abos) {
       stage_prog_data->binding_table.abo_start = next_binding_table_offset;
-      next_binding_table_offset += shader->NumAtomicBuffers;
+      next_binding_table_offset += prog->info.num_abos;
    } else {
       stage_prog_data->binding_table.abo_start = 0xd0d0d0d0;
    }
index 06bdfa3762f626156bbdee107216996668f7bf2d..775c7350ec5e0c84c66a420db5488254a0843119 100644 (file)
@@ -103,11 +103,12 @@ brw_upload_tcs_abo_surfaces(struct brw_context *brw)
    /* _NEW_PROGRAM */
    struct gl_shader_program *prog =
       ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
+   const struct gl_program *tcp = brw->tess_ctrl_program;
 
-   if (prog) {
+   if (tcp && prog) {
       /* BRW_NEW_TCS_PROG_DATA */
       brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL],
-                              &brw->tcs.base, brw->tcs.base.prog_data);
+                              tcp, &brw->tcs.base, brw->tcs.base.prog_data);
    }
 }
 
index 1b31b203a1120e4b3439fcf0107a1ea2ef74e79f..a9b3dfaaaff7f405cfc236045938b8f18ba1213f 100644 (file)
@@ -103,11 +103,12 @@ brw_upload_tes_abo_surfaces(struct brw_context *brw)
    /* _NEW_PROGRAM */
    struct gl_shader_program *prog =
       ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
+   const struct gl_program *tep = brw->tess_eval_program;
 
-   if (prog) {
+   if (tep && prog) {
       /* BRW_NEW_TES_PROG_DATA */
       brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL],
-                              &brw->tes.base, brw->tes.base.prog_data);
+                              tep, &brw->tes.base, brw->tes.base.prog_data);
    }
 }
 
index 891fd5db3f221423d476f54ae8903e3223ba1063..514f26569cc58344b1a9b96e9855b944e760b4a1 100644 (file)
@@ -169,11 +169,12 @@ brw_upload_vs_abo_surfaces(struct brw_context *brw)
    /* _NEW_PROGRAM */
    struct gl_shader_program *prog =
       ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
+   const struct gl_program *vp = brw->vertex_program;
 
-   if (prog) {
+   if (vp && prog) {
       /* BRW_NEW_VS_PROG_DATA */
       brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_VERTEX],
-                              &brw->vs.base, brw->vs.base.prog_data);
+                              vp, &brw->vs.base, brw->vs.base.prog_data);
    }
 }
 
index c275b71ed4b6d45df0fb24f942d6e67a37a09083..300eff926e4a707e13b05292de6fbe6c20cf3b36 100644 (file)
@@ -1485,6 +1485,7 @@ 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)
 {
@@ -1492,8 +1493,9 @@ brw_upload_abo_surfaces(struct brw_context *brw,
    uint32_t *surf_offsets =
       &stage_state->surf_offset[prog_data->binding_table.abo_start];
 
-   if (shader && shader->NumAtomicBuffers) {
-      for (unsigned i = 0; i < shader->NumAtomicBuffers; i++) {
+   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];
          struct intel_buffer_object *intel_bo =
@@ -1516,11 +1518,12 @@ 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) {
       /* BRW_NEW_FS_PROG_DATA */
       brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
-                              &brw->wm.base, brw->wm.base.prog_data);
+                              wm, &brw->wm.base, brw->wm.base.prog_data);
    }
 }
 
@@ -1542,11 +1545,12 @@ brw_upload_cs_abo_surfaces(struct brw_context *brw)
    /* _NEW_PROGRAM */
    struct gl_shader_program *prog =
       ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+   const struct gl_program *cp = brw->compute_program;
 
-   if (prog) {
+   if (cp && prog) {
       /* BRW_NEW_CS_PROG_DATA */
       brw_upload_abo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_COMPUTE],
-                              &brw->cs.base, brw->cs.base.prog_data);
+                              cp, &brw->cs.base, brw->cs.base.prog_data);
    }
 }