glsl: Get rid of hardcoded arrays of shader target names.
authorPaul Berry <stereotype441@gmail.com>
Tue, 17 Dec 2013 17:46:08 +0000 (09:46 -0800)
committerPaul Berry <stereotype441@gmail.com>
Mon, 30 Dec 2013 19:21:21 +0000 (11:21 -0800)
We already have a function for converting a shader type index to a
string: _mesa_shader_type_to_string().

Reviewed-by: Brian Paul <brianp@vmware.com>
src/glsl/link_atomics.cpp
src/glsl/linker.cpp

index 33903ad54e332ef1ffa1eb0e7f0277097966c24e..6b7682cf8454757df26a43136db71d4f06d8a6cb 100644 (file)
@@ -21,6 +21,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include "glsl_parser_extras.h"
 #include "ir.h"
 #include "ir_uniform.h"
 #include "linker.h"
@@ -214,9 +215,6 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
                                     struct gl_shader_program *prog)
 {
    STATIC_ASSERT(MESA_SHADER_TYPES == 3);
-   static const char *shader_names[MESA_SHADER_TYPES] = {
-      "vertex", "geometry", "fragment"
-   };
    const unsigned max_atomic_counters[MESA_SHADER_TYPES] = {
       ctx->Const.VertexProgram.MaxAtomicCounters,
       ctx->Const.GeometryProgram.MaxAtomicCounters,
@@ -260,11 +258,11 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
    for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
       if (atomic_counters[i] > max_atomic_counters[i])
          linker_error(prog, "Too many %s shader atomic counters",
-                      shader_names[i]);
+                      _mesa_shader_type_to_string(i));
 
       if (atomic_buffers[i] > max_atomic_buffers[i])
          linker_error(prog, "Too many %s shader atomic counter buffers",
-                      shader_names[i]);
+                      _mesa_shader_type_to_string(i));
    }
 
    if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters)
index f6d7a9095503a5eea4aa683e9585dab6cebb8fd2..6edf7c180594427047b385c08cd3aefde79c0a78 100644 (file)
@@ -1893,10 +1893,6 @@ store_fragdepth_layout(struct gl_shader_program *prog)
 static void
 check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 {
-   static const char *const shader_names[MESA_SHADER_TYPES] = {
-      "vertex", "geometry", "fragment"
-   };
-
    const unsigned max_samplers[MESA_SHADER_TYPES] = {
       ctx->Const.VertexProgram.MaxTextureImageUnits,
       ctx->Const.GeometryProgram.MaxTextureImageUnits,
@@ -1929,7 +1925,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
 
       if (sh->num_samplers > max_samplers[i]) {
         linker_error(prog, "Too many %s shader texture samplers",
-                     shader_names[i]);
+                     _mesa_shader_type_to_string(i));
       }
 
       if (sh->num_uniform_components > max_default_uniform_components[i]) {
@@ -1938,11 +1934,11 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
                            "components, but the driver will try to optimize "
                            "them out; this is non-portable out-of-spec "
                           "behavior\n",
-                           shader_names[i]);
+                           _mesa_shader_type_to_string(i));
          } else {
             linker_error(prog, "Too many %s shader default uniform block "
                         "components",
-                         shader_names[i]);
+                         _mesa_shader_type_to_string(i));
          }
       }
 
@@ -1952,10 +1948,10 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
             linker_warning(prog, "Too many %s shader uniform components, "
                            "but the driver will try to optimize them out; "
                            "this is non-portable out-of-spec behavior\n",
-                           shader_names[i]);
+                           _mesa_shader_type_to_string(i));
          } else {
             linker_error(prog, "Too many %s shader uniform components",
-                         shader_names[i]);
+                         _mesa_shader_type_to_string(i));
          }
       }
    }
@@ -1979,7 +1975,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
         for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
            if (blocks[i] > max_uniform_blocks[i]) {
               linker_error(prog, "Too many %s uniform blocks (%d/%d)",
-                           shader_names[i],
+                           _mesa_shader_type_to_string(i),
                            blocks[i],
                            max_uniform_blocks[i]);
               break;