From be51020f2ad2ce8e8dc4d0f3a79186000fb01454 Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Fri, 4 Dec 2015 15:27:18 +1100 Subject: [PATCH] gallium/drivers/nouveau: Make use of ARRAY_SIZE macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Edward O'Callaghan Signed-off-by: Marek Olšák --- 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 2452071762b..9ecbcd1087a 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 b4ea08d4d13..fd7c7cdf677 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 1df6bd943de..d14d603adc9 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 1a520d2df0c..38eca1771c5 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 8b121477a37..d98992cedd7 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 6058c22138b..dbde1bfcebe 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 6b0b7148dcb..48f16211afc 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 d13480c21d5..37d7d443289 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 43d7c7b1123..67a25acf778 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 5dce5f0e65d..5da0ea81a27 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 205e7dc6ae9..b02a590c375 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 9139bc1c911..4392f62c530 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 4ceec4fbffc..e4504e6c411 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 91543782dfc..73d55148151 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.30.2