[Mesa-dev] [PATCH 4/7] mesa: Convert some runtime asserts to static asserts.
Eric Anholt
eric at anholt.net
Fri Sep 20 18:52:22 PDT 2013
Noticed while grepping through the code for something else.
---
src/mesa/program/program.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index 2529c13..5dd68d9 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -55,27 +55,35 @@ _mesa_init_program(struct gl_context *ctx)
* If this assertion fails, we need to increase the field
* size for register indexes (see INST_INDEX_BITS).
*/
- ASSERT(ctx->Const.VertexProgram.MaxUniformComponents / 4
+ STATIC_ASSERT(ctx->Const.VertexProgram.MaxUniformComponents / 4
<= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.FragmentProgram.MaxUniformComponents / 4
+ STATIC_ASSERT(ctx->Const.FragmentProgram.MaxUniformComponents / 4
<= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.VertexProgram.MaxTemps <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.VertexProgram.MaxLocalParams <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.FragmentProgram.MaxTemps <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.FragmentProgram.MaxLocalParams <= (1 << INST_INDEX_BITS));
-
- ASSERT(ctx->Const.VertexProgram.MaxUniformComponents <= 4 * MAX_UNIFORMS);
- ASSERT(ctx->Const.FragmentProgram.MaxUniformComponents <= 4 * MAX_UNIFORMS);
-
- ASSERT(ctx->Const.VertexProgram.MaxAddressOffset <= (1 << INST_INDEX_BITS));
- ASSERT(ctx->Const.FragmentProgram.MaxAddressOffset <= (1 << INST_INDEX_BITS));
+ STATIC_ASSERT(ctx->Const.VertexProgram.MaxTemps <=
+ (1 << INST_INDEX_BITS));
+ STATIC_ASSERT(ctx->Const.VertexProgram.MaxLocalParams <=
+ (1 << INST_INDEX_BITS));
+ STATIC_ASSERT(ctx->Const.FragmentProgram.MaxTemps <=
+ (1 << INST_INDEX_BITS));
+ STATIC_ASSERT(ctx->Const.FragmentProgram.MaxLocalParams <=
+ (1 << INST_INDEX_BITS));
+
+ STATIC_ASSERT(ctx->Const.VertexProgram.MaxUniformComponents <=
+ 4 * MAX_UNIFORMS);
+ STATIC_ASSERT(ctx->Const.FragmentProgram.MaxUniformComponents <=
+ 4 * MAX_UNIFORMS);
+
+ STATIC_ASSERT(ctx->Const.VertexProgram.MaxAddressOffset <=
+ (1 << INST_INDEX_BITS));
+ STATIC_ASSERT(ctx->Const.FragmentProgram.MaxAddressOffset <=
+ (1 << INST_INDEX_BITS));
/* If this fails, increase prog_instruction::TexSrcUnit size */
- ASSERT(MAX_TEXTURE_UNITS <= (1 << 5));
+ STATIC_ASSERT(MAX_TEXTURE_UNITS <= (1 << 5));
/* If this fails, increase prog_instruction::TexSrcTarget size */
- ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4));
+ STATIC_ASSERT(NUM_TEXTURE_TARGETS <= (1 << 4));
ctx->Program.ErrorPos = -1;
ctx->Program.ErrorString = _mesa_strdup("");
--
1.8.4.rc3
More information about the mesa-dev
mailing list