ilo: s/Elements/ARRAY_SIZE/

Signed-off-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Brian Paul 2016-04-28 11:39:15 -06:00
parent 951bf8b4a6
commit e193c5dd59
14 changed files with 43 additions and 43 deletions

View file

@ -162,7 +162,7 @@ ilo_blit_resolve_framebuffer(struct ilo_context *ilo)
unsigned sh, i; unsigned sh, i;
/* Not all bound views are sampled by the shaders. How do we tell? */ /* Not all bound views are sampled by the shaders. How do we tell? */
for (sh = 0; sh < Elements(vec->view); sh++) { for (sh = 0; sh < ARRAY_SIZE(vec->view); sh++) {
for (i = 0; i < vec->view[sh].count; i++) { for (i = 0; i < vec->view[sh].count; i++) {
if (vec->view[sh].states[i]) if (vec->view[sh].states[i])
ilo_blit_resolve_view(ilo, vec->view[sh].states[i]); ilo_blit_resolve_view(ilo, vec->view[sh].states[i]);

View file

@ -287,7 +287,7 @@ ilo_render_emit_query(struct ilo_render *render,
break; break;
case PIPE_QUERY_PIPELINE_STATISTICS: case PIPE_QUERY_PIPELINE_STATISTICS:
regs = pipeline_statistics_regs; regs = pipeline_statistics_regs;
reg_count = Elements(pipeline_statistics_regs); reg_count = ARRAY_SIZE(pipeline_statistics_regs);
break; break;
default: default:
break; break;

View file

@ -186,8 +186,8 @@ gen6_emit_draw_dynamic_samplers(struct ilo_render *r,
if (skip) if (skip)
return; return;
assert(sampler_count <= Elements(vec->view[shader_type].states) && assert(sampler_count <= ARRAY_SIZE(vec->view[shader_type].states) &&
sampler_count <= Elements(vec->sampler[shader_type].cso)); sampler_count <= ARRAY_SIZE(vec->sampler[shader_type].cso));
if (emit_border_color) { if (emit_border_color) {
for (i = 0; i < sampler_count; i++) { for (i = 0; i < sampler_count; i++) {
@ -482,8 +482,8 @@ gen6_emit_launch_grid_dynamic_samplers(struct ilo_render *r,
sampler_count = ilo_shader_get_kernel_param(cs, ILO_KERNEL_SAMPLER_COUNT); sampler_count = ilo_shader_get_kernel_param(cs, ILO_KERNEL_SAMPLER_COUNT);
assert(sampler_count <= Elements(vec->view[shader_type].states) && assert(sampler_count <= ARRAY_SIZE(vec->view[shader_type].states) &&
sampler_count <= Elements(vec->sampler[shader_type].cso)); sampler_count <= ARRAY_SIZE(vec->sampler[shader_type].cso));
for (i = 0; i < sampler_count; i++) { for (i = 0; i < sampler_count; i++) {
const struct ilo_sampler_cso *cso = vec->sampler[shader_type].cso[i]; const struct ilo_sampler_cso *cso = vec->sampler[shader_type].cso[i];

View file

@ -530,9 +530,9 @@ gen6_emit_launch_grid_surface_global(struct ilo_render *r,
if (!count) if (!count)
return; return;
if (base + count > Elements(r->state.cs.SURFACE_STATE)) { if (base + count > ARRAY_SIZE(r->state.cs.SURFACE_STATE)) {
ilo_warn("too many global bindings\n"); ilo_warn("too many global bindings\n");
count = Elements(r->state.cs.SURFACE_STATE) - base; count = ARRAY_SIZE(r->state.cs.SURFACE_STATE) - base;
} }
/* SURFACE_STATEs for global bindings */ /* SURFACE_STATEs for global bindings */

View file

@ -211,7 +211,7 @@ ilo_get_compute_param(struct pipe_screen *screen,
size = strlen(val.ir_target) + 1; size = strlen(val.ir_target) + 1;
break; break;
case PIPE_COMPUTE_CAP_GRID_DIMENSION: case PIPE_COMPUTE_CAP_GRID_DIMENSION:
val.grid_dimension = Elements(val.max_grid_size); val.grid_dimension = ARRAY_SIZE(val.max_grid_size);
ptr = &val.grid_dimension; ptr = &val.grid_dimension;
size = sizeof(val.grid_dimension); size = sizeof(val.grid_dimension);

View file

@ -1168,8 +1168,8 @@ ilo_shader_select_kernel_sbe(struct ilo_shader_state *shader,
routing->sprite_coord_enable = sprite_coord_enable; routing->sprite_coord_enable = sprite_coord_enable;
routing->sprite_coord_mode = sprite_coord_mode; routing->sprite_coord_mode = sprite_coord_mode;
assert(kernel->in.count <= Elements(swizzles)); assert(kernel->in.count <= ARRAY_SIZE(swizzles));
dst_len = MIN2(kernel->in.count, Elements(swizzles)); dst_len = MIN2(kernel->in.count, ARRAY_SIZE(swizzles));
memset(&swizzles, 0, sizeof(swizzles)); memset(&swizzles, 0, sizeof(swizzles));
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));

View file

@ -1060,7 +1060,7 @@ ilo_bind_sampler_states(struct pipe_context *pipe, unsigned shader,
bool changed = false; bool changed = false;
unsigned i; unsigned i;
assert(start + count <= Elements(dst->cso)); assert(start + count <= ARRAY_SIZE(dst->cso));
if (samplers) { if (samplers) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@ -1544,8 +1544,8 @@ ilo_set_constant_buffer(struct pipe_context *pipe,
const unsigned count = 1; const unsigned count = 1;
unsigned i; unsigned i;
assert(shader < Elements(vec->cbuf)); assert(shader < ARRAY_SIZE(vec->cbuf));
assert(index + count <= Elements(vec->cbuf[shader].cso)); assert(index + count <= ARRAY_SIZE(vec->cbuf[shader].cso));
if (buf) { if (buf) {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
@ -1809,7 +1809,7 @@ ilo_set_sampler_views(struct pipe_context *pipe, unsigned shader,
struct ilo_view_state *dst = &vec->view[shader]; struct ilo_view_state *dst = &vec->view[shader];
unsigned i; unsigned i;
assert(start + count <= Elements(dst->states)); assert(start + count <= ARRAY_SIZE(dst->states));
if (views) { if (views) {
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -1858,7 +1858,7 @@ ilo_set_shader_images(struct pipe_context *pipe, unsigned shader,
struct ilo_resource_state *dst = &vec->resource; struct ilo_resource_state *dst = &vec->resource;
unsigned i; unsigned i;
assert(start + count <= Elements(dst->states)); assert(start + count <= ARRAY_SIZE(dst->states));
if (surfaces) { if (surfaces) {
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -2220,7 +2220,7 @@ ilo_set_compute_resources(struct pipe_context *pipe,
struct ilo_resource_state *dst = &vec->cs_resource; struct ilo_resource_state *dst = &vec->cs_resource;
unsigned i; unsigned i;
assert(start + count <= Elements(dst->states)); assert(start + count <= ARRAY_SIZE(dst->states));
if (surfaces) { if (surfaces) {
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -2407,7 +2407,7 @@ ilo_state_vector_cleanup(struct ilo_state_vector *vec)
{ {
unsigned i, sh; unsigned i, sh;
for (i = 0; i < Elements(vec->vb.states); i++) { for (i = 0; i < ARRAY_SIZE(vec->vb.states); i++) {
if (vec->vb.enabled_mask & (1 << i)) if (vec->vb.enabled_mask & (1 << i))
pipe_resource_reference(&vec->vb.states[i].buffer, NULL); pipe_resource_reference(&vec->vb.states[i].buffer, NULL);
} }
@ -2424,7 +2424,7 @@ ilo_state_vector_cleanup(struct ilo_state_vector *vec)
pipe_sampler_view_reference(&view, NULL); pipe_sampler_view_reference(&view, NULL);
} }
for (i = 0; i < Elements(vec->cbuf[sh].cso); i++) { for (i = 0; i < ARRAY_SIZE(vec->cbuf[sh].cso); i++) {
struct ilo_cbuf_cso *cbuf = &vec->cbuf[sh].cso[i]; struct ilo_cbuf_cso *cbuf = &vec->cbuf[sh].cso[i];
pipe_resource_reference(&cbuf->resource, NULL); pipe_resource_reference(&cbuf->resource, NULL);
} }
@ -2513,7 +2513,7 @@ ilo_state_vector_resource_renamed(struct ilo_state_vector *vec,
} }
if (res->target == PIPE_BUFFER) { if (res->target == PIPE_BUFFER) {
for (i = 0; i < Elements(vec->cbuf[sh].cso); i++) { for (i = 0; i < ARRAY_SIZE(vec->cbuf[sh].cso); i++) {
struct ilo_cbuf_cso *cbuf = &vec->cbuf[sh].cso[i]; struct ilo_cbuf_cso *cbuf = &vec->cbuf[sh].cso[i];
if (cbuf->resource == res) { if (cbuf->resource == res) {

View file

@ -1123,7 +1123,7 @@ fs_lower_opcode_tgsi_sampling(struct fs_compile_context *fcc,
toy_compiler_lower_to_send(tc, inst, false, GEN6_SFID_SAMPLER); toy_compiler_lower_to_send(tc, inst, false, GEN6_SFID_SAMPLER);
inst->src[0] = tsrc(TOY_FILE_MRF, fcc->first_free_mrf, 0); inst->src[0] = tsrc(TOY_FILE_MRF, fcc->first_free_mrf, 0);
inst->src[1] = desc; inst->src[1] = desc;
for (i = 2; i < Elements(inst->src); i++) for (i = 2; i < ARRAY_SIZE(inst->src); i++)
inst->src[i] = tsrc_null(); inst->src[i] = tsrc_null();
/* write to temps first */ /* write to temps first */
@ -1450,12 +1450,12 @@ fs_write_fb(struct fs_compile_context *fcc)
int color_slots[ILO_MAX_DRAW_BUFFERS], num_cbufs; int color_slots[ILO_MAX_DRAW_BUFFERS], num_cbufs;
int pos_slot = -1, cbuf, i; int pos_slot = -1, cbuf, i;
for (i = 0; i < Elements(color_slots); i++) for (i = 0; i < ARRAY_SIZE(color_slots); i++)
color_slots[i] = -1; color_slots[i] = -1;
for (i = 0; i < fcc->tgsi.num_outputs; i++) { for (i = 0; i < fcc->tgsi.num_outputs; i++) {
if (fcc->tgsi.outputs[i].semantic_name == TGSI_SEMANTIC_COLOR) { if (fcc->tgsi.outputs[i].semantic_name == TGSI_SEMANTIC_COLOR) {
assert(fcc->tgsi.outputs[i].semantic_index < Elements(color_slots)); assert(fcc->tgsi.outputs[i].semantic_index < ARRAY_SIZE(color_slots));
color_slots[fcc->tgsi.outputs[i].semantic_index] = i; color_slots[fcc->tgsi.outputs[i].semantic_index] = i;
} }
else if (fcc->tgsi.outputs[i].semantic_name == TGSI_SEMANTIC_POSITION) { else if (fcc->tgsi.outputs[i].semantic_name == TGSI_SEMANTIC_POSITION) {
@ -1674,7 +1674,7 @@ fs_setup_payloads(struct fs_compile_context *fcc)
/* r1-r2: coordinates and etc. */ /* r1-r2: coordinates and etc. */
grf += (fcc->dispatch_mode == GEN6_PS_DISPATCH_32) ? 2 : 1; grf += (fcc->dispatch_mode == GEN6_PS_DISPATCH_32) ? 2 : 1;
for (i = 0; i < Elements(fcc->payloads); i++) { for (i = 0; i < ARRAY_SIZE(fcc->payloads); i++) {
const int reg_scale = const int reg_scale =
(fcc->dispatch_mode == GEN6_PS_DISPATCH_8) ? 1 : 2; (fcc->dispatch_mode == GEN6_PS_DISPATCH_8) ? 1 : 2;

View file

@ -329,7 +329,7 @@ vs_add_sampler_params(struct toy_compiler *tc, int msg_type, int base_mrf,
assert(num_coords <= 4); assert(num_coords <= 4);
assert(num_derivs <= 3 && num_derivs <= num_coords); assert(num_derivs <= 3 && num_derivs <= num_coords);
for (i = 0; i < Elements(m); i++) for (i = 0; i < ARRAY_SIZE(m); i++)
m[i] = tdst(TOY_FILE_MRF, base_mrf + i, 0); m[i] = tdst(TOY_FILE_MRF, base_mrf + i, 0);
switch (msg_type) { switch (msg_type) {

View file

@ -449,7 +449,7 @@ tc_dump_inst(struct toy_compiler *tc, const struct toy_inst *inst)
tc_dump_dst(tc, inst->dst); tc_dump_dst(tc, inst->dst);
for (i = 0; i < Elements(inst->src); i++) { for (i = 0; i < ARRAY_SIZE(inst->src); i++) {
if (tsrc_is_null(inst->src[i])) if (tsrc_is_null(inst->src[i]))
break; break;
@ -522,10 +522,10 @@ tc_init_inst_templ(struct toy_compiler *tc)
templ->marker = false; templ->marker = false;
templ->dst = tdst_null(); templ->dst = tdst_null();
for (i = 0; i < Elements(templ->src); i++) for (i = 0; i < ARRAY_SIZE(templ->src); i++)
templ->src[i] = tsrc_null(); templ->src[i] = tsrc_null();
for (i = 0; i < Elements(templ->tex.offsets); i++) for (i = 0; i < ARRAY_SIZE(templ->tex.offsets); i++)
templ->tex.offsets[i] = tsrc_null(); templ->tex.offsets[i] = tsrc_null();
list_inithead(&templ->list); list_inithead(&templ->list);

View file

@ -943,7 +943,7 @@ codegen_validate_region_restrictions(const struct codegen *cg)
/* 1. (we don't do 32 anyway) */ /* 1. (we don't do 32 anyway) */
assert(exec_size <= 16); assert(exec_size <= 16);
for (i = 0; i < Elements(cg->src); i++) { for (i = 0; i < ARRAY_SIZE(cg->src); i++) {
const int width = width_map[cg->src[i].width]; const int width = width_map[cg->src[i].width];
const int horz_stride = horz_stride_map[cg->src[i].horz_stride]; const int horz_stride = horz_stride_map[cg->src[i].horz_stride];
const int vert_stride = vert_stride_map[cg->src[i].vert_stride]; const int vert_stride = vert_stride_map[cg->src[i].vert_stride];
@ -1077,7 +1077,7 @@ codegen_prepare(struct codegen *cg, const struct ilo_dev *dev,
break; break;
} }
for (i = 0; i < Elements(cg->src); i++) { for (i = 0; i < ARRAY_SIZE(cg->src); i++) {
struct codegen_src *src = &cg->src[i]; struct codegen_src *src = &cg->src[i];
src->file = translate_vfile(inst->src[i].file); src->file = translate_vfile(inst->src[i].file);

View file

@ -80,7 +80,7 @@ toy_compiler_lower_math(struct toy_compiler *tc, struct toy_inst *inst)
int i; int i;
/* see commit 250770b74d33bb8625c780a74a89477af033d13a */ /* see commit 250770b74d33bb8625c780a74a89477af033d13a */
for (i = 0; i < Elements(inst->src); i++) { for (i = 0; i < ARRAY_SIZE(inst->src); i++) {
if (tsrc_is_null(inst->src[i])) if (tsrc_is_null(inst->src[i]))
break; break;
@ -179,7 +179,7 @@ validate_imm(struct toy_compiler *tc, struct toy_inst *inst)
bool move_inst = false; bool move_inst = false;
int i; int i;
for (i = 0; i < Elements(inst->src); i++) { for (i = 0; i < ARRAY_SIZE(inst->src); i++) {
struct toy_dst tmp; struct toy_dst tmp;
if (tsrc_is_null(inst->src[i])) if (tsrc_is_null(inst->src[i]))
@ -201,7 +201,7 @@ validate_imm(struct toy_compiler *tc, struct toy_inst *inst)
} }
/* this is the last operand */ /* this is the last operand */
if (i + 1 == Elements(inst->src) || tsrc_is_null(inst->src[i + 1])) if (i + 1 == ARRAY_SIZE(inst->src) || tsrc_is_null(inst->src[i + 1]))
break; break;
/* need to use a temp if this imm is not the last operand */ /* need to use a temp if this imm is not the last operand */
@ -600,7 +600,7 @@ toy_compiler_legalize_for_asm(struct toy_compiler *tc)
/* MRF to GRF */ /* MRF to GRF */
if (ilo_dev_gen(tc->dev) >= ILO_GEN(7)) { if (ilo_dev_gen(tc->dev) >= ILO_GEN(7)) {
for (i = 0; i < Elements(inst->src); i++) { for (i = 0; i < ARRAY_SIZE(inst->src); i++) {
if (inst->src[i].file != TOY_FILE_MRF) if (inst->src[i].file != TOY_FILE_MRF)
continue; continue;
else if (tsrc_is_null(inst->src[i])) else if (tsrc_is_null(inst->src[i]))

View file

@ -407,7 +407,7 @@ linear_scan_init_live_intervals(struct linear_scan *ls,
} }
} }
for (i = 0; i < Elements(inst->src); i++) { for (i = 0; i < ARRAY_SIZE(inst->src); i++) {
if (inst->src[i].file != TOY_FILE_VRF) if (inst->src[i].file != TOY_FILE_VRF)
continue; continue;
@ -539,7 +539,7 @@ linear_scan_allocation(struct toy_compiler *tc,
inst->dst.val32 = reg * TOY_REG_WIDTH + subreg; inst->dst.val32 = reg * TOY_REG_WIDTH + subreg;
} }
for (i = 0; i < Elements(inst->src); i++) { for (i = 0; i < ARRAY_SIZE(inst->src); i++) {
const uint32_t val32 = inst->src[i].val32; const uint32_t val32 = inst->src[i].val32;
int reg, subreg; int reg, subreg;
@ -589,7 +589,7 @@ trivial_allocation(struct toy_compiler *tc,
max_grf = reg; max_grf = reg;
} }
for (i = 0; i < Elements(inst->src); i++) { for (i = 0; i < ARRAY_SIZE(inst->src); i++) {
const uint32_t val32 = inst->src[i].val32; const uint32_t val32 = inst->src[i].val32;
int reg, subreg; int reg, subreg;

View file

@ -190,7 +190,7 @@ aos_simple(struct toy_compiler *tc,
inst->dst = dst[0]; inst->dst = dst[0];
} }
assert(num_src <= Elements(inst->src)); assert(num_src <= ARRAY_SIZE(inst->src));
for (i = 0; i < num_src; i++) for (i = 0; i < num_src; i++)
inst->src[i] = src[i]; inst->src[i] = src[i];
} }
@ -380,7 +380,7 @@ aos_tex(struct toy_compiler *tc,
inst->opcode = opcode; inst->opcode = opcode;
inst->tex.target = tgsi_inst->Texture.Texture; inst->tex.target = tgsi_inst->Texture.Texture;
assert(tgsi_inst->Instruction.NumSrcRegs <= Elements(inst->src)); assert(tgsi_inst->Instruction.NumSrcRegs <= ARRAY_SIZE(inst->src));
assert(tgsi_inst->Instruction.NumDstRegs == 1); assert(tgsi_inst->Instruction.NumDstRegs == 1);
inst->dst = dst[0]; inst->dst = dst[0];
@ -449,7 +449,7 @@ aos_sample(struct toy_compiler *tc,
inst = tc_add(tc); inst = tc_add(tc);
inst->opcode = opcode; inst->opcode = opcode;
assert(tgsi_inst->Instruction.NumSrcRegs <= Elements(inst->src)); assert(tgsi_inst->Instruction.NumSrcRegs <= ARRAY_SIZE(inst->src));
assert(tgsi_inst->Instruction.NumDstRegs == 1); assert(tgsi_inst->Instruction.NumDstRegs == 1);
inst->dst = dst[0]; inst->dst = dst[0];
@ -2118,7 +2118,7 @@ decl_add_in(struct toy_tgsi *tgsi, const struct tgsi_full_declaration *decl)
(decl->Declaration.Interpolate) ? &decl->Interp: &default_interp; (decl->Declaration.Interpolate) ? &decl->Interp: &default_interp;
int index; int index;
if (decl->Range.Last >= Elements(tgsi->inputs)) { if (decl->Range.Last >= ARRAY_SIZE(tgsi->inputs)) {
assert(!"invalid IN"); assert(!"invalid IN");
return; return;
} }
@ -2146,7 +2146,7 @@ decl_add_out(struct toy_tgsi *tgsi, const struct tgsi_full_declaration *decl)
{ {
int index; int index;
if (decl->Range.Last >= Elements(tgsi->outputs)) { if (decl->Range.Last >= ARRAY_SIZE(tgsi->outputs)) {
assert(!"invalid OUT"); assert(!"invalid OUT");
return; return;
} }
@ -2169,7 +2169,7 @@ decl_add_sv(struct toy_tgsi *tgsi, const struct tgsi_full_declaration *decl)
{ {
int index; int index;
if (decl->Range.Last >= Elements(tgsi->system_values)) { if (decl->Range.Last >= ARRAY_SIZE(tgsi->system_values)) {
assert(!"invalid SV"); assert(!"invalid SV");
return; return;
} }