Standardize on the later macro rather than a mix of both.
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
cmd->soid = soid;
cmd->numOutputStreamEntries = numOutputStreamEntries;
- for (i = 0; i < Elements(cmd->streamOutputStrideInBytes); i++)
+ for (i = 0; i < ARRAY_SIZE(cmd->streamOutputStrideInBytes); i++)
cmd->streamOutputStrideInBytes[i] = streamOutputStrideInBytes[i];
memcpy(cmd->decl, decl,
unsigned shader, i;
/* free any alternate rasterizer states used for point sprite */
- for (i = 0; i < Elements(svga->rasterizer_no_cull); i++) {
+ for (i = 0; i < ARRAY_SIZE(svga->rasterizer_no_cull); i++) {
if (svga->rasterizer_no_cull[i]) {
pipe->delete_rasterizer_state(pipe, svga->rasterizer_no_cull[i]);
}
pipe_resource_reference(&svga->polygon_stipple.texture, NULL);
/* free HW constant buffers */
- for (shader = 0; shader < Elements(svga->state.hw_draw.constbuf); shader++) {
+ for (shader = 0; shader < ARRAY_SIZE(svga->state.hw_draw.constbuf); shader++) {
pipe_resource_reference(&svga->state.hw_draw.constbuf[shader], NULL);
}
/* free user's constant buffers */
for (shader = 0; shader < PIPE_SHADER_TYPES; ++shader) {
- for (i = 0; i < Elements(svga->curr.constbufs[shader]); ++i) {
+ for (i = 0; i < ARRAY_SIZE(svga->curr.constbufs[shader]); ++i) {
pipe_resource_reference(&svga->curr.constbufs[shader][i].buffer, NULL);
}
}
SVGA3dSurfaceFormat *svga_format,
unsigned *vf_flags)
{
- assert(format < Elements(format_conversion_table));
- if (format >= Elements(format_conversion_table)) {
+ assert(format < ARRAY_SIZE(format_conversion_table));
+ if (format >= ARRAY_SIZE(format_conversion_table)) {
format = PIPE_FORMAT_NONE;
}
*svga_format = format_conversion_table[format].vertex_format;
if (first_call) {
unsigned i;
- STATIC_ASSERT(Elements(format_cap_table) == SVGA3D_FORMAT_MAX);
- for (i = 0; i < Elements(format_cap_table); i++) {
+ STATIC_ASSERT(ARRAY_SIZE(format_cap_table) == SVGA3D_FORMAT_MAX);
+ for (i = 0; i < ARRAY_SIZE(format_cap_table); i++) {
assert(format_cap_table[i].format == i);
}
- STATIC_ASSERT(Elements(format_conversion_table) == PIPE_FORMAT_COUNT);
- for (i = 0; i < Elements(format_conversion_table); i++) {
+ STATIC_ASSERT(ARRAY_SIZE(format_conversion_table) == PIPE_FORMAT_COUNT);
+ for (i = 0; i < ARRAY_SIZE(format_conversion_table); i++) {
assert(format_conversion_table[i].pformat == i);
}
(void) check_format_tables;
#endif
- assert(format < Elements(format_cap_table));
+ assert(format < ARRAY_SIZE(format_cap_table));
entry = &format_cap_table[format];
assert(entry->format == format);
unsigned *block_height,
unsigned *bytes_per_block)
{
- assert(format < Elements(format_cap_table));
+ assert(format < ARRAY_SIZE(format_cap_table));
*block_width = format_cap_table[format].block_width;
*block_height = format_cap_table[format].block_height;
*bytes_per_block = format_cap_table[format].block_bytes;
const char *
svga_format_name(SVGA3dSurfaceFormat format)
{
- assert(format < Elements(format_cap_table));
+ assert(format < ARRAY_SIZE(format_cap_table));
return format_cap_table[format].name;
}
boolean
svga_format_support_gen_mips(enum pipe_format format)
{
- assert(format < Elements(format_conversion_table));
+ assert(format < ARRAY_SIZE(format_conversion_table));
return ((format_conversion_table[format].flags & TF_GEN_MIPS) > 0);
}
{
unsigned i, free_slot;
- for (i = 0; i < Elements(linkage->input_map); i++) {
+ for (i = 0; i < ARRAY_SIZE(linkage->input_map); i++) {
linkage->input_map[i] = INVALID_INDEX;
}
* We'll modify the input shader's inputs to match the output shader.
*/
assert(inshader_info->num_inputs <=
- Elements(inshader_info->input_semantic_name));
+ ARRAY_SIZE(inshader_info->input_semantic_name));
/* free register index that can be used for built-in varyings */
free_slot = outshader_info->num_outputs + 1;
else {
/* search output shader outputs for same item */
for (j = 0; j < outshader_info->num_outputs; j++) {
- assert(j < Elements(outshader_info->output_semantic_name));
+ assert(j < ARRAY_SIZE(outshader_info->output_semantic_name));
if (outshader_info->output_semantic_name[j] == sem_name &&
outshader_info->output_semantic_index[j] == sem_index) {
linkage->input_map[i] = j;
}
assert(shader < PIPE_SHADER_TYPES);
- assert(index < Elements(svga->curr.constbufs[shader]));
+ assert(index < ARRAY_SIZE(svga->curr.constbufs[shader]));
assert(index < svgascreen->max_const_buffers);
(void) svgascreen;
boolean any_change = FALSE;
assert(shader < PIPE_SHADER_TYPES);
- assert(start + num <= Elements(svga->curr.sampler_views[shader]));
+ assert(start + num <= ARRAY_SIZE(svga->curr.sampler_views[shader]));
/* Pre-VGPU10 only supports FS textures */
if (!svga_have_vgpu10(svga) && shader != PIPE_SHADER_FRAGMENT)
if (!tgsi_text_translate(text,
tokens,
- Elements(tokens)))
+ ARRAY_SIZE(tokens)))
{
assert(0);
return NULL;
static inline void
svga_age_texture_view(struct svga_texture *tex, unsigned level)
{
- assert(level < Elements(tex->view_age));
+ assert(level < ARRAY_SIZE(tex->view_age));
tex->view_age[level] = ++(tex->age);
}
for (i = v->min_lod; i <= v->max_lod; i++) {
for (k = 0; k < numFaces; k++) {
- assert(i < Elements(tex->view_age));
+ assert(i < ARRAY_SIZE(tex->view_age));
if (v->age < tex->view_age[i])
svga_texture_copy_handle(svga,
tex->handle, 0, 0, 0, i, k,
#undef QUERY
if (!info)
- return Elements(queries);
+ return ARRAY_SIZE(queries);
- if (index >= Elements(queries))
+ if (index >= ARRAY_SIZE(queries))
return 0;
*info = queries[index];
{
unsigned i, idx = 0;
- assert(shader < Elements(svga->curr.num_sampler_views));
+ assert(shader < ARRAY_SIZE(svga->curr.num_sampler_views));
for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) {
struct pipe_sampler_view *view = svga->curr.sampler_views[shader][i];
assert(variant);
offset = variant->shader->info.file_max[TGSI_FILE_CONSTANT] + 1;
- assert(count <= Elements(extras));
+ assert(count <= ARRAY_SIZE(extras));
if (count > 0) {
if (ss->hw_version >= SVGA3D_HWVERSION_WS8_B1) {
#define EMIT_RS(svga, value, token, fail) \
do { \
- STATIC_ASSERT(SVGA3D_RS_##token < Elements(svga->state.hw_draw.rs)); \
+ STATIC_ASSERT(SVGA3D_RS_##token < ARRAY_SIZE(svga->state.hw_draw.rs)); \
if (svga->state.hw_draw.rs[SVGA3D_RS_##token] != value) { \
svga_queue_rs( &queue, SVGA3D_RS_##token, value ); \
svga->state.hw_draw.rs[SVGA3D_RS_##token] = value; \
#define EMIT_RS_FLOAT(svga, fvalue, token, fail) \
do { \
unsigned value = fui(fvalue); \
- STATIC_ASSERT(SVGA3D_RS_##token < Elements(svga->state.hw_draw.rs)); \
+ STATIC_ASSERT(SVGA3D_RS_##token < ARRAY_SIZE(svga->state.hw_draw.rs)); \
if (svga->state.hw_draw.rs[SVGA3D_RS_##token] != value) { \
svga_queue_rs( &queue, SVGA3D_RS_##token, value ); \
svga->state.hw_draw.rs[SVGA3D_RS_##token] = value; \
surfaces[i] = surface;
}
- for (; i < Elements(ids); i++) {
+ for (; i < ARRAY_SIZE(ids); i++) {
ids[i] = SVGA3D_INVALID_ID;
surfaces[i] = NULL;
}
const unsigned shader = PIPE_SHADER_FRAGMENT;
unsigned i;
- for (i = 0; i < Elements(svga->state.hw_draw.views); i++) {
+ for (i = 0; i < ARRAY_SIZE(svga->state.hw_draw.views); i++) {
struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
if (view) {
svga_sampler_view_reference(&view->v, NULL);
#define EMIT_TS(svga, unit, val, token) \
do { \
- assert(unit < Elements(svga->state.hw_draw.ts)); \
- STATIC_ASSERT(SVGA3D_TS_##token < Elements(svga->state.hw_draw.ts[unit])); \
+ assert(unit < ARRAY_SIZE(svga->state.hw_draw.ts)); \
+ STATIC_ASSERT(SVGA3D_TS_##token < ARRAY_SIZE(svga->state.hw_draw.ts[unit])); \
if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \
svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \
svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \
#define EMIT_TS_FLOAT(svga, unit, fvalue, token) \
do { \
unsigned val = fui(fvalue); \
- assert(unit < Elements(svga->state.hw_draw.ts)); \
- STATIC_ASSERT(SVGA3D_TS_##token < Elements(svga->state.hw_draw.ts[unit])); \
+ assert(unit < ARRAY_SIZE(svga->state.hw_draw.ts)); \
+ STATIC_ASSERT(SVGA3D_TS_##token < ARRAY_SIZE(svga->state.hw_draw.ts[unit])); \
if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \
svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \
svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \
}
/* Map constant buffers */
- for (i = 0; i < Elements(svga->curr.constbufs[PIPE_SHADER_VERTEX]); ++i) {
+ for (i = 0; i < ARRAY_SIZE(svga->curr.constbufs[PIPE_SHADER_VERTEX]); ++i) {
if (svga->curr.constbufs[PIPE_SHADER_VERTEX][i].buffer == NULL) {
continue;
}
draw_set_indexes(draw, NULL, 0, 0);
}
- for (i = 0; i < Elements(svga->curr.constbufs[PIPE_SHADER_VERTEX]); ++i) {
+ for (i = 0; i < ARRAY_SIZE(svga->curr.constbufs[PIPE_SHADER_VERTEX]); ++i) {
if (svga->curr.constbufs[PIPE_SHADER_VERTEX][i].buffer) {
pipe_buffer_unmap(&svga->pipe, cb_transfer[i]);
}
dcl.values[0] |= 1<<31;
return (emit_instruction(emit, opcode) &&
- svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+ svga_shader_emit_dwords( emit, dcl.values, ARRAY_SIZE(dcl.values)));
}
dcl.values[0] |= 1<<31;
return (emit_instruction(emit, opcode) &&
- svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+ svga_shader_emit_dwords( emit, dcl.values, ARRAY_SIZE(dcl.values)));
}
}
return (emit_instruction(emit, opcode) &&
- svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+ svga_shader_emit_dwords( emit, dcl.values, ARRAY_SIZE(dcl.values)));
}
dcl.values[0] |= 1<<31;
return (emit_instruction(emit, opcode) &&
- svga_shader_emit_dwords( emit, dcl.values, Elements(dcl.values)));
+ svga_shader_emit_dwords( emit, dcl.values, ARRAY_SIZE(dcl.values)));
}
boolean
}
if (!emit_instruction(emit, opcode) ||
- !svga_shader_emit_dwords( emit, def.values, Elements(def.values)))
+ !svga_shader_emit_dwords( emit, def.values, ARRAY_SIZE(def.values)))
return FALSE;
return TRUE;
break;
}
- if (emit->nr_labels == Elements(emit->label))
+ if (emit->nr_labels == ARRAY_SIZE(emit->label))
return FALSE;
if (i == emit->nr_labels) {
assert(emit->inverted_texcoords & (1 << unit));
- assert(unit < Elements(emit->ps_true_texcoord));
+ assert(unit < ARRAY_SIZE(emit->ps_true_texcoord));
- assert(unit < Elements(emit->ps_inverted_texcoord_input));
+ assert(unit < ARRAY_SIZE(emit->ps_inverted_texcoord_input));
assert(emit->ps_inverted_texcoord_input[unit]
- < Elements(emit->input_map));
+ < ARRAY_SIZE(emit->input_map));
/* inverted = coord * (1, -1, 1, 1) + (0, 1, 0, 0) */
if (!submit_op3(emit,
}
}
else if (file == TGSI_FILE_SYSTEM_VALUE) {
- assert(index < Elements(emit->system_value_indexes));
+ assert(index < ARRAY_SIZE(emit->system_value_indexes));
index = emit->system_value_indexes[index];
}
}
if (operand0.operandType == VGPU10_OPERAND_TYPE_IMMEDIATE32) {
/* Emit the four float/int in-line immediate values */
unsigned *c;
- assert(index < Elements(emit->immediates));
+ assert(index < ARRAY_SIZE(emit->immediates));
assert(file == TGSI_FILE_IMMEDIATE);
assert(swizzleX < 4);
assert(swizzleY < 4);
{
unsigned n = emit->num_immediates++;
assert(!emit->immediates_emitted);
- assert(n < Elements(emit->immediates));
+ assert(n < ARRAY_SIZE(emit->immediates));
emit->immediates[n][0] = imm[0];
emit->immediates[n][1] = imm[1];
emit->immediates[n][2] = imm[2];
alloc_system_value_index(struct svga_shader_emitter_v10 *emit, unsigned index)
{
const unsigned n = emit->info.file_max[TGSI_FILE_INPUT] + 1 + index;
- assert(index < Elements(emit->system_value_indexes));
+ assert(index < ARRAY_SIZE(emit->system_value_indexes));
emit->system_value_indexes[index] = n;
return n;
}
switch (prop->Property.PropertyName) {
case TGSI_PROPERTY_GS_INPUT_PRIM:
- assert(prop->u[0].Data < Elements(primType));
+ assert(prop->u[0].Data < ARRAY_SIZE(primType));
emit->gs.prim_type = primType[prop->u[0].Data];
assert(emit->gs.prim_type != VGPU10_PRIMITIVE_UNDEFINED);
emit->gs.input_size = inputArraySize[emit->gs.prim_type];
break;
case TGSI_PROPERTY_GS_OUTPUT_PRIM:
- assert(prop->u[0].Data < Elements(primTopology));
+ assert(prop->u[0].Data < ARRAY_SIZE(primTopology));
emit->gs.prim_topology = primTopology[prop->u[0].Data];
assert(emit->gs.prim_topology != VGPU10_PRIMITIVE_TOPOLOGY_UNDEFINED);
break;
* have linked due to constbuf index out of bounds, so we shouldn't
* have reached here.
*/
- assert(constbuf < Elements(emit->num_shader_consts));
+ assert(constbuf < ARRAY_SIZE(emit->num_shader_consts));
num_consts = MAX2(emit->num_shader_consts[constbuf],
decl->Range.Last + 1);
if (emit->unit == PIPE_SHADER_FRAGMENT) {
if (semantic_name == TGSI_SEMANTIC_COLOR) {
- assert(semantic_index < Elements(emit->fs.color_out_index));
+ assert(semantic_index < ARRAY_SIZE(emit->fs.color_out_index));
emit->fs.color_out_index[semantic_index] = index;
}
/* Declare remaining constant buffers (UBOs) */
- for (i = 1; i < Elements(emit->num_shader_consts); i++) {
+ for (i = 1; i < ARRAY_SIZE(emit->num_shader_consts); i++) {
if (emit->num_shader_consts[i] > 0) {
begin_emit_instruction(emit);
emit_dword(emit, opcode0.value);
alloc_immediate_int4(emit, 22, 30, 0, 0);
}
- assert(n <= Elements(emit->common_immediate_pos));
+ assert(n <= ARRAY_SIZE(emit->common_immediate_pos));
emit->num_common_immediates = n;
}