mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 17:50:12 +01:00
frontend/dri: move callbacks from the VTable into dri_screen, dri_drawable
This just moves the callbacks and renames the functions. Some functions had to be moved up because they are initialized there. Remove some obsolete comments. Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19741>
This commit is contained in:
parent
f34d607d2f
commit
7d5b1cd02c
8 changed files with 96 additions and 115 deletions
|
|
@ -2275,6 +2275,23 @@ dri2_init_screen_extensions(struct dri_screen *screen,
|
|||
assert(!*nExt);
|
||||
}
|
||||
|
||||
static struct dri_drawable *
|
||||
dri2_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
boolean isPixmap, void *loaderPrivate)
|
||||
{
|
||||
struct dri_drawable *drawable = dri_create_drawable(screen, visual, isPixmap,
|
||||
loaderPrivate);
|
||||
if (!drawable)
|
||||
return NULL;
|
||||
|
||||
drawable->allocate_textures = dri2_allocate_textures;
|
||||
drawable->flush_frontbuffer = dri2_flush_frontbuffer;
|
||||
drawable->update_tex_buffer = dri2_update_tex_buffer;
|
||||
drawable->flush_swapbuffers = dri2_flush_swapbuffers;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the driver specific part of the createNewScreen entry point.
|
||||
*
|
||||
|
|
@ -2320,6 +2337,10 @@ dri2_init_screen(struct dri_screen *screen)
|
|||
screen->lookup_egl_image_validated = dri2_lookup_egl_image_validated;
|
||||
}
|
||||
|
||||
screen->create_drawable = dri2_create_drawable;
|
||||
screen->allocate_buffer = dri2_allocate_buffer;
|
||||
screen->release_buffer = dri2_release_buffer;
|
||||
|
||||
return configs;
|
||||
|
||||
destroy_screen:
|
||||
|
|
@ -2386,35 +2407,14 @@ release_pipe:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct dri_drawable *
|
||||
dri2_create_buffer(struct dri_screen *screen, const struct gl_config *visual,
|
||||
boolean isPixmap, void *loaderPrivate)
|
||||
{
|
||||
struct dri_drawable *drawable = dri_create_buffer(screen, visual, isPixmap,
|
||||
loaderPrivate);
|
||||
if (!drawable)
|
||||
return NULL;
|
||||
|
||||
drawable->allocate_textures = dri2_allocate_textures;
|
||||
drawable->flush_frontbuffer = dri2_flush_frontbuffer;
|
||||
drawable->update_tex_buffer = dri2_update_tex_buffer;
|
||||
drawable->flush_swapbuffers = dri2_flush_swapbuffers;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* DRI driver virtual function table.
|
||||
*
|
||||
* DRI versions differ in their implementation of init_screen and swap_buffers.
|
||||
*/
|
||||
static const struct __DRIDriverVtableExtensionRec galliumdrm_vtable = {
|
||||
.base = { __DRI_DRIVER_VTABLE, 1 },
|
||||
static const struct __DRIBackendVtableExtensionRec galliumdrm_vtable = {
|
||||
.base = { __DRI_BACKEND_VTABLE, 1 },
|
||||
.InitScreen = dri2_init_screen,
|
||||
.CreateBuffer = dri2_create_buffer,
|
||||
|
||||
.AllocateBuffer = dri2_allocate_buffer,
|
||||
.ReleaseBuffer = dri2_release_buffer,
|
||||
};
|
||||
|
||||
/* This is the table of extensions that the loader will dlsym() for. */
|
||||
|
|
@ -2434,13 +2434,9 @@ const __DRIextension *galliumdrm_driver_extensions[] = {
|
|||
* hook. The latter is used to explicitly initialise the kms_swrast driver
|
||||
* rather than selecting the approapriate driver as suggested by the loader.
|
||||
*/
|
||||
static const struct __DRIDriverVtableExtensionRec dri_swrast_kms_vtable = {
|
||||
.base = { __DRI_DRIVER_VTABLE, 1 },
|
||||
static const struct __DRIBackendVtableExtensionRec dri_swrast_kms_vtable = {
|
||||
.base = { __DRI_BACKEND_VTABLE, 1 },
|
||||
.InitScreen = dri_swrast_kms_init_screen,
|
||||
.CreateBuffer = dri2_create_buffer,
|
||||
|
||||
.AllocateBuffer = dri2_allocate_buffer,
|
||||
.ReleaseBuffer = dri2_release_buffer,
|
||||
};
|
||||
|
||||
const __DRIextension *dri_swrast_kms_driver_extensions[] = {
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ dri_st_framebuffer_flush_swapbuffers(struct st_context_iface *stctx,
|
|||
* This is called when we need to set up GL rendering to a new X window.
|
||||
*/
|
||||
struct dri_drawable *
|
||||
dri_create_buffer(struct dri_screen *screen, const struct gl_config *visual,
|
||||
bool isPixmap, void *loaderPrivate)
|
||||
dri_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
bool isPixmap, void *loaderPrivate)
|
||||
{
|
||||
struct dri_drawable *drawable = NULL;
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ fail:
|
|||
}
|
||||
|
||||
static void
|
||||
dri_destroy_buffer(struct dri_drawable *drawable)
|
||||
dri_destroy_drawable(struct dri_drawable *drawable)
|
||||
{
|
||||
struct dri_screen *screen = drawable->screen;
|
||||
int i;
|
||||
|
|
@ -212,7 +212,7 @@ dri_put_drawable(struct dri_drawable *drawable)
|
|||
if (drawable->refcount)
|
||||
return;
|
||||
|
||||
dri_destroy_buffer(drawable);
|
||||
dri_destroy_drawable(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ struct dri_drawable
|
|||
struct pipe_resource *res);
|
||||
void (*flush_swapbuffers)(struct dri_context *ctx,
|
||||
struct dri_drawable *drawable);
|
||||
|
||||
void (*swap_buffers)(struct dri_drawable *drawable);
|
||||
};
|
||||
|
||||
/* Typecast the opaque pointer to our own type. */
|
||||
|
|
@ -138,8 +140,8 @@ dri_get_drawable(struct dri_drawable *drawable)
|
|||
* dri_drawable.c
|
||||
*/
|
||||
struct dri_drawable *
|
||||
dri_create_buffer(struct dri_screen *screen, const struct gl_config *visual,
|
||||
bool isPixmap, void *loaderPrivate);
|
||||
dri_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
bool isPixmap, void *loaderPrivate);
|
||||
|
||||
void
|
||||
dri_put_drawable(struct dri_drawable *drawable);
|
||||
|
|
|
|||
|
|
@ -53,9 +53,6 @@ struct dri_screen
|
|||
struct st_manager base;
|
||||
|
||||
/* dri */
|
||||
/* Backend-specific entrypoints (dri, swrast, kopper) */
|
||||
const struct __DRIDriverVtableExtensionRec *driver;
|
||||
|
||||
/* Current screen's number */
|
||||
int myNum;
|
||||
|
||||
|
|
@ -140,6 +137,18 @@ struct dri_screen
|
|||
bool has_dmabuf;
|
||||
bool has_modifiers;
|
||||
bool is_sw;
|
||||
|
||||
struct dri_drawable *(*create_drawable)(struct dri_screen *screen,
|
||||
const struct gl_config *glVis,
|
||||
GLboolean pixmapBuffer,
|
||||
void *loaderPrivate);
|
||||
|
||||
__DRIbuffer *(*allocate_buffer)(struct dri_screen *screen,
|
||||
unsigned int attachment,
|
||||
unsigned int format,
|
||||
int width, int height);
|
||||
|
||||
void (*release_buffer)(__DRIbuffer *buffer);
|
||||
};
|
||||
|
||||
/** cast wrapper */
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ driCreateNewScreen2(int scrn, int fd,
|
|||
{
|
||||
static const __DRIextension *emptyExtensionList[] = { NULL };
|
||||
struct dri_screen *screen;
|
||||
const struct __DRIBackendVtableExtensionRec *backend = NULL;
|
||||
|
||||
screen = CALLOC_STRUCT(dri_screen);
|
||||
if (!screen)
|
||||
|
|
@ -117,9 +118,8 @@ driCreateNewScreen2(int scrn, int fd,
|
|||
|
||||
assert(driver_extensions);
|
||||
for (int i = 0; driver_extensions[i]; i++) {
|
||||
if (strcmp(driver_extensions[i]->name, __DRI_DRIVER_VTABLE) == 0) {
|
||||
screen->driver =
|
||||
(__DRIDriverVtableExtension *)driver_extensions[i];
|
||||
if (strcmp(driver_extensions[i]->name, __DRI_BACKEND_VTABLE) == 0) {
|
||||
backend = (__DRIBackendVtableExtension *)driver_extensions[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ driCreateNewScreen2(int scrn, int fd,
|
|||
driParseConfigFiles(&screen->optionCache, &screen->optionInfo, screen->myNum,
|
||||
"dri2", NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
||||
*driver_configs = screen->driver->InitScreen(screen);
|
||||
*driver_configs = backend->InitScreen(screen);
|
||||
if (*driver_configs == NULL) {
|
||||
free(screen);
|
||||
return NULL;
|
||||
|
|
@ -745,7 +745,7 @@ driCreateNewDrawable(__DRIscreen *psp,
|
|||
|
||||
struct dri_screen *screen = dri_screen(psp);
|
||||
struct dri_drawable *drawable =
|
||||
screen->driver->CreateBuffer(screen, &config->modes, GL_FALSE, data);
|
||||
screen->create_drawable(screen, &config->modes, GL_FALSE, data);
|
||||
|
||||
return opaque_dri_drawable(drawable);
|
||||
}
|
||||
|
|
@ -763,8 +763,7 @@ dri2AllocateBuffer(__DRIscreen *psp,
|
|||
{
|
||||
struct dri_screen *screen = dri_screen(psp);
|
||||
|
||||
return screen->driver->AllocateBuffer(screen, attachment, format,
|
||||
width, height);
|
||||
return screen->allocate_buffer(screen, attachment, format, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -772,7 +771,7 @@ dri2ReleaseBuffer(__DRIscreen *psp, __DRIbuffer *buffer)
|
|||
{
|
||||
struct dri_screen *screen = dri_screen(psp);
|
||||
|
||||
screen->driver->ReleaseBuffer(buffer);
|
||||
screen->release_buffer(buffer);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -848,7 +847,7 @@ driSwapBuffers(__DRIdrawable *pdp)
|
|||
|
||||
assert(drawable->screen->swrast_loader);
|
||||
|
||||
drawable->screen->driver->SwapBuffers(drawable);
|
||||
drawable->swap_buffers(drawable);
|
||||
}
|
||||
|
||||
/** Core interface */
|
||||
|
|
|
|||
|
|
@ -27,29 +27,10 @@
|
|||
* \file dri_util.h
|
||||
* DRI utility functions definitions.
|
||||
*
|
||||
* This module acts as glue between GLX and the actual hardware driver. A DRI
|
||||
* driver doesn't really \e have to use any of this - it's optional. But, some
|
||||
* useful stuff is done here that otherwise would have to be duplicated in most
|
||||
* drivers.
|
||||
*
|
||||
* Basically, these utility functions take care of some of the dirty details of
|
||||
* screen initialization, context creation, context binding, DRM setup, etc.
|
||||
*
|
||||
* These functions are compiled into each DRI driver so libGL.so knows nothing
|
||||
* about them.
|
||||
*
|
||||
* \sa dri_util.c.
|
||||
*
|
||||
* \author Kevin E. Martin <kevin@precisioninsight.com>
|
||||
* \author Brian Paul <brian@precisioninsight.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* The following structs are shared between DRISW and DRI2, the DRISW structs
|
||||
* are essentially base classes of the DRI2 structs. DRISW needs to compile on
|
||||
* platforms without DRM, so keep the structs opaque to DRM.
|
||||
*/
|
||||
|
||||
#ifndef _DRI_UTIL_H_
|
||||
#define _DRI_UTIL_H_
|
||||
|
||||
|
|
@ -62,29 +43,14 @@
|
|||
#include "util/xmlconfig.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
|
||||
|
||||
struct dri_screen;
|
||||
|
||||
typedef struct __DRIDriverVtableExtensionRec {
|
||||
#define __DRI_BACKEND_VTABLE "DRI_DriverVtable"
|
||||
|
||||
typedef struct __DRIBackendVtableExtensionRec {
|
||||
__DRIextension base;
|
||||
|
||||
const __DRIconfig **(*InitScreen)(struct dri_screen *screen);
|
||||
|
||||
struct dri_drawable *(*CreateBuffer)(struct dri_screen *screen,
|
||||
const struct gl_config *glVis,
|
||||
GLboolean pixmapBuffer,
|
||||
void *loaderPrivate);
|
||||
|
||||
void (*SwapBuffers)(struct dri_drawable *drawable);
|
||||
|
||||
__DRIbuffer *(*AllocateBuffer)(struct dri_screen *screen,
|
||||
unsigned int attachment,
|
||||
unsigned int format,
|
||||
int width, int height);
|
||||
|
||||
void (*ReleaseBuffer)(__DRIbuffer *buffer);
|
||||
} __DRIDriverVtableExtension;
|
||||
} __DRIBackendVtableExtension;
|
||||
|
||||
struct __DRIconfigRec {
|
||||
struct gl_config modes;
|
||||
|
|
|
|||
|
|
@ -523,6 +523,24 @@ static const struct drisw_loader_funcs drisw_shm_lf = {
|
|||
.put_image_shm = drisw_put_image_shm
|
||||
};
|
||||
|
||||
static struct dri_drawable *
|
||||
drisw_create_drawable(struct dri_screen *screen, const struct gl_config * visual,
|
||||
boolean isPixmap, void *loaderPrivate)
|
||||
{
|
||||
struct dri_drawable *drawable = dri_create_drawable(screen, visual, isPixmap,
|
||||
loaderPrivate);
|
||||
if (!drawable)
|
||||
return NULL;
|
||||
|
||||
drawable->allocate_textures = drisw_allocate_textures;
|
||||
drawable->update_drawable_info = drisw_update_drawable_info;
|
||||
drawable->flush_frontbuffer = drisw_flush_frontbuffer;
|
||||
drawable->update_tex_buffer = drisw_update_tex_buffer;
|
||||
drawable->swap_buffers = drisw_swap_buffers;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
static const __DRIconfig **
|
||||
drisw_init_screen(struct dri_screen *screen)
|
||||
{
|
||||
|
|
@ -574,6 +592,8 @@ drisw_init_screen(struct dri_screen *screen)
|
|||
screen->lookup_egl_image_validated = dri2_lookup_egl_image_validated;
|
||||
}
|
||||
|
||||
screen->create_drawable = drisw_create_drawable;
|
||||
|
||||
return configs;
|
||||
fail:
|
||||
dri_destroy_screen_helper(screen);
|
||||
|
|
@ -583,33 +603,14 @@ fail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct dri_drawable *
|
||||
drisw_create_buffer(struct dri_screen *screen, const struct gl_config * visual,
|
||||
boolean isPixmap, void *loaderPrivate)
|
||||
{
|
||||
struct dri_drawable *drawable = dri_create_buffer(screen, visual, isPixmap,
|
||||
loaderPrivate);
|
||||
if (!drawable)
|
||||
return NULL;
|
||||
|
||||
drawable->allocate_textures = drisw_allocate_textures;
|
||||
drawable->update_drawable_info = drisw_update_drawable_info;
|
||||
drawable->flush_frontbuffer = drisw_flush_frontbuffer;
|
||||
drawable->update_tex_buffer = drisw_update_tex_buffer;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* DRI driver virtual function table.
|
||||
*
|
||||
* DRI versions differ in their implementation of init_screen and swap_buffers.
|
||||
*/
|
||||
static const struct __DRIDriverVtableExtensionRec galliumsw_vtable = {
|
||||
.base = { __DRI_DRIVER_VTABLE, 1 },
|
||||
static const struct __DRIBackendVtableExtensionRec galliumsw_vtable = {
|
||||
.base = { __DRI_BACKEND_VTABLE, 1 },
|
||||
.InitScreen = drisw_init_screen,
|
||||
.CreateBuffer = drisw_create_buffer,
|
||||
.SwapBuffers = drisw_swap_buffers,
|
||||
};
|
||||
|
||||
/* swrast copy sub buffer entrypoint. */
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@
|
|||
extern const __DRIimageExtension driVkImageExtension;
|
||||
extern const __DRIimageExtension driVkImageExtensionSw;
|
||||
|
||||
static struct dri_drawable *
|
||||
kopper_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
boolean isPixmap, void *loaderPrivate);
|
||||
|
||||
static void
|
||||
kopper_flush_drawable(__DRIdrawable *dPriv)
|
||||
{
|
||||
|
|
@ -167,6 +171,8 @@ kopper_init_screen(struct dri_screen *screen)
|
|||
screen->lookup_egl_image_validated = dri2_lookup_egl_image_validated;
|
||||
}
|
||||
|
||||
screen->create_drawable = kopper_create_drawable;
|
||||
|
||||
return configs;
|
||||
fail:
|
||||
dri_destroy_screen_helper(screen);
|
||||
|
|
@ -812,13 +818,16 @@ kopper_flush_swapbuffers(struct dri_context *ctx,
|
|||
/* does this actually need to do anything? */
|
||||
}
|
||||
|
||||
static void
|
||||
kopper_swap_buffers(struct dri_drawable *drawable);
|
||||
|
||||
static struct dri_drawable *
|
||||
kopper_create_buffer(struct dri_screen *screen, const struct gl_config *visual,
|
||||
boolean isPixmap, void *loaderPrivate)
|
||||
kopper_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
boolean isPixmap, void *loaderPrivate)
|
||||
{
|
||||
/* always pass !pixmap because it isn't "handled" or relevant */
|
||||
struct dri_drawable *drawable = dri_create_buffer(screen, visual, false,
|
||||
loaderPrivate);
|
||||
struct dri_drawable *drawable = dri_create_drawable(screen, visual, false,
|
||||
loaderPrivate);
|
||||
if (!drawable)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -832,6 +841,7 @@ kopper_create_buffer(struct dri_screen *screen, const struct gl_config *visual,
|
|||
drawable->flush_frontbuffer = kopper_flush_frontbuffer;
|
||||
drawable->update_tex_buffer = kopper_update_tex_buffer;
|
||||
drawable->flush_swapbuffers = kopper_flush_swapbuffers;
|
||||
drawable->swap_buffers = kopper_swap_buffers;
|
||||
|
||||
drawable->info.has_alpha = visual->alphaBits > 0;
|
||||
if (screen->kopper_loader->SetSurfaceCreateInfo)
|
||||
|
|
@ -898,7 +908,7 @@ kopperCreateNewDrawable(__DRIscreen *psp,
|
|||
|
||||
struct dri_screen *screen = dri_screen(psp);
|
||||
struct dri_drawable *drawable =
|
||||
screen->driver->CreateBuffer(screen, &config->modes, is_pixmap, data);
|
||||
screen->create_drawable(screen, &config->modes, is_pixmap, data);
|
||||
|
||||
return opaque_dri_drawable(drawable);
|
||||
}
|
||||
|
|
@ -948,11 +958,9 @@ const __DRIkopperExtension driKopperExtension = {
|
|||
.queryBufferAge = kopperQueryBufferAge,
|
||||
};
|
||||
|
||||
static const struct __DRIDriverVtableExtensionRec galliumvk_vtable = {
|
||||
.base = { __DRI_DRIVER_VTABLE, 1 },
|
||||
static const struct __DRIBackendVtableExtensionRec galliumvk_vtable = {
|
||||
.base = { __DRI_BACKEND_VTABLE, 1 },
|
||||
.InitScreen = kopper_init_screen,
|
||||
.CreateBuffer = kopper_create_buffer,
|
||||
.SwapBuffers = kopper_swap_buffers,
|
||||
};
|
||||
|
||||
const __DRIextension *galliumvk_driver_extensions[] = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue