From: Brian Paul Date: Mon, 25 Apr 2016 22:00:31 +0000 (-0600) Subject: llvmpipe: s/Elements/ARRAY_SIZE/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1d242b688265a405dfd8077ea32ac4ea673b02a2;p=mesa.git llvmpipe: s/Elements/ARRAY_SIZE/ Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index bd7c0a1e4af..84912c6f114 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -73,20 +73,20 @@ static void llvmpipe_destroy( struct pipe_context *pipe ) pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL); - for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) { + for (i = 0; i < ARRAY_SIZE(llvmpipe->sampler_views[0]); i++) { pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL); } - for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) { + for (i = 0; i < ARRAY_SIZE(llvmpipe->sampler_views[0]); i++) { pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], NULL); } - for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) { + for (i = 0; i < ARRAY_SIZE(llvmpipe->sampler_views[0]); i++) { pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_GEOMETRY][i], NULL); } - for (i = 0; i < Elements(llvmpipe->constants); i++) { - for (j = 0; j < Elements(llvmpipe->constants[i]); j++) { + for (i = 0; i < ARRAY_SIZE(llvmpipe->constants); i++) { + for (j = 0; j < ARRAY_SIZE(llvmpipe->constants[i]); j++) { pipe_resource_reference(&llvmpipe->constants[i][j].buffer, NULL); } } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index b915c1d64ff..21260369aca 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -56,7 +56,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) elem_types[LP_JIT_VIEWPORT_MAX_DEPTH] = LLVMFloatTypeInContext(lc); viewport_type = LLVMStructTypeInContext(lc, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); LP_CHECK_MEMBER_OFFSET(struct lp_jit_viewport, min_depth, gallivm->target, viewport_type, @@ -84,7 +84,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TEXTURE_LEVELS); texture_type = LLVMStructTypeInContext(lc, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width, gallivm->target, texture_type, @@ -127,7 +127,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LLVMArrayType(LLVMFloatTypeInContext(lc), 4); sampler_type = LLVMStructTypeInContext(lc, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, min_lod, gallivm->target, sampler_type, @@ -166,7 +166,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) PIPE_MAX_SAMPLERS); context_type = LLVMStructTypeInContext(lc, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants, gallivm->target, context_type, @@ -216,7 +216,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LLVMInt32TypeInContext(lc); thread_data_type = LLVMStructTypeInContext(lc, elem_types, - Elements(elem_types), 0); + ARRAY_SIZE(elem_types), 0); lp->jit_thread_data_ptr_type = LLVMPointerType(thread_data_type, 0); } diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c b/src/gallium/drivers/llvmpipe/lp_rast_debug.c index b5ae9dadf6d..e36ade0e307 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c +++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c @@ -58,7 +58,7 @@ static const char *cmd_names[LP_RAST_OP_MAX] = static const char *cmd_name(unsigned cmd) { - assert(Elements(cmd_names) > cmd); + assert(ARRAY_SIZE(cmd_names) > cmd); return cmd_names[cmd]; } diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 34d3c812b60..0a45db94723 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -69,7 +69,7 @@ lp_setup_get_empty_scene(struct lp_setup_context *setup) assert(setup->scene == NULL); setup->scene_idx++; - setup->scene_idx %= Elements(setup->scenes); + setup->scene_idx %= ARRAY_SIZE(setup->scenes); setup->scene = setup->scenes[setup->scene_idx]; @@ -123,7 +123,7 @@ void lp_setup_reset( struct lp_setup_context *setup ) LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__); /* Reset derived state */ - for (i = 0; i < Elements(setup->constants); ++i) { + for (i = 0; i < ARRAY_SIZE(setup->constants); ++i) { setup->constants[i].stored_size = 0; setup->constants[i].stored_data = NULL; } @@ -650,12 +650,12 @@ lp_setup_set_fs_constants(struct lp_setup_context *setup, LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, (void *) buffers); - assert(num <= Elements(setup->constants)); + assert(num <= ARRAY_SIZE(setup->constants)); for (i = 0; i < num; ++i) { util_copy_constant_buffer(&setup->constants[i].current, &buffers[i]); } - for (; i < Elements(setup->constants); i++) { + for (; i < ARRAY_SIZE(setup->constants); i++) { util_copy_constant_buffer(&setup->constants[i].current, NULL); } setup->dirty |= LP_SETUP_NEW_CONSTANTS; @@ -990,7 +990,7 @@ lp_setup_is_resource_referenced( const struct lp_setup_context *setup, } /* check textures referenced by the scene */ - for (i = 0; i < Elements(setup->scenes); i++) { + for (i = 0; i < ARRAY_SIZE(setup->scenes); i++) { if (lp_scene_is_resource_referenced(setup->scenes[i], texture)) { return LP_REFERENCED_FOR_READ; } @@ -1081,7 +1081,7 @@ try_update_scene_state( struct lp_setup_context *setup ) } if (setup->dirty & LP_SETUP_NEW_CONSTANTS) { - for (i = 0; i < Elements(setup->constants); ++i) { + for (i = 0; i < ARRAY_SIZE(setup->constants); ++i) { struct pipe_resource *buffer = setup->constants[i].current.buffer; const unsigned current_size = MIN2(setup->constants[i].current.buffer_size, LP_MAX_TGSI_CONST_BUFFER_SIZE); @@ -1166,7 +1166,7 @@ try_update_scene_state( struct lp_setup_context *setup ) /* The scene now references the textures in the rasterization * state record. Note that now. */ - for (i = 0; i < Elements(setup->fs.current_tex); i++) { + for (i = 0; i < ARRAY_SIZE(setup->fs.current_tex); i++) { if (setup->fs.current_tex[i]) { if (!lp_scene_add_resource_reference(scene, setup->fs.current_tex[i], @@ -1283,16 +1283,16 @@ lp_setup_destroy( struct lp_setup_context *setup ) util_unreference_framebuffer_state(&setup->fb); - for (i = 0; i < Elements(setup->fs.current_tex); i++) { + for (i = 0; i < ARRAY_SIZE(setup->fs.current_tex); i++) { pipe_resource_reference(&setup->fs.current_tex[i], NULL); } - for (i = 0; i < Elements(setup->constants); i++) { + for (i = 0; i < ARRAY_SIZE(setup->constants); i++) { pipe_resource_reference(&setup->constants[i].current.buffer, NULL); } /* free the scenes in the 'empty' queue */ - for (i = 0; i < Elements(setup->scenes); i++) { + for (i = 0; i < ARRAY_SIZE(setup->scenes); i++) { struct lp_scene *scene = setup->scenes[i]; if (scene->fence) diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index c90f2f270fe..9e29902619a 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -237,7 +237,7 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe ) if (llvmpipe->dirty & LP_NEW_CONSTANTS) lp_setup_set_fs_constants(llvmpipe->setup, - Elements(llvmpipe->constants[PIPE_SHADER_FRAGMENT]), + ARRAY_SIZE(llvmpipe->constants[PIPE_SHADER_FRAGMENT]), llvmpipe->constants[PIPE_SHADER_FRAGMENT]); if (llvmpipe->dirty & (LP_NEW_SAMPLER_VIEW)) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 76cbb5be8ef..7dceff7bc57 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -134,7 +134,7 @@ generate_quad_mask(struct gallivm_state *gallivm, * XXX: We'll need a different path for 16 x u8 */ assert(fs_type.width == 32); - assert(fs_type.length <= Elements(bits)); + assert(fs_type.length <= ARRAY_SIZE(bits)); mask_type = lp_int_type(fs_type); /* @@ -646,7 +646,7 @@ generate_fs_twiddle(struct gallivm_state *gallivm, src_count = num_fs * src_channels; assert(pixels == 2 || pixels == 1); - assert(num_fs * src_channels <= Elements(src)); + assert(num_fs * src_channels <= ARRAY_SIZE(src)); /* * Transpose from SoA -> AoS @@ -2267,7 +2267,7 @@ generate_fragment(struct llvmpipe_context *lp, arg_types[12] = int32_type; /* depth_stride */ func_type = LLVMFunctionType(LLVMVoidTypeInContext(gallivm->context), - arg_types, Elements(arg_types), 0); + arg_types, ARRAY_SIZE(arg_types), 0); function = LLVMAddFunction(gallivm->module, func_name, func_type); LLVMSetFunctionCallConv(function, LLVMCCallConv); @@ -2277,7 +2277,7 @@ generate_fragment(struct llvmpipe_context *lp, /* XXX: need to propagate noalias down into color param now we are * passing a pointer-to-pointer? */ - 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(function, i), LLVMNoAliasAttribute); @@ -2842,7 +2842,7 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, struct pipe_resource *constants = cb ? cb->buffer : NULL; assert(shader < PIPE_SHADER_TYPES); - assert(index < Elements(llvmpipe->constants[shader])); + assert(index < ARRAY_SIZE(llvmpipe->constants[shader])); /* note: reference counting */ util_copy_constant_buffer(&llvmpipe->constants[shader][index], cb); diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c index 32bf9fdd25d..81b998ac410 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c +++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c @@ -75,7 +75,7 @@ llvmpipe_bind_sampler_states(struct pipe_context *pipe, unsigned i; assert(shader < PIPE_SHADER_TYPES); - assert(start + num <= Elements(llvmpipe->samplers[shader])); + assert(start + num <= ARRAY_SIZE(llvmpipe->samplers[shader])); draw_flush(llvmpipe->draw); @@ -117,7 +117,7 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe, assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS); assert(shader < PIPE_SHADER_TYPES); - assert(start + num <= Elements(llvmpipe->sampler_views[shader])); + assert(start + num <= ARRAY_SIZE(llvmpipe->sampler_views[shader])); draw_flush(llvmpipe->draw); diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c index fec0ec1f705..a57e2f04b6c 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c @@ -760,7 +760,7 @@ generate_setup_variant(struct lp_setup_variant_key *key, arg_types[6] = LLVMPointerType(vec4f_type, 0); /* dady, aligned */ func_type = LLVMFunctionType(LLVMVoidTypeInContext(gallivm->context), - arg_types, Elements(arg_types), 0); + arg_types, ARRAY_SIZE(arg_types), 0); variant->function = LLVMAddFunction(gallivm->module, func_name, func_type); if (!variant->function) @@ -791,7 +791,7 @@ generate_setup_variant(struct lp_setup_variant_key *key, variant->function, "entry"); LLVMPositionBuilderAtEnd(builder, block); - set_noalias(builder, variant->function, arg_types, Elements(arg_types)); + set_noalias(builder, variant->function, arg_types, ARRAY_SIZE(arg_types)); init_args(gallivm, &variant->key, &args); emit_tri_coef(gallivm, &variant->key, &args); diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c index 875d51c5a38..acba7ed44a8 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c @@ -295,23 +295,23 @@ const float fract_values[] = { static const struct unary_test_t unary_tests[] = { - {"abs", &lp_build_abs, &fabsf, sgn_values, Elements(sgn_values), 20.0 }, - {"neg", &lp_build_negate, &negf, sgn_values, Elements(sgn_values), 20.0 }, - {"sgn", &lp_build_sgn, &sgnf, sgn_values, Elements(sgn_values), 20.0 }, - {"exp2", &lp_build_exp2, &exp2f, exp2_values, Elements(exp2_values), 18.0 }, - {"log2", &lp_build_log2_safe, &log2f, log2_values, Elements(log2_values), 20.0 }, - {"exp", &lp_build_exp, &expf, exp2_values, Elements(exp2_values), 18.0 }, - {"log", &lp_build_log_safe, &logf, log2_values, Elements(log2_values), 20.0 }, - {"rcp", &lp_build_rcp, &rcpf, rcp_values, Elements(rcp_values), 20.0 }, - {"rsqrt", &lp_build_rsqrt, &rsqrtf, rsqrt_values, Elements(rsqrt_values), 20.0 }, - {"sin", &lp_build_sin, &sinf, sincos_values, Elements(sincos_values), 20.0 }, - {"cos", &lp_build_cos, &cosf, sincos_values, Elements(sincos_values), 20.0 }, - {"sgn", &lp_build_sgn, &sgnf, sgn_values, Elements(sgn_values), 20.0 }, - {"round", &lp_build_round, &nearbyintf, round_values, Elements(round_values), 24.0 }, - {"trunc", &lp_build_trunc, &truncf, round_values, Elements(round_values), 24.0 }, - {"floor", &lp_build_floor, &floorf, round_values, Elements(round_values), 24.0 }, - {"ceil", &lp_build_ceil, &ceilf, round_values, Elements(round_values), 24.0 }, - {"fract", &lp_build_fract_safe, &fractf, fract_values, Elements(fract_values), 24.0 }, + {"abs", &lp_build_abs, &fabsf, sgn_values, ARRAY_SIZE(sgn_values), 20.0 }, + {"neg", &lp_build_negate, &negf, sgn_values, ARRAY_SIZE(sgn_values), 20.0 }, + {"sgn", &lp_build_sgn, &sgnf, sgn_values, ARRAY_SIZE(sgn_values), 20.0 }, + {"exp2", &lp_build_exp2, &exp2f, exp2_values, ARRAY_SIZE(exp2_values), 18.0 }, + {"log2", &lp_build_log2_safe, &log2f, log2_values, ARRAY_SIZE(log2_values), 20.0 }, + {"exp", &lp_build_exp, &expf, exp2_values, ARRAY_SIZE(exp2_values), 18.0 }, + {"log", &lp_build_log_safe, &logf, log2_values, ARRAY_SIZE(log2_values), 20.0 }, + {"rcp", &lp_build_rcp, &rcpf, rcp_values, ARRAY_SIZE(rcp_values), 20.0 }, + {"rsqrt", &lp_build_rsqrt, &rsqrtf, rsqrt_values, ARRAY_SIZE(rsqrt_values), 20.0 }, + {"sin", &lp_build_sin, &sinf, sincos_values, ARRAY_SIZE(sincos_values), 20.0 }, + {"cos", &lp_build_cos, &cosf, sincos_values, ARRAY_SIZE(sincos_values), 20.0 }, + {"sgn", &lp_build_sgn, &sgnf, sgn_values, ARRAY_SIZE(sgn_values), 20.0 }, + {"round", &lp_build_round, &nearbyintf, round_values, ARRAY_SIZE(round_values), 24.0 }, + {"trunc", &lp_build_trunc, &truncf, round_values, ARRAY_SIZE(round_values), 24.0 }, + {"floor", &lp_build_floor, &floorf, round_values, ARRAY_SIZE(round_values), 24.0 }, + {"ceil", &lp_build_ceil, &ceilf, round_values, ARRAY_SIZE(round_values), 24.0 }, + {"fract", &lp_build_fract_safe, &fractf, fract_values, ARRAY_SIZE(fract_values), 24.0 }, }; @@ -331,7 +331,7 @@ build_unary_test_func(struct gallivm_state *gallivm, LLVMTypeRef args[2] = { LLVMPointerType(vf32t, 0), LLVMPointerType(vf32t, 0) }; LLVMValueRef func = LLVMAddFunction(module, test_name, LLVMFunctionType(LLVMVoidTypeInContext(context), - args, Elements(args), 0)); + args, ARRAY_SIZE(args), 0)); LLVMValueRef arg0 = LLVMGetParam(func, 0); LLVMValueRef arg1 = LLVMGetParam(func, 1); LLVMBuilderRef builder = gallivm->builder; @@ -503,7 +503,7 @@ test_all(unsigned verbose, FILE *fp) boolean success = TRUE; int i; - for (i = 0; i < Elements(unary_tests); ++i) { + for (i = 0; i < ARRAY_SIZE(unary_tests); ++i) { unsigned max_length = lp_native_vector_width / 32; unsigned length; for (length = 1; length <= max_length; length *= 2) { diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index ae4c3f8e2e2..9b16162131f 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -107,7 +107,7 @@ add_fetch_rgba_test(struct gallivm_state *gallivm, unsigned verbose, func = LLVMAddFunction(module, name, LLVMFunctionType(LLVMVoidTypeInContext(context), - args, Elements(args), 0)); + args, ARRAY_SIZE(args), 0)); LLVMSetFunctionCallConv(func, LLVMCCallConv); rgba_ptr = LLVMGetParam(func, 0); packed_ptr = LLVMGetParam(func, 1); diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index 8adaa8e77d9..5d0d3509195 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -112,7 +112,7 @@ lp_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, ""); @@ -190,7 +190,7 @@ lp_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/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index c2ca8b8d6a0..ee419481d5d 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -546,7 +546,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe, if ((usage & PIPE_TRANSFER_WRITE) && (resource->bind & PIPE_BIND_CONSTANT_BUFFER)) { unsigned i; - for (i = 0; i < Elements(llvmpipe->constants[PIPE_SHADER_FRAGMENT]); ++i) { + for (i = 0; i < ARRAY_SIZE(llvmpipe->constants[PIPE_SHADER_FRAGMENT]); ++i) { if (resource == llvmpipe->constants[PIPE_SHADER_FRAGMENT][i].buffer) { /* constants may have changed */ llvmpipe->dirty |= LP_NEW_CONSTANTS;