mesa: rename gl_shader_program's NumUniformBlocks to NumBufferInterfaceBlocks
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Fri, 11 Sep 2015 10:29:37 +0000 (12:29 +0200)
committerSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Tue, 29 Sep 2015 08:03:47 +0000 (10:03 +0200)
Because it counts shader storage blocks too.

v2:
- Use NumBufferInterfaceBlocks instead (Jordan).

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/glsl/link_uniform_initializers.cpp
src/glsl/link_uniforms.cpp
src/glsl/linker.cpp
src/glsl/standalone_scaffolding.cpp
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c
src/mesa/main/shaderobj.c
src/mesa/main/uniforms.c

index 05000fc39efad1e2a65dd12d192c7f386869ac19..34830829b4a63de3a7fba63856b5f1973ed93aae 100644 (file)
@@ -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->NumBufferInterfaceBlocks; i++) {
       if (!strcmp(shProg->UniformBlocks[i].Name, uniformBlockName))
         return i;
    }
index 94d7287221a2f2a3931b2f5bfddafd33a0841967..47d49c84e65ca96bc667b326c102f41aea950e8b 100644 (file)
@@ -500,7 +500,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->NumBufferInterfaceBlocks; i++) {
                if (strncmp(var->get_interface_type()->name,
                            prog->UniformBlocks[i].Name,
                            l) == 0
@@ -510,7 +510,7 @@ public:
                }
             }
          } else {
-            for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+            for (unsigned i = 0; i < prog->NumBufferInterfaceBlocks; i++) {
                if (strcmp(var->get_interface_type()->name,
                           prog->UniformBlocks[i].Name) == 0) {
                   ubo_block_index = i;
index 75396fb39369427e4b8e6e2ba2b5fccfa999b120..9bacd22b9d49924eb8180731f96601ee7227d4d2 100644 (file)
@@ -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->NumBufferInterfaceBlocks,
                                                       &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->NumBufferInterfaceBlocks; 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->NumBufferInterfaceBlocks,
                      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->NumBufferInterfaceBlocks; j++) {
             int stage_index = prog->UniformBlockStageIndex[i][j];
             if (stage_index != -1 && sh->UniformBlocks[stage_index].IsShaderStorage)
                total_shader_storage_blocks++;
@@ -3418,7 +3418,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->NumBufferInterfaceBlocks; 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,
index e52869f288ecb606f6b3511ff145a5331e6415e0..ea9334fd7b7f403323ed98c988e83af4ee286027 100644 (file)
@@ -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->NumBufferInterfaceBlocks = 0;
    for (i = 0; i < MESA_SHADER_STAGES; i++) {
       ralloc_free(shProg->UniformBlockStageIndex[i]);
       shProg->UniformBlockStageIndex[i] = NULL;
index a2bc5c64e4e383cd501f4500dbe0eea4e78de80c..cf7e74256fc71628603153e9f311e1065f8fa7a5 100644 (file)
@@ -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->NumBufferInterfaceBlocks - 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->NumBufferInterfaceBlocks - 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->NumBufferInterfaceBlocks - 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->NumBufferInterfaceBlocks - 1);
    }
 
    fs_reg offset = get_nir_src(instr->src[1]);
index 2d2e5753effde1c8a27c7f75a427e05da09b3d8d..94906d2e70505d6d34d1221703edad9194531fce 100644 (file)
@@ -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->NumBufferInterfaceBlocks - 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->NumBufferInterfaceBlocks - 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->NumBufferInterfaceBlocks - 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->NumBufferInterfaceBlocks - 1);
    }
 
    src_reg offset = get_nir_src(instr->src[1], 1);
index 3443e5cb7594052103aebb2c2c5eca3f9baeb1e7..3cb783ece1c675c447028469d90323730436d591 100644 (file)
@@ -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->NumBufferInterfaceBlocks - 1);
       }
 
       if (const_offset_ir) {
index a872942d2a87b48ba0d27428deea49cf02aa66f6..288d75790a496a93d4b5160e35503b6daf710e4a 100644 (file)
@@ -2689,7 +2689,7 @@ struct gl_shader_program
     */
    unsigned LastClipDistanceArraySize;
 
-   unsigned NumUniformBlocks;
+   unsigned NumBufferInterfaceBlocks;
    struct gl_uniform_block *UniformBlocks;
 
    /**
index 00c51e2bd3d7ba0b7d4f1d90cecfd7d999108c3e..418121dcb991adbd725091f3db23ca16054969d3 100644 (file)
@@ -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->NumBufferInterfaceBlocks; i++) {
         /* Add one for the terminating NUL character.
          */
         const GLint len = strlen(shProg->UniformBlocks[i].Name) + 1;
@@ -730,7 +730,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
          break;
 
       *params = 0;
-      for (unsigned i = 0; i < shProg->NumUniformBlocks; i++) {
+      for (unsigned i = 0; i < shProg->NumBufferInterfaceBlocks; i++) {
          if (!shProg->UniformBlocks[i].IsShaderStorage)
             (*params)++;
       }
index 71d4ed69285cf445f0be8ce5cde1f45d96d955a7..5cd37d7e4c49317b3f23f1f295ab045525a6e041 100644 (file)
@@ -294,7 +294,7 @@ _mesa_clear_shader_program_data(struct gl_shader_program *shProg)
 
    ralloc_free(shProg->UniformBlocks);
    shProg->UniformBlocks = NULL;
-   shProg->NumUniformBlocks = 0;
+   shProg->NumBufferInterfaceBlocks = 0;
    for (i = 0; i < MESA_SHADER_STAGES; i++) {
       ralloc_free(shProg->UniformBlockStageIndex[i]);
       shProg->UniformBlockStageIndex[i] = NULL;
index c491707e9370e20fc6a2205629b6a1318e570ecf..04cc81f98099c834d9d388200773f13958c9ecd5 100644 (file)
@@ -1002,10 +1002,10 @@ _mesa_UniformBlockBinding(GLuint program,
    if (!shProg)
       return;
 
-   if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+   if (uniformBlockIndex >= shProg->NumBufferInterfaceBlocks) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                  "glUniformBlockBinding(block index %u >= %u)",
-                 uniformBlockIndex, shProg->NumUniformBlocks);
+                 uniformBlockIndex, shProg->NumBufferInterfaceBlocks);
       return;
    }
 
@@ -1054,10 +1054,10 @@ _mesa_ShaderStorageBlockBinding(GLuint program,
    if (!shProg)
       return;
 
-   if (shaderStorageBlockIndex >= shProg->NumUniformBlocks) {
+   if (shaderStorageBlockIndex >= shProg->NumBufferInterfaceBlocks) {
       _mesa_error(ctx, GL_INVALID_VALUE,
                  "glShaderStorageBlockBinding(block index %u >= %u)",
-                 shaderStorageBlockIndex, shProg->NumUniformBlocks);
+                 shaderStorageBlockIndex, shProg->NumBufferInterfaceBlocks);
       return;
    }