[Mesa-dev] [PATCH 1/7] gallium/drivers/nouveau: Make use of ARRAY_SIZE macro
Edward O'Callaghan
eocallaghan at alterapraxis.com
Thu Dec 3 22:50:51 PST 2015
Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
src/gallium/drivers/nouveau/nv30/nv30_transfer.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv50_state.c | 6 +++---
src/gallium/drivers/nouveau/nv50/nv50_state_validate.c | 3 +--
src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv84_video_vp.c | 6 +++---
src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv98_video_vp.c | 2 +-
src/gallium/drivers/nouveau/nvc0/nvc0_program.c | 2 +-
src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 6 +++---
src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c | 3 +--
src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c | 2 +-
src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c | 2 +-
src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c | 2 +-
14 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_transfer.c b/src/gallium/drivers/nouveau/nv30/nv30_transfer.c
index 2452071..9ecbcd1 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_transfer.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_transfer.c
@@ -155,7 +155,7 @@ nv30_transfer_rect_blit(XFER_ARGS)
u32 format, stride;
if (nouveau_pushbuf_space(push, 512, 8, 0) ||
- nouveau_pushbuf_refn (push, refs, sizeof(refs) / sizeof(refs[0])))
+ nouveau_pushbuf_refn (push, refs, ARRAY_SIZE(refs)))
return;
/* various switches depending on cpp of the transfer */
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c
index b4ea08d..fd7c7cd 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_state.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c
@@ -189,7 +189,7 @@ nv50_blend_state_create(struct pipe_context *pipe,
SB_DATA (so, nv50_colormask(cso->rt[0].colormask));
}
- assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
+ assert(so->size <= ARRAY_SIZE(so->state));
return so;
}
@@ -326,7 +326,7 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
SB_BEGIN_3D(so, PIXEL_CENTER_INTEGER, 1);
SB_DATA (so, !cso->half_pixel_center);
- assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
+ assert(so->size <= ARRAY_SIZE(so->state));
return (void *)so;
}
@@ -415,7 +415,7 @@ nv50_zsa_state_create(struct pipe_context *pipe,
SB_DATA (so, 0);
}
- assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
+ assert(so->size <= ARRAY_SIZE(so->state));
return (void *)so;
}
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
index 1df6bd9..d14d603 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c
@@ -508,7 +508,6 @@ static struct state_validate {
{ nv50_vertex_arrays_validate, NV50_NEW_VERTEX | NV50_NEW_ARRAYS },
{ nv50_validate_min_samples, NV50_NEW_MIN_SAMPLES },
};
-#define validate_list_len (sizeof(validate_list) / sizeof(validate_list[0]))
bool
nv50_state_validate(struct nv50_context *nv50, uint32_t mask, unsigned words)
@@ -523,7 +522,7 @@ nv50_state_validate(struct nv50_context *nv50, uint32_t mask, unsigned words)
state_mask = nv50->dirty & mask;
if (state_mask) {
- for (i = 0; i < validate_list_len; ++i) {
+ for (i = 0; i < ARRAY_SIZE(validate_list); ++i) {
struct state_validate *validate = &validate_list[i];
if (state_mask & validate->states)
diff --git a/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c b/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c
index 1a520d2..38eca17 100644
--- a/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c
@@ -200,7 +200,7 @@ nv84_decoder_bsp(struct nv84_decoder *dec,
memcpy(dec->bitstream->map + 0x600, more_params, sizeof(more_params));
PUSH_SPACE(push, 5 + 21 + 3 + 2 + 4 + 2);
- nouveau_pushbuf_refn(push, bo_refs, sizeof(bo_refs)/sizeof(bo_refs[0]));
+ nouveau_pushbuf_refn(push, bo_refs, ARRAY_SIZE(bo_refs));
/* Wait for the fence = 1 */
BEGIN_NV04(push, SUBC_BSP(0x10), 4);
diff --git a/src/gallium/drivers/nouveau/nv50/nv84_video_vp.c b/src/gallium/drivers/nouveau/nv50/nv84_video_vp.c
index 8b12147..d98992c 100644
--- a/src/gallium/drivers/nouveau/nv50/nv84_video_vp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv84_video_vp.c
@@ -81,7 +81,7 @@ nv84_decoder_vp_h264(struct nv84_decoder *dec,
{ dec->vp_params, NOUVEAU_BO_RDWR | NOUVEAU_BO_GART },
{ dec->fence, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
};
- int num_refs = sizeof(bo_refs)/sizeof(*bo_refs);
+ int num_refs = ARRAY_SIZE(bo_refs);
bool is_ref = desc->is_reference;
STATIC_ASSERT(sizeof(struct h264_iparm1) == 0x218);
@@ -141,7 +141,7 @@ nv84_decoder_vp_h264(struct nv84_decoder *dec,
{ bo1, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
{ bo2, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
};
- nouveau_pushbuf_refn(push, bo_refs, sizeof(bo_refs)/sizeof(bo_refs[0]));
+ nouveau_pushbuf_refn(push, bo_refs, ARRAY_SIZE(bo_refs));
}
memcpy(dec->vp_params->map, ¶m1, sizeof(param1));
@@ -490,7 +490,7 @@ nv84_decoder_vp_mpeg12(struct nv84_decoder *dec,
{ NULL, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
{ dec->mpeg12_bo, NOUVEAU_BO_RDWR | NOUVEAU_BO_GART },
};
- int i, num_refs = sizeof(bo_refs) / sizeof(*bo_refs);
+ int i, num_refs = ARRAY_SIZE(bo_refs);
struct mpeg12_header header = {0};
struct nv50_miptree *y = nv50_miptree(dest->resources[0]);
struct nv50_miptree *uv = nv50_miptree(dest->resources[1]);
diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c b/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c
index 6058c22..dbde1bf 100644
--- a/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c
@@ -56,7 +56,7 @@ nv98_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
#endif
{ dec->bitplane_bo, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
};
- int num_refs = sizeof(bo_refs)/sizeof(*bo_refs);
+ int num_refs = ARRAY_SIZE(bo_refs);
if (!dec->bitplane_bo)
num_refs--;
diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c b/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c
index 6b0b714..48f1621 100644
--- a/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c
@@ -40,7 +40,7 @@ nv98_decoder_setup_ppp(struct nouveau_vp3_decoder *dec, struct nouveau_vp3_video
{ dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },
#endif
};
- unsigned num_refs = sizeof(bo_refs)/sizeof(*bo_refs);
+ unsigned num_refs = ARRAY_SIZE(bo_refs);
for (i = 0; i < 2; ++i) {
struct nv50_miptree *mt = (struct nv50_miptree *)target->resources[i];
diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c b/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c
index d13480c..37d7d44 100644
--- a/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c
@@ -86,7 +86,7 @@ nv98_decoder_vp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
#endif
{ dec->fw_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
};
- int num_refs = sizeof(bo_refs)/sizeof(*bo_refs) - !dec->fw_bo;
+ int num_refs = ARRAY_SIZE(bo_refs) - !dec->fw_bo;
#if NOUVEAU_VP3_DEBUG_FENCE
fence_extra = 4;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
index 43d7c7b..67a25ac 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
@@ -502,7 +502,7 @@ nvc0_program_dump(struct nvc0_program *prog)
unsigned pos;
if (prog->type != PIPE_SHADER_COMPUTE) {
- for (pos = 0; pos < sizeof(prog->hdr) / sizeof(prog->hdr[0]); ++pos)
+ for (pos = 0; pos < ARRAY_SIZE(prog->hdr); ++pos)
debug_printf("HDR[%02"PRIxPTR"] = 0x%08x\n",
pos * sizeof(prog->hdr[0]), prog->hdr[pos]);
}
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
index 5dce5f0..5da0ea8 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
@@ -176,7 +176,7 @@ nvc0_blend_state_create(struct pipe_context *pipe,
}
}
- assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
+ assert(so->size <= ARRAY_SIZE(so->state));
return so;
}
@@ -305,7 +305,7 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe,
SB_IMMED_3D(so, PIXEL_CENTER_INTEGER, !cso->half_pixel_center);
- assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
+ assert(so->size <= ARRAY_SIZE(so->state));
return (void *)so;
}
@@ -383,7 +383,7 @@ nvc0_zsa_state_create(struct pipe_context *pipe,
SB_DATA (so, nvgl_comparison_op(cso->alpha.func));
}
- assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
+ assert(so->size <= ARRAY_SIZE(so->state));
return (void *)so;
}
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
index 205e7dc..b02a590 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
@@ -667,7 +667,6 @@ static struct state_validate {
{ nvc0_tfb_validate, NVC0_NEW_TFB_TARGETS | NVC0_NEW_GMTYPROG },
{ nvc0_validate_min_samples, NVC0_NEW_MIN_SAMPLES },
};
-#define validate_list_len (sizeof(validate_list) / sizeof(validate_list[0]))
bool
nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask, unsigned words)
@@ -682,7 +681,7 @@ nvc0_state_validate(struct nvc0_context *nvc0, uint32_t mask, unsigned words)
state_mask = nvc0->dirty & mask;
if (state_mask) {
- for (i = 0; i < validate_list_len; ++i) {
+ for (i = 0; i < ARRAY_SIZE(validate_list); ++i) {
struct state_validate *validate = &validate_list[i];
if (state_mask & validate->states)
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
index 9139bc1..4392f62 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
@@ -56,7 +56,7 @@ nvc0_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
#endif
{ dec->bitplane_bo, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
};
- int num_refs = sizeof(bo_refs)/sizeof(*bo_refs);
+ int num_refs = ARRAY_SIZE(bo_refs);
if (!dec->bitplane_bo)
num_refs--;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c
index 4ceec4f..e4504e6 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c
@@ -40,7 +40,7 @@ nvc0_decoder_setup_ppp(struct nouveau_vp3_decoder *dec, struct nouveau_vp3_video
{ dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },
#endif
};
- unsigned num_refs = sizeof(bo_refs)/sizeof(*bo_refs);
+ unsigned num_refs = ARRAY_SIZE(bo_refs);
for (i = 0; i < 2; ++i) {
struct nv50_miptree *mt = (struct nv50_miptree *)target->resources[i];
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c
index 9154378..73d5514 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c
@@ -86,7 +86,7 @@ nvc0_decoder_vp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
#endif
{ dec->fw_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
};
- int num_refs = sizeof(bo_refs)/sizeof(*bo_refs) - !dec->fw_bo;
+ int num_refs = ARRAY_SIZE(bo_refs) - !dec->fw_bo;
#if NOUVEAU_VP3_DEBUG_FENCE
fence_extra = 4;
--
2.5.0
More information about the mesa-dev
mailing list