diff options
author | Brian Paul <[email protected]> | 2015-02-28 09:11:23 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-03-02 08:55:30 -0700 |
commit | c16c719647664abf7531896770c31eda1dbe7a58 (patch) | |
tree | 45e8296addc08b5d1542c989e5f523208692c789 | |
parent | 70b401029cf800f22e6c4318cfd2ab9bf118bb6c (diff) |
glsl: replace Elements() with ARRAY_SIZE()
Acked-by: Ilia Mirkin <[email protected]>
-rw-r--r-- | src/glsl/builtin_functions.cpp | 2 | ||||
-rw-r--r-- | src/glsl/builtin_variables.cpp | 2 | ||||
-rw-r--r-- | src/glsl/glsl_parser.yy | 4 | ||||
-rw-r--r-- | src/glsl/glsl_parser_extras.cpp | 8 | ||||
-rw-r--r-- | src/glsl/ir.cpp | 6 | ||||
-rw-r--r-- | src/glsl/ir_clone.cpp | 2 | ||||
-rw-r--r-- | src/glsl/ir_constant_expression.cpp | 2 | ||||
-rw-r--r-- | src/glsl/loop_controls.cpp | 2 | ||||
-rw-r--r-- | src/glsl/s_expression.h | 4 | ||||
-rw-r--r-- | src/glsl/tests/copy_constant_to_storage_tests.cpp | 10 | ||||
-rw-r--r-- | src/glsl/tests/uniform_initializer_utils.cpp | 2 |
11 files changed, 22 insertions, 22 deletions
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index b643927d021..84bbdc2a4c6 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -2549,7 +2549,7 @@ builtin_builder::add_image_function(const char *name, }; ir_function *f = new(mem_ctx) ir_function(name); - for (unsigned i = 0; i < Elements(types); ++i) { + for (unsigned i = 0; i < ARRAY_SIZE(types); ++i) { if (types[i]->sampler_type != GLSL_TYPE_FLOAT || (flags & IMAGE_FUNCTION_SUPPORTS_FLOAT_DATA_TYPE)) f->add_signature(_image(types[i], intrinsic_name, diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 65e32ad7397..21e7331c767 100644 --- a/src/glsl/builtin_variables.cpp +++ b/src/glsl/builtin_variables.cpp @@ -227,7 +227,7 @@ static const struct gl_builtin_uniform_element gl_NormalMatrix_elements[] = { #undef MATRIX -#define STATEVAR(name) {#name, name ## _elements, Elements(name ## _elements)} +#define STATEVAR(name) {#name, name ## _elements, ARRAY_SIZE(name ## _elements)} static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { STATEVAR(gl_NumSamples), diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy index ea3bd8a2408..90c216ed984 100644 --- a/src/glsl/glsl_parser.yy +++ b/src/glsl/glsl_parser.yy @@ -1280,7 +1280,7 @@ layout_qualifier_id: { "triangles_adjacency", GL_TRIANGLES_ADJACENCY }, { "triangle_strip", GL_TRIANGLE_STRIP }, }; - for (unsigned i = 0; i < Elements(map); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) { if (match_layout_qualifier($1, map[i].s, state) == 0) { $$.flags.q.prim_type = 1; $$.prim_type = map[i].e; @@ -1344,7 +1344,7 @@ layout_qualifier_id: { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT } }; - for (unsigned i = 0; i < Elements(map); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) { if (match_layout_qualifier($1, map[i].name, state) == 0) { $$.flags.q.explicit_image_format = 1; $$.image_format = map[i].format; diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index f19804b7238..79624bc263c 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -119,9 +119,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings; /* Compute shader constants */ - for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupCount); i++) + for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupCount); i++) this->Const.MaxComputeWorkGroupCount[i] = ctx->Const.MaxComputeWorkGroupCount[i]; - for (unsigned i = 0; i < Elements(this->Const.MaxComputeWorkGroupSize); i++) + for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupSize); i++) this->Const.MaxComputeWorkGroupSize[i] = ctx->Const.MaxComputeWorkGroupSize[i]; this->Const.MaxImageUnits = ctx->Const.MaxImageUnits; @@ -636,7 +636,7 @@ void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state, */ static const _mesa_glsl_extension *find_extension(const char *name) { - for (unsigned i = 0; i < Elements(_mesa_glsl_supported_extensions); ++i) { + for (unsigned i = 0; i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) { if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) { return &_mesa_glsl_supported_extensions[i]; } @@ -674,7 +674,7 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp, return false; } else { for (unsigned i = 0; - i < Elements(_mesa_glsl_supported_extensions); ++i) { + i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) { const _mesa_glsl_extension *extension = &_mesa_glsl_supported_extensions[i]; if (extension->compatible_with_state(state)) { diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index f4f92e9df95..54656f89933 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -618,8 +618,8 @@ static const char *const operator_strs[] = { const char *ir_expression::operator_string(ir_expression_operation op) { - assert((unsigned int) op < Elements(operator_strs)); - assert(Elements(operator_strs) == (ir_quadop_vector + 1)); + assert((unsigned int) op < ARRAY_SIZE(operator_strs)); + assert(ARRAY_SIZE(operator_strs) == (ir_quadop_vector + 1)); return operator_strs[op]; } @@ -1707,7 +1707,7 @@ const char *const ir_variable::warn_extension_table[] = { void ir_variable::enable_extension_warning(const char *extension) { - for (unsigned i = 0; i < Elements(warn_extension_table); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(warn_extension_table); i++) { if (strcmp(warn_extension_table[i], extension) == 0) { this->data.warn_extension_index = i; return; diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index 5c7279ca3d8..914e0e4d540 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -158,7 +158,7 @@ ir_call::clone(void *mem_ctx, struct hash_table *ht) const ir_expression * ir_expression::clone(void *mem_ctx, struct hash_table *ht) const { - ir_rvalue *op[Elements(this->operands)] = { NULL, }; + ir_rvalue *op[ARRAY_SIZE(this->operands)] = { NULL, }; unsigned int i; for (i = 0; i < get_num_operands(); i++) { diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 07dd439d5ed..388c4c28683 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -506,7 +506,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) if (this->type->is_error()) return NULL; - ir_constant *op[Elements(this->operands)] = { NULL, }; + ir_constant *op[ARRAY_SIZE(this->operands)] = { NULL, }; ir_constant_data data; memset(&data, 0, sizeof(data)); diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index 2459fc1c303..d7f0b28090f 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -123,7 +123,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment, const int bias[] = { -1, 0, 1 }; bool valid_loop = false; - for (unsigned i = 0; i < Elements(bias); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(bias); i++) { /* Increment may be of type int, uint or float. */ switch (increment->type->base_type) { case GLSL_TYPE_INT: diff --git a/src/glsl/s_expression.h b/src/glsl/s_expression.h index 1d4753530bc..f0dffb1b2f8 100644 --- a/src/glsl/s_expression.h +++ b/src/glsl/s_expression.h @@ -39,8 +39,8 @@ #define SX_AS_INT(x) SX_AS_(int, x) /* Pattern matching macros */ -#define MATCH(list, pat) s_match(list, Elements(pat), pat, false) -#define PARTIAL_MATCH(list, pat) s_match(list, Elements(pat), pat, true) +#define MATCH(list, pat) s_match(list, ARRAY_SIZE(pat), pat, false) +#define PARTIAL_MATCH(list, pat) s_match(list, ARRAY_SIZE(pat), pat, true) /* For our purposes, S-Expressions are: * - <int> diff --git a/src/glsl/tests/copy_constant_to_storage_tests.cpp b/src/glsl/tests/copy_constant_to_storage_tests.cpp index acf2789f2b5..cd48bc523c1 100644 --- a/src/glsl/tests/copy_constant_to_storage_tests.cpp +++ b/src/glsl/tests/copy_constant_to_storage_tests.cpp @@ -70,7 +70,7 @@ copy_constant_to_storage::int_test(unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_INT, 1, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -90,7 +90,7 @@ copy_constant_to_storage::uint_test(unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_UINT, 1, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -110,7 +110,7 @@ copy_constant_to_storage::float_test(unsigned columns, unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_FLOAT, columns, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -130,7 +130,7 @@ copy_constant_to_storage::bool_test(unsigned rows) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_BOOL, 1, rows, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); @@ -155,7 +155,7 @@ copy_constant_to_storage::sampler_test(void) ir_constant *val; generate_data(mem_ctx, GLSL_TYPE_INT, 1, 1, val); - const unsigned red_zone_size = Elements(storage) - val->type->components(); + const unsigned red_zone_size = ARRAY_SIZE(storage) - val->type->components(); fill_storage_array_with_sentinels(storage, val->type->components(), red_zone_size); diff --git a/src/glsl/tests/uniform_initializer_utils.cpp b/src/glsl/tests/uniform_initializer_utils.cpp index 297f342c1b3..b90bdcaed3b 100644 --- a/src/glsl/tests/uniform_initializer_utils.cpp +++ b/src/glsl/tests/uniform_initializer_utils.cpp @@ -79,7 +79,7 @@ generate_data_element(void *mem_ctx, const glsl_type *type, ir_constant_data data; memset(&data, 0, sizeof(data)); for (unsigned i = 0; i < type->components(); i++) { - const unsigned idx = (i + data_index_base) % Elements(values); + const unsigned idx = (i + data_index_base) % ARRAY_SIZE(values); switch (type->base_type) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: |