[Mesa-dev] [PATCH] gallium/util: s/Elements/ARRAY_SIZE/

Brian Paul brianp at vmware.com
Wed Apr 27 16:44:52 UTC 2016


---
 src/gallium/auxiliary/util/u_blit.c           |  6 +++---
 src/gallium/auxiliary/util/u_blitter.c        |  8 ++++----
 src/gallium/auxiliary/util/u_dump_defines.c   | 12 ++++++------
 src/gallium/auxiliary/util/u_dump_state.c     |  4 ++--
 src/gallium/auxiliary/util/u_format_tests.c   |  2 +-
 src/gallium/auxiliary/util/u_framebuffer.c    |  2 +-
 src/gallium/auxiliary/util/u_simple_shaders.c | 12 ++++++------
 src/gallium/auxiliary/util/u_tests.c          |  2 +-
 src/gallium/auxiliary/util/u_vbuf.c           |  2 +-
 9 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 3677515..5bcd8bb 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -140,9 +140,9 @@ util_destroy_blit(struct blit_state *ctx)
    if (ctx->vs)
       pipe->delete_vs_state(pipe, ctx->vs);
 
-   for (i = 0; i < Elements(ctx->fs); i++) {
-      for (j = 0; j < Elements(ctx->fs[i]); j++) {
-         for (k = 0; k < Elements(ctx->fs[i][j]); k++) {
+   for (i = 0; i < ARRAY_SIZE(ctx->fs); i++) {
+      for (j = 0; j < ARRAY_SIZE(ctx->fs[i]); j++) {
+         for (k = 0; k < ARRAY_SIZE(ctx->fs[i][j]); k++) {
             if (ctx->fs[i][j][k])
                pipe->delete_fs_state(pipe, ctx->fs[i][j][k]);
          }
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 8d7cc96..958d2ab 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -428,7 +428,7 @@ void util_blitter_destroy(struct blitter_context *blitter)
       for (j = 0; j < 2; j++)
          pipe->delete_blend_state(pipe, ctx->blend[i][j]);
 
-   for (i = 0; i < Elements(ctx->blend_clear); i++) {
+   for (i = 0; i < ARRAY_SIZE(ctx->blend_clear); i++) {
       if (ctx->blend_clear[i])
          pipe->delete_blend_state(pipe, ctx->blend_clear[i]);
    }
@@ -483,17 +483,17 @@ void util_blitter_destroy(struct blitter_context *blitter)
       if (ctx->fs_texfetch_stencil_msaa[i])
          ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil_msaa[i]);
 
-      for (j = 0; j< Elements(ctx->fs_resolve[i]); j++)
+      for (j = 0; j< ARRAY_SIZE(ctx->fs_resolve[i]); j++)
          for (f = 0; f < 2; f++)
             if (ctx->fs_resolve[i][j][f])
                ctx->delete_fs_state(pipe, ctx->fs_resolve[i][j][f]);
 
-      for (j = 0; j< Elements(ctx->fs_resolve_sint[i]); j++)
+      for (j = 0; j< ARRAY_SIZE(ctx->fs_resolve_sint[i]); j++)
          for (f = 0; f < 2; f++)
             if (ctx->fs_resolve_sint[i][j][f])
                ctx->delete_fs_state(pipe, ctx->fs_resolve_sint[i][j][f]);
 
-      for (j = 0; j< Elements(ctx->fs_resolve_uint[i]); j++)
+      for (j = 0; j< ARRAY_SIZE(ctx->fs_resolve_uint[i]); j++)
          for (f = 0; f < 2; f++)
             if (ctx->fs_resolve_uint[i][j][f])
                ctx->delete_fs_state(pipe, ctx->fs_resolve_uint[i][j][f]);
diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c
index 3ddc955..9d831ef 100644
--- a/src/gallium/auxiliary/util/u_dump_defines.c
+++ b/src/gallium/auxiliary/util/u_dump_defines.c
@@ -67,9 +67,9 @@ util_dump_enum_continuous(unsigned value,
    util_dump_##_name(unsigned value, boolean shortened) \
    { \
       if(shortened) \
-         return util_dump_enum_continuous(value, Elements(util_dump_##_name##_short_names), util_dump_##_name##_short_names); \
+         return util_dump_enum_continuous(value, ARRAY_SIZE(util_dump_##_name##_short_names), util_dump_##_name##_short_names); \
       else \
-         return util_dump_enum_continuous(value, Elements(util_dump_##_name##_names), util_dump_##_name##_names); \
+         return util_dump_enum_continuous(value, ARRAY_SIZE(util_dump_##_name##_names), util_dump_##_name##_names); \
    }
 
 
@@ -81,12 +81,12 @@ util_dump_enum_continuous(unsigned value,
    const char * \
    util_dump_##_name(unsigned value, boolean shortened) \
    { \
-      STATIC_ASSERT(Elements(util_dump_##_name##_names) == _count); \
-      STATIC_ASSERT(Elements(util_dump_##_name##_short_names) == _count); \
+      STATIC_ASSERT(ARRAY_SIZE(util_dump_##_name##_names) == _count); \
+      STATIC_ASSERT(ARRAY_SIZE(util_dump_##_name##_short_names) == _count); \
       if(shortened) \
-         return util_dump_enum_continuous(value, Elements(util_dump_##_name##_short_names), util_dump_##_name##_short_names); \
+         return util_dump_enum_continuous(value, ARRAY_SIZE(util_dump_##_name##_short_names), util_dump_##_name##_short_names); \
       else \
-         return util_dump_enum_continuous(value, Elements(util_dump_##_name##_names), util_dump_##_name##_names); \
+         return util_dump_enum_continuous(value, ARRAY_SIZE(util_dump_##_name##_names), util_dump_##_name##_names); \
    }
 
 
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index b1f3982..bad38fb 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -474,7 +474,7 @@ util_dump_shader_state(FILE *stream, const struct pipe_shader_state *state)
       util_dump_struct_begin(stream, "pipe_stream_output_info");
       util_dump_member(stream, uint, &state->stream_output, num_outputs);
       util_dump_array(stream, uint, state->stream_output.stride,
-                      Elements(state->stream_output.stride));
+                      ARRAY_SIZE(state->stream_output.stride));
       util_dump_array_begin(stream);
       for(i = 0; i < state->stream_output.num_outputs; ++i) {
          util_dump_elem_begin(stream);
@@ -519,7 +519,7 @@ util_dump_depth_stencil_alpha_state(FILE *stream, const struct pipe_depth_stenci
 
    util_dump_member_begin(stream, "stencil");
    util_dump_array_begin(stream);
-   for(i = 0; i < Elements(state->stencil); ++i) {
+   for(i = 0; i < ARRAY_SIZE(state->stencil); ++i) {
       util_dump_elem_begin(stream);
       util_dump_struct_begin(stream, "pipe_stencil_state");
       util_dump_member(stream, bool, &state->stencil[i], enabled);
diff --git a/src/gallium/auxiliary/util/u_format_tests.c b/src/gallium/auxiliary/util/u_format_tests.c
index 64224cd..3075ea0 100644
--- a/src/gallium/auxiliary/util/u_format_tests.c
+++ b/src/gallium/auxiliary/util/u_format_tests.c
@@ -1008,4 +1008,4 @@ util_format_test_cases[] =
 };
 
 
-const unsigned util_format_nr_test_cases = Elements(util_format_test_cases);
+const unsigned util_format_nr_test_cases = ARRAY_SIZE(util_format_test_cases);
diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c
index f9b8046..deaa058 100644
--- a/src/gallium/auxiliary/util/u_framebuffer.c
+++ b/src/gallium/auxiliary/util/u_framebuffer.c
@@ -96,7 +96,7 @@ util_copy_framebuffer_state(struct pipe_framebuffer_state *dst,
       pipe_surface_reference(&dst->cbufs[i], src->cbufs[i]);
 
    /* Set remaining dest cbuf pointers to NULL */
-   for ( ; i < Elements(dst->cbufs); i++)
+   for ( ; i < ARRAY_SIZE(dst->cbufs); i++)
       pipe_surface_reference(&dst->cbufs[i], NULL);
 
    dst->nr_cbufs = src->nr_cbufs;
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index 8c739da..8a32dbc 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -123,7 +123,7 @@ void *util_make_layered_clear_vertex_shader(struct pipe_context *pipe)
    struct tgsi_token tokens[1000];
    struct pipe_shader_state state = {tokens};
 
-   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+   if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
       assert(0);
       return NULL;
    }
@@ -151,7 +151,7 @@ void *util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe)
    struct tgsi_token tokens[1000];
    struct pipe_shader_state state = {tokens};
 
-   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+   if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
       assert(0);
       return NULL;
    }
@@ -194,7 +194,7 @@ void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe)
    struct tgsi_token tokens[1000];
    struct pipe_shader_state state = {tokens};
 
-   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+   if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
       assert(0);
       return NULL;
    }
@@ -478,7 +478,7 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
            tgsi_semantic_names[input_semantic],
            tgsi_interpolate_names[input_interpolate]);
 
-   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+   if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
       assert(0);
       return NULL;
    }
@@ -566,7 +566,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
    sprintf(text, shader_templ, type, samp_type,
            output_semantic, output_mask, type);
 
-   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+   if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
       puts(text);
       assert(0);
       return NULL;
@@ -666,7 +666,7 @@ util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe,
 
    sprintf(text, shader_templ, type, type, type);
 
-   if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+   if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
       assert(0);
       return NULL;
    }
diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index 006dfa9..e699828 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -424,7 +424,7 @@ null_constant_buffer(struct pipe_context *ctx)
       struct tgsi_token tokens[1000];
       struct pipe_shader_state state = {tokens};
 
-      if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+      if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
          puts("Can't compile a fragment shader.");
          util_report_result(FAIL);
          return;
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index e16ee36..c4c2694 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -269,7 +269,7 @@ boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps)
    for (i = 0; i < PIPE_FORMAT_COUNT; i++)
       caps->format_translation[i] = i;
 
-   for (i = 0; i < Elements(vbuf_format_fallbacks); i++) {
+   for (i = 0; i < ARRAY_SIZE(vbuf_format_fallbacks); i++) {
       enum pipe_format format = vbuf_format_fallbacks[i].from;
 
       if (!screen->is_format_supported(screen, format, PIPE_BUFFER, 0,
-- 
1.9.1



More information about the mesa-dev mailing list