[Mesa-dev] [PATCH 23/70] st/mesa/glsl/i965: move ShaderStorageBlocks to gl_program
Timothy Arceri
timothy.arceri at collabora.com
Tue Dec 20 10:37:33 UTC 2016
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.
---
src/compiler/glsl/link_uniforms.cpp | 3 ++-
src/compiler/glsl/linker.cpp | 9 +++++----
src/compiler/glsl/lower_ubo_reference.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 +-
src/mesa/main/mtypes.h | 3 +--
src/mesa/state_tracker/st_atom_storagebuf.c | 2 +-
6 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index dba4677..90eac5c 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -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);
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index e1e8a04..b01ec6c 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -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];
@@ -2283,11 +2284,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;
diff --git a/src/compiler/glsl/lower_ubo_reference.cpp b/src/compiler/glsl/lower_ubo_reference.cpp
index 02a97bd..bfaddac 100644
--- a/src/compiler/glsl/lower_ubo_reference.cpp
+++ b/src/compiler/glsl/lower_ubo_reference.cpp
@@ -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;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 28cb2ca..220e597 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -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]);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 797b2c3..3902653 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1996,6 +1996,7 @@ struct gl_program
GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
struct gl_uniform_block **UniformBlocks;
+ struct gl_uniform_block **ShaderStorageBlocks;
union {
struct {
@@ -2380,8 +2381,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;
diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c b/src/mesa/state_tracker/st_atom_storagebuf.c
index d01688c..e1efd62 100644
--- a/src/mesa/state_tracker/st_atom_storagebuf.c
+++ b/src/mesa/state_tracker/st_atom_storagebuf.c
@@ -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;
--
2.9.3
More information about the mesa-dev
mailing list