st/mesa/glsl/i965: set num_ssbos directly in shader_info
authorTimothy Arceri <timothy.arceri@collabora.com>
Fri, 4 Nov 2016 22:24:51 +0000 (09:24 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 6 Jan 2017 00:21:41 +0000 (11:21 +1100)
Here we also remove the duplicate field in gl_linked_shader and always
get the value from shader_info instead.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/linker.cpp
src/compiler/glsl/lower_ubo_reference.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_atom_storagebuf.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 2620b417498dd55705cfa7ed8a3b9eed89fe89f0..cf3511e10b97e66d4a7ff6c93e8a837a36201286 100644 (file)
@@ -150,7 +150,6 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
    if (shader_prog->Label)
       shader->info->label = ralloc_strdup(shader, shader_prog->Label);
    shader->info->num_textures = util_last_bit(sh->Program->SamplersUsed);
-   shader->info->num_ssbos = sh->NumShaderStorageBlocks;
    shader->info->clip_distance_array_size = sh->Program->ClipDistanceArraySize;
    shader->info->cull_distance_array_size = sh->Program->CullDistanceArraySize;
    shader->info->has_transform_feedback_varyings =
index f614b9a98bcc2252e3d82145f120ceedd6b7dbcf..dba46771ec2570d62934a14ce732342cfe397ee6 100644 (file)
@@ -901,7 +901,7 @@ link_update_uniform_buffer_variables(struct gl_linked_shader *shader,
              var->data.mode == ir_var_shader_storage);
 
       unsigned num_blocks = var->data.mode == ir_var_uniform ?
-         shader->Program->info.num_ubos : shader->NumShaderStorageBlocks;
+         shader->Program->info.num_ubos : shader->Program->info.num_ssbos;
       struct gl_uniform_block **blks = var->data.mode == ir_var_uniform ?
          shader->Program->sh.UniformBlocks : shader->ShaderStorageBlocks;
 
index c4e221ee369e3e23164ba1046e6a63107cad74c9..9de89f40abda71e4fed545a4e57447131e6a8fa3 100644 (file)
@@ -1137,7 +1137,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
       if (prog->_LinkedShaders[i]) {
          if (validate_ssbo) {
             max_num_buffer_blocks +=
-               prog->_LinkedShaders[i]->NumShaderStorageBlocks;
+               prog->_LinkedShaders[i]->Program->info.num_ssbos;
          } else {
             max_num_buffer_blocks +=
                prog->_LinkedShaders[i]->Program->info.num_ubos;
@@ -1158,7 +1158,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
       unsigned sh_num_blocks;
       struct gl_uniform_block **sh_blks;
       if (validate_ssbo) {
-         sh_num_blocks = prog->_LinkedShaders[i]->NumShaderStorageBlocks;
+         sh_num_blocks = prog->_LinkedShaders[i]->Program->info.num_ssbos;
          sh_blks = sh->ShaderStorageBlocks;
       } else {
          sh_num_blocks = prog->_LinkedShaders[i]->Program->info.num_ubos;
@@ -2287,7 +2287,7 @@ link_intrastage_shaders(void *mem_ctx,
    for (unsigned i = 0; i < num_ssbo_blocks; i++) {
       linked->ShaderStorageBlocks[i] = &ssbo_blocks[i];
    }
-   linked->NumShaderStorageBlocks = num_ssbo_blocks;
+   linked->Program->info.num_ssbos = num_ssbo_blocks;
 
    /* At this point linked should contain all of the linked IR, so
     * validate it to make sure nothing went wrong.
@@ -3099,7 +3099,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
          }
       }
 
-      total_shader_storage_blocks += sh->NumShaderStorageBlocks;
+      total_shader_storage_blocks += sh->Program->info.num_ssbos;
       total_uniform_blocks += sh->Program->info.num_ubos;
 
       const unsigned max_uniform_blocks =
@@ -3112,10 +3112,10 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 
       const unsigned max_shader_storage_blocks =
          ctx->Const.Program[i].MaxShaderStorageBlocks;
-      if (max_shader_storage_blocks < sh->NumShaderStorageBlocks) {
+      if (max_shader_storage_blocks < sh->Program->info.num_ssbos) {
          linker_error(prog, "Too many %s shader storage blocks (%d/%d)\n",
                       _mesa_shader_stage_to_string(i),
-                      sh->NumShaderStorageBlocks, max_shader_storage_blocks);
+                      sh->Program->info.num_ssbos, max_shader_storage_blocks);
       }
    }
 
@@ -3224,7 +3224,7 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
                          ctx->Const.Program[i].MaxImageUniforms);
 
          total_image_units += sh->NumImages;
-         total_shader_storage_blocks += sh->NumShaderStorageBlocks;
+         total_shader_storage_blocks += sh->Program->info.num_ssbos;
 
          if (i == MESA_SHADER_FRAGMENT) {
             foreach_in_list(ir_instruction, node, sh->ir) {
index 5beda458667981bc86acaae8fc7d45412ef138db..02a97bd352edae6f70bce0576a51360743f57252 100644 (file)
@@ -289,7 +289,7 @@ lower_ubo_reference_visitor::setup_for_load_or_store(void *mem_ctx,
    unsigned num_blocks;
    struct gl_uniform_block **blocks;
    if (this->buffer_access_type != ubo_load_access) {
-      num_blocks = shader->NumShaderStorageBlocks;
+      num_blocks = shader->Program->info.num_ssbos;
       blocks = shader->ShaderStorageBlocks;
    } else {
       num_blocks = shader->Program->info.num_ubos;
index e45f6cce0887dd448203858c5e67779f16c4f9e2..cabaf622a6f0a07ce92a8b10b44b50983b33b0cd 100644 (file)
@@ -1207,16 +1207,19 @@ brw_assign_common_binding_table_offsets(gl_shader_stage stage,
    stage_prog_data->binding_table.texture_start = next_binding_table_offset;
    next_binding_table_offset += num_textures;
 
-   if (shader) {
+   if (prog->info.num_ubos) {
       assert(prog->info.num_ubos <= BRW_MAX_UBO);
       stage_prog_data->binding_table.ubo_start = next_binding_table_offset;
       next_binding_table_offset += prog->info.num_ubos;
+   } else {
+      stage_prog_data->binding_table.ubo_start = 0xd0d0d0d0;
+   }
 
-      assert(shader->NumShaderStorageBlocks <= BRW_MAX_SSBO);
+   if (prog->info.num_ssbos) {
+      assert(prog->info.num_ssbos <= BRW_MAX_SSBO);
       stage_prog_data->binding_table.ssbo_start = next_binding_table_offset;
-      next_binding_table_offset += shader->NumShaderStorageBlocks;
+      next_binding_table_offset += prog->info.num_ssbos;
    } else {
-      stage_prog_data->binding_table.ubo_start = 0xd0d0d0d0;
       stage_prog_data->binding_table.ssbo_start = 0xd0d0d0d0;
    }
 
index 2140312a80291e65eefd122f5327194ce6bc7b45..28cb2ca2bd45efe5ceb3769404b58479bac839f0 100644 (file)
@@ -1408,7 +1408,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
    uint32_t *ssbo_surf_offsets =
       &stage_state->surf_offset[prog_data->binding_table.ssbo_start];
 
-   for (int i = 0; i < shader->NumShaderStorageBlocks; i++) {
+   for (int i = 0; i < shader->Program->info.num_ssbos; i++) {
       struct gl_shader_storage_buffer_binding *binding =
          &ctx->ShaderStorageBufferBindings[shader->ShaderStorageBlocks[i]->Binding];
 
@@ -1430,7 +1430,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
       }
    }
 
-   if (shader->Program->info.num_ubos || shader->NumShaderStorageBlocks)
+   if (shader->Program->info.num_ubos || shader->Program->info.num_ssbos)
       brw->ctx.NewDriverState |= BRW_NEW_SURFACES;
 }
 
index 308af2d3a757a8f286e981889e739db4ac9fe899..e4be2ea9a3a2df1f3cde74b4a91b6542bd94f00f 100644 (file)
@@ -2384,7 +2384,6 @@ struct gl_linked_shader
     */
    unsigned num_combined_uniform_components;
 
-   unsigned NumShaderStorageBlocks;
    struct gl_uniform_block **ShaderStorageBlocks;
 
    struct exec_list *ir;
index 1b6ed99e54a7b938625e1d1b460978734130ead8..d01688cd64998f40f8f2d03eb9a7965b31bc37b6 100644 (file)
@@ -53,7 +53,7 @@ st_bind_ssbos(struct st_context *st, struct gl_linked_shader *shader,
 
    c = &st->ctx->Const.Program[shader->Stage];
 
-   for (i = 0; i < shader->NumShaderStorageBlocks; i++) {
+   for (i = 0; i < shader->Program->info.num_ssbos; i++) {
       struct gl_shader_storage_buffer_binding *binding;
       struct st_buffer_object *st_obj;
       struct pipe_shader_buffer *sb = &buffers[i];
@@ -80,13 +80,13 @@ st_bind_ssbos(struct st_context *st, struct gl_linked_shader *shader,
       }
    }
    st->pipe->set_shader_buffers(st->pipe, shader_type, c->MaxAtomicBuffers,
-                                shader->NumShaderStorageBlocks, buffers);
+                                shader->Program->info.num_ssbos, buffers);
    /* clear out any stale shader buffers */
-   if (shader->NumShaderStorageBlocks < c->MaxShaderStorageBlocks)
+   if (shader->Program->info.num_ssbos < c->MaxShaderStorageBlocks)
       st->pipe->set_shader_buffers(
             st->pipe, shader_type,
-            c->MaxAtomicBuffers + shader->NumShaderStorageBlocks,
-            c->MaxShaderStorageBlocks - shader->NumShaderStorageBlocks,
+            c->MaxAtomicBuffers + shader->Program->info.num_ssbos,
+            c->MaxShaderStorageBlocks - shader->Program->info.num_ssbos,
             NULL);
 }
 
index 393d66820d8be58ee86c6eb82cdf89c20e37776e..b4ccc5f052535ff8c77fa8ac3737638ecc9435f9 100644 (file)
@@ -6645,7 +6645,7 @@ set_affected_state_flags(uint64_t *states,
    if (prog->info.num_ubos)
       *states |= new_ubos;
 
-   if (shader->NumShaderStorageBlocks)
+   if (prog->info.num_ssbos)
       *states |= new_ssbos;
 
    if (prog->info.num_abos)