[Mesa-dev] [PATCH] svga: s/Elements/ARRAY_SIZE/

Charmaine Lee charmainel at vmware.com
Mon Apr 25 16:25:31 UTC 2016


Reviewed-by: Charmaine Lee <charmainel at vmware.com>
________________________________________
From: Brian Paul <brianp at vmware.com>
Sent: Monday, April 25, 2016 8:48 AM
To: mesa-dev at lists.freedesktop.org
Cc: Charmaine Lee
Subject: [PATCH] svga: s/Elements/ARRAY_SIZE/

Standardize on the later macro rather than a mix of both.
---
 src/gallium/drivers/svga/svga_cmd_vgpu10.c       |  2 +-
 src/gallium/drivers/svga/svga_context.c          |  6 +++---
 src/gallium/drivers/svga/svga_format.c           | 20 ++++++++++----------
 src/gallium/drivers/svga/svga_link.c             |  6 +++---
 src/gallium/drivers/svga/svga_pipe_constants.c   |  2 +-
 src/gallium/drivers/svga/svga_pipe_sampler.c     |  2 +-
 src/gallium/drivers/svga/svga_pipe_vs.c          |  2 +-
 src/gallium/drivers/svga/svga_resource_texture.h |  2 +-
 src/gallium/drivers/svga/svga_sampler_view.c     |  2 +-
 src/gallium/drivers/svga/svga_screen.c           |  4 ++--
 src/gallium/drivers/svga/svga_shader.c           |  2 +-
 src/gallium/drivers/svga/svga_state_constants.c  |  2 +-
 src/gallium/drivers/svga/svga_state_rss.c        |  4 ++--
 src/gallium/drivers/svga/svga_state_sampler.c    |  2 +-
 src/gallium/drivers/svga/svga_state_tss.c        | 10 +++++-----
 src/gallium/drivers/svga/svga_swtnl_draw.c       |  4 ++--
 src/gallium/drivers/svga/svga_tgsi_decl_sm30.c   |  8 ++++----
 src/gallium/drivers/svga/svga_tgsi_insn.c        | 10 +++++-----
 src/gallium/drivers/svga/svga_tgsi_vgpu10.c      | 20 ++++++++++----------
 19 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_cmd_vgpu10.c b/src/gallium/drivers/svga/svga_cmd_vgpu10.c
index 99c9add..2729655 100644
--- a/src/gallium/drivers/svga/svga_cmd_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_cmd_vgpu10.c
@@ -1112,7 +1112,7 @@ SVGA3D_vgpu10_DefineStreamOutput(struct svga_winsys_context *swc,
    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,
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
index 896dcdf..32dc209 100644
--- a/src/gallium/drivers/svga/svga_context.c
+++ b/src/gallium/drivers/svga/svga_context.c
@@ -61,7 +61,7 @@ static void svga_destroy( struct pipe_context *pipe )
    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]);
       }
@@ -78,7 +78,7 @@ static void svga_destroy( struct pipe_context *pipe )
    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);
    }

@@ -116,7 +116,7 @@ static void svga_destroy( struct pipe_context *pipe )

    /* 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);
       }
    }
diff --git a/src/gallium/drivers/svga/svga_format.c b/src/gallium/drivers/svga/svga_format.c
index 0186736..2fc920a 100644
--- a/src/gallium/drivers/svga/svga_format.c
+++ b/src/gallium/drivers/svga/svga_format.c
@@ -366,8 +366,8 @@ svga_translate_vertex_format_vgpu10(enum pipe_format format,
                                     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;
@@ -1838,13 +1838,13 @@ check_format_tables(void)
    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);
       }

@@ -1873,7 +1873,7 @@ svga_get_format_cap(struct svga_screen *ss,
    (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);

@@ -1912,7 +1912,7 @@ svga_format_size(SVGA3dSurfaceFormat 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;
@@ -1928,7 +1928,7 @@ svga_format_size(SVGA3dSurfaceFormat format,
 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;
 }

@@ -1970,7 +1970,7 @@ svga_format_is_integer(SVGA3dSurfaceFormat format)
 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);
 }

diff --git a/src/gallium/drivers/svga/svga_link.c b/src/gallium/drivers/svga/svga_link.c
index f3e524d..0aaaada 100644
--- a/src/gallium/drivers/svga/svga_link.c
+++ b/src/gallium/drivers/svga/svga_link.c
@@ -45,7 +45,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info,
 {
    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;
    }

@@ -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.
     */
    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;
