summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-12-17 09:54:38 -0800
committerPaul Berry <[email protected]>2013-12-30 11:21:27 -0800
commit99e822fa18a322f7bf0d32ce99eab534d5614469 (patch)
treed2dd92b2c2f2312a9d5582534dc4b2f5073b274d /src/glsl/linker.cpp
parentb30e25f29752fe3782d9ad43cb2cee46885c487d (diff)
mesa: Improve static error checking of arrays sized by MESA_SHADER_TYPES.
This patch replaces the following pattern: foo bar[MESA_SHADER_TYPES] = { ... }; With: foo bar[] = { ... }; STATIC_ASSERT(Elements(bar) == MESA_SHADER_TYPES); This way, when a new shader type is added in a future version of Mesa, we will get a compile error to remind us that the array needs to be updated. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/glsl/linker.cpp')
-rw-r--r--src/glsl/linker.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 9cfbb9b5163..a81e107372b 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1894,29 +1894,35 @@ store_fragdepth_layout(struct gl_shader_program *prog)
static void
check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
{
- const unsigned max_samplers[MESA_SHADER_TYPES] = {
+ const unsigned max_samplers[] = {
ctx->Const.VertexProgram.MaxTextureImageUnits,
ctx->Const.GeometryProgram.MaxTextureImageUnits,
ctx->Const.FragmentProgram.MaxTextureImageUnits
};
+ STATIC_ASSERT(Elements(max_samplers) == MESA_SHADER_TYPES);
- const unsigned max_default_uniform_components[MESA_SHADER_TYPES] = {
+ const unsigned max_default_uniform_components[] = {
ctx->Const.VertexProgram.MaxUniformComponents,
ctx->Const.GeometryProgram.MaxUniformComponents,
ctx->Const.FragmentProgram.MaxUniformComponents
};
+ STATIC_ASSERT(Elements(max_default_uniform_components) ==
+ MESA_SHADER_TYPES);
- const unsigned max_combined_uniform_components[MESA_SHADER_TYPES] = {
+ const unsigned max_combined_uniform_components[] = {
ctx->Const.VertexProgram.MaxCombinedUniformComponents,
ctx->Const.GeometryProgram.MaxCombinedUniformComponents,
ctx->Const.FragmentProgram.MaxCombinedUniformComponents
};
+ STATIC_ASSERT(Elements(max_combined_uniform_components) ==
+ MESA_SHADER_TYPES);
- const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
+ const unsigned max_uniform_blocks[] = {
ctx->Const.VertexProgram.MaxUniformBlocks,
ctx->Const.GeometryProgram.MaxUniformBlocks,
ctx->Const.FragmentProgram.MaxUniformBlocks
};
+ STATIC_ASSERT(Elements(max_uniform_blocks) == MESA_SHADER_TYPES);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
struct gl_shader *sh = prog->_LinkedShaders[i];