draw: s/Elements/ARRAY_SIZE/
authorBrian Paul <brianp@vmware.com>
Mon, 25 Apr 2016 21:55:01 +0000 (15:55 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 27 Apr 2016 16:23:19 +0000 (10:23 -0600)
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm_sample.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
src/gallium/auxiliary/draw/draw_vertex.h
src/gallium/auxiliary/draw/draw_vs.c
src/gallium/auxiliary/draw/draw_vs_exec.c

index 75551fbe2dd6fb3acf487b7a31e69df3d498587d..3f36b347ddabf3c1addf8076718f9643cc33ec8d 100644 (file)
@@ -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;
index 9c68d4fbf78e964d5cc236a6f182b7ff51ebefbb..c1460cc91c05e2ec1fa90017e519737dd08244a5 100644 (file)
@@ -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);
index 1845c0560a958b606577398e8cb3f31472a2e877..2671ff0fc4b93dacfcbe83744a6dd736c405c795 100644 (file)
@@ -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, "");
index edd4541270a7ca62f44efede6e1e98497c55ca7e..4033eddca6e937e77e094ac59da181d11ff079a2 100644 (file)
@@ -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];
index c7b1afe5dde34e03f10fa2cd49ea601edac8f1f2..d834869e3bd80b4cbe08fc4fa106d8ffd38a32db 100644 (file)
@@ -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++;
index 5b42b69b5caf1bf8efe3c280552b88d02f002e30..ae94421ed4c4a570d6e4462762c588b0d25dd29f 100644 (file)
@@ -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;
    }
index 483ee90f2a43511ff4d9913eaca1cf890bd817a8..5125eb4dff13f10c92fe35908d83a7cb9eb35b34 100644 (file)
@@ -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;
          }