Commit e0184b39 authored by Brian Paul's avatar Brian Paul
Browse files

svga: s/Elements/ARRAY_SIZE/



Standardize on the later macro rather than a mix of both.
Reviewed-by: Charmaine Lee's avatarCharmaine Lee <charmainel@vmware.com>
parent 77e4b416
...@@ -1112,7 +1112,7 @@ SVGA3D_vgpu10_DefineStreamOutput(struct svga_winsys_context *swc, ...@@ -1112,7 +1112,7 @@ SVGA3D_vgpu10_DefineStreamOutput(struct svga_winsys_context *swc,
cmd->soid = soid; cmd->soid = soid;
cmd->numOutputStreamEntries = numOutputStreamEntries; 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]; cmd->streamOutputStrideInBytes[i] = streamOutputStrideInBytes[i];
memcpy(cmd->decl, decl, memcpy(cmd->decl, decl,
......
...@@ -61,7 +61,7 @@ static void svga_destroy( struct pipe_context *pipe ) ...@@ -61,7 +61,7 @@ static void svga_destroy( struct pipe_context *pipe )
unsigned shader, i; unsigned shader, i;
/* free any alternate rasterizer states used for point sprite */ /* 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]) { if (svga->rasterizer_no_cull[i]) {
pipe->delete_rasterizer_state(pipe, svga->rasterizer_no_cull[i]); pipe->delete_rasterizer_state(pipe, svga->rasterizer_no_cull[i]);
} }
...@@ -78,7 +78,7 @@ static void svga_destroy( struct pipe_context *pipe ) ...@@ -78,7 +78,7 @@ static void svga_destroy( struct pipe_context *pipe )
pipe_resource_reference(&svga->polygon_stipple.texture, NULL); pipe_resource_reference(&svga->polygon_stipple.texture, NULL);
/* free HW constant buffers */ /* 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); pipe_resource_reference(&svga->state.hw_draw.constbuf[shader], NULL);
} }
...@@ -116,7 +116,7 @@ static void svga_destroy( struct pipe_context *pipe ) ...@@ -116,7 +116,7 @@ static void svga_destroy( struct pipe_context *pipe )
/* free user's constant buffers */ /* free user's constant buffers */
for (shader = 0; shader < PIPE_SHADER_TYPES; ++shader) { 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); pipe_resource_reference(&svga->curr.constbufs[shader][i].buffer, NULL);
} }
} }
......
...@@ -366,8 +366,8 @@ svga_translate_vertex_format_vgpu10(enum pipe_format format, ...@@ -366,8 +366,8 @@ svga_translate_vertex_format_vgpu10(enum pipe_format format,
SVGA3dSurfaceFormat *svga_format, SVGA3dSurfaceFormat *svga_format,
unsigned *vf_flags) unsigned *vf_flags)
{ {
assert(format < Elements(format_conversion_table)); assert(format < ARRAY_SIZE(format_conversion_table));
if (format >= Elements(format_conversion_table)) { if (format >= ARRAY_SIZE(format_conversion_table)) {
format = PIPE_FORMAT_NONE; format = PIPE_FORMAT_NONE;
} }
*svga_format = format_conversion_table[format].vertex_format; *svga_format = format_conversion_table[format].vertex_format;
...@@ -1838,13 +1838,13 @@ check_format_tables(void) ...@@ -1838,13 +1838,13 @@ check_format_tables(void)
if (first_call) { if (first_call) {
unsigned i; unsigned i;
STATIC_ASSERT(Elements(format_cap_table) == SVGA3D_FORMAT_MAX); STATIC_ASSERT(ARRAY_SIZE(format_cap_table) == SVGA3D_FORMAT_MAX);
for (i = 0; i < Elements(format_cap_table); i++) { for (i = 0; i < ARRAY_SIZE(format_cap_table); i++) {
assert(format_cap_table[i].format == i); assert(format_cap_table[i].format == i);
} }
STATIC_ASSERT(Elements(format_conversion_table) == PIPE_FORMAT_COUNT); STATIC_ASSERT(ARRAY_SIZE(format_conversion_table) == PIPE_FORMAT_COUNT);
for (i = 0; i < Elements(format_conversion_table); i++) { for (i = 0; i < ARRAY_SIZE(format_conversion_table); i++) {
assert(format_conversion_table[i].pformat == i); assert(format_conversion_table[i].pformat == i);
} }
...@@ -1873,7 +1873,7 @@ svga_get_format_cap(struct svga_screen *ss, ...@@ -1873,7 +1873,7 @@ svga_get_format_cap(struct svga_screen *ss,
(void) check_format_tables; (void) check_format_tables;
#endif #endif
assert(format < Elements(format_cap_table)); assert(format < ARRAY_SIZE(format_cap_table));
entry = &format_cap_table[format]; entry = &format_cap_table[format];
assert(entry->format == format); assert(entry->format == format);
...@@ -1912,7 +1912,7 @@ svga_format_size(SVGA3dSurfaceFormat format, ...@@ -1912,7 +1912,7 @@ svga_format_size(SVGA3dSurfaceFormat format,
unsigned *block_height, unsigned *block_height,
unsigned *bytes_per_block) 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_width = format_cap_table[format].block_width;
*block_height = format_cap_table[format].block_height; *block_height = format_cap_table[format].block_height;
*bytes_per_block = format_cap_table[format].block_bytes; *bytes_per_block = format_cap_table[format].block_bytes;
...@@ -1928,7 +1928,7 @@ svga_format_size(SVGA3dSurfaceFormat format, ...@@ -1928,7 +1928,7 @@ svga_format_size(SVGA3dSurfaceFormat format,
const char * const char *
svga_format_name(SVGA3dSurfaceFormat format) svga_format_name(SVGA3dSurfaceFormat format)
{ {
assert(format < Elements(format_cap_table)); assert(format < ARRAY_SIZE(format_cap_table));
return format_cap_table[format].name; return format_cap_table[format].name;
} }
...@@ -1970,7 +1970,7 @@ svga_format_is_integer(SVGA3dSurfaceFormat format) ...@@ -1970,7 +1970,7 @@ svga_format_is_integer(SVGA3dSurfaceFormat format)
boolean boolean
svga_format_support_gen_mips(enum pipe_format format) 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); return ((format_conversion_table[format].flags & TF_GEN_MIPS) > 0);
} }
......
...@@ -45,7 +45,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, ...@@ -45,7 +45,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info,
{ {
unsigned i, free_slot; 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; linkage->input_map[i] = INVALID_INDEX;
} }
...@@ -55,7 +55,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, ...@@ -55,7 +55,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info,
* We'll modify the input shader's inputs to match the output shader. * We'll modify the input shader's inputs to match the output shader.
*/ */
assert(inshader_info->num_inputs <= 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 register index that can be used for built-in varyings */
free_slot = outshader_info->num_outputs + 1; free_slot = outshader_info->num_outputs + 1;
...@@ -76,7 +76,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info, ...@@ -76,7 +76,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info,
else { else {
/* search output shader outputs for same item */ /* search output shader outputs for same item */
for (j = 0; j < outshader_info->num_outputs; j++) { 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 && if (outshader_info->output_semantic_name[j] == sem_name &&
outshader_info->output_semantic_index[j] == sem_index) { outshader_info->output_semantic_index[j] == sem_index) {
linkage->input_map[i] = j; linkage->input_map[i] = j;
......
...@@ -64,7 +64,7 @@ static void svga_set_constant_buffer(struct pipe_context *pipe, ...@@ -64,7 +64,7 @@ static void svga_set_constant_buffer(struct pipe_context *pipe,
} }
assert(shader < PIPE_SHADER_TYPES); 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); assert(index < svgascreen->max_const_buffers);
(void) svgascreen; (void) svgascreen;
......
...@@ -425,7 +425,7 @@ svga_set_sampler_views(struct pipe_context *pipe, ...@@ -425,7 +425,7 @@ svga_set_sampler_views(struct pipe_context *pipe,
boolean any_change = FALSE; boolean any_change = FALSE;
assert(shader < PIPE_SHADER_TYPES); 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 */ /* Pre-VGPU10 only supports FS textures */
if (!svga_have_vgpu10(svga) && shader != PIPE_SHADER_FRAGMENT) if (!svga_have_vgpu10(svga) && shader != PIPE_SHADER_FRAGMENT)
......
...@@ -80,7 +80,7 @@ substitute_vs(unsigned shader_id, const struct tgsi_token *old_tokens) ...@@ -80,7 +80,7 @@ substitute_vs(unsigned shader_id, const struct tgsi_token *old_tokens)
if (!tgsi_text_translate(text, if (!tgsi_text_translate(text,
tokens, tokens,
Elements(tokens))) ARRAY_SIZE(tokens)))
{ {
assert(0); assert(0);
return NULL; return NULL;
......
...@@ -136,7 +136,7 @@ svga_transfer(struct pipe_transfer *transfer) ...@@ -136,7 +136,7 @@ svga_transfer(struct pipe_transfer *transfer)
static inline void static inline void
svga_age_texture_view(struct svga_texture *tex, unsigned level) 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); tex->view_age[level] = ++(tex->age);
} }
......
...@@ -200,7 +200,7 @@ svga_validate_sampler_view(struct svga_context *svga, ...@@ -200,7 +200,7 @@ svga_validate_sampler_view(struct svga_context *svga,
for (i = v->min_lod; i <= v->max_lod; i++) { for (i = v->min_lod; i <= v->max_lod; i++) {
for (k = 0; k < numFaces; k++) { 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]) if (v->age < tex->view_age[i])
svga_texture_copy_handle(svga, svga_texture_copy_handle(svga,
tex->handle, 0, 0, 0, i, k, tex->handle, 0, 0, 0, i, k,
......
...@@ -867,9 +867,9 @@ svga_get_driver_query_info(struct pipe_screen *screen, ...@@ -867,9 +867,9 @@ svga_get_driver_query_info(struct pipe_screen *screen,
#undef QUERY #undef QUERY
if (!info) if (!info)
return Elements(queries); return ARRAY_SIZE(queries);
if (index >= Elements(queries)) if (index >= ARRAY_SIZE(queries))
return 0; return 0;
*info = queries[index]; *info = queries[index];
......
...@@ -171,7 +171,7 @@ svga_init_shader_key_common(const struct svga_context *svga, unsigned shader, ...@@ -171,7 +171,7 @@ svga_init_shader_key_common(const struct svga_context *svga, unsigned shader,
{ {
unsigned i, idx = 0; 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++) { for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) {
struct pipe_sampler_view *view = svga->curr.sampler_views[shader][i]; struct pipe_sampler_view *view = svga->curr.sampler_views[shader][i];
......
...@@ -518,7 +518,7 @@ emit_consts_vgpu9(struct svga_context *svga, unsigned shader) ...@@ -518,7 +518,7 @@ emit_consts_vgpu9(struct svga_context *svga, unsigned shader)
assert(variant); assert(variant);
offset = variant->shader->info.file_max[TGSI_FILE_CONSTANT] + 1; offset = variant->shader->info.file_max[TGSI_FILE_CONSTANT] + 1;
assert(count <= Elements(extras)); assert(count <= ARRAY_SIZE(extras));
if (count > 0) { if (count > 0) {
if (ss->hw_version >= SVGA3D_HWVERSION_WS8_B1) { if (ss->hw_version >= SVGA3D_HWVERSION_WS8_B1) {
......
...@@ -47,7 +47,7 @@ struct rs_queue { ...@@ -47,7 +47,7 @@ struct rs_queue {
#define EMIT_RS(svga, value, token, fail) \ #define EMIT_RS(svga, value, token, fail) \
do { \ 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) { \ if (svga->state.hw_draw.rs[SVGA3D_RS_##token] != value) { \
svga_queue_rs( &queue, SVGA3D_RS_##token, value ); \ svga_queue_rs( &queue, SVGA3D_RS_##token, value ); \
svga->state.hw_draw.rs[SVGA3D_RS_##token] = value; \ svga->state.hw_draw.rs[SVGA3D_RS_##token] = value; \
...@@ -57,7 +57,7 @@ do { \ ...@@ -57,7 +57,7 @@ do { \
#define EMIT_RS_FLOAT(svga, fvalue, token, fail) \ #define EMIT_RS_FLOAT(svga, fvalue, token, fail) \
do { \ do { \
unsigned value = fui(fvalue); \ 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) { \ if (svga->state.hw_draw.rs[SVGA3D_RS_##token] != value) { \
svga_queue_rs( &queue, SVGA3D_RS_##token, value ); \ svga_queue_rs( &queue, SVGA3D_RS_##token, value ); \
svga->state.hw_draw.rs[SVGA3D_RS_##token] = value; \ svga->state.hw_draw.rs[SVGA3D_RS_##token] = value; \
......
...@@ -226,7 +226,7 @@ update_sampler_resources(struct svga_context *svga, unsigned dirty) ...@@ -226,7 +226,7 @@ update_sampler_resources(struct svga_context *svga, unsigned dirty)
surfaces[i] = surface; surfaces[i] = surface;
} }
for (; i < Elements(ids); i++) { for (; i < ARRAY_SIZE(ids); i++) {
ids[i] = SVGA3D_INVALID_ID; ids[i] = SVGA3D_INVALID_ID;
surfaces[i] = NULL; surfaces[i] = NULL;
} }
......
...@@ -44,7 +44,7 @@ void svga_cleanup_tss_binding(struct svga_context *svga) ...@@ -44,7 +44,7 @@ void svga_cleanup_tss_binding(struct svga_context *svga)
const unsigned shader = PIPE_SHADER_FRAGMENT; const unsigned shader = PIPE_SHADER_FRAGMENT;
unsigned i; 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]; struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
if (view) { if (view) {
svga_sampler_view_reference(&view->v, NULL); svga_sampler_view_reference(&view->v, NULL);
...@@ -326,8 +326,8 @@ svga_queue_tss( struct ts_queue *q, ...@@ -326,8 +326,8 @@ svga_queue_tss( struct ts_queue *q,
#define EMIT_TS(svga, unit, val, token) \ #define EMIT_TS(svga, unit, val, token) \
do { \ do { \
assert(unit < Elements(svga->state.hw_draw.ts)); \ assert(unit < ARRAY_SIZE(svga->state.hw_draw.ts)); \
STATIC_ASSERT(SVGA3D_TS_##token < Elements(svga->state.hw_draw.ts[unit])); \ STATIC_ASSERT(SVGA3D_TS_##token < ARRAY_SIZE(svga->state.hw_draw.ts[unit])); \
if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \ if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \
svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \ svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \
svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \ svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \
...@@ -337,8 +337,8 @@ do { \ ...@@ -337,8 +337,8 @@ do { \
#define EMIT_TS_FLOAT(svga, unit, fvalue, token) \ #define EMIT_TS_FLOAT(svga, unit, fvalue, token) \
do { \ do { \
unsigned val = fui(fvalue); \ unsigned val = fui(fvalue); \
assert(unit < Elements(svga->state.hw_draw.ts)); \ assert(unit < ARRAY_SIZE(svga->state.hw_draw.ts)); \
STATIC_ASSERT(SVGA3D_TS_##token < Elements(svga->state.hw_draw.ts[unit])); \ STATIC_ASSERT(SVGA3D_TS_##token < ARRAY_SIZE(svga->state.hw_draw.ts[unit])); \
if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \ if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \
svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \ svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \
svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \ svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \
......
...@@ -90,7 +90,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga, ...@@ -90,7 +90,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
} }
/* Map constant buffers */ /* 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) { if (svga->curr.constbufs[PIPE_SHADER_VERTEX][i].buffer == NULL) {
continue; continue;
} }
...@@ -128,7 +128,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga, ...@@ -128,7 +128,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
draw_set_indexes(draw, NULL, 0, 0); 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) { if (svga->curr.constbufs[PIPE_SHADER_VERTEX][i].buffer) {
pipe_buffer_unmap(&svga->pipe, cb_transfer[i]); pipe_buffer_unmap(&svga->pipe, cb_transfer[i]);
} }
......
...@@ -118,7 +118,7 @@ emit_decl(struct svga_shader_emitter *emit, ...@@ -118,7 +118,7 @@ emit_decl(struct svga_shader_emitter *emit,
dcl.values[0] |= 1<<31; dcl.values[0] |= 1<<31;
return (emit_instruction(emit, opcode) && 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)));
} }
...@@ -410,7 +410,7 @@ vs30_input(struct svga_shader_emitter *emit, ...@@ -410,7 +410,7 @@ vs30_input(struct svga_shader_emitter *emit,
dcl.values[0] |= 1<<31; dcl.values[0] |= 1<<31;
return (emit_instruction(emit, opcode) && 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)));
} }
...@@ -509,7 +509,7 @@ vs30_output(struct svga_shader_emitter *emit, ...@@ -509,7 +509,7 @@ vs30_output(struct svga_shader_emitter *emit,
} }
return (emit_instruction(emit, opcode) && 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)));
} }
...@@ -549,7 +549,7 @@ ps30_sampler( struct svga_shader_emitter *emit, ...@@ -549,7 +549,7 @@ ps30_sampler( struct svga_shader_emitter *emit,
dcl.values[0] |= 1<<31; dcl.values[0] |= 1<<31;
return (emit_instruction(emit, opcode) && 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 boolean
......
...@@ -767,7 +767,7 @@ emit_def_const(struct svga_shader_emitter *emit, ...@@ -767,7 +767,7 @@ emit_def_const(struct svga_shader_emitter *emit,
} }
if (!emit_instruction(emit, opcode) || 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 FALSE;
return TRUE; return TRUE;
...@@ -2866,7 +2866,7 @@ emit_call(struct svga_shader_emitter *emit, ...@@ -2866,7 +2866,7 @@ emit_call(struct svga_shader_emitter *emit,
break; break;
} }
if (emit->nr_labels == Elements(emit->label)) if (emit->nr_labels == ARRAY_SIZE(emit->label))
return FALSE; return FALSE;
if (i == emit->nr_labels) { if (i == emit->nr_labels) {
...@@ -3487,12 +3487,12 @@ emit_inverted_texcoords(struct svga_shader_emitter *emit) ...@@ -3487,12 +3487,12 @@ emit_inverted_texcoords(struct svga_shader_emitter *emit)
assert(emit->inverted_texcoords & (1 << unit)); 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] 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) */ /* inverted = coord * (1, -1, 1, 1) + (0, 1, 0, 0) */
if (!submit_op3(emit, if (!submit_op3(emit,
......
...@@ -1022,7 +1022,7 @@ emit_src_register(struct svga_shader_emitter_v10 *emit, ...@@ -1022,7 +1022,7 @@ emit_src_register(struct svga_shader_emitter_v10 *emit,
} }
} }
else if (file == TGSI_FILE_SYSTEM_VALUE) { 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]; index = emit->system_value_indexes[index];
} }
} }
...@@ -1078,7 +1078,7 @@ emit_src_register(struct svga_shader_emitter_v10 *emit, ...@@ -1078,7 +1078,7 @@ emit_src_register(struct svga_shader_emitter_v10 *emit,
if (operand0.operandType == VGPU10_OPERAND_TYPE_IMMEDIATE32) { if (operand0.operandType == VGPU10_OPERAND_TYPE_IMMEDIATE32) {
/* Emit the four float/int in-line immediate values */ /* Emit the four float/int in-line immediate values */
unsigned *c; unsigned *c;
assert(index < Elements(emit->immediates)); assert(index < ARRAY_SIZE(emit->immediates));
assert(file == TGSI_FILE_IMMEDIATE); assert(file == TGSI_FILE_IMMEDIATE);
assert(swizzleX < 4); assert(swizzleX < 4);
assert(swizzleY < 4); assert(swizzleY < 4);
...@@ -1735,7 +1735,7 @@ alloc_immediate_4(struct svga_shader_emitter_v10 *emit, ...@@ -1735,7 +1735,7 @@ alloc_immediate_4(struct svga_shader_emitter_v10 *emit,
{ {
unsigned n = emit->num_immediates++; unsigned n = emit->num_immediates++;
assert(!emit->immediates_emitted); assert(!emit->immediates_emitted);
assert(n < Elements(emit->immediates)); assert(n < ARRAY_SIZE(emit->immediates));
emit->immediates[n][0] = imm[0]; emit->immediates[n][0] = imm[0];
emit->immediates[n][1] = imm[1]; emit->immediates[n][1] = imm[1];
emit->immediates[n][2] = imm[2]; emit->immediates[n][2] = imm[2];
...@@ -1785,7 +1785,7 @@ static unsigned ...@@ -1785,7 +1785,7 @@ static unsigned
alloc_system_value_index(struct svga_shader_emitter_v10 *emit, unsigned index) alloc_system_value_index(struct svga_shader_emitter_v10 *emit, unsigned index)
{ {
const unsigned n = emit->info.file_max[TGSI_FILE_INPUT] + 1 + 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; emit->system_value_indexes[index] = n;
return n; return n;
} }
...@@ -1922,14 +1922,14 @@ emit_vgpu10_property(struct svga_shader_emitter_v10 *emit, ...@@ -1922,14 +1922,14 @@ emit_vgpu10_property(struct svga_shader_emitter_v10 *emit,