From 2f0143ca968d739e8b9cefb213ac61402a7f6587 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 28 Feb 2015 09:01:33 -0700 Subject: st/mesa: replace Elements() with ARRAY_SIZE() Acked-by: Ilia Mirkin --- src/mesa/state_tracker/st_atom.c | 4 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 4 ++-- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_cb_xformfb.c | 8 ++++---- src/mesa/state_tracker/st_context.c | 6 +++--- src/mesa/state_tracker/st_extensions.c | 24 ++++++++++++------------ src/mesa/state_tracker/st_format.c | 2 +- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 22 +++++++++++----------- src/mesa/state_tracker/st_mesa_to_tgsi.c | 14 +++++++------- src/mesa/state_tracker/st_program.c | 4 ++-- 10 files changed, 45 insertions(+), 45 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 625ea2965fe..8cc6af26082 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -197,7 +197,7 @@ void st_validate_state( struct st_context *st ) memset(&examined, 0, sizeof(examined)); prev = *state; - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { const struct st_tracked_state *atom = atoms[i]; struct st_state_flags generated; @@ -228,7 +228,7 @@ void st_validate_state( struct st_context *st ) } else { - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { if (check_state(state, &atoms[i]->dirty)) atoms[i]->update( st ); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 14fc1395235..3edf31bad52 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -201,7 +201,7 @@ st_make_drawpix_z_stencil_program(struct st_context *st, GLuint ic = 0; const GLuint shaderIndex = write_depth * 2 + write_stencil; - assert(shaderIndex < Elements(st->drawpix.shaders)); + assert(shaderIndex < ARRAY_SIZE(st->drawpix.shaders)); if (st->drawpix.shaders[shaderIndex]) { /* already have the proper shader */ @@ -1684,7 +1684,7 @@ st_destroy_drawpix(struct st_context *st) { GLuint i; - for (i = 0; i < Elements(st->drawpix.shaders); i++) { + for (i = 0; i < ARRAY_SIZE(st->drawpix.shaders); i++) { if (st->drawpix.shaders[i]) _mesa_reference_fragprog(st->ctx, &st->drawpix.shaders[i], NULL); } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index b051aedab9e..272cbb91d52 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -191,7 +191,7 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw) rs->stage.destroy = rastpos_destroy; rs->ctx = ctx; - for (i = 0; i < Elements(rs->array); i++) { + for (i = 0; i < ARRAY_SIZE(rs->array); i++) { rs->array[i].Size = 4; rs->array[i].Type = GL_FLOAT; rs->array[i].Format = GL_RGBA; diff --git a/src/mesa/state_tracker/st_cb_xformfb.c b/src/mesa/state_tracker/st_cb_xformfb.c index 39d0b61c874..07c118e227b 100644 --- a/src/mesa/state_tracker/st_cb_xformfb.c +++ b/src/mesa/state_tracker/st_cb_xformfb.c @@ -95,7 +95,7 @@ st_delete_transform_feedback(struct gl_context *ctx, pipe_so_target_reference(&sobj->targets[i], NULL); } - for (i = 0; i < Elements(sobj->base.Buffers); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->base.Buffers); i++) { _mesa_reference_buffer_object(ctx, &sobj->base.Buffers[i], NULL); } @@ -115,8 +115,8 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum mode, unsigned i, max_num_targets; unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0}; - max_num_targets = MIN2(Elements(sobj->base.Buffers), - Elements(sobj->targets)); + max_num_targets = MIN2(ARRAY_SIZE(sobj->base.Buffers), + ARRAY_SIZE(sobj->targets)); /* Convert the transform feedback state into the gallium representation. */ for (i = 0; i < max_num_targets; i++) { @@ -185,7 +185,7 @@ st_transform_feedback_get_draw_target(struct gl_transform_feedback_object *obj) st_transform_feedback_object(obj); unsigned i; - for (i = 0; i < Elements(sobj->targets); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->targets); i++) { if (sobj->targets[i]) { return sobj->targets[i]; } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 5834ebad3be..5fe132ac245 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -117,8 +117,8 @@ st_destroy_context_priv(struct st_context *st) st_destroy_drawpix(st); st_destroy_drawtex(st); - for (shader = 0; shader < Elements(st->state.sampler_views); shader++) { - for (i = 0; i < Elements(st->state.sampler_views[0]); i++) { + for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) { + for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) { pipe_sampler_view_release(st->pipe, &st->state.sampler_views[shader][i]); } @@ -200,7 +200,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, /* Vertex element objects used for drawing rectangles for glBitmap, * glDrawPixels, glClear, etc. */ - for (i = 0; i < Elements(st->velems_util_draw); i++) { + for (i = 0; i < ARRAY_SIZE(st->velems_util_draw); i++) { memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element)); st->velems_util_draw[i].src_offset = i * 4 * sizeof(float); st->velems_util_draw[i].instance_divisor = 0; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index ce29d076c2c..bc20f73230d 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -347,8 +347,8 @@ init_format_extensions(struct pipe_screen *screen, GLboolean *extension_table = (GLboolean *) extensions; unsigned i; int j; - int num_formats = Elements(mapping->format); - int num_ext = Elements(mapping->extension_offset); + int num_formats = ARRAY_SIZE(mapping->format); + int num_ext = ARRAY_SIZE(mapping->extension_offset); for (i = 0; i < num_mappings; i++) { int num_supported = 0; @@ -630,7 +630,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->OES_draw_texture = GL_TRUE; /* Expose the extensions which directly correspond to gallium caps. */ - for (i = 0; i < Elements(cap_mapping); i++) { + for (i = 0; i < ARRAY_SIZE(cap_mapping); i++) { if (screen->get_param(screen, cap_mapping[i].cap)) { extension_table[cap_mapping[i].extension_offset] = GL_TRUE; } @@ -638,16 +638,16 @@ void st_init_extensions(struct pipe_screen *screen, /* Expose the extensions which directly correspond to gallium formats. */ init_format_extensions(screen, extensions, rendertarget_mapping, - Elements(rendertarget_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D, PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, depthstencil_mapping, - Elements(depthstencil_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(depthstencil_mapping), PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, texture_mapping, - Elements(texture_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, vertex_mapping, - Elements(vertex_mapping), PIPE_BUFFER, + ARRAY_SIZE(vertex_mapping), PIPE_BUFFER, PIPE_BIND_VERTEX_BUFFER); /* Figure out GLSL support. */ @@ -758,22 +758,22 @@ void st_init_extensions(struct pipe_screen *screen, }; consts->MaxSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, 16, PIPE_BIND_RENDER_TARGET); consts->MaxColorTextureSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxDepthTextureSamples = - get_max_samples_for_formats(screen, Elements(depth_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(depth_formats), depth_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxIntegerSamples = - get_max_samples_for_formats(screen, Elements(int_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats), int_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); } @@ -831,7 +831,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->ARB_texture_buffer_range = GL_TRUE; init_format_extensions(screen, extensions, tbo_rgb32, - Elements(tbo_rgb32), PIPE_BUFFER, + ARRAY_SIZE(tbo_rgb32), PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW); } diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 7868bb501ea..72dbf3bd4c0 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -1855,7 +1855,7 @@ st_choose_format(struct st_context *st, GLenum internalFormat, return pf; /* search table for internalFormat */ - for (i = 0; i < Elements(format_map); i++) { + for (i = 0; i < ARRAY_SIZE(format_map); i++) { const struct format_mapping *mapping = &format_map[i]; for (j = 0; mapping->glFormats[j]; j++) { if (mapping->glFormats[j] == internalFormat) { diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index b3055076591..bd191d864fe 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1497,7 +1497,7 @@ void glsl_to_tgsi_visitor::visit(ir_expression *ir) { unsigned int operand; - st_src_reg op[Elements(ir->operands)]; + st_src_reg op[ARRAY_SIZE(ir->operands)]; st_src_reg result_src; st_dst_reg result_dst; @@ -4022,7 +4022,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) /* Continuing the block, clear any channels from the write array that * are read by this instruction. */ - for (unsigned i = 0; i < Elements(inst->src); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->src); i++) { if (inst->src[i].file == PROGRAM_TEMPORARY && inst->src[i].reladdr){ /* Any temporary might be read, so no dead code elimination * across this instruction. @@ -4067,7 +4067,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) * If there is already an instruction in the write array for one or more * of the channels, flag that channel write as dead. */ - for (unsigned i = 0; i < Elements(inst->dst); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->dst); i++) { if (inst->dst[i].file == PROGRAM_TEMPORARY && !inst->dst[i].reladdr && !inst->saturate) { @@ -4625,7 +4625,7 @@ dst_register(struct st_translate *t, case PROGRAM_ARRAY: array = index >> 16; - assert(array < Elements(t->arrays)); + assert(array < ARRAY_SIZE(t->arrays)); if (ureg_dst_is_undef(t->arrays[array])) t->arrays[array] = ureg_DECL_array_temporary( @@ -4642,7 +4642,7 @@ dst_register(struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -4685,18 +4685,18 @@ src_register(struct st_translate *t, const st_src_reg *reg) return t->immediates[reg->index]; case PROGRAM_INPUT: - assert(t->inputMapping[reg->index] < Elements(t->inputs)); + assert(t->inputMapping[reg->index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[reg->index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[reg->index] < Elements(t->outputs)); + assert(t->outputMapping[reg->index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[reg->index]); case PROGRAM_SYSTEM_VALUE: - assert(reg->index < (int) Elements(t->systemValues)); + assert(reg->index < (int) ARRAY_SIZE(t->systemValues)); return t->systemValues[reg->index]; default: @@ -4824,7 +4824,7 @@ translate_tex_offset(struct st_translate *t, array = in_offset->index >> 16; assert(array >= 0); - assert(array < (int) Elements(t->arrays)); + assert(array < (int) ARRAY_SIZE(t->arrays)); dst = t->arrays[array]; offset.File = dst.File; @@ -5200,8 +5200,8 @@ st_translate_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_FRONT_FACE] == TGSI_SEMANTIC_FACE); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 4684421b525..2f101611067 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -172,7 +172,7 @@ dst_register( struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -200,7 +200,7 @@ src_register( struct st_translate *t, case PROGRAM_TEMPORARY: assert(index >= 0); - assert(index < Elements(t->temps)); + assert(index < ARRAY_SIZE(t->temps)); if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_temporary( t->ureg ); return ureg_src(t->temps[index]); @@ -216,18 +216,18 @@ src_register( struct st_translate *t, return t->constants[index]; case PROGRAM_INPUT: - assert(t->inputMapping[index] < Elements(t->inputs)); + assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[index]); case PROGRAM_SYSTEM_VALUE: - assert(index < Elements(t->systemValues)); + assert(index < ARRAY_SIZE(t->systemValues)); return t->systemValues[index]; default: @@ -1027,8 +1027,8 @@ st_translate_mesa_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); t = &translate; memset(t, 0, sizeof *t); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 8ce461eb36a..4cfd817cee4 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1054,7 +1054,7 @@ st_translate_geometry_program(struct st_context *st, /* fall through */ case VARYING_SLOT_VAR0: default: - assert(slot < Elements(gs_output_semantic_name)); + assert(slot < ARRAY_SIZE(gs_output_semantic_name)); assert(attr >= VARYING_SLOT_VAR0); gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; gs_output_semantic_index[slot] = @@ -1247,7 +1247,7 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData) destroy_program_variants(st, shProg->Shaders[i]->Program); } - for (i = 0; i < Elements(shProg->_LinkedShaders); i++) { + for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) { if (shProg->_LinkedShaders[i]) destroy_program_variants(st, shProg->_LinkedShaders[i]->Program); } -- cgit v1.2.3