st/mesa/glsl/i965: move ShaderStorageBlocks to gl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Fri, 4 Nov 2016 23:10:02 +0000 (10:10 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Fri, 6 Jan 2017 00:21:41 +0000 (11:21 +1100)
Having it here rather than in gl_linked_shader allows us to simplify
the code.

Also it is error prone to depend on the gl_linked_shader for programs
in current use because a failed linking attempt will free infomation
about the current program. In i965 we could be trying to recompile
a shader variant but may have lost some required fields.

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_storagebuf.c

index dba46771ec2570d62934a14ce732342cfe397ee6..90eac5cc512bb5a589d899ad9c0c048024849897 100644 (file)
@@ -903,7 +903,8 @@ 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->Program->info.num_ssbos;
       struct gl_uniform_block **blks = var->data.mode == ir_var_uniform ?
-         shader->Program->sh.UniformBlocks : shader->ShaderStorageBlocks;
+         shader->Program->sh.UniformBlocks :
+         shader->Program->sh.ShaderStorageBlocks;
 
       if (var->is_interface_instance()) {
          const ir_array_refcount_entry *const entry = v.get_variable_entry(var);
index 9de89f40abda71e4fed545a4e57447131e6a8fa3..38cbbfa680fdc21e772efd4a8c50f41c16e93bdc 100644 (file)
@@ -1159,7 +1159,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
       struct gl_uniform_block **sh_blks;
       if (validate_ssbo) {
          sh_num_blocks = prog->_LinkedShaders[i]->Program->info.num_ssbos;
-         sh_blks = sh->ShaderStorageBlocks;
+         sh_blks = sh->Program->sh.ShaderStorageBlocks;
       } else {
          sh_num_blocks = prog->_LinkedShaders[i]->Program->info.num_ubos;
          sh_blks = sh->Program->sh.UniformBlocks;
@@ -1194,7 +1194,8 @@ 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->Program->sh.UniformBlocks;
+               sh->Program->sh.ShaderStorageBlocks :
+               sh->Program->sh.UniformBlocks;
 
             blks[j].stageref |= sh_blks[stage_index]->stageref;
             sh_blks[stage_index] = &blks[j];
@@ -2281,11 +2282,11 @@ link_intrastage_shaders(void *mem_ctx,
    linked->Program->info.num_ubos = num_ubo_blocks;
 
    /* Copy ssbo blocks to linked shader list */
-   linked->ShaderStorageBlocks =
+   linked->Program->sh.ShaderStorageBlocks =
       ralloc_array(linked, gl_uniform_block *, num_ssbo_blocks);
    ralloc_steal(linked, ssbo_blocks);
    for (unsigned i = 0; i < num_ssbo_blocks; i++) {
-      linked->ShaderStorageBlocks[i] = &ssbo_blocks[i];
+      linked->Program->sh.ShaderStorageBlocks[i] = &ssbo_blocks[i];
    }
    linked->Program->info.num_ssbos = num_ssbo_blocks;
 
index 02a97bd352edae6f70bce0576a51360743f57252..bfaddac3add99fef2df39d24d09b8d729abf94fa 100644 (file)
@@ -290,7 +290,7 @@ lower_ubo_reference_visitor::setup_for_load_or_store(void *mem_ctx,
    struct gl_uniform_block **blocks;
    if (this->buffer_access_type != ubo_load_access) {
       num_blocks = shader->Program->info.num_ssbos;
-      blocks = shader->ShaderStorageBlocks;
+      blocks = shader->Program->sh.ShaderStorageBlocks;
    } else {
       num_blocks = shader->Program->info.num_ubos;
       blocks = shader->Program->sh.UniformBlocks;
index 28cb2ca2bd45efe5ceb3769404b58479bac839f0..220e597338fd994d1054706dceb7ed55dc18a557 100644 (file)
@@ -1410,7 +1410,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
 
    for (int i = 0; i < shader->Program->info.num_ssbos; i++) {
       struct gl_shader_storage_buffer_binding *binding =
-         &ctx->ShaderStorageBufferBindings[shader->ShaderStorageBlocks[i]->Binding];
+         &ctx->ShaderStorageBufferBindings[shader->Program->sh.ShaderStorageBlocks[i]->Binding];
 
       if (binding->BufferObject == ctx->Shared->NullBufferObj) {
          brw->vtbl.emit_null_surface_state(brw, 1, 1, 1, &ssbo_surf_offsets[i]);
index e4be2ea9a3a2df1f3cde74b4a91b6542bd94f00f..0301eb57f8fcc79dfe96dfcbbc145889a954e581 100644 (file)
@@ -2000,6 +2000,7 @@ struct gl_program
          GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
 
          struct gl_uniform_block **UniformBlocks;
+         struct gl_uniform_block **ShaderStorageBlocks;
 
          union {
             struct {
@@ -2384,8 +2385,6 @@ struct gl_linked_shader
     */
    unsigned num_combined_uniform_components;
 
-   struct gl_uniform_block **ShaderStorageBlocks;
-
    struct exec_list *ir;
    struct exec_list *packed_varyings;
    struct exec_list *fragdata_arrays;
index d01688cd64998f40f8f2d03eb9a7965b31bc37b6..e1efd624a4becf030d2af8d9ff6ea8fe7479f5ee 100644 (file)
@@ -59,7 +59,7 @@ st_bind_ssbos(struct st_context *st, struct gl_linked_shader *shader,
       struct pipe_shader_buffer *sb = &buffers[i];
 
       binding = &st->ctx->ShaderStorageBufferBindings[
-            shader->ShaderStorageBlocks[i]->Binding];
+            shader->Program->sh.ShaderStorageBlocks[i]->Binding];
       st_obj = st_buffer_object(binding->BufferObject);
 
       sb->buffer = st_obj->buffer;