mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 02:10:11 +01:00
dri: rework drawable creation
this consolidates all the creation code into the dri frontend, enabling a single caller from the loader Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30619>
This commit is contained in:
parent
374f204e1e
commit
9042e9a8c0
14 changed files with 53 additions and 124 deletions
|
|
@ -1376,20 +1376,9 @@ dri2_create_drawable(struct dri2_egl_display *dri2_dpy,
|
|||
const __DRIconfig *config,
|
||||
struct dri2_egl_surface *dri2_surf, void *loaderPrivate)
|
||||
{
|
||||
if (dri2_dpy->kopper) {
|
||||
dri2_surf->dri_drawable = kopperCreateNewDrawable(
|
||||
dri2_dpy->dri_screen_render_gpu, config, loaderPrivate,
|
||||
&(__DRIkopperDrawableInfo){
|
||||
#if defined(HAVE_X11_PLATFORM) && defined(HAVE_DRI3)
|
||||
.multiplanes_available = dri2_dpy->multibuffers_available,
|
||||
#endif
|
||||
.is_pixmap = dri2_surf->base.Type == EGL_PBUFFER_BIT ||
|
||||
dri2_surf->base.Type == EGL_PIXMAP_BIT,
|
||||
});
|
||||
} else {
|
||||
dri2_surf->dri_drawable = driCreateNewDrawable(
|
||||
dri2_dpy->dri_screen_render_gpu, config, loaderPrivate);
|
||||
}
|
||||
bool is_pixmap = dri2_surf->base.Type == EGL_PBUFFER_BIT ||
|
||||
dri2_surf->base.Type == EGL_PIXMAP_BIT;
|
||||
dri2_surf->dri_drawable = dri_create_drawable(dri2_dpy->dri_screen_render_gpu, config, is_pixmap, loaderPrivate);
|
||||
if (dri2_surf->dri_drawable == NULL)
|
||||
return _eglError(EGL_BAD_ALLOC, "createNewDrawable");
|
||||
|
||||
|
|
|
|||
|
|
@ -1989,21 +1989,13 @@ dri_set_blob_cache_funcs(__DRIscreen *sPriv, __DRIblobCacheSet set,
|
|||
* Backend function init_screen.
|
||||
*/
|
||||
|
||||
static struct dri_drawable *
|
||||
dri2_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
bool isPixmap, void *loaderPrivate)
|
||||
void
|
||||
dri2_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2019,8 +2011,6 @@ dri2_init_screen(struct dri_screen *screen, bool driver_name_is_inferred)
|
|||
screen->can_share_buffer = true;
|
||||
screen->auto_fake_front = dri_with_format(screen);
|
||||
|
||||
screen->create_drawable = dri2_create_drawable;
|
||||
|
||||
#ifdef HAVE_LIBDRM
|
||||
if (pipe_loader_drm_probe_fd(&screen->dev, screen->fd, false))
|
||||
pscreen = pipe_loader_create_screen(screen->dev, driver_name_is_inferred);
|
||||
|
|
@ -2040,7 +2030,6 @@ dri_swrast_kms_init_screen(struct dri_screen *screen, bool driver_name_is_inferr
|
|||
struct pipe_screen *pscreen = NULL;
|
||||
screen->can_share_buffer = false;
|
||||
screen->auto_fake_front = dri_with_format(screen);
|
||||
screen->create_drawable = dri2_create_drawable;
|
||||
|
||||
#if defined(HAVE_DRISW_KMS) && defined(HAVE_SWRAST)
|
||||
if (pipe_loader_sw_probe_kms(&screen->dev, screen->fd))
|
||||
|
|
|
|||
|
|
@ -148,18 +148,17 @@ dri_st_framebuffer_flush_swapbuffers(struct st_context *st,
|
|||
/**
|
||||
* This is called when we need to set up GL rendering to a new X window.
|
||||
*/
|
||||
struct dri_drawable *
|
||||
dri_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
__DRIdrawable *
|
||||
dri_create_drawable(__DRIscreen *psp, const __DRIconfig *config,
|
||||
bool isPixmap, void *loaderPrivate)
|
||||
{
|
||||
struct dri_screen *screen = dri_screen(psp);
|
||||
const struct gl_config *visual = &config->modes;
|
||||
struct dri_drawable *drawable = NULL;
|
||||
|
||||
if (isPixmap)
|
||||
goto fail; /* not implemented */
|
||||
|
||||
drawable = CALLOC_STRUCT(dri_drawable);
|
||||
if (drawable == NULL)
|
||||
goto fail;
|
||||
if (!drawable)
|
||||
return NULL;
|
||||
|
||||
drawable->loaderPrivate = loaderPrivate;
|
||||
drawable->refcount = 1;
|
||||
|
|
@ -181,10 +180,20 @@ dri_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
|||
drawable->base.ID = p_atomic_inc_return(&drifb_ID);
|
||||
drawable->base.fscreen = &screen->base;
|
||||
|
||||
return drawable;
|
||||
fail:
|
||||
FREE(drawable);
|
||||
return NULL;
|
||||
switch (screen->type) {
|
||||
case DRI_SCREEN_DRI3:
|
||||
case DRI_SCREEN_KMS_SWRAST:
|
||||
dri2_init_drawable(drawable, isPixmap, visual->alphaBits);
|
||||
break;
|
||||
case DRI_SCREEN_SWRAST:
|
||||
drisw_init_drawable(drawable, isPixmap, visual->alphaBits);
|
||||
break;
|
||||
case DRI_SCREEN_KOPPER:
|
||||
kopper_init_drawable(drawable, isPixmap, visual->alphaBits);
|
||||
break;
|
||||
}
|
||||
|
||||
return opaque_dri_drawable(drawable);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -138,10 +138,6 @@ dri_get_drawable(struct dri_drawable *drawable)
|
|||
/***********************************************************************
|
||||
* dri_drawable.c
|
||||
*/
|
||||
struct dri_drawable *
|
||||
dri_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
bool isPixmap, void *loaderPrivate);
|
||||
|
||||
void
|
||||
dri_put_drawable(struct dri_drawable *drawable);
|
||||
|
||||
|
|
@ -172,6 +168,12 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
|
|||
struct dri_context *ctx,
|
||||
struct pipe_resource *res);
|
||||
|
||||
void
|
||||
kopper_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits);
|
||||
void
|
||||
drisw_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits);
|
||||
void
|
||||
dri2_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits);
|
||||
#endif
|
||||
|
||||
/* vim: set sw=3 ts=8 sts=3 expandtab: */
|
||||
|
|
|
|||
|
|
@ -130,11 +130,6 @@ struct dri_screen
|
|||
struct pipe_screen *unwrapped_screen;
|
||||
bool has_dmabuf;
|
||||
bool is_sw;
|
||||
|
||||
struct dri_drawable *(*create_drawable)(struct dri_screen *screen,
|
||||
const struct gl_config *glVis,
|
||||
bool pixmapBuffer,
|
||||
void *loaderPrivate);
|
||||
};
|
||||
|
||||
/** cast wrapper */
|
||||
|
|
|
|||
|
|
@ -714,21 +714,6 @@ int driUnbindContext(__DRIcontext *pcp)
|
|||
|
||||
/*@}*/
|
||||
|
||||
__DRIdrawable *
|
||||
driCreateNewDrawable(__DRIscreen *psp,
|
||||
const __DRIconfig *config,
|
||||
void *data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
struct dri_screen *screen = dri_screen(psp);
|
||||
struct dri_drawable *drawable =
|
||||
screen->create_drawable(screen, &config->modes, GL_FALSE, data);
|
||||
drawable->buffer_age = 0;
|
||||
|
||||
return opaque_dri_drawable(drawable);
|
||||
}
|
||||
|
||||
void
|
||||
driDestroyDrawable(__DRIdrawable *pdp)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -123,7 +123,8 @@ driImageFormatToSizedInternalGLFormat(uint32_t image_format);
|
|||
PUBLIC unsigned int
|
||||
driGetAPIMask(__DRIscreen *screen);
|
||||
PUBLIC __DRIdrawable *
|
||||
driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, void *data);
|
||||
dri_create_drawable(__DRIscreen *psp, const __DRIconfig *config,
|
||||
bool isPixmap, void *loaderPrivate);
|
||||
extern const __DRIimageDriverExtension driImageDriverExtension;
|
||||
PUBLIC void driDestroyScreen(__DRIscreen *psp);
|
||||
PUBLIC int
|
||||
|
|
|
|||
|
|
@ -603,23 +603,15 @@ 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,
|
||||
bool isPixmap, void *loaderPrivate)
|
||||
void
|
||||
drisw_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits)
|
||||
{
|
||||
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;
|
||||
drawable->swap_buffers_with_damage = drisw_swap_buffers_with_damage;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
struct pipe_screen *
|
||||
|
|
@ -635,7 +627,6 @@ drisw_init_screen(struct dri_screen *screen, bool driver_name_is_inferred)
|
|||
if (loader->putImageShm)
|
||||
lf = &drisw_shm_lf;
|
||||
}
|
||||
screen->create_drawable = drisw_create_drawable;
|
||||
|
||||
bool success = false;
|
||||
#ifdef HAVE_DRISW_KMS
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ kopper_init_screen(struct dri_screen *screen, bool driver_name_is_inferred)
|
|||
}
|
||||
|
||||
screen->can_share_buffer = true;
|
||||
screen->create_drawable = kopper_create_drawable;
|
||||
|
||||
bool success;
|
||||
#ifdef HAVE_LIBDRM
|
||||
|
|
@ -505,17 +504,11 @@ kopper_swap_buffers(struct dri_drawable *drawable);
|
|||
static void
|
||||
kopper_swap_buffers_with_damage(struct dri_drawable *drawable, int nrects, const int *rects);
|
||||
|
||||
static struct dri_drawable *
|
||||
kopper_create_drawable(struct dri_screen *screen, const struct gl_config *visual,
|
||||
bool isPixmap, void *loaderPrivate)
|
||||
void
|
||||
kopper_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits)
|
||||
{
|
||||
/* always pass !pixmap because it isn't "handled" or relevant */
|
||||
struct dri_drawable *drawable = dri_create_drawable(screen, visual, false,
|
||||
loaderPrivate);
|
||||
if (!drawable)
|
||||
return NULL;
|
||||
struct dri_screen *screen = drawable->screen;
|
||||
|
||||
// and fill in the vtable
|
||||
drawable->allocate_textures = kopper_allocate_textures;
|
||||
drawable->update_drawable_info = kopper_update_drawable_info;
|
||||
drawable->flush_frontbuffer = kopper_flush_frontbuffer;
|
||||
|
|
@ -524,13 +517,11 @@ kopper_create_drawable(struct dri_screen *screen, const struct gl_config *visual
|
|||
drawable->swap_buffers = kopper_swap_buffers;
|
||||
drawable->swap_buffers_with_damage = kopper_swap_buffers_with_damage;
|
||||
|
||||
drawable->info.has_alpha = visual->alphaBits > 0;
|
||||
drawable->info.has_alpha = alphaBits > 0;
|
||||
if (screen->kopper_loader->SetSurfaceCreateInfo)
|
||||
screen->kopper_loader->SetSurfaceCreateInfo(drawable->loaderPrivate,
|
||||
&drawable->info);
|
||||
drawable->is_window = !isPixmap && drawable->info.bos.sType != 0;
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
int64_t
|
||||
|
|
@ -606,20 +597,6 @@ kopper_swap_buffers(struct dri_drawable *drawable)
|
|||
kopper_swap_buffers_with_damage(drawable, 0, NULL);
|
||||
}
|
||||
|
||||
__DRIdrawable *
|
||||
kopperCreateNewDrawable(__DRIscreen *psp,
|
||||
const __DRIconfig *config,
|
||||
void *data,
|
||||
__DRIkopperDrawableInfo *info)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
struct dri_screen *screen = dri_screen(psp);
|
||||
struct dri_drawable *drawable = kopper_create_drawable(screen, &config->modes, info->is_pixmap, data);
|
||||
|
||||
return opaque_dri_drawable(drawable);
|
||||
}
|
||||
|
||||
void
|
||||
kopperSetSwapInterval(__DRIdrawable *dPriv, int interval)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,15 +14,6 @@ kopperSwapBuffersWithDamage(__DRIdrawable *dPriv, uint32_t flush_flags, int nrec
|
|||
return 0;
|
||||
}
|
||||
|
||||
__DRIdrawable *
|
||||
kopperCreateNewDrawable(__DRIscreen *psp,
|
||||
const __DRIconfig *config,
|
||||
void *data,
|
||||
__DRIkopperDrawableInfo *info)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
kopperSetSwapInterval(__DRIdrawable *dPriv, int interval)
|
||||
{
|
||||
|
|
@ -41,3 +32,11 @@ kopper_init_screen(struct dri_screen *screen, bool driver_name_is_inferred)
|
|||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct dri_drawable;
|
||||
void
|
||||
kopper_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits);
|
||||
void
|
||||
kopper_init_drawable(struct dri_drawable *drawable, bool isPixmap, int alphaBits)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,7 +423,8 @@ loader_dri3_drawable_init(xcb_connection_t *conn,
|
|||
dri3_update_max_num_back(draw);
|
||||
|
||||
/* Create a new drawable */
|
||||
draw->dri_drawable = driCreateNewDrawable(dri_screen_render_gpu, dri_config, draw);
|
||||
draw->dri_drawable = dri_create_drawable(dri_screen_render_gpu, dri_config,
|
||||
type == LOADER_DRI3_DRAWABLE_PIXMAP, draw);
|
||||
|
||||
if (!draw->dri_drawable)
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@
|
|||
dri_get_screen_param;
|
||||
dri3*;
|
||||
loader_dri3*;
|
||||
dri_create_drawable;
|
||||
@nouveau_drm_screen_create@
|
||||
@radeon_drm_winsys_create@
|
||||
@amdgpu_winsys_create@
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
|
|||
DRI2CreateDrawable(psc->base.dpy, xDrawable);
|
||||
/* Create a new drawable */
|
||||
pdraw->driDrawable =
|
||||
driCreateNewDrawable(psc->driScreen, config->driConfig, pdraw);
|
||||
dri_create_drawable(psc->driScreen, config->driConfig, false, pdraw);
|
||||
|
||||
if (!pdraw->driDrawable) {
|
||||
DRI2DestroyDrawable(psc->base.dpy, xDrawable);
|
||||
|
|
|
|||
|
|
@ -683,19 +683,9 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable,
|
|||
|
||||
pdp->swapInterval = dri_get_initial_swap_interval(psc->driScreen);
|
||||
/* Create a new drawable */
|
||||
if (psc->kopper) {
|
||||
pdp->driDrawable =
|
||||
kopperCreateNewDrawable(psc->driScreen, config->driConfig, pdp,
|
||||
&(__DRIkopperDrawableInfo){
|
||||
.multiplanes_available = base->display->has_multibuffer,
|
||||
.is_pixmap = !(type & GLX_WINDOW_BIT),
|
||||
});
|
||||
|
||||
pdp->driDrawable = dri_create_drawable(psc->driScreen, config->driConfig, !(type & GLX_WINDOW_BIT), pdp);
|
||||
if (psc->kopper)
|
||||
kopperSetSwapInterval(pdp->driDrawable, pdp->swapInterval);
|
||||
}
|
||||
else
|
||||
pdp->driDrawable =
|
||||
driCreateNewDrawable(psc->driScreen, config->driConfig, pdp);
|
||||
|
||||
if (!pdp->driDrawable) {
|
||||
XDestroyDrawable(pdp, psc->base.dpy, xDrawable);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue