bo = dri2_surf->current->bo;
- if (device->dri2) {
+ if (!device->swrast) {
dri2_surf->current->locked = true;
dri2_surf->current = NULL;
}
return 0;
}
-static void
-back_bo_to_dri_buffer(struct dri2_egl_surface *dri2_surf, __DRIbuffer *buffer)
-{
- struct dri2_egl_display *dri2_dpy =
- dri2_egl_display(dri2_surf->base.Resource.Display);
- struct gbm_dri_bo *bo;
- int name, pitch;
-
- bo = gbm_dri_bo(dri2_surf->back->bo);
-
- dri2_dpy->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_NAME, &name);
- dri2_dpy->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE, &pitch);
-
- buffer->attachment = __DRI_BUFFER_BACK_LEFT;
- buffer->name = name;
- buffer->pitch = pitch;
- buffer->cpp = 4;
- buffer->flags = 0;
-}
-
-static __DRIbuffer *
-dri2_drm_get_buffers_with_format(__DRIdrawable *driDrawable, int *width,
- int *height, unsigned int *attachments,
- int count, int *out_count, void *loaderPrivate)
-{
- struct dri2_egl_surface *dri2_surf = loaderPrivate;
- int i, j;
-
- for (i = 0, j = 0; i < 2 * count; i += 2, j++) {
- __DRIbuffer *local;
-
- assert(attachments[i] < __DRI_BUFFER_COUNT);
- assert(j < ARRAY_SIZE(dri2_surf->buffers));
-
- switch (attachments[i]) {
- case __DRI_BUFFER_BACK_LEFT:
- if (get_back_bo(dri2_surf) < 0) {
- _eglError(EGL_BAD_ALLOC, "failed to allocate color buffer");
- return NULL;
- }
- back_bo_to_dri_buffer(dri2_surf, &dri2_surf->buffers[j]);
- break;
- default:
- local = dri2_egl_surface_alloc_local_buffer(dri2_surf, attachments[i],
- attachments[i + 1]);
-
- if (!local) {
- _eglError(EGL_BAD_ALLOC, "failed to allocate local buffer");
- return NULL;
- }
- dri2_surf->buffers[j] = *local;
- break;
- }
- }
-
- *out_count = j;
- if (j == 0)
- return NULL;
-
- *width = dri2_surf->base.Width;
- *height = dri2_surf->base.Height;
-
- return dri2_surf->buffers;
-}
-
-static __DRIbuffer *
-dri2_drm_get_buffers(__DRIdrawable *driDrawable, int *width, int *height,
- unsigned int *attachments, int count, int *out_count,
- void *loaderPrivate)
-{
- unsigned int *attachments_with_format;
- __DRIbuffer *buffer;
- const unsigned int format = 32;
-
- attachments_with_format = calloc(count, 2 * sizeof(unsigned int));
- if (!attachments_with_format) {
- *out_count = 0;
- return NULL;
- }
-
- for (int i = 0; i < count; ++i) {
- attachments_with_format[2 * i] = attachments[i];
- attachments_with_format[2 * i + 1] = format;
- }
-
- buffer = dri2_drm_get_buffers_with_format(driDrawable, width, height,
- attachments_with_format, count,
- out_count, loaderPrivate);
-
- free(attachments_with_format);
-
- return buffer;
-}
-
static int
dri2_drm_image_get_buffers(__DRIdrawable *driDrawable, unsigned int format,
uint32_t *stamp, void *loaderPrivate,
dri2_dpy->is_render_node =
drmGetNodeTypeFromFd(dri2_dpy->fd_render_gpu) == DRM_NODE_RENDER;
- /* render nodes cannot use Gem names, and thus do not support
- * the __DRI_DRI2_LOADER extension */
- if (!dri2_dpy->is_render_node) {
- if (!dri2_load_driver(disp)) {
- err = "DRI2: failed to load driver";
- goto cleanup;
- }
- } else {
- if (!dri2_load_driver_dri3(disp)) {
- err = "DRI3: failed to load driver";
- goto cleanup;
- }
+ if (!dri2_load_driver_dri3(disp)) {
+ err = "DRI3: failed to load driver";
+ goto cleanup;
}
dri2_dpy->dri_screen_render_gpu = dri2_dpy->gbm_dri->screen;
dri2_dpy->core = dri2_dpy->gbm_dri->core;
- dri2_dpy->dri2 = dri2_dpy->gbm_dri->dri2;
+ dri2_dpy->image_driver = dri2_dpy->gbm_dri->image_driver;
dri2_dpy->swrast = dri2_dpy->gbm_dri->swrast;
dri2_dpy->kopper = dri2_dpy->gbm_dri->kopper;
dri2_dpy->driver_configs = dri2_dpy->gbm_dri->driver_configs;
dri2_dpy->gbm_dri->lookup_image_validated = dri2_lookup_egl_image_validated;
dri2_dpy->gbm_dri->lookup_user_data = disp;
- dri2_dpy->gbm_dri->get_buffers = dri2_drm_get_buffers;
dri2_dpy->gbm_dri->flush_front_buffer = dri2_drm_flush_front_buffer;
- dri2_dpy->gbm_dri->get_buffers_with_format =
- dri2_drm_get_buffers_with_format;
dri2_dpy->gbm_dri->image_get_buffers = dri2_drm_image_get_buffers;
dri2_dpy->gbm_dri->swrast_put_image2 = swrast_put_image2;
dri2_dpy->gbm_dri->swrast_get_image = swrast_get_image;
return dri->lookup_image_validated(image, dri->lookup_user_data);
}
-static __DRIbuffer *
-dri_get_buffers(__DRIdrawable * driDrawable,
- int *width, int *height,
- unsigned int *attachments, int count,
- int *out_count, void *data)
-{
- struct gbm_dri_surface *surf = data;
- struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
-
- if (dri->get_buffers == NULL)
- return NULL;
-
- return dri->get_buffers(driDrawable, width, height, attachments,
- count, out_count, surf->dri_private);
-}
-
static void
dri_flush_front_buffer(__DRIdrawable * driDrawable, void *data)
{
dri->flush_front_buffer(driDrawable, surf->dri_private);
}
-static __DRIbuffer *
-dri_get_buffers_with_format(__DRIdrawable * driDrawable,
- int *width, int *height,
- unsigned int *attachments, int count,
- int *out_count, void *data)
-{
- struct gbm_dri_surface *surf = data;
- struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
-
- if (dri->get_buffers_with_format == NULL)
- return NULL;
-
- return
- dri->get_buffers_with_format(driDrawable, width, height, attachments,
- count, out_count, surf->dri_private);
-}
-
static unsigned
dri_get_capability(void *loaderPrivate, enum dri_loader_cap cap)
{
.lookupEGLImageValidated = dri_lookup_egl_image_validated,
};
-static const __DRIdri2LoaderExtension dri2_loader_extension = {
- .base = { __DRI_DRI2_LOADER, 4 },
-
- .getBuffers = dri_get_buffers,
- .flushFrontBuffer = dri_flush_front_buffer,
- .getBuffersWithFormat = dri_get_buffers_with_format,
- .getCapability = dri_get_capability,
-};
-
static const __DRIimageLoaderExtension image_loader_extension = {
.base = { __DRI_IMAGE_LOADER, 2 },
static const __DRIextension *gbm_dri_screen_extensions[] = {
&image_lookup_extension.base,
&use_invalidate.base,
- &dri2_loader_extension.base,
&image_loader_extension.base,
&swrast_loader_extension.base,
&kopper_loader_extension.base,
static struct dri_extension_match gbm_dri_device_extensions[] = {
{ __DRI_CORE, 1, offsetof(struct gbm_dri_device, core), false },
{ __DRI_MESA, 1, offsetof(struct gbm_dri_device, mesa), false },
- { __DRI_DRI2, 4, offsetof(struct gbm_dri_device, dri2), false },
+ { __DRI_IMAGE_DRIVER, 1, offsetof(struct gbm_dri_device, image_driver), false },
};
static struct dri_extension_match gbm_swrast_device_extensions[] = {
}
mtx_lock(&dri->mutex);
- if (!dri->context)
- dri->context = dri->dri2->createNewContext(dri->screen, NULL,
- NULL, NULL);
+ if (!dri->context) {
+ unsigned error;
+
+ dri->context =
+ dri->image_driver->createContextAttribs(dri->screen,
+ __DRI_API_OPENGL,
+ NULL, NULL, 0, NULL,
+ &error, NULL);
+ }
assert(dri->context);
mtx_unlock(&dri->mutex);
const __DRIcoreExtension *core;
const __DRImesaCoreExtension *mesa;
- const __DRIdri2Extension *dri2;
const __DRIimageExtension *image;
+ const __DRIimageDriverExtension *image_driver;
const __DRIswrastExtension *swrast;
const __DRIkopperExtension *kopper;
const __DRI2flushExtension *flush;
__DRIimage *(*lookup_image_validated)(void *image, void *data);
void *lookup_user_data;
- __DRIbuffer *(*get_buffers)(__DRIdrawable * driDrawable,
- int *width, int *height,
- unsigned int *attachments, int count,
- int *out_count, void *data);
void (*flush_front_buffer)(__DRIdrawable * driDrawable, void *data);
- __DRIbuffer *(*get_buffers_with_format)(__DRIdrawable * driDrawable,
- int *width, int *height,
- unsigned int *attachments, int count,
- int *out_count, void *data);
int (*image_get_buffers)(__DRIdrawable *driDrawable,
unsigned int format,
uint32_t *stamp,