[Mesa-dev] [PATCH 2/6] mesa: rename gl_shader_program's NumUniformBlocks to NumUniformShaderStorageBlocks
Jordan Justen
jordan.l.justen at intel.com
Mon Sep 28 10:31:52 PDT 2015
On 2015-09-28 02:55:48, Samuel Iglesias Gonsálvez wrote:
>
>
> On 26/09/15 09:51, Jordan Justen wrote:
> > On 2015-09-25 01:24:46, Samuel Iglesias Gonsalvez wrote:
> >> Because it counts shader storage blocks too.
> >>
> >> Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
> >> ---
> >> src/glsl/link_uniform_initializers.cpp | 2 +-
> >> src/glsl/link_uniforms.cpp | 4 ++--
> >> src/glsl/linker.cpp | 10 +++++-----
> >> src/glsl/standalone_scaffolding.cpp | 2 +-
> >> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 8 ++++----
> >> src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 8 ++++----
> >> src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 2 +-
> >> src/mesa/main/mtypes.h | 2 +-
> >> src/mesa/main/shaderapi.c | 2 +-
> >> src/mesa/main/shaderobj.c | 2 +-
> >> src/mesa/main/uniforms.c | 8 ++++----
> >> 11 files changed, 25 insertions(+), 25 deletions(-)
> >>
> >> diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp
> >> index 05000fc..f7fbcb0 100644
> >> --- a/src/glsl/link_uniform_initializers.cpp
> >> +++ b/src/glsl/link_uniform_initializers.cpp
> >> @@ -48,7 +48,7 @@ static unsigned
> >> get_uniform_block_index(const gl_shader_program *shProg,
> >> const char *uniformBlockName)
> >> {
> >> - for (unsigned i = 0; i < shProg->NumUniformBlocks; i++) {
> >> + for (unsigned i = 0; i < shProg->NumUniformShaderStorageBlocks; i++) {
> >
> > Since UBO and SSBO both fall under the interface blocks category, what
> > about NumBufferInterfaceBlocks instead? 'Buffer' seems to distinguish
> > them from interstage interface blocks.
> >
>
> OK, thanks! I'll use that name instead.
Ok, with that change:
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
> >
> >> if (!strcmp(shProg->UniformBlocks[i].Name, uniformBlockName))
> >> return i;
> >> }
> >> diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
> >> index 1c901e2..7b6c6d6 100644
> >> --- a/src/glsl/link_uniforms.cpp
> >> +++ b/src/glsl/link_uniforms.cpp
> >> @@ -504,7 +504,7 @@ public:
> >> if (var->is_interface_instance() && var->type->is_array()) {
> >> unsigned l = strlen(var->get_interface_type()->name);
> >>
> >> - for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
> >> + for (unsigned i = 0; i < prog->NumUniformShaderStorageBlocks; i++) {
> >> if (strncmp(var->get_interface_type()->name,
> >> prog->UniformBlocks[i].Name,
> >> l) == 0
> >> @@ -514,7 +514,7 @@ public:
> >> }
> >> }
> >> } else {
> >> - for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
> >> + for (unsigned i = 0; i < prog->NumUniformShaderStorageBlocks; i++) {
> >> if (strcmp(var->get_interface_type()->name,
> >> prog->UniformBlocks[i].Name) == 0) {
> >> ubo_block_index = i;
> >> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> >> index 9d419ac..d6a62bf 100644
> >> --- a/src/glsl/linker.cpp
> >> +++ b/src/glsl/linker.cpp
> >> @@ -1187,7 +1187,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog)
> >> for (unsigned int j = 0; j < sh->NumUniformBlocks; j++) {
> >> int index = link_cross_validate_uniform_block(prog,
> >> &prog->UniformBlocks,
> >> - &prog->NumUniformBlocks,
> >> + &prog->NumUniformShaderStorageBlocks,
> >> &sh->UniformBlocks[j]);
> >>
> >> if (index == -1) {
> >> @@ -2802,7 +2802,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
> >> unsigned shader_blocks[MESA_SHADER_STAGES] = {0};
> >> unsigned total_shader_storage_blocks = 0;
> >>
> >> - for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
> >> + for (unsigned i = 0; i < prog->NumUniformShaderStorageBlocks; i++) {
> >> /* Don't check SSBOs for Uniform Block Size */
> >> if (!prog->UniformBlocks[i].IsShaderStorage &&
> >> prog->UniformBlocks[i].UniformBufferSize > ctx->Const.MaxUniformBlockSize) {
> >> @@ -2836,7 +2836,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
> >>
> >> if (total_uniform_blocks > ctx->Const.MaxCombinedUniformBlocks) {
> >> linker_error(prog, "Too many combined uniform blocks (%d/%d)\n",
> >> - prog->NumUniformBlocks,
> >> + prog->NumUniformShaderStorageBlocks,
> >> ctx->Const.MaxCombinedUniformBlocks);
> >> } else {
> >> for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> >> @@ -2939,7 +2939,7 @@ check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
> >>
> >> total_image_units += sh->NumImages;
> >>
> >> - for (unsigned j = 0; j < prog->NumUniformBlocks; j++) {
> >> + for (unsigned j = 0; j < prog->NumUniformShaderStorageBlocks; j++) {
> >> int stage_index = prog->UniformBlockStageIndex[i][j];
> >> if (stage_index != -1 && sh->UniformBlocks[stage_index].IsShaderStorage)
> >> total_shader_storage_blocks++;
> >> @@ -3414,7 +3414,7 @@ build_program_resource_list(struct gl_shader_program *shProg)
> >> }
> >>
> >> /* Add program uniform blocks and shader storage blocks. */
> >> - for (unsigned i = 0; i < shProg->NumUniformBlocks; i++) {
> >> + for (unsigned i = 0; i < shProg->NumUniformShaderStorageBlocks; i++) {
> >> bool is_shader_storage = shProg->UniformBlocks[i].IsShaderStorage;
> >> GLenum type = is_shader_storage ? GL_SHADER_STORAGE_BLOCK : GL_UNIFORM_BLOCK;
> >> if (!add_program_resource(shProg, type,
> >> diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp
> >> index e52869f..998b658 100644
> >> --- a/src/glsl/standalone_scaffolding.cpp
> >> +++ b/src/glsl/standalone_scaffolding.cpp
> >> @@ -101,7 +101,7 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
> >>
> >> ralloc_free(shProg->UniformBlocks);
> >> shProg->UniformBlocks = NULL;
> >> - shProg->NumUniformBlocks = 0;
> >> + shProg->NumUniformShaderStorageBlocks = 0;
> >> for (i = 0; i < MESA_SHADER_STAGES; i++) {
> >> ralloc_free(shProg->UniformBlockStageIndex[i]);
> >> shProg->UniformBlockStageIndex[i] = NULL;
> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> >> index a2bc5c6..db0d250 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> >> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> >> @@ -1530,7 +1530,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
> >> */
> >> brw_mark_surface_used(prog_data,
> >> stage_prog_data->binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> if (has_indirect) {
> >> @@ -1593,7 +1593,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
> >> */
> >> brw_mark_surface_used(prog_data,
> >> stage_prog_data->binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> /* Get the offset to read from */
> >> @@ -1786,7 +1786,7 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr
> >>
> >> brw_mark_surface_used(prog_data,
> >> stage_prog_data->binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> /* Offset */
> >> @@ -1952,7 +1952,7 @@ fs_visitor::nir_emit_ssbo_atomic(const fs_builder &bld,
> >> */
> >> brw_mark_surface_used(prog_data,
> >> stage_prog_data->binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> fs_reg offset = get_nir_src(instr->src[1]);
> >> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> >> index 2d2e575..5947a8f 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> >> +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> >> @@ -592,7 +592,7 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
> >>
> >> brw_mark_surface_used(&prog_data->base,
> >> prog_data->base.binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> /* Offset */
> >> @@ -739,7 +739,7 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
> >> */
> >> brw_mark_surface_used(&prog_data->base,
> >> prog_data->base.binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> src_reg offset_reg = src_reg(this, glsl_type::uint_type);
> >> @@ -889,7 +889,7 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
> >> */
> >> brw_mark_surface_used(&prog_data->base,
> >> prog_data->base.binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> unsigned const_offset = instr->const_index[0];
> >> @@ -950,7 +950,7 @@ vec4_visitor::nir_emit_ssbo_atomic(int op, nir_intrinsic_instr *instr)
> >> */
> >> brw_mark_surface_used(&prog_data->base,
> >> prog_data->base.binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> src_reg offset = get_nir_src(instr->src[1], 1);
> >> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> >> index 3443e5c..155f9fb 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> >> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> >> @@ -1872,7 +1872,7 @@ vec4_visitor::visit(ir_expression *ir)
> >> */
> >> brw_mark_surface_used(&prog_data->base,
> >> prog_data->base.binding_table.ubo_start +
> >> - shader_prog->NumUniformBlocks - 1);
> >> + shader_prog->NumUniformShaderStorageBlocks - 1);
> >> }
> >>
> >> if (const_offset_ir) {
> >> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> >> index d53d99a..c19d95f 100644
> >> --- a/src/mesa/main/mtypes.h
> >> +++ b/src/mesa/main/mtypes.h
> >> @@ -2687,7 +2687,7 @@ struct gl_shader_program
> >> */
> >> unsigned LastClipDistanceArraySize;
> >>
> >> - unsigned NumUniformBlocks;
> >> + unsigned NumUniformShaderStorageBlocks;
> >> struct gl_uniform_block *UniformBlocks;
> >>
> >> /**
> >> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> >> index 7866a20..67a27c2 100644
> >> --- a/src/mesa/main/shaderapi.c
> >> +++ b/src/mesa/main/shaderapi.c
> >> @@ -713,7 +713,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
> >> if (!has_ubo)
> >> break;
> >>
> >> - for (i = 0; i < shProg->NumUniformBlocks; i++) {
> >> + for (i = 0; i < shProg->NumUniformShaderStorageBlocks; i++) {
> >> /* Add one for the terminating NUL character.
> >> */
> >> const GLint len = strlen(shProg->UniformBlocks[i].Name) + 1;
> >> diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
> >> index 110a18e..5a12790 100644
> >> --- a/src/mesa/main/shaderobj.c
> >> +++ b/src/mesa/main/shaderobj.c
> >> @@ -306,7 +306,7 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
> >>
> >> ralloc_free(shProg->UniformBlocks);
> >> shProg->UniformBlocks = NULL;
> >> - shProg->NumUniformBlocks = 0;
> >> + shProg->NumUniformShaderStorageBlocks = 0;
> >> for (i = 0; i < MESA_SHADER_STAGES; i++) {
> >> ralloc_free(shProg->UniformBlockStageIndex[i]);
> >> shProg->UniformBlockStageIndex[i] = NULL;
> >> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
> >> index c491707..a8ad90d 100644
> >> --- a/src/mesa/main/uniforms.c
> >> +++ b/src/mesa/main/uniforms.c
> >> @@ -1002,10 +1002,10 @@ _mesa_UniformBlockBinding(GLuint program,
> >> if (!shProg)
> >> return;
> >>
> >> - if (uniformBlockIndex >= shProg->NumUniformBlocks) {
> >> + if (uniformBlockIndex >= shProg->NumUniformShaderStorageBlocks) {
> >> _mesa_error(ctx, GL_INVALID_VALUE,
> >> "glUniformBlockBinding(block index %u >= %u)",
> >> - uniformBlockIndex, shProg->NumUniformBlocks);
> >> + uniformBlockIndex, shProg->NumUniformShaderStorageBlocks);
> >> return;
> >> }
> >>
> >> @@ -1054,10 +1054,10 @@ _mesa_ShaderStorageBlockBinding(GLuint program,
> >> if (!shProg)
> >> return;
> >>
> >> - if (shaderStorageBlockIndex >= shProg->NumUniformBlocks) {
> >> + if (shaderStorageBlockIndex >= shProg->NumUniformShaderStorageBlocks) {
> >> _mesa_error(ctx, GL_INVALID_VALUE,
> >> "glShaderStorageBlockBinding(block index %u >= %u)",
> >> - shaderStorageBlockIndex, shProg->NumUniformBlocks);
> >> + shaderStorageBlockIndex, shProg->NumUniformShaderStorageBlocks);
> >> return;
> >> }
> >>
> >> --
> >> 2.1.4
> >>
> >> _______________________________________________
> >> mesa-dev mailing list
> >> mesa-dev at lists.freedesktop.org
> >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
More information about the mesa-dev
mailing list