diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 75551fbe2dd..3f36b347dda 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -556,7 +556,7 @@ draw_alloc_extra_vertex_attrib(struct draw_context *draw, num_outputs = draw_current_shader_outputs(draw); n = draw->extra_shader_outputs.num; - assert(n < Elements(draw->extra_shader_outputs.semantic_name)); + assert(n < ARRAY_SIZE(draw->extra_shader_outputs.semantic_name)); draw->extra_shader_outputs.semantic_name[n] = semantic_name; draw->extra_shader_outputs.semantic_index[n] = semantic_index; diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 9c68d4fbf78..c1460cc91c0 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -95,7 +95,7 @@ create_jit_dvbuffer_type(struct gallivm_state *gallivm, elem_types[DRAW_JIT_DVBUFFER_SIZE] = int32_type; dvbuffer_type = LLVMStructTypeInContext(gallivm->context, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); (void) target; /* silence unused var warning for non-debug build */ LP_CHECK_MEMBER_OFFSET(struct draw_vertex_buffer, map, @@ -132,7 +132,7 @@ create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name) LLVMArrayType(int32_type, PIPE_MAX_TEXTURE_LEVELS); texture_type = LLVMStructTypeInContext(gallivm->context, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); (void) target; /* silence unused var warning for non-debug build */ LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width, @@ -186,7 +186,7 @@ create_jit_sampler_type(struct gallivm_state *gallivm, const char *struct_name) LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4); sampler_type = LLVMStructTypeInContext(gallivm->context, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); (void) target; /* silence unused var warning for non-debug build */ LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, min_lod, @@ -234,7 +234,7 @@ create_jit_context_type(struct gallivm_state *gallivm, elem_types[5] = LLVMArrayType(sampler_type, PIPE_MAX_SAMPLERS); /* samplers */ context_type = LLVMStructTypeInContext(gallivm->context, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); (void) target; /* silence unused var warning for non-debug build */ LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants, @@ -293,7 +293,7 @@ create_gs_jit_context_type(struct gallivm_state *gallivm, vector_length), 0); context_type = LLVMStructTypeInContext(gallivm->context, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); (void) target; /* silence unused var warning for non-debug build */ LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, constants, @@ -357,7 +357,7 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm, elem_types[3] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); vb_type = LLVMStructTypeInContext(gallivm->context, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); (void) target; /* silence unused var warning for non-debug build */ LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride, @@ -389,7 +389,7 @@ create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems) elem_types[DRAW_JIT_VERTEX_DATA] = LLVMArrayType(elem_types[1], data_elems); vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); /* these are bit-fields and we can't take address of them LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask, @@ -1535,7 +1535,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, LLVMTypeRef int32_type = LLVMInt32TypeInContext(context); LLVMTypeRef arg_types[11]; unsigned num_arg_types = - elts ? Elements(arg_types) : Elements(arg_types) - 1; + elts ? ARRAY_SIZE(arg_types) : ARRAY_SIZE(arg_types) - 1; LLVMTypeRef func_type; LLVMValueRef context_ptr; LLVMBasicBlockRef block; @@ -1973,11 +1973,11 @@ draw_llvm_set_mapped_texture(struct draw_context *draw, shader_stage == PIPE_SHADER_GEOMETRY); if (shader_stage == PIPE_SHADER_VERTEX) { - assert(sview_idx < Elements(draw->llvm->jit_context.textures)); + assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_context.textures)); jit_tex = &draw->llvm->jit_context.textures[sview_idx]; } else if (shader_stage == PIPE_SHADER_GEOMETRY) { - assert(sview_idx < Elements(draw->llvm->gs_jit_context.textures)); + assert(sview_idx < ARRAY_SIZE(draw->llvm->gs_jit_context.textures)); jit_tex = &draw->llvm->gs_jit_context.textures[sview_idx]; } else { @@ -2148,7 +2148,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm, LLVMVectorType(int32_type, vector_length), 0); /* prim_id_ptr */ arg_types[6] = int32_type; - func_type = LLVMFunctionType(int32_type, arg_types, Elements(arg_types), 0); + func_type = LLVMFunctionType(int32_type, arg_types, ARRAY_SIZE(arg_types), 0); variant_func = LLVMAddFunction(gallivm->module, func_name, func_type); @@ -2156,7 +2156,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm, LLVMSetFunctionCallConv(variant_func, LLVMCCallConv); - for (i = 0; i < Elements(arg_types); ++i) + for (i = 0; i < ARRAY_SIZE(arg_types); ++i) if (LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind) LLVMAddAttribute(LLVMGetParam(variant_func, i), LLVMNoAliasAttribute); diff --git a/src/gallium/auxiliary/draw/draw_llvm_sample.c b/src/gallium/auxiliary/draw/draw_llvm_sample.c index 1845c0560a9..2671ff0fc4b 100644 --- a/src/gallium/auxiliary/draw/draw_llvm_sample.c +++ b/src/gallium/auxiliary/draw/draw_llvm_sample.c @@ -106,7 +106,7 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, /* context[0].textures[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, ARRAY_SIZE(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); @@ -152,7 +152,7 @@ draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, /* context[0].samplers[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, ARRAY_SIZE(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index edd4541270a..4033eddca6e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -277,7 +277,7 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle) struct draw_llvm *llvm = fpme->llvm; unsigned i; - for (i = 0; i < Elements(llvm->jit_context.vs_constants); ++i) { + for (i = 0; i < ARRAY_SIZE(llvm->jit_context.vs_constants); ++i) { int num_consts = draw->pt.user.vs_constants_size[i] / (sizeof(float) * 4); llvm->jit_context.vs_constants[i] = draw->pt.user.vs_constants[i]; @@ -286,7 +286,7 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle) llvm->jit_context.vs_constants[i] = fake_const_buf; } } - for (i = 0; i < Elements(llvm->gs_jit_context.constants); ++i) { + for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.constants); ++i) { int num_consts = draw->pt.user.gs_constants_size[i] / (sizeof(float) * 4); llvm->gs_jit_context.constants[i] = draw->pt.user.gs_constants[i]; diff --git a/src/gallium/auxiliary/draw/draw_vertex.h b/src/gallium/auxiliary/draw/draw_vertex.h index c7b1afe5dde..d834869e3bd 100644 --- a/src/gallium/auxiliary/draw/draw_vertex.h +++ b/src/gallium/auxiliary/draw/draw_vertex.h @@ -122,7 +122,7 @@ draw_emit_vertex_attr(struct vertex_info *vinfo, src_index = DRAW_ATTR_NONEXIST; } - assert(n < Elements(vinfo->attrib)); + assert(n < ARRAY_SIZE(vinfo->attrib)); vinfo->attrib[n].emit = emit; vinfo->attrib[n].src_index = src_index; vinfo->num_attribs++; diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index 5b42b69b5ca..ae94421ed4c 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -205,12 +205,12 @@ draw_vs_lookup_variant( struct draw_vertex_shader *vs, /* Add it to our list, could be smarter: */ - if (vs->nr_variants < Elements(vs->variant)) { + if (vs->nr_variants < ARRAY_SIZE(vs->variant)) { vs->variant[vs->nr_variants++] = variant; } else { vs->last_variant++; - vs->last_variant %= Elements(vs->variant); + vs->last_variant %= ARRAY_SIZE(vs->variant); vs->variant[vs->last_variant]->destroy(vs->variant[vs->last_variant]); vs->variant[vs->last_variant] = variant; } diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index 483ee90f2a4..5125eb4dff1 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -105,7 +105,7 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, if (shader->info.uses_instanceid) { unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_INSTANCEID]; - assert(i < Elements(machine->SystemValue)); + assert(i < ARRAY_SIZE(machine->SystemValue)); for (j = 0; j < TGSI_QUAD_SIZE; j++) machine->SystemValue[i].xyzw[0].i[j] = shader->draw->instance_id; } @@ -129,19 +129,19 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, if (shader->info.uses_vertexid) { unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_VERTEXID]; - assert(vid < Elements(machine->SystemValue)); + assert(vid < ARRAY_SIZE(machine->SystemValue)); machine->SystemValue[vid].xyzw[0].i[j] = i + j; /* XXX this should include base vertex. Where to get it??? */ } if (shader->info.uses_basevertex) { unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_BASEVERTEX]; - assert(vid < Elements(machine->SystemValue)); + assert(vid < ARRAY_SIZE(machine->SystemValue)); machine->SystemValue[vid].xyzw[0].i[j] = 0; /* XXX Where to get it??? */ } if (shader->info.uses_vertexid_nobase) { unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_VERTEXID_NOBASE]; - assert(vid < Elements(machine->SystemValue)); + assert(vid < ARRAY_SIZE(machine->SystemValue)); machine->SystemValue[vid].xyzw[0].i[j] = i + j; }