diff options
author | Timothy Arceri <[email protected]> | 2016-11-05 08:55:57 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-01-06 11:21:41 +1100 |
commit | 0e7eec1ab5f27ced1aa4b2d77c2c63512d299694 (patch) | |
tree | 1cf0ae90e08fd5c0f177a773a62a74c39545223d /src | |
parent | b792c3897927c1d89968bc0040faef02ec976184 (diff) |
st/mesa/glsl/i965: move per stage UniformBlocks to gl_program
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/link_uniforms.cpp | 4 | ||||
-rw-r--r-- | src/compiler/glsl/linker.cpp | 8 | ||||
-rw-r--r-- | src/compiler/glsl/lower_ubo_reference.cpp | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_constbuf.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 18 |
7 files changed, 19 insertions, 21 deletions
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index fd8331be497..f614b9a98bc 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/glsl/link_uniforms.cpp @@ -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; } } diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 332b799145c..c4e221ee369 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -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; diff --git a/src/compiler/glsl/lower_ubo_reference.cpp b/src/compiler/glsl/lower_ubo_reference.cpp index 985ecea554e..5beda458667 100644 --- a/src/compiler/glsl/lower_ubo_reference.cpp +++ b/src/compiler/glsl/lower_ubo_reference.cpp @@ -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++) { 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 e3a6033e01a..2140312a802 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -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]); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9c1bbd5b40a..308af2d3a75 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -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; diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 30bffa648c5..45bb8853599 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -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; diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 99422df7f74..393d66820d8 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -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. |