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 <lionel.g.landwerlin@intel.com>
This commit is contained in:
@@ -903,7 +903,7 @@ link_update_uniform_buffer_variables(struct gl_linked_shader *shader,
|
|||||||
unsigned num_blocks = var->data.mode == ir_var_uniform ?
|
unsigned num_blocks = var->data.mode == ir_var_uniform ?
|
||||||
shader->Program->info.num_ubos : shader->NumShaderStorageBlocks;
|
shader->Program->info.num_ubos : shader->NumShaderStorageBlocks;
|
||||||
struct gl_uniform_block **blks = var->data.mode == ir_var_uniform ?
|
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()) {
|
if (var->is_interface_instance()) {
|
||||||
const ir_array_refcount_entry *const entry = v.get_variable_entry(var);
|
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++) {
|
for (unsigned i = 0; i < sh->Program->info.num_ubos; i++) {
|
||||||
sh->num_combined_uniform_components +=
|
sh->num_combined_uniform_components +=
|
||||||
sh->UniformBlocks[i]->UniformBufferSize / 4;
|
sh->Program->sh.UniformBlocks[i]->UniformBufferSize / 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1162,7 +1162,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
|
|||||||
sh_blks = sh->ShaderStorageBlocks;
|
sh_blks = sh->ShaderStorageBlocks;
|
||||||
} else {
|
} else {
|
||||||
sh_num_blocks = prog->_LinkedShaders[i]->Program->info.num_ubos;
|
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++) {
|
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_linked_shader *sh = prog->_LinkedShaders[i];
|
||||||
|
|
||||||
struct gl_uniform_block **sh_blks = validate_ssbo ?
|
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;
|
blks[j].stageref |= sh_blks[stage_index]->stageref;
|
||||||
sh_blks[stage_index] = &blks[j];
|
sh_blks[stage_index] = &blks[j];
|
||||||
@@ -2272,11 +2272,11 @@ link_intrastage_shaders(void *mem_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy ubo blocks to linked shader list */
|
/* Copy ubo blocks to linked shader list */
|
||||||
linked->UniformBlocks =
|
linked->Program->sh.UniformBlocks =
|
||||||
ralloc_array(linked, gl_uniform_block *, num_ubo_blocks);
|
ralloc_array(linked, gl_uniform_block *, num_ubo_blocks);
|
||||||
ralloc_steal(linked, ubo_blocks);
|
ralloc_steal(linked, ubo_blocks);
|
||||||
for (unsigned i = 0; i < num_ubo_blocks; i++) {
|
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;
|
linked->Program->info.num_ubos = num_ubo_blocks;
|
||||||
|
|
||||||
|
@@ -293,7 +293,7 @@ lower_ubo_reference_visitor::setup_for_load_or_store(void *mem_ctx,
|
|||||||
blocks = shader->ShaderStorageBlocks;
|
blocks = shader->ShaderStorageBlocks;
|
||||||
} else {
|
} else {
|
||||||
num_blocks = shader->Program->info.num_ubos;
|
num_blocks = shader->Program->info.num_ubos;
|
||||||
blocks = shader->UniformBlocks;
|
blocks = shader->Program->sh.UniformBlocks;
|
||||||
}
|
}
|
||||||
this->uniform_block = NULL;
|
this->uniform_block = NULL;
|
||||||
for (unsigned i = 0; i < num_blocks; i++) {
|
for (unsigned i = 0; i < num_blocks; i++) {
|
||||||
|
@@ -1385,7 +1385,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
|
|||||||
|
|
||||||
for (int i = 0; i < shader->Program->info.num_ubos; i++) {
|
for (int i = 0; i < shader->Program->info.num_ubos; i++) {
|
||||||
struct gl_uniform_buffer_binding *binding =
|
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) {
|
if (binding->BufferObject == ctx->Shared->NullBufferObj) {
|
||||||
brw->vtbl.emit_null_surface_state(brw, 1, 1, 1, &ubo_surf_offsets[i]);
|
brw->vtbl.emit_null_surface_state(brw, 1, 1, 1, &ubo_surf_offsets[i]);
|
||||||
|
@@ -1999,6 +1999,8 @@ struct gl_program
|
|||||||
*/
|
*/
|
||||||
GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
|
GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
|
||||||
|
|
||||||
|
struct gl_uniform_block **UniformBlocks;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
/**
|
/**
|
||||||
@@ -2382,8 +2384,6 @@ struct gl_linked_shader
|
|||||||
*/
|
*/
|
||||||
unsigned num_combined_uniform_components;
|
unsigned num_combined_uniform_components;
|
||||||
|
|
||||||
struct gl_uniform_block **UniformBlocks;
|
|
||||||
|
|
||||||
unsigned NumShaderStorageBlocks;
|
unsigned NumShaderStorageBlocks;
|
||||||
struct gl_uniform_block **ShaderStorageBlocks;
|
struct gl_uniform_block **ShaderStorageBlocks;
|
||||||
|
|
||||||
|
@@ -252,7 +252,7 @@ static void st_bind_ubos(struct st_context *st,
|
|||||||
struct gl_uniform_buffer_binding *binding;
|
struct gl_uniform_buffer_binding *binding;
|
||||||
struct st_buffer_object *st_obj;
|
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);
|
st_obj = st_buffer_object(binding->BufferObject);
|
||||||
|
|
||||||
cb.buffer = st_obj->buffer;
|
cb.buffer = st_obj->buffer;
|
||||||
|
@@ -6301,16 +6301,14 @@ st_translate_program(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program->shader) {
|
for (i = 0; i < proginfo->info.num_ubos; i++) {
|
||||||
for (i = 0; i < proginfo->info.num_ubos; i++) {
|
unsigned size = proginfo->sh.UniformBlocks[i]->UniformBufferSize;
|
||||||
unsigned size = program->shader->UniformBlocks[i]->UniformBufferSize;
|
unsigned num_const_vecs = (size + 15) / 16;
|
||||||
unsigned num_const_vecs = (size + 15) / 16;
|
unsigned first, last;
|
||||||
unsigned first, last;
|
assert(num_const_vecs > 0);
|
||||||
assert(num_const_vecs > 0);
|
first = 0;
|
||||||
first = 0;
|
last = num_const_vecs > 0 ? num_const_vecs - 1 : 0;
|
||||||
last = num_const_vecs > 0 ? num_const_vecs - 1 : 0;
|
ureg_DECL_constant2D(t->ureg, first, last, i + 1);
|
||||||
ureg_DECL_constant2D(t->ureg, first, last, i + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit immediate values.
|
/* Emit immediate values.
|
||||||
|
Reference in New Issue
Block a user