st/mesa/glsl/i965: set num_ubos directly in shader_info
authorTimothy Arceri <timothy.arceri@collabora.com>
Fri, 4 Nov 2016 21:44:22 +0000 (08:44 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 6 Jan 2017 00:21:41 +0000 (11:21 +1100)
This also removes the duplicate field in gl_linked_shader, and
gets num_ubos 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_constbuf.c
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 4e0a33a9e74d2f407f7da5a97b03b1aa27efe0d8..2620b417498dd55705cfa7ed8a3b9eed89fe89f0 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_ubos = sh->NumUniformBlocks;
    shader->info->num_ssbos = sh->NumShaderStorageBlocks;
    shader->info->clip_distance_array_size = sh->Program->ClipDistanceArraySize;
    shader->info->cull_distance_array_size = sh->Program->CullDistanceArraySize;
index cd00837cca929a351932b39b0f7a9a08f7802e4e..fd8331be4973873774fa59c71864eab2ab173a8d 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->NumUniformBlocks : shader->NumShaderStorageBlocks;
+         shader->Program->info.num_ubos : shader->NumShaderStorageBlocks;
       struct gl_uniform_block **blks = var->data.mode == ir_var_uniform ?
          shader->UniformBlocks : shader->ShaderStorageBlocks;
 
@@ -1330,7 +1330,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
       sh->num_uniform_components = uniform_size.num_shader_uniform_components;
       sh->num_combined_uniform_components = sh->num_uniform_components;
 
-      for (unsigned i = 0; i < sh->NumUniformBlocks; i++) {
+      for (unsigned i = 0; i < sh->Program->info.num_ubos; i++) {
          sh->num_combined_uniform_components +=
             sh->UniformBlocks[i]->UniformBufferSize / 4;
       }
index 13fbb30b27bc71ee8dccd592754f4046d12203d0..332b799145cdc6387180516bb2a62f43f27bcd1e 100644 (file)
@@ -1140,7 +1140,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
                prog->_LinkedShaders[i]->NumShaderStorageBlocks;
          } else {
             max_num_buffer_blocks +=
-               prog->_LinkedShaders[i]->NumUniformBlocks;
+               prog->_LinkedShaders[i]->Program->info.num_ubos;
          }
       }
    }
@@ -1161,7 +1161,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
          sh_num_blocks = prog->_LinkedShaders[i]->NumShaderStorageBlocks;
          sh_blks = sh->ShaderStorageBlocks;
       } else {
-         sh_num_blocks = prog->_LinkedShaders[i]->NumUniformBlocks;
+         sh_num_blocks = prog->_LinkedShaders[i]->Program->info.num_ubos;
          sh_blks = sh->UniformBlocks;
       }
 
@@ -2278,7 +2278,7 @@ link_intrastage_shaders(void *mem_ctx,
    for (unsigned i = 0; i < num_ubo_blocks; i++) {
       linked->UniformBlocks[i] = &ubo_blocks[i];
    }
-   linked->NumUniformBlocks = num_ubo_blocks;
+   linked->Program->info.num_ubos = num_ubo_blocks;
 
    /* Copy ssbo blocks to linked shader list */
    linked->ShaderStorageBlocks =
@@ -3100,14 +3100,14 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
       }
 
       total_shader_storage_blocks += sh->NumShaderStorageBlocks;
-      total_uniform_blocks += sh->NumUniformBlocks;
+      total_uniform_blocks += sh->Program->info.num_ubos;
 
       const unsigned max_uniform_blocks =
          ctx->Const.Program[i].MaxUniformBlocks;
-      if (max_uniform_blocks < sh->NumUniformBlocks) {
+      if (max_uniform_blocks < sh->Program->info.num_ubos) {
          linker_error(prog, "Too many %s uniform blocks (%d/%d)\n",
-                      _mesa_shader_stage_to_string(i), sh->NumUniformBlocks,
-                      max_uniform_blocks);
+                      _mesa_shader_stage_to_string(i),
+                      sh->Program->info.num_ubos, max_uniform_blocks);
       }
 
       const unsigned max_shader_storage_blocks =
