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);
}
}
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,
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,
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,
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,
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);
}
static const char *cmd_name(unsigned cmd)
{
- assert(Elements(cmd_names) > cmd);
+ assert(ARRAY_SIZE(cmd_names) > cmd);
return cmd_names[cmd];
}
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];
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;
}
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;
}
/* 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;
}
}
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);
/* 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],
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)
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))
* 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);
/*
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
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);
/* 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);
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);
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);
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);
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)
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);
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 },
};
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;
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) {
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);
/* 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, "");
/* 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, "");
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;