glx: unify dri bind_context
these were all more or less the same 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:

committed by
Marge Bot

parent
09eae187dd
commit
b62601a716
@@ -99,33 +99,6 @@ dri2_destroy_context(struct glx_context *context)
|
||||
free(context);
|
||||
}
|
||||
|
||||
static Bool
|
||||
dri2_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
__GLXDRIdrawable *pdraw, *pread;
|
||||
__DRIdrawable *dri_draw = NULL, *dri_read = NULL;
|
||||
|
||||
pdraw = driFetchDrawable(context, draw);
|
||||
pread = driFetchDrawable(context, read);
|
||||
|
||||
driReleaseDrawables(context);
|
||||
|
||||
if (pdraw)
|
||||
dri_draw = pdraw->dri_drawable;
|
||||
else if (draw != None)
|
||||
return GLXBadDrawable;
|
||||
|
||||
if (pread)
|
||||
dri_read = pread->dri_drawable;
|
||||
else if (read != None)
|
||||
return GLXBadDrawable;
|
||||
|
||||
if (!driBindContext(context->driContext, dri_draw, dri_read))
|
||||
return GLXBadContext;
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
dri2_unbind_context(struct glx_context *context)
|
||||
{
|
||||
@@ -811,7 +784,7 @@ dri2_bind_tex_image(__GLXDRIdrawable *base,
|
||||
|
||||
static const struct glx_context_vtable dri2_context_vtable = {
|
||||
.destroy = dri2_destroy_context,
|
||||
.bind = dri2_bind_context,
|
||||
.bind = dri_bind_context,
|
||||
.unbind = dri2_unbind_context,
|
||||
.wait_gl = dri2_wait_gl,
|
||||
.wait_x = dri2_wait_x,
|
||||
|
@@ -157,38 +157,6 @@ dri3_destroy_context(struct glx_context *context)
|
||||
free(context);
|
||||
}
|
||||
|
||||
static Bool
|
||||
dri3_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
__GLXDRIdrawable *pdraw, *pread;
|
||||
__DRIdrawable *dri_draw = NULL, *dri_read = NULL;
|
||||
|
||||
pdraw = driFetchDrawable(context, draw);
|
||||
pread = driFetchDrawable(context, read);
|
||||
|
||||
driReleaseDrawables(context);
|
||||
|
||||
if (pdraw)
|
||||
dri_draw = pdraw->dri_drawable;
|
||||
else if (draw != None)
|
||||
return GLXBadDrawable;
|
||||
|
||||
if (pread)
|
||||
dri_read = pread->dri_drawable;
|
||||
else if (read != None)
|
||||
return GLXBadDrawable;
|
||||
|
||||
if (!driBindContext(context->driContext, dri_draw, dri_read))
|
||||
return GLXBadContext;
|
||||
|
||||
if (dri_draw)
|
||||
dri_invalidate_drawable(dri_draw);
|
||||
if (dri_read && dri_read != dri_draw)
|
||||
dri_invalidate_drawable(dri_read);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
dri3_unbind_context(struct glx_context *context)
|
||||
{
|
||||
@@ -653,7 +621,7 @@ dri3_bind_tex_image(__GLXDRIdrawable *base,
|
||||
|
||||
static const struct glx_context_vtable dri3_context_vtable = {
|
||||
.destroy = dri3_destroy_context,
|
||||
.bind = dri3_bind_context,
|
||||
.bind = dri_bind_context,
|
||||
.unbind = dri3_unbind_context,
|
||||
.wait_gl = dri3_wait_gl,
|
||||
.wait_x = dri3_wait_x,
|
||||
|
@@ -766,4 +766,39 @@ const __DRIuseInvalidateExtension dri2UseInvalidate = {
|
||||
.base = { __DRI_USE_INVALIDATE, 1 }
|
||||
};
|
||||
|
||||
Bool
|
||||
dri_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
__GLXDRIdrawable *pdraw, *pread;
|
||||
__DRIdrawable *dri_draw = NULL, *dri_read = NULL;
|
||||
|
||||
pdraw = driFetchDrawable(context, draw);
|
||||
pread = driFetchDrawable(context, read);
|
||||
|
||||
driReleaseDrawables(context);
|
||||
|
||||
if (pdraw)
|
||||
dri_draw = pdraw->dri_drawable;
|
||||
else if (draw != None)
|
||||
return GLXBadDrawable;
|
||||
|
||||
if (pread)
|
||||
dri_read = pread->dri_drawable;
|
||||
else if (read != None)
|
||||
return GLXBadDrawable;
|
||||
|
||||
if (!driBindContext(context->driContext, dri_draw, dri_read))
|
||||
return GLXBadContext;
|
||||
|
||||
if (context->psc->display->driver == GLX_DRIVER_DRI3 ||
|
||||
context->psc->display->driver == GLX_DRIVER_ZINK_YES) {
|
||||
if (dri_draw)
|
||||
dri_invalidate_drawable(dri_draw);
|
||||
if (dri_read && dri_read != dri_draw)
|
||||
dri_invalidate_drawable(dri_read);
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
#endif /* GLX_DIRECT_RENDERING */
|
||||
|
@@ -89,6 +89,8 @@ dri_common_create_context(struct glx_screen *base,
|
||||
extern const __DRIbackgroundCallableExtension driBackgroundCallable;
|
||||
extern const __DRIuseInvalidateExtension dri2UseInvalidate;
|
||||
|
||||
Bool
|
||||
dri_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read);
|
||||
#endif /* GLX_DIRECT_RENDERING */
|
||||
|
||||
#endif /* _DRI_COMMON_H */
|
||||
|
@@ -431,31 +431,6 @@ drisw_destroy_context(struct glx_context *context)
|
||||
free(context);
|
||||
}
|
||||
|
||||
static int
|
||||
drisw_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
struct drisw_screen *psc = (struct drisw_screen *) context->psc;
|
||||
__GLXDRIdrawable *pdraw, *pread;
|
||||
|
||||
pdraw = driFetchDrawable(context, draw);
|
||||
pread = driFetchDrawable(context, read);
|
||||
|
||||
driReleaseDrawables(context);
|
||||
|
||||
if (!driBindContext(context->driContext,
|
||||
pdraw ? pdraw->dri_drawable : NULL,
|
||||
pread ? pread->dri_drawable : NULL))
|
||||
return GLXBadContext;
|
||||
if (psc->kopper) {
|
||||
if (pdraw)
|
||||
dri_invalidate_drawable(pdraw->dri_drawable);
|
||||
if (pread && (!pdraw || pread->dri_drawable != pdraw->dri_drawable))
|
||||
dri_invalidate_drawable(pread->dri_drawable);
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static void
|
||||
drisw_unbind_context(struct glx_context *context)
|
||||
{
|
||||
@@ -498,7 +473,7 @@ kopper_get_buffer_age(__GLXDRIdrawable *pdraw)
|
||||
|
||||
static const struct glx_context_vtable drisw_context_vtable = {
|
||||
.destroy = drisw_destroy_context,
|
||||
.bind = drisw_bind_context,
|
||||
.bind = dri_bind_context,
|
||||
.unbind = drisw_unbind_context,
|
||||
.wait_gl = drisw_wait_gl,
|
||||
.wait_x = drisw_wait_x,
|
||||
|
Reference in New Issue
Block a user