index eafa1dd75252a6d649addac68edebd9ba32dec27..985ecea554edb15885e7d9aedc26eadd324d5c58 100644 (file)
@@ -292,7 +292,7 @@ lower_ubo_reference_visitor::setup_for_load_or_store(void *mem_ctx,
       num_blocks = shader->NumShaderStorageBlocks;
       blocks = shader->ShaderStorageBlocks;
    } else {
-      num_blocks = shader->NumUniformBlocks;
+      num_blocks = shader->Program->info.num_ubos;
       blocks = shader->UniformBlocks;
    }
    this->uniform_block = NULL;
index dfc7407ea5ba551558b9f47e7eaf8b2ad4d3665e..e45f6cce0887dd448203858c5e67779f16c4f9e2 100644 (file)
@@ -1208,9 +1208,9 @@ brw_assign_common_binding_table_offsets(gl_shader_stage stage,
    next_binding_table_offset += num_textures;
 
    if (shader) {
-      assert(shader->NumUniformBlocks <= BRW_MAX_UBO);
+      assert(prog->info.num_ubos <= BRW_MAX_UBO);
       stage_prog_data->binding_table.ubo_start = next_binding_table_offset;
-      next_binding_table_offset += shader->NumUniformBlocks;
+      next_binding_table_offset += prog->info.num_ubos;
 
       assert(shader->NumShaderStorageBlocks <= BRW_MAX_SSBO);
       stage_prog_data->binding_table.ssbo_start = next_binding_table_offset;
index 34fec7e7d946bd943a4636a68e3545c85b826dd8..e3a6033e01a94d513aaee02249fb3f3c698244dd 100644 (file)
@@ -1383,7 +1383,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
    uint32_t *ubo_surf_offsets =
       &stage_state->surf_offset[prog_data->binding_table.ubo_start];
 
-   for (int i = 0; i < shader->NumUniformBlocks; i++) {
+   for (int i = 0; i < shader->Program->info.num_ubos; i++) {
       struct gl_uniform_buffer_binding *binding =
          &ctx->UniformBufferBindings[shader->UniformBlocks[i]->Binding];
 
@@ -1430,7 +1430,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
       }
    }
 
-   if (shader->NumUniformBlocks || shader->NumShaderStorageBlocks)
+   if (shader->Program->info.num_ubos || shader->NumShaderStorageBlocks)
       brw->ctx.NewDriverState |= BRW_NEW_SURFACES;
 }
 
index fa14c87a2c0c406735088afe33669a36d8ecb2e2..9c1bbd5b40abca55f8fa4ade292d97b70d296e54 100644 (file)
@@ -2382,7 +2382,6 @@ struct gl_linked_shader
     */
    unsigned num_combined_uniform_components;
 
-   unsigned NumUniformBlocks;
    struct gl_uniform_block **UniformBlocks;
 
    unsigned NumShaderStorageBlocks;
index 3b5031dcf204c542c1336ebcec3aa56818578dcd..30bffa648c5408444c97d043d50ca40d1cb98098 100644 (file)
@@ -248,7 +248,7 @@ static void st_bind_ubos(struct st_context *st,
    if (!shader)
       return;
 
-   for (i = 0; i < shader->NumUniformBlocks; i++) {
+   for (i = 0; i < shader->Program->info.num_ubos; i++) {
       struct gl_uniform_buffer_binding *binding;
       struct st_buffer_object *st_obj;
 
index df7a1bc0cfeb7750609c3f0349a064e0f10996c1..99422df7f748ca9485fc55c8771873c9fef1437a 100644 (file)
@@ -6302,9 +6302,7 @@ st_translate_program(
    }
 
    if (program->shader) {
-      unsigned num_ubos = program->shader->NumUniformBlocks;
-
-      for (i = 0; i < num_ubos; i++) {
+      for (i = 0; i < proginfo->info.num_ubos; i++) {
          unsigned size = program->shader->UniformBlocks[i]->UniformBufferSize;
          unsigned num_const_vecs = (size + 15) / 16;
          unsigned first, last;
@@ -6646,7 +6644,7 @@ set_affected_state_flags(uint64_t *states,
    if (shader->NumImages)
       *states |= new_images;
 
-   if (shader->NumUniformBlocks)
+   if (prog->info.num_ubos)
       *states |= new_ubos;
 
    if (shader->NumShaderStorageBlocks)