dri: Use __DRI_BUFFER_COUNT consistently internally

These arrays were all sized with insufficiently large magic numbers,
which is probably not a good idea.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10142>
This commit is contained in:
Adam Jackson 2021-04-08 18:46:02 -04:00 committed by Marge Bot
parent 17b5ca5869
commit b5c33174a1
6 changed files with 9 additions and 6 deletions

View file

@ -107,10 +107,11 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
boolean with_format;
__DRIbuffer *buffers;
int num_buffers;
unsigned attachments[10];
unsigned attachments[__DRI_BUFFER_COUNT];
unsigned num_attachments, i;
assert(loader);
assert(*count <= __DRI_BUFFER_COUNT);
with_format = dri_with_format(drawable->sPriv);
num_attachments = 0;
@ -410,6 +411,8 @@ dri2_allocate_textures(struct dri_context *ctx,
struct winsys_handle whandle;
unsigned num_buffers = statts_count;
assert(num_buffers <= __DRI_BUFFER_COUNT);
/* First get the buffers from the loader */
if (image) {
if (!dri_image_drawable_get_buffers(drawable, &images,

View file

@ -47,7 +47,7 @@ struct dri_drawable
__DRIdrawable *dPriv;
__DRIscreen *sPriv;
__DRIbuffer old[8];
__DRIbuffer old[__DRI_BUFFER_COUNT];
unsigned old_num;
unsigned old_w;
unsigned old_h;

View file

@ -683,7 +683,7 @@ intel_query_dri2_buffers(struct intel_context *intel,
__DRIscreen *screen = intel->intelScreen->driScrnPriv;
struct gl_framebuffer *fb = drawable->driverPrivate;
int i = 0;
unsigned attachments[8];
unsigned attachments[__DRI_BUFFER_COUNT];
struct intel_renderbuffer *front_rb;
struct intel_renderbuffer *back_rb;

View file

@ -1607,7 +1607,7 @@ brw_query_dri2_buffers(struct brw_context *brw,
__DRIscreen *dri_screen = brw->screen->driScrnPriv;
struct gl_framebuffer *fb = drawable->driverPrivate;
int i = 0;
unsigned attachments[8];
unsigned attachments[__DRI_BUFFER_COUNT];
struct brw_renderbuffer *front_rb;
struct brw_renderbuffer *back_rb;

View file

@ -238,7 +238,7 @@ nouveau_update_renderbuffers(__DRIcontext *dri_ctx, __DRIdrawable *draw)
__DRIscreen *screen = dri_ctx->driScreenPriv;
struct gl_framebuffer *fb = draw->driverPrivate;
struct nouveau_framebuffer *nfb = to_nouveau_framebuffer(fb);
unsigned int attachments[10];
unsigned int attachments[__DRI_BUFFER_COUNT];
__DRIbuffer *buffers = NULL;
int i = 0, count, ret;

View file

@ -361,7 +361,7 @@ void
radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
GLboolean front_only)
{
unsigned int attachments[10];
unsigned int attachments[__DRI_BUFFER_COUNT];
__DRIbuffer *buffers = NULL;
__DRIscreen *screen;
struct radeon_renderbuffer *rb;