glsl: replace Elements() with ARRAY_SIZE()
Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user