st/mesa/glsl/i965: move per stage UniformBlocks to gl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Fri, 4 Nov 2016 21:55:57 +0000 (08:55 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 6 Jan 2017 00:21:41 +0000 (11:21 +1100)
This will help allow us to store pointers to gl_program structs in the
CurrentProgram array resulting in a bunch of code simplifications.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/linker.cpp
src/compiler/glsl/lower_ubo_reference.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 fd8331be4973873774fa59c71864eab2ab173a8d..f614b9a98bcc2252e3d82145f120ceedd6b7dbcf 100644 (file)
@@ -903,7 +903,7 @@ link_update_uniform_buffer_variables(struct gl_linked_shader *shader,
       unsigned num_blocks = var->data.mode == ir_var_uniform ?
          shader->Program->info.num_ubos : shader->NumShaderStorageBlocks;
       struct gl_uniform_block **blks = var->data.mode == ir_var_uniform ?
-         shader->UniformBlocks : shader->ShaderStorageBlocks;
+         shader->Program->sh.UniformBlocks : shader->ShaderStorageBlocks;
 
       if (var->is_interface_instance()) {
          const ir_array_refcount_entry *const entry = v.get_variable_entry(var);
@@ -1332,7 +1332,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
 
       for (unsigned i = 0; i < sh->Program->info.num_ubos; i++) {
          sh->num_combined_uniform_components +=
-            sh->UniformBlocks[i]->UniformBufferSize / 4;
+            sh->Program->sh.UniformBlocks[i]->UniformBufferSize / 4;
       }
    }
 
index 332b799145cdc6387180516bb2a62f43f27bcd1e..c4e221ee369e3e23164ba1046e6a63107cad74c9 100644 (file)
@@ -1162,7 +1162,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
          sh_blks = sh->ShaderStorageBlocks;
       } else {
          sh_num_blocks = prog->_LinkedShaders[i]->Program->info.num_ubos;
-         sh_blks = sh->UniformBlocks;
+         sh_blks = sh->Program->sh.UniformBlocks;
       }
 
       for (unsigned int j = 0; j < sh_num_blocks; j++) {
@@ -1194,7 +1194,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
             struct gl_linked_shader *sh = prog->_LinkedShaders[i];
 
             struct gl_uniform_block **sh_blks = validate_ssbo ?
-               sh->ShaderStorageBlocks : sh->UniformBlocks;
+               sh->ShaderStorageBlocks : sh->Program->sh.UniformBlocks;
 
             blks[j].stageref |= sh_blks[stage_index]->stageref;
             sh_blks[stage_index] = &blks[j];
@@ -2272,11 +2272,11 @@ link_intrastage_shaders(void *mem_ctx,
    }
 
    /* Copy ubo blocks to linked shader list */
-   linked->UniformBlocks =
+   linked->Program->sh.UniformBlocks =
       ralloc_array(linked, gl_uniform_block *, num_ubo_blocks);
    ralloc_steal(linked, ubo_blocks);
    for (unsigned i = 0; i < num_ubo_blocks; i++) {
-      linked->UniformBlocks[i] = &ubo_blocks[i];
+      linked->Program->sh.UniformBlocks[i] = &ubo_blocks[i];
    }
    linked->Program->info.num_ubos = num_ubo_blocks;
 
index 985ecea554edb15885e7d9aedc26eadd324d5c58..5beda458667981bc86acaae8fc7d45412ef138db 100644 (file)
@@ -293,7 +293,7 @@ lower_ubo_reference_visitor::setup_for_load_or_store(void *mem_ctx,
       blocks = shader->ShaderStorageBlocks;
    } else {
       num_blocks = shader->Program->info.num_ubos;
-      blocks = shader->UniformBlocks;
+      blocks = shader->Program->sh.UniformBlocks;
    }
    this->uniform_block = NULL;
    for (unsigned i = 0; i < num_blocks; i++) {
index e3a6033e01a94d513aaee02249fb3f3c698244dd..2140312a80291e65eefd122f5327194ce6bc7b45 100644 (file)
@@ -1385,7 +1385,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
 
    for (int i = 0; i < shader->Program->info.num_ubos; i++) {
       struct gl_uniform_buffer_binding *binding =
-         &ctx->UniformBufferBindings[shader->UniformBlocks[i]->Binding];
+         &ctx->UniformBufferBindings[shader->Program->sh.UniformBlocks[i]->Binding];
 
       if (binding->BufferObject == ctx->Shared->NullBufferObj) {
          brw->vtbl.emit_null_surface_state(brw, 1, 1, 1, &ubo_surf_offsets[i]);
index 9c1bbd5b40abca55f8fa4ade292d97b70d296e54..308af2d3a757a8f286e981889e739db4ac9fe899 100644 (file)
@@ -1999,6 +1999,8 @@ struct gl_program
           */
          GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
 
+         struct gl_uniform_block **UniformBlocks;
+
          union {
             struct {
                /**
@@ -2382,8 +2384,6 @@ struct gl_linked_shader
     */
    unsigned num_combined_uniform_components;
 
-   struct gl_uniform_block **UniformBlocks;
-
    unsigned NumShaderStorageBlocks;
    struct gl_uniform_block **ShaderStorageBlocks;
 
index 30bffa648c5408444c97d043d50ca40d1cb98098..45bb885359922787b6a25c178007ac78903ee78d 100644 (file)
@@ -252,7 +252,7 @@ static void st_bind_ubos(struct st_context *st,
       struct gl_uniform_buffer_binding *binding;
       struct st_buffer_object *st_obj;
 
-      binding = &st->ctx->UniformBufferBindings[shader->UniformBlocks[i]->Binding];
+      binding = &st->ctx->UniformBufferBindings[shader->Program->sh.UniformBlocks[i]->Binding];
       st_obj = st_buffer_object(binding->BufferObject);
 
       cb.buffer = st_obj->buffer;
index 99422df7f748ca9485fc55c8771873c9fef1437a..393d66820d8be58ee86c6eb82cdf89c20e37776e 100644 (file)
@@ -6301,16 +6301,14 @@ st_translate_program(
       }
    }
 
-   if (program->shader) {
-      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;
-         assert(num_const_vecs > 0);
-         first = 0;
-         last = num_const_vecs > 0 ? num_const_vecs - 1 : 0;
-         ureg_DECL_constant2D(t->ureg, first, last, i + 1);
-      }
+   for (i = 0; i < proginfo->info.num_ubos; i++) {
+      unsigned size = proginfo->sh.UniformBlocks[i]->UniformBufferSize;
+      unsigned num_const_vecs = (size + 15) / 16;
+      unsigned first, last;
+      assert(num_const_vecs > 0);
+      first = 0;
+      last = num_const_vecs > 0 ? num_const_vecs - 1 : 0;
+      ureg_DECL_constant2D(t->ureg, first, last, i + 1);
    }
 
    /* Emit immediate values.