@@ -76,7 +76,7 @@ svga_link_shaders(const struct tgsi_shader_info *outshader_info,
       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;
diff --git a/src/gallium/drivers/svga/svga_pipe_constants.c b/src/gallium/drivers/svga/svga_pipe_constants.c
index 8150879..204b13c 100644
--- a/src/gallium/drivers/svga/svga_pipe_constants.c
+++ b/src/gallium/drivers/svga/svga_pipe_constants.c
@@ -64,7 +64,7 @@ static void svga_set_constant_buffer(struct pipe_context *pipe,
    }

    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;

diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
index 298bd1b..c1bfed1 100644
--- a/src/gallium/drivers/svga/svga_pipe_sampler.c
+++ b/src/gallium/drivers/svga/svga_pipe_sampler.c
@@ -421,7 +421,7 @@ svga_set_sampler_views(struct pipe_context *pipe,
    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)
diff --git a/src/gallium/drivers/svga/svga_pipe_vs.c b/src/gallium/drivers/svga/svga_pipe_vs.c
index 630f490..50cd0ac 100644
--- a/src/gallium/drivers/svga/svga_pipe_vs.c
+++ b/src/gallium/drivers/svga/svga_pipe_vs.c
@@ -80,7 +80,7 @@ substitute_vs(unsigned shader_id, const struct tgsi_token *old_tokens)

    if (!tgsi_text_translate(text,
                              tokens,
-                             Elements(tokens)))
+                             ARRAY_SIZE(tokens)))
    {
       assert(0);
       return NULL;
diff --git a/src/gallium/drivers/svga/svga_resource_texture.h b/src/gallium/drivers/svga/svga_resource_texture.h
index 99ba33b..283b87f 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.h
+++ b/src/gallium/drivers/svga/svga_resource_texture.h
@@ -136,7 +136,7 @@ svga_transfer(struct pipe_transfer *transfer)
 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);
 }

diff --git a/src/gallium/drivers/svga/svga_sampler_view.c b/src/gallium/drivers/svga/svga_sampler_view.c
index 9c33a79..d43f8cc 100644
--- a/src/gallium/drivers/svga/svga_sampler_view.c
+++ b/src/gallium/drivers/svga/svga_sampler_view.c
@@ -200,7 +200,7 @@ svga_validate_sampler_view(struct svga_context *svga,

    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,
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index 010d94b..69e625f 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -867,9 +867,9 @@ svga_get_driver_query_info(struct pipe_screen *screen,
 #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];
diff --git a/src/gallium/drivers/svga/svga_shader.c b/src/gallium/drivers/svga/svga_shader.c
index d56cce4..abfef0f 100644
--- a/src/gallium/drivers/svga/svga_shader.c
+++ b/src/gallium/drivers/svga/svga_shader.c
@@ -171,7 +171,7 @@ svga_init_shader_key_common(const struct svga_context *svga, unsigned shader,
 {
    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];
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
index 5ae0382..51f393f 100644
--- a/src/gallium/drivers/svga/svga_state_constants.c
+++ b/src/gallium/drivers/svga/svga_state_constants.c
@@ -518,7 +518,7 @@ emit_consts_vgpu9(struct svga_context *svga, unsigned shader)

       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) {
diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c
index 317b44e..e22268d 100644
--- a/src/gallium/drivers/svga/svga_state_rss.c
+++ b/src/gallium/drivers/svga/svga_state_rss.c
@@ -47,7 +47,7 @@ struct rs_queue {

 #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;        \
@@ -57,7 +57,7 @@ do {                                                            \
 #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;        \
diff --git a/src/gallium/drivers/svga/svga_state_sampler.c b/src/gallium/drivers/svga/svga_state_sampler.c
index 6179a79..6e78825 100644
--- a/src/gallium/drivers/svga/svga_state_sampler.c
+++ b/src/gallium/drivers/svga/svga_state_sampler.c
@@ -226,7 +226,7 @@ update_sampler_resources(struct svga_context *svga, unsigned dirty)
          surfaces[i] = surface;
       }

-      for (; i < Elements(ids); i++) {
+      for (; i < ARRAY_SIZE(ids); i++) {
          ids[i] = SVGA3D_INVALID_ID;
          surfaces[i] = NULL;
       }
diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c
index fd6d1ce..b5272d2 100644
--- a/src/gallium/drivers/svga/svga_state_tss.c
+++ b/src/gallium/drivers/svga/svga_state_tss.c
@@ -44,7 +44,7 @@ void svga_cleanup_tss_binding(struct svga_context *svga)
    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);
@@ -326,8 +326,8 @@ svga_queue_tss( struct ts_queue *q,

 #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;            \
@@ -337,8 +337,8 @@ do {                                                                    \
 #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;            \
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index 6a8e857..67d1fae 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -90,7 +90,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
    }

    /* 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;
       }
@@ -128,7 +128,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga,
       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]);
       }
diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
index 418f898..42a3593e 100644
--- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
+++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c
@@ -118,7 +118,7 @@ emit_decl(struct svga_shader_emitter *emit,
    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)));
 }


@@ -410,7 +410,7 @@ vs30_input(struct svga_shader_emitter *emit,
    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)));
 }


@@ -509,7 +509,7 @@ vs30_output(struct svga_shader_emitter *emit,
    }

    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,
    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
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index f0ef65f..a7fa6a2 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -767,7 +767,7 @@ emit_def_const(struct svga_shader_emitter *emit,
    }

    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;
@@ -2866,7 +2866,7 @@ emit_call(struct svga_shader_emitter *emit,
          break;
    }

-   if (emit->nr_labels == Elements(emit->label))
+   if (emit->nr_labels == ARRAY_SIZE(emit->label))
       return FALSE;

    if (i == emit->nr_labels) {
@@ -3487,12 +3487,12 @@ emit_inverted_texcoords(struct svga_shader_emitter *emit)

       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,
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index a899c47..8639333 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -1022,7 +1022,7 @@ emit_src_register(struct svga_shader_emitter_v10 *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];
       }
    }
@@ -1078,7 +1078,7 @@ emit_src_register(struct svga_shader_emitter_v10 *emit,
    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);
@@ -1735,7 +1735,7 @@ alloc_immediate_4(struct svga_shader_emitter_v10 *emit,
 {
    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];
@@ -1785,7 +1785,7 @@ static unsigned
 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;
 }
@@ -1922,14 +1922,14 @@ emit_vgpu10_property(struct svga_shader_emitter_v10 *emit,

    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;
@@ -2269,7 +2269,7 @@ emit_vgpu10_declaration(struct svga_shader_emitter_v10 *emit,
           * 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);
@@ -2490,7 +2490,7 @@ emit_output_declarations(struct svga_shader_emitter_v10 *emit)

       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;

@@ -2875,7 +2875,7 @@ emit_constant_declaration(struct svga_shader_emitter_v10 *emit)
    }

    /* 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);
@@ -6295,7 +6295,7 @@ alloc_common_immediates(struct svga_shader_emitter_v10 *emit)
          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;
 }

--
1.9.1



More information about the mesa-dev mailing list