/** * Retrieve __DRIbuffer from the DRI loader. */ static __DRIbuffer * dri2_drawable_get_buffers(struct dri_drawable *drawable, const enum st_attachment_type *atts, unsigned *count) { __DRIdrawable *dri_drawable = drawable->dPriv; const __DRIdri2LoaderExtension *loader = drawable->sPriv->dri2.loader; boolean with_format; __DRIbuffer *buffers; int num_buffers; unsigned attachments[10]; unsigned num_attachments, i; assert(loader); with_format = dri_with_format(drawable->sPriv); num_attachments = 0; /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */ if (!with_format) attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT; for (i = 0; i < *count; i++) { enum pipe_format format; unsigned bind; int att, depth; dri_drawable_get_format(drawable, atts[i], &format, &bind); if (format == PIPE_FORMAT_NONE) continue; switch (atts[i]) { case ST_ATTACHMENT_FRONT_LEFT: /* already added */ if (!with_format) continue; att = __DRI_BUFFER_FRONT_LEFT; break; case ST_ATTACHMENT_BACK_LEFT: att = __DRI_BUFFER_BACK_LEFT; break; case ST_ATTACHMENT_FRONT_RIGHT: att = __DRI_BUFFER_FRONT_RIGHT; break; case ST_ATTACHMENT_BACK_RIGHT: att = __DRI_BUFFER_BACK_RIGHT; break; default: continue; } /* * In this switch statement we must support all formats that * may occur as the stvis->color_format. */ switch(format) { case PIPE_FORMAT_B8G8R8A8_UNORM: depth = 32; break; case PIPE_FORMAT_B8G8R8X8_UNORM: depth = 24; break; case PIPE_FORMAT_B5G6R5_UNORM: depth = 16; break; default: depth = util_format_get_blocksizebits(format); assert(!"Unexpected format in dri2_drawable_get_buffers()"); } attachments[num_attachments++] = att; if (with_format) { attachments[num_attachments++] = depth; } } if (with_format) { num_attachments /= 2; buffers = loader->getBuffersWithFormat(dri_drawable, &dri_drawable->w, &dri_drawable->h, attachments, num_attachments, &num_buffers, dri_drawable->loaderPrivate); } else { buffers = loader->getBuffers(dri_drawable, &dri_drawable->w, &dri_drawable->h, attachments, num_attachments, &num_buffers, dri_drawable->loaderPrivate); } if (buffers) *count = num_buffers; return buffers; }
/** * Retrieve __DRIbuffer from the DRI loader. */ static __DRIbuffer * dri2_drawable_get_buffers(struct dri_drawable *drawable, const enum st_attachment_type *statts, unsigned *count) { __DRIdrawable *dri_drawable = drawable->dPriv; struct __DRIdri2LoaderExtensionRec *loader = drawable->sPriv->dri2.loader; boolean with_format; __DRIbuffer *buffers; int num_buffers; unsigned attachments[10]; unsigned num_attachments, i; assert(loader); with_format = dri_with_format(drawable->sPriv); num_attachments = 0; /* for Xserver 1.6.0 (DRI2 version 1) we always need to ask for the front */ if (!with_format) attachments[num_attachments++] = __DRI_BUFFER_FRONT_LEFT; for (i = 0; i < *count; i++) { enum pipe_format format; unsigned bind; int att, bpp; dri_drawable_get_format(drawable, statts[i], &format, &bind); if (format == PIPE_FORMAT_NONE) continue; switch (statts[i]) { case ST_ATTACHMENT_FRONT_LEFT: /* already added */ if (!with_format) continue; att = __DRI_BUFFER_FRONT_LEFT; break; case ST_ATTACHMENT_BACK_LEFT: att = __DRI_BUFFER_BACK_LEFT; break; case ST_ATTACHMENT_FRONT_RIGHT: att = __DRI_BUFFER_FRONT_RIGHT; break; case ST_ATTACHMENT_BACK_RIGHT: att = __DRI_BUFFER_BACK_RIGHT; break; case ST_ATTACHMENT_DEPTH_STENCIL: att = __DRI_BUFFER_DEPTH_STENCIL; break; default: att = -1; break; } bpp = util_format_get_blocksizebits(format); if (att >= 0) { attachments[num_attachments++] = att; if (with_format) { attachments[num_attachments++] = bpp; } } } if (with_format) { num_attachments /= 2; buffers = loader->getBuffersWithFormat(dri_drawable, &dri_drawable->w, &dri_drawable->h, attachments, num_attachments, &num_buffers, dri_drawable->loaderPrivate); } else { buffers = loader->getBuffers(dri_drawable, &dri_drawable->w, &dri_drawable->h, attachments, num_attachments, &num_buffers, dri_drawable->loaderPrivate); } if (buffers) { /* set one cliprect to cover the whole dri_drawable */ dri_drawable->x = 0; dri_drawable->y = 0; dri_drawable->backX = 0; dri_drawable->backY = 0; dri_drawable->numClipRects = 1; dri_drawable->pClipRects[0].x1 = 0; dri_drawable->pClipRects[0].y1 = 0; dri_drawable->pClipRects[0].x2 = dri_drawable->w; dri_drawable->pClipRects[0].y2 = dri_drawable->h; dri_drawable->numBackClipRects = 1; dri_drawable->pBackClipRects[0].x1 = 0; dri_drawable->pBackClipRects[0].y1 = 0; dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; *count = num_buffers; } return buffers; }