static struct dri3_drawable *
loader_drawable_to_dri3_drawable(struct loader_dri3_drawable *draw) {
size_t offset = offsetof(struct dri3_drawable, loader_drawable);
+ if (!draw)
+ return NULL;
return (struct dri3_drawable *)(((void*) draw) - offset);
}
glx_dri3_in_current_context(struct loader_dri3_drawable *draw)
{
struct dri3_drawable *priv = loader_drawable_to_dri3_drawable(draw);
+
+ if (!priv)
+ return false;
+
struct dri3_context *pcp = (struct dri3_context *) __glXGetCurrentContext();
struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc;
glx_dri3_get_dri_context(struct loader_dri3_drawable *draw)
{
struct glx_context *gc = __glXGetCurrentContext();
+ struct dri3_context *dri3Ctx = (struct dri3_context *) gc;
- if (gc) {
- struct dri3_context *dri3Ctx = (struct dri3_context *) gc;
- return dri3Ctx->driContext;
- }
+ return (gc != &dummyContext) ? dri3Ctx->driContext : NULL;
+}
- return NULL;
+static __DRIscreen *
+glx_dri3_get_dri_screen(struct loader_dri3_drawable *draw)
+{
+ struct glx_context *gc = __glXGetCurrentContext();
+ struct dri3_context *pcp = (struct dri3_context *) gc;
+ struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc;
+
+ return (gc != &dummyContext && psc) ? psc->driScreen : NULL;
}
static void
}
}
-static struct loader_dri3_vtable glx_dri3_vtable = {
+static const struct loader_dri3_vtable glx_dri3_vtable = {
.get_swap_interval = glx_dri3_get_swap_interval,
.clamp_swap_interval = glx_dri3_clamp_swap_interval,
.set_swap_interval = glx_dri3_set_swap_interval,
.set_drawable_size = glx_dri3_set_drawable_size,
.in_current_context = glx_dri3_in_current_context,
.get_dri_context = glx_dri3_get_dri_context,
+ .get_dri_screen = glx_dri3_get_dri_screen,
.flush_drawable = glx_dri3_flush_drawable,
.show_fps = glx_dri3_show_fps,
};
struct dri3_context *pcp = (struct dri3_context *) context;
struct dri3_screen *psc = (struct dri3_screen *) pcp->base.psc;
struct dri3_drawable *pdraw, *pread;
+ __DRIdrawable *dri_draw = NULL, *dri_read = NULL;
pdraw = (struct dri3_drawable *) driFetchDrawable(context, draw);
pread = (struct dri3_drawable *) driFetchDrawable(context, read);
driReleaseDrawables(&pcp->base);
- if (pdraw == NULL || pread == NULL)
+ if (pdraw)
+ dri_draw = pdraw->loader_drawable.dri_drawable;
+ else if (draw != None)
return GLXBadDrawable;
- if (!(*psc->core->bindContext) (pcp->driContext,
- pdraw->loader_drawable.dri_drawable,
- pread->loader_drawable.dri_drawable))
+ if (pread)
+ dri_read = pread->loader_drawable.dri_drawable;
+ else if (read != None)
+ return GLXBadDrawable;
+
+ if (!(*psc->core->bindContext) (pcp->driContext, dri_draw, dri_read))
return GLXBadContext;
return Success;
static int
dri3_set_swap_interval(__GLXDRIdrawable *pdraw, int interval)
{
+ assert(pdraw != NULL);
+
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc;
static int
dri3_get_swap_interval(__GLXDRIdrawable *pdraw)
{
+ assert(pdraw != NULL);
+
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
return priv->swap_interval;
psc->fd = loader_get_user_preferred_fd(psc->fd, &psc->is_different_gpu);
deviceName = NULL;
- driverName = loader_get_driver_for_fd(psc->fd, 0);
+ driverName = loader_get_driver_for_fd(psc->fd);
if (!driverName) {
ErrorMessageF("No driver found\n");
goto handle_error;