summaryrefslogtreecommitdiff
path: root/lib/mesa/src/glx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/glx')
-rw-r--r--lib/mesa/src/glx/apple/glx_empty.c16
-rw-r--r--lib/mesa/src/glx/dri2.c6
-rw-r--r--lib/mesa/src/glx/dri2_glx.c49
-rw-r--r--lib/mesa/src/glx/dri3_glx.c1463
-rw-r--r--lib/mesa/src/glx/dri_glx.c8
-rw-r--r--lib/mesa/src/glx/drisw_glx.c24
-rw-r--r--lib/mesa/src/glx/glx_pbuffer.c34
-rw-r--r--lib/mesa/src/glx/glxclient.h34
-rw-r--r--lib/mesa/src/glx/glxcmds.c249
-rw-r--r--lib/mesa/src/glx/glxconfig.c1
-rw-r--r--lib/mesa/src/glx/glxextensions.h18
-rw-r--r--lib/mesa/src/glx/indirect.c637
-rw-r--r--lib/mesa/src/glx/indirect.h10
-rw-r--r--lib/mesa/src/glx/indirect_size.c11
-rw-r--r--lib/mesa/src/glx/tests/Makefile.am5
15 files changed, 1616 insertions, 949 deletions
diff --git a/lib/mesa/src/glx/apple/glx_empty.c b/lib/mesa/src/glx/apple/glx_empty.c
index 33fffb5f6..1e9593c6d 100644
--- a/lib/mesa/src/glx/apple/glx_empty.c
+++ b/lib/mesa/src/glx/apple/glx_empty.c
@@ -263,3 +263,19 @@ glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * visinfo)
return NULL;
}
#endif
+
+
+_X_EXPORT
+GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
+ (Display * dpy, GLXDrawable pbuf),
+ (dpy, pbuf), glXDestroyPbuffer)
+
+ _X_EXPORT GLX_ALIAS_VOID(glXSelectEventSGIX,
+ (Display * dpy, GLXDrawable drawable,
+ unsigned long mask), (dpy, drawable, mask),
+ glXSelectEvent)
+
+ _X_EXPORT GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
+ (Display * dpy, GLXDrawable drawable,
+ unsigned long *mask), (dpy, drawable, mask),
+ glXGetSelectedEvent)
diff --git a/lib/mesa/src/glx/dri2.c b/lib/mesa/src/glx/dri2.c
index f00b96525..9ebd00ac8 100644
--- a/lib/mesa/src/glx/dri2.c
+++ b/lib/mesa/src/glx/dri2.c
@@ -94,6 +94,7 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
+#ifdef X_DRI2SwapBuffers
case DRI2_BufferSwapComplete:
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
@@ -142,6 +143,8 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
return True;
}
+#endif
+#ifdef DRI2_InvalidateBuffers
case DRI2_InvalidateBuffers:
{
xDRI2InvalidateBuffers *awire = (xDRI2InvalidateBuffers *)wire;
@@ -149,6 +152,7 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
dri2InvalidateBuffers(dpy, awire->drawable);
return False;
}
+#endif
default:
/* client doesn't support server event */
break;
@@ -281,6 +285,7 @@ DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
req->window = window;
req->driverType = DRI2DriverDRI;
+#ifdef DRI2DriverPrimeShift
{
char *prime = getenv("DRI_PRIME");
if (prime) {
@@ -292,6 +297,7 @@ DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName)
((primeid & DRI2DriverPrimeMask) << DRI2DriverPrimeShift);
}
}
+#endif
if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
UnlockDisplay(dpy);
diff --git a/lib/mesa/src/glx/dri2_glx.c b/lib/mesa/src/glx/dri2_glx.c
index 145f44d6e..27ea9521e 100644
--- a/lib/mesa/src/glx/dri2_glx.c
+++ b/lib/mesa/src/glx/dri2_glx.c
@@ -74,7 +74,13 @@ struct dri2_display
__glxHashTable *dri2Hash;
- const __DRIextension *loader_extensions[5];
+ const __DRIextension *loader_extensions[4];
+};
+
+struct dri2_context
+{
+ struct glx_context base;
+ __DRIcontext *driContext;
};
struct dri2_drawable
@@ -399,7 +405,7 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
}
DRI2CreateDrawable(psc->base.dpy, xDrawable);
- pdp = (struct dri2_display *)dpyPriv->dri2Display;
+ pdp = (struct dri2_display *)dpyPriv->dri2Display;;
/* Create a new drawable */
pdraw->driDrawable =
(*psc->dri2->createNewDrawable) (psc->driScreen,
@@ -514,7 +520,7 @@ dri2GetCurrentContext()
struct glx_context *gc = __glXGetCurrentContext();
struct dri2_context *dri2Ctx = (struct dri2_context *)gc;
- return (gc != &dummyContext) ? dri2Ctx->driContext : NULL;
+ return dri2Ctx ? dri2Ctx->driContext : NULL;
}
/**
@@ -946,13 +952,6 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw)
return priv->swap_interval;
}
-static void
-driSetBackgroundContext(void *loaderPrivate)
-{
- struct dri2_context *pcp = (struct dri2_context *) loaderPrivate;
- __glXSetCurrentContext(&pcp->base);
-}
-
static const __DRIdri2LoaderExtension dri2LoaderExtension = {
.base = { __DRI_DRI2_LOADER, 3 },
@@ -973,12 +972,6 @@ static const __DRIuseInvalidateExtension dri2UseInvalidate = {
.base = { __DRI_USE_INVALIDATE, 1 }
};
-static const __DRIbackgroundCallableExtension driBackgroundCallable = {
- .base = { __DRI_BACKGROUND_CALLABLE, 1 },
-
- .setBackgroundContext = driSetBackgroundContext,
-};
-
_X_HIDDEN void
dri2InvalidateBuffers(Display *dpy, XID drawable)
{
@@ -1068,8 +1061,6 @@ static const struct glx_context_vtable dri2_context_vtable = {
.bind_tex_image = dri2_bind_tex_image,
.release_tex_image = dri2_release_tex_image,
.get_proc_address = NULL,
- .interop_query_device_info = dri2_interop_query_device_info,
- .interop_export_object = dri2_interop_export_object
};
static void
@@ -1111,14 +1102,9 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv,
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
- if ((mask & ((1 << __DRI_API_GLES) |
- (1 << __DRI_API_GLES2) |
- (1 << __DRI_API_GLES3))) != 0) {
- __glXEnableDirectExtension(&psc->base,
- "GLX_EXT_create_context_es_profile");
- __glXEnableDirectExtension(&psc->base,
- "GLX_EXT_create_context_es2_profile");
- }
+ if ((mask & (1 << __DRI_API_GLES2)) != 0)
+ __glXEnableDirectExtension(&psc->base,
+ "GLX_EXT_create_context_es2_profile");
}
for (i = 0; extensions[i]; i++) {
@@ -1154,9 +1140,6 @@ dri2BindExtensions(struct dri2_screen *psc, struct glx_display * priv,
psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
}
-
- if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0)
- psc->interop = (__DRI2interopExtension*)extensions[i];
}
}
@@ -1219,7 +1202,7 @@ dri2CreateScreen(int screen, struct glx_display * priv)
/* If Mesa knows about the appropriate driver for this fd, then trust it.
* Otherwise, default to the server's value.
*/
- loader_driverName = loader_get_driver_for_fd(psc->fd);
+ loader_driverName = loader_get_driver_for_fd(psc->fd, 0);
if (loader_driverName) {
free(driverName);
driverName = loader_driverName;
@@ -1306,7 +1289,7 @@ dri2CreateScreen(int screen, struct glx_display * priv)
__glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control");
}
- /* DRI2 supports SubBuffer through DRI2CopyRegion, so it's always
+ /* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always
* available.*/
psp->copySubBuffer = dri2CopySubBuffer;
__glXEnableDirectExtension(&psc->base, "GLX_MESA_copy_sub_buffer");
@@ -1406,9 +1389,9 @@ dri2CreateDisplay(Display * dpy)
else
pdp->loader_extensions[i++] = &dri2LoaderExtension.base;
- pdp->loader_extensions[i++] = &dri2UseInvalidate.base;
+ pdp->loader_extensions[i++] = &systemTimeExtension.base;
- pdp->loader_extensions[i++] = &driBackgroundCallable.base;
+ pdp->loader_extensions[i++] = &dri2UseInvalidate.base;
pdp->loader_extensions[i++] = NULL;
diff --git a/lib/mesa/src/glx/dri3_glx.c b/lib/mesa/src/glx/dri3_glx.c
index e7ad40ad6..96f13e6a0 100644
--- a/lib/mesa/src/glx/dri3_glx.c
+++ b/lib/mesa/src/glx/dri3_glx.c
@@ -78,122 +78,40 @@
#include "loader.h"
#include "dri2.h"
-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);
-}
-
-static int
-glx_dri3_get_swap_interval(struct loader_dri3_drawable *draw)
-{
- struct dri3_drawable *priv = loader_drawable_to_dri3_drawable(draw);
-
- return priv->swap_interval;
-}
-
-static int
-glx_dri3_clamp_swap_interval(struct loader_dri3_drawable *draw, int interval)
-{
- return interval;
-}
-
-static void
-glx_dri3_set_swap_interval(struct loader_dri3_drawable *draw, int interval)
-{
- struct dri3_drawable *priv = loader_drawable_to_dri3_drawable(draw);
-
- priv->swap_interval = interval;
-}
+static const struct glx_context_vtable dri3_context_vtable;
-static void
-glx_dri3_set_drawable_size(struct loader_dri3_drawable *draw,
- int width, int height)
+static inline void
+dri3_fence_reset(xcb_connection_t *c, struct dri3_buffer *buffer)
{
- /* Nothing to do */
+ xshmfence_reset(buffer->shm_fence);
}
-static bool
-glx_dri3_in_current_context(struct loader_dri3_drawable *draw)
+static inline void
+dri3_fence_set(struct dri3_buffer *buffer)
{
- 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;
-
- return (&pcp->base != &dummyContext) && pcp->base.psc == &psc->base;
+ xshmfence_trigger(buffer->shm_fence);
}
-static __DRIcontext *
-glx_dri3_get_dri_context(struct loader_dri3_drawable *draw)
+static inline void
+dri3_fence_trigger(xcb_connection_t *c, struct dri3_buffer *buffer)
{
- struct glx_context *gc = __glXGetCurrentContext();
- struct dri3_context *dri3Ctx = (struct dri3_context *) gc;
-
- return (gc != &dummyContext) ? dri3Ctx->driContext : NULL;
+ xcb_sync_trigger_fence(c, buffer->sync_fence);
}
-static __DRIscreen *
-glx_dri3_get_dri_screen(struct loader_dri3_drawable *draw)
+static inline void
+dri3_fence_await(xcb_connection_t *c, struct dri3_buffer *buffer)
{
- 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;
+ xcb_flush(c);
+ xshmfence_await(buffer->shm_fence);
}
-static void
-glx_dri3_flush_drawable(struct loader_dri3_drawable *draw, unsigned flags)
+static inline Bool
+dri3_fence_triggered(struct dri3_buffer *buffer)
{
- loader_dri3_flush(draw, flags, __DRI2_THROTTLE_SWAPBUFFER);
+ return xshmfence_query(buffer->shm_fence);
}
static void
-glx_dri3_show_fps(struct loader_dri3_drawable *draw, uint64_t current_ust)
-{
- struct dri3_drawable *priv = loader_drawable_to_dri3_drawable(draw);
- const uint64_t interval =
- ((struct dri3_screen *) priv->base.psc)->show_fps_interval;
-
- if (!interval)
- return;
-
- priv->frames++;
-
- /* DRI3+Present together uses microseconds for UST. */
- if (priv->previous_ust + interval * 1000000 <= current_ust) {
- if (priv->previous_ust) {
- fprintf(stderr, "libGL: FPS = %.1f\n",
- ((uint64_t) priv->frames * 1000000) /
- (double)(current_ust - priv->previous_ust));
- }
- priv->frames = 0;
- priv->previous_ust = current_ust;
- }
-}
-
-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,
-};
-
-
-static const struct glx_context_vtable dri3_context_vtable;
-
-static void
dri3_destroy_context(struct glx_context *context)
{
struct dri3_context *pcp = (struct dri3_context *) context;
@@ -215,31 +133,19 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old,
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)
- dri_draw = pdraw->loader_drawable.dri_drawable;
- else if (draw != None)
+ if (pdraw == NULL || pread == NULL)
return GLXBadDrawable;
- 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))
+ if (!(*psc->core->bindContext) (pcp->driContext,
+ pdraw->driDrawable, pread->driDrawable))
return GLXBadContext;
- if (dri_draw)
- (*psc->f->invalidate)(dri_draw);
- if (dri_read && dri_read != dri_draw)
- (*psc->f->invalidate)(dri_read);
-
return Success;
}
@@ -359,12 +265,38 @@ dri3_create_context(struct glx_screen *base,
}
static void
+dri3_free_render_buffer(struct dri3_drawable *pdraw, struct dri3_buffer *buffer);
+
+static void
+dri3_update_num_back(struct dri3_drawable *priv)
+{
+ priv->num_back = 1;
+ if (priv->flipping) {
+ if (!priv->is_pixmap && !(priv->present_capabilities & XCB_PRESENT_CAPABILITY_ASYNC))
+ priv->num_back++;
+ priv->num_back++;
+ }
+ if (priv->swap_interval == 0)
+ priv->num_back++;
+}
+
+static void
dri3_destroy_drawable(__GLXDRIdrawable *base)
{
+ struct dri3_screen *psc = (struct dri3_screen *) base->psc;
struct dri3_drawable *pdraw = (struct dri3_drawable *) base;
+ xcb_connection_t *c = XGetXCBConnection(pdraw->base.psc->dpy);
+ int i;
+
+ (*psc->core->destroyDrawable) (pdraw->driDrawable);
- loader_dri3_drawable_fini(&pdraw->loader_drawable);
+ for (i = 0; i < DRI3_NUM_BUFFERS; i++) {
+ if (pdraw->buffers[i])
+ dri3_free_render_buffer(pdraw, pdraw->buffers[i]);
+ }
+ if (pdraw->special_event)
+ xcb_unregister_for_special_event(c, pdraw->special_event);
free(pdraw);
}
@@ -375,6 +307,7 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable,
struct dri3_drawable *pdraw;
struct dri3_screen *psc = (struct dri3_screen *) base;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
+ GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
pdraw = calloc(1, sizeof(*pdraw));
if (!pdraw)
@@ -384,21 +317,158 @@ dri3_create_drawable(struct glx_screen *base, XID xDrawable,
pdraw->base.xDrawable = xDrawable;
pdraw->base.drawable = drawable;
pdraw->base.psc = &psc->base;
+ pdraw->swap_interval = 1; /* default may be overridden below */
+ pdraw->have_back = 0;
+ pdraw->have_fake_front = 0;
+
+ if (psc->config)
+ psc->config->configQueryi(psc->driScreen,
+ "vblank_mode", &vblank_mode);
+
+ switch (vblank_mode) {
+ case DRI_CONF_VBLANK_NEVER:
+ case DRI_CONF_VBLANK_DEF_INTERVAL_0:
+ pdraw->swap_interval = 0;
+ break;
+ case DRI_CONF_VBLANK_DEF_INTERVAL_1:
+ case DRI_CONF_VBLANK_ALWAYS_SYNC:
+ default:
+ pdraw->swap_interval = 1;
+ break;
+ }
+
+ dri3_update_num_back(pdraw);
(void) __glXInitialize(psc->base.dpy);
- if (loader_dri3_drawable_init(XGetXCBConnection(base->dpy),
- xDrawable, psc->driScreen,
- psc->is_different_gpu, config->driConfig,
- &psc->loader_dri3_ext, &glx_dri3_vtable,
- &pdraw->loader_drawable)) {
+ /* Create a new drawable */
+ pdraw->driDrawable =
+ (*psc->image_driver->createNewDrawable) (psc->driScreen,
+ config->driConfig, pdraw);
+
+ if (!pdraw->driDrawable) {
free(pdraw);
return NULL;
}
+ /*
+ * Make sure server has the same swap interval we do for the new
+ * drawable.
+ */
+ if (psc->vtable.setSwapInterval)
+ psc->vtable.setSwapInterval(&pdraw->base, pdraw->swap_interval);
+
return &pdraw->base;
}
+static void
+show_fps(struct dri3_drawable *draw, uint64_t current_ust)
+{
+ const uint64_t interval =
+ ((struct dri3_screen *) draw->base.psc)->show_fps_interval;
+
+ draw->frames++;
+
+ /* DRI3+Present together uses microseconds for UST. */
+ if (draw->previous_ust + interval * 1000000 <= current_ust) {
+ if (draw->previous_ust) {
+ fprintf(stderr, "libGL: FPS = %.1f\n",
+ ((uint64_t) draw->frames * 1000000) /
+ (double)(current_ust - draw->previous_ust));
+ }
+ draw->frames = 0;
+ draw->previous_ust = current_ust;
+ }
+}
+
+/*
+ * Process one Present event
+ */
+static void
+dri3_handle_present_event(struct dri3_drawable *priv, xcb_present_generic_event_t *ge)
+{
+ struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc;
+
+ switch (ge->evtype) {
+ case XCB_PRESENT_CONFIGURE_NOTIFY: {
+ xcb_present_configure_notify_event_t *ce = (void *) ge;
+
+ priv->width = ce->width;
+ priv->height = ce->height;
+ break;
+ }
+ case XCB_PRESENT_COMPLETE_NOTIFY: {
+ xcb_present_complete_notify_event_t *ce = (void *) ge;
+
+ /* Compute the processed SBC number from the received 32-bit serial number merged
+ * with the upper 32-bits of the sent 64-bit serial number while checking for
+ * wrap
+ */
+ if (ce->kind == XCB_PRESENT_COMPLETE_KIND_PIXMAP) {
+ priv->recv_sbc = (priv->send_sbc & 0xffffffff00000000LL) | ce->serial;
+ if (priv->recv_sbc > priv->send_sbc)
+ priv->recv_sbc -= 0x100000000;
+ switch (ce->mode) {
+ case XCB_PRESENT_COMPLETE_MODE_FLIP:
+ priv->flipping = true;
+ break;
+ case XCB_PRESENT_COMPLETE_MODE_COPY:
+ priv->flipping = false;
+ break;
+ }
+ dri3_update_num_back(priv);
+
+ if (psc->show_fps_interval)
+ show_fps(priv, ce->ust);
+
+ priv->ust = ce->ust;
+ priv->msc = ce->msc;
+ } else {
+ priv->recv_msc_serial = ce->serial;
+ priv->notify_ust = ce->ust;
+ priv->notify_msc = ce->msc;
+ }
+ break;
+ }
+ case XCB_PRESENT_EVENT_IDLE_NOTIFY: {
+ xcb_present_idle_notify_event_t *ie = (void *) ge;
+ int b;
+
+ for (b = 0; b < sizeof (priv->buffers) / sizeof (priv->buffers[0]); b++) {
+ struct dri3_buffer *buf = priv->buffers[b];
+
+ if (buf && buf->pixmap == ie->pixmap) {
+ buf->busy = 0;
+ if (priv->num_back <= b && b < DRI3_MAX_BACK) {
+ dri3_free_render_buffer(priv, buf);
+ priv->buffers[b] = NULL;
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ free(ge);
+}
+
+static bool
+dri3_wait_for_event(__GLXDRIdrawable *pdraw)
+{
+ xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
+ struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
+ xcb_generic_event_t *ev;
+ xcb_present_generic_event_t *ge;
+
+ xcb_flush(c);
+ ev = xcb_wait_for_special_event(c, priv->special_event);
+ if (!ev)
+ return false;
+ ge = (void *) ev;
+ dri3_handle_present_event(priv, ge);
+ return true;
+}
+
/** dri3_wait_for_msc
*
* Get the X server to send an event when the target msc/divisor/remainder is
@@ -408,10 +478,32 @@ static int
dri3_wait_for_msc(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc)
{
+ xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
+ uint32_t msc_serial;
+
+ /* Ask for the an event for the target MSC */
+ msc_serial = ++priv->send_msc_serial;
+ xcb_present_notify_msc(c,
+ priv->base.xDrawable,
+ msc_serial,
+ target_msc,
+ divisor,
+ remainder);
+
+ xcb_flush(c);
+
+ /* Wait for the event */
+ if (priv->special_event) {
+ while ((int32_t) (msc_serial - priv->recv_msc_serial) > 0) {
+ if (!dri3_wait_for_event(pdraw))
+ return 0;
+ }
+ }
- loader_dri3_wait_for_msc(&priv->loader_drawable, target_msc, divisor,
- remainder, ust, msc, sbc);
+ *ust = priv->notify_ust;
+ *msc = priv->notify_msc;
+ *sbc = priv->recv_sbc;
return 1;
}
@@ -440,8 +532,101 @@ dri3_wait_for_sbc(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust,
{
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
- return loader_dri3_wait_for_sbc(&priv->loader_drawable, target_sbc,
- ust, msc, sbc);
+ /* From the GLX_OML_sync_control spec:
+ *
+ * "If <target_sbc> = 0, the function will block until all previous
+ * swaps requested with glXSwapBuffersMscOML for that window have
+ * completed."
+ */
+ if (!target_sbc)
+ target_sbc = priv->send_sbc;
+
+ while (priv->recv_sbc < target_sbc) {
+ if (!dri3_wait_for_event(pdraw))
+ return 0;
+ }
+
+ *ust = priv->ust;
+ *msc = priv->msc;
+ *sbc = priv->recv_sbc;
+ return 1;
+}
+
+/**
+ * Asks the driver to flush any queued work necessary for serializing with the
+ * X command stream, and optionally the slightly more strict requirement of
+ * glFlush() equivalence (which would require flushing even if nothing had
+ * been drawn to a window system framebuffer, for example).
+ */
+static void
+dri3_flush(struct dri3_screen *psc,
+ struct dri3_drawable *draw,
+ unsigned flags,
+ enum __DRI2throttleReason throttle_reason)
+{
+ struct glx_context *gc = __glXGetCurrentContext();
+
+ if (gc) {
+ struct dri3_context *dri3Ctx = (struct dri3_context *)gc;
+
+ (*psc->f->flush_with_flags)(dri3Ctx->driContext, draw->driDrawable, flags, throttle_reason);
+ }
+}
+
+static xcb_gcontext_t
+dri3_drawable_gc(struct dri3_drawable *priv)
+{
+ if (!priv->gc) {
+ uint32_t v;
+ xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
+
+ v = 0;
+ xcb_create_gc(c,
+ (priv->gc = xcb_generate_id(c)),
+ priv->base.xDrawable,
+ XCB_GC_GRAPHICS_EXPOSURES,
+ &v);
+ }
+ return priv->gc;
+}
+
+static struct dri3_buffer *
+dri3_back_buffer(struct dri3_drawable *priv)
+{
+ return priv->buffers[DRI3_BACK_ID(priv->cur_back)];
+}
+
+static struct dri3_buffer *
+dri3_fake_front_buffer(struct dri3_drawable *priv)
+{
+ return priv->buffers[DRI3_FRONT_ID];
+}
+
+static void
+dri3_copy_area (xcb_connection_t *c /**< */,
+ xcb_drawable_t src_drawable /**< */,
+ xcb_drawable_t dst_drawable /**< */,
+ xcb_gcontext_t gc /**< */,
+ int16_t src_x /**< */,
+ int16_t src_y /**< */,
+ int16_t dst_x /**< */,
+ int16_t dst_y /**< */,
+ uint16_t width /**< */,
+ uint16_t height /**< */)
+{
+ xcb_void_cookie_t cookie;
+
+ cookie = xcb_copy_area_checked(c,
+ src_drawable,
+ dst_drawable,
+ gc,
+ src_x,
+ src_y,
+ dst_x,
+ dst_y,
+ width,
+ height);
+ xcb_discard_reply(c, cookie.sequence);
}
static void
@@ -450,29 +635,144 @@ dri3_copy_sub_buffer(__GLXDRIdrawable *pdraw, int x, int y,
Bool flush)
{
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
+ struct dri3_screen *psc = (struct dri3_screen *) pdraw->psc;
+ struct dri3_context *pcp = (struct dri3_context *) __glXGetCurrentContext();
+ xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
+ struct dri3_buffer *back;
+
+ unsigned flags = __DRI2_FLUSH_DRAWABLE;
+
+ /* Check we have the right attachments */
+ if (!priv->have_back || priv->is_pixmap)
+ return;
+
+ if (flush)
+ flags |= __DRI2_FLUSH_CONTEXT;
+ dri3_flush(psc, priv, flags, __DRI2_THROTTLE_SWAPBUFFER);
+
+ back = dri3_back_buffer(priv);
+ y = priv->height - y - height;
+
+ if (psc->is_different_gpu && (&pcp->base != &dummyContext) && pcp->base.psc == &psc->base) {
+ /* Update the linear buffer part of the back buffer
+ * for the dri3_copy_area operation
+ */
+ psc->image->blitImage(pcp->driContext,
+ back->linear_buffer,
+ back->image,
+ 0, 0, back->width,
+ back->height,
+ 0, 0, back->width,
+ back->height, __BLIT_FLAG_FLUSH);
+ /* We use blitImage to update our fake front,
+ */
+ if (priv->have_fake_front)
+ psc->image->blitImage(pcp->driContext,
+ dri3_fake_front_buffer(priv)->image,
+ back->image,
+ x, y, width, height,
+ x, y, width, height, __BLIT_FLAG_FLUSH);
+ }
- loader_dri3_copy_sub_buffer(&priv->loader_drawable, x, y,
- width, height, flush);
+ dri3_fence_reset(c, back);
+ dri3_copy_area(c,
+ dri3_back_buffer(priv)->pixmap,
+ priv->base.xDrawable,
+ dri3_drawable_gc(priv),
+ x, y, x, y, width, height);
+ dri3_fence_trigger(c, back);
+ /* Refresh the fake front (if present) after we just damaged the real
+ * front.
+ */
+ if (priv->have_fake_front && !psc->is_different_gpu) {
+ dri3_fence_reset(c, dri3_fake_front_buffer(priv));
+ dri3_copy_area(c,
+ dri3_back_buffer(priv)->pixmap,
+ dri3_fake_front_buffer(priv)->pixmap,
+ dri3_drawable_gc(priv),
+ x, y, x, y, width, height);
+ dri3_fence_trigger(c, dri3_fake_front_buffer(priv));
+ dri3_fence_await(c, dri3_fake_front_buffer(priv));
+ }
+ dri3_fence_await(c, back);
+}
+
+static void
+dri3_copy_drawable(struct dri3_drawable *priv, Drawable dest, Drawable src)
+{
+ struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc;
+ xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
+
+ dri3_flush(psc, priv, __DRI2_FLUSH_DRAWABLE, 0);
+
+ dri3_fence_reset(c, dri3_fake_front_buffer(priv));
+ dri3_copy_area(c,
+ src, dest,
+ dri3_drawable_gc(priv),
+ 0, 0, 0, 0, priv->width, priv->height);
+ dri3_fence_trigger(c, dri3_fake_front_buffer(priv));
+ dri3_fence_await(c, dri3_fake_front_buffer(priv));
}
static void
dri3_wait_x(struct glx_context *gc)
{
+ struct dri3_context *pcp = (struct dri3_context *) gc;
struct dri3_drawable *priv = (struct dri3_drawable *)
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
+ struct dri3_screen *psc;
+ struct dri3_buffer *front;
+
+ if (priv == NULL || !priv->have_fake_front)
+ return;
+
+ psc = (struct dri3_screen *) priv->base.psc;
+ front = dri3_fake_front_buffer(priv);
+
+ dri3_copy_drawable(priv, front->pixmap, priv->base.xDrawable);
- if (priv)
- loader_dri3_wait_x(&priv->loader_drawable);
+ /* In the psc->is_different_gpu case, the linear buffer has been updated,
+ * but not yet the tiled buffer.
+ * Copy back to the tiled buffer we use for rendering.
+ * Note that we don't need flushing.
+ */
+ if (psc->is_different_gpu && (&pcp->base != &dummyContext) && pcp->base.psc == &psc->base)
+ psc->image->blitImage(pcp->driContext,
+ front->image,
+ front->linear_buffer,
+ 0, 0, front->width,
+ front->height,
+ 0, 0, front->width,
+ front->height, 0);
}
static void
dri3_wait_gl(struct glx_context *gc)
{
+ struct dri3_context *pcp = (struct dri3_context *) gc;
struct dri3_drawable *priv = (struct dri3_drawable *)
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
+ struct dri3_screen *psc;
+ struct dri3_buffer *front;
+
+ if (priv == NULL || !priv->have_fake_front)
+ return;
+
+ psc = (struct dri3_screen *) priv->base.psc;
+ front = dri3_fake_front_buffer(priv);
- if (priv)
- loader_dri3_wait_gl(&priv->loader_drawable);
+ /* In the psc->is_different_gpu case, we update the linear_buffer
+ * before updating the real front.
+ */
+ if (psc->is_different_gpu && (&pcp->base != &dummyContext) && pcp->base.psc == &psc->base)
+ psc->image->blitImage(pcp->driContext,
+ front->linear_buffer,
+ front->image,
+ 0, 0, front->width,
+ front->height,
+ 0, 0, front->width,
+ front->height, __BLIT_FLAG_FLUSH);
+ dri3_copy_drawable(priv, priv->base.xDrawable, front->pixmap);
}
/**
@@ -482,8 +782,8 @@ dri3_wait_gl(struct glx_context *gc)
static void
dri3_flush_front_buffer(__DRIdrawable *driDrawable, void *loaderPrivate)
{
- struct loader_dri3_drawable *draw = loaderPrivate;
- struct dri3_drawable *pdraw = loader_drawable_to_dri3_drawable(draw);
+ struct glx_context *gc;
+ struct dri3_drawable *pdraw = loaderPrivate;
struct dri3_screen *psc;
if (!pdraw)
@@ -496,17 +796,699 @@ dri3_flush_front_buffer(__DRIdrawable *driDrawable, void *loaderPrivate)
(void) __glXInitialize(psc->base.dpy);
- loader_dri3_flush(draw, __DRI2_FLUSH_DRAWABLE, __DRI2_THROTTLE_FLUSHFRONT);
+ gc = __glXGetCurrentContext();
+
+ dri3_flush(psc, pdraw, __DRI2_FLUSH_DRAWABLE, __DRI2_THROTTLE_FLUSHFRONT);
- (*psc->f->invalidate)(driDrawable);
- loader_dri3_wait_gl(draw);
+ dri3_wait_gl(gc);
}
+static uint32_t
+dri3_cpp_for_format(uint32_t format) {
+ switch (format) {
+ case __DRI_IMAGE_FORMAT_R8:
+ return 1;
+ case __DRI_IMAGE_FORMAT_RGB565:
+ case __DRI_IMAGE_FORMAT_GR88:
+ return 2;
+ case __DRI_IMAGE_FORMAT_XRGB8888:
+ case __DRI_IMAGE_FORMAT_ARGB8888:
+ case __DRI_IMAGE_FORMAT_ABGR8888:
+ case __DRI_IMAGE_FORMAT_XBGR8888:
+ case __DRI_IMAGE_FORMAT_XRGB2101010:
+ case __DRI_IMAGE_FORMAT_ARGB2101010:
+ case __DRI_IMAGE_FORMAT_SARGB8:
+ return 4;
+ case __DRI_IMAGE_FORMAT_NONE:
+ default:
+ return 0;
+ }
+}
+
+
+/** dri3_alloc_render_buffer
+ *
+ * Use the driver createImage function to construct a __DRIimage, then
+ * get a file descriptor for that and create an X pixmap from that
+ *
+ * Allocate an xshmfence for synchronization
+ */
+static struct dri3_buffer *
+dri3_alloc_render_buffer(struct glx_screen *glx_screen, Drawable draw,
+ unsigned int format, int width, int height, int depth)
+{
+ struct dri3_screen *psc = (struct dri3_screen *) glx_screen;
+ Display *dpy = glx_screen->dpy;
+ struct dri3_buffer *buffer;
+ __DRIimage *pixmap_buffer;
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_pixmap_t pixmap;
+ xcb_sync_fence_t sync_fence;
+ struct xshmfence *shm_fence;
+ int buffer_fd, fence_fd;
+ int stride;
+
+ /* Create an xshmfence object and
+ * prepare to send that to the X server
+ */
+
+ fence_fd = xshmfence_alloc_shm();
+ if (fence_fd < 0) {
+ ErrorMessageF("DRI3 Fence object allocation failure %s\n", strerror(errno));
+ return NULL;
+ }
+ shm_fence = xshmfence_map_shm(fence_fd);
+ if (shm_fence == NULL) {
+ ErrorMessageF("DRI3 Fence object map failure %s\n", strerror(errno));
+ goto no_shm_fence;
+ }
+
+ /* Allocate the image from the driver
+ */
+ buffer = calloc(1, sizeof (struct dri3_buffer));
+ if (!buffer)
+ goto no_buffer;
+
+ buffer->cpp = dri3_cpp_for_format(format);
+ if (!buffer->cpp) {
+ ErrorMessageF("DRI3 buffer format %d invalid\n", format);
+ goto no_image;
+ }
+
+ if (!psc->is_different_gpu) {
+ buffer->image = (*psc->image->createImage) (psc->driScreen,
+ width, height,
+ format,
+ __DRI_IMAGE_USE_SHARE |
+ __DRI_IMAGE_USE_SCANOUT,
+ buffer);
+ pixmap_buffer = buffer->image;
+
+ if (!buffer->image) {
+ ErrorMessageF("DRI3 gpu image creation failure\n");
+ goto no_image;
+ }
+ } else {
+ buffer->image = (*psc->image->createImage) (psc->driScreen,
+ width, height,
+ format,
+ 0,
+ buffer);
+
+ if (!buffer->image) {
+ ErrorMessageF("DRI3 other gpu image creation failure\n");
+ goto no_image;
+ }
+
+ buffer->linear_buffer = (*psc->image->createImage) (psc->driScreen,
+ width, height,
+ format,
+ __DRI_IMAGE_USE_SHARE |
+ __DRI_IMAGE_USE_LINEAR,
+ buffer);
+ pixmap_buffer = buffer->linear_buffer;
+
+ if (!buffer->linear_buffer) {
+ ErrorMessageF("DRI3 gpu linear image creation failure\n");
+ goto no_linear_buffer;
+ }
+ }
+
+ /* X wants the stride, so ask the image for it
+ */
+ if (!(*psc->image->queryImage)(pixmap_buffer, __DRI_IMAGE_ATTRIB_STRIDE, &stride)) {
+ ErrorMessageF("DRI3 get image stride failed\n");
+ goto no_buffer_attrib;
+ }
+
+ buffer->pitch = stride;
+
+ if (!(*psc->image->queryImage)(pixmap_buffer, __DRI_IMAGE_ATTRIB_FD, &buffer_fd)) {
+ ErrorMessageF("DRI3 get image FD failed\n");
+ goto no_buffer_attrib;
+ }
+
+ xcb_dri3_pixmap_from_buffer(c,
+ (pixmap = xcb_generate_id(c)),
+ draw,
+ buffer->size,
+ width, height, buffer->pitch,
+ depth, buffer->cpp * 8,
+ buffer_fd);
+
+ xcb_dri3_fence_from_fd(c,
+ pixmap,
+ (sync_fence = xcb_generate_id(c)),
+ false,
+ fence_fd);
+
+ buffer->pixmap = pixmap;
+ buffer->own_pixmap = true;
+ buffer->sync_fence = sync_fence;
+ buffer->shm_fence = shm_fence;
+ buffer->width = width;
+ buffer->height = height;
+
+ /* Mark the buffer as idle
+ */
+ dri3_fence_set(buffer);
+
+ return buffer;
+
+no_buffer_attrib:
+ (*psc->image->destroyImage)(pixmap_buffer);
+no_linear_buffer:
+ if (psc->is_different_gpu)
+ (*psc->image->destroyImage)(buffer->image);
+no_image:
+ free(buffer);
+no_buffer:
+ xshmfence_unmap_shm(shm_fence);
+no_shm_fence:
+ close(fence_fd);
+ ErrorMessageF("DRI3 alloc_render_buffer failed\n");
+ return NULL;
+}
+
+/** dri3_free_render_buffer
+ *
+ * Free everything associated with one render buffer including pixmap, fence
+ * stuff and the driver image
+ */
+static void
+dri3_free_render_buffer(struct dri3_drawable *pdraw, struct dri3_buffer *buffer)
+{
+ struct dri3_screen *psc = (struct dri3_screen *) pdraw->base.psc;
+ xcb_connection_t *c = XGetXCBConnection(pdraw->base.psc->dpy);
+
+ if (buffer->own_pixmap)
+ xcb_free_pixmap(c, buffer->pixmap);
+ xcb_sync_destroy_fence(c, buffer->sync_fence);
+ xshmfence_unmap_shm(buffer->shm_fence);
+ (*psc->image->destroyImage)(buffer->image);
+ if (buffer->linear_buffer)
+ (*psc->image->destroyImage)(buffer->linear_buffer);
+ free(buffer);
+}
+
+
+/** dri3_flush_present_events
+ *
+ * Process any present events that have been received from the X server
+ */
+static void
+dri3_flush_present_events(struct dri3_drawable *priv)
+{
+ xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
+
+ /* Check to see if any configuration changes have occurred
+ * since we were last invoked
+ */
+ if (priv->special_event) {
+ xcb_generic_event_t *ev;
+
+ while ((ev = xcb_poll_for_special_event(c, priv->special_event)) != NULL) {
+ xcb_present_generic_event_t *ge = (void *) ev;
+ dri3_handle_present_event(priv, ge);
+ }
+ }
+}
+
+/** dri3_update_drawable
+ *
+ * Called the first time we use the drawable and then
+ * after we receive present configure notify events to
+ * track the geometry of the drawable
+ */
+static int
+dri3_update_drawable(__DRIdrawable *driDrawable, void *loaderPrivate)
+{
+ struct dri3_drawable *priv = loaderPrivate;
+ xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
+
+ /* First time through, go get the current drawable geometry
+ */
+ if (priv->width == 0 || priv->height == 0 || priv->depth == 0) {
+ xcb_get_geometry_cookie_t geom_cookie;
+ xcb_get_geometry_reply_t *geom_reply;
+ xcb_void_cookie_t cookie;
+ xcb_generic_error_t *error;
+ xcb_present_query_capabilities_cookie_t present_capabilities_cookie;
+ xcb_present_query_capabilities_reply_t *present_capabilities_reply;
+
+
+ /* Try to select for input on the window.
+ *
+ * If the drawable is a window, this will get our events
+ * delivered.
+ *
+ * Otherwise, we'll get a BadWindow error back from this request which
+ * will let us know that the drawable is a pixmap instead.
+ */
+
+
+ cookie = xcb_present_select_input_checked(c,
+ (priv->eid = xcb_generate_id(c)),
+ priv->base.xDrawable,
+ XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY|
+ XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY|
+ XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
+
+ present_capabilities_cookie = xcb_present_query_capabilities(c, priv->base.xDrawable);
+
+ /* Create an XCB event queue to hold present events outside of the usual
+ * application event queue
+ */
+ priv->special_event = xcb_register_for_special_xge(c,
+ &xcb_present_id,
+ priv->eid,
+ priv->stamp);
+
+ geom_cookie = xcb_get_geometry(c, priv->base.xDrawable);
+
+ geom_reply = xcb_get_geometry_reply(c, geom_cookie, NULL);
+
+ if (!geom_reply)
+ return false;
+
+ priv->width = geom_reply->width;
+ priv->height = geom_reply->height;
+ priv->depth = geom_reply->depth;
+ priv->is_pixmap = false;
+
+ free(geom_reply);
+
+ /* Check to see if our select input call failed. If it failed with a
+ * BadWindow error, then assume the drawable is a pixmap. Destroy the
+ * special event queue created above and mark the drawable as a pixmap
+ */
+
+ error = xcb_request_check(c, cookie);
+
+ present_capabilities_reply = xcb_present_query_capabilities_reply(c,
+ present_capabilities_cookie,
+ NULL);
+
+ if (present_capabilities_reply) {
+ priv->present_capabilities = present_capabilities_reply->capabilities;
+ free(present_capabilities_reply);
+ } else
+ priv->present_capabilities = 0;
+
+ if (error) {
+ if (error->error_code != BadWindow) {
+ free(error);
+ return false;
+ }
+ priv->is_pixmap = true;
+ xcb_unregister_for_special_event(c, priv->special_event);
+ priv->special_event = NULL;
+ }
+ }
+ dri3_flush_present_events(priv);
+ return true;
+}
+
+/* the DRIimage createImage function takes __DRI_IMAGE_FORMAT codes, while
+ * the createImageFromFds call takes __DRI_IMAGE_FOURCC codes. To avoid
+ * complete confusion, just deal in __DRI_IMAGE_FORMAT codes for now and
+ * translate to __DRI_IMAGE_FOURCC codes in the call to createImageFromFds
+ */
+static int
+image_format_to_fourcc(int format)
+{
+
+ /* Convert from __DRI_IMAGE_FORMAT to __DRI_IMAGE_FOURCC (sigh) */
+ switch (format) {
+ case __DRI_IMAGE_FORMAT_SARGB8: return __DRI_IMAGE_FOURCC_SARGB8888;
+ case __DRI_IMAGE_FORMAT_RGB565: return __DRI_IMAGE_FOURCC_RGB565;
+ case __DRI_IMAGE_FORMAT_XRGB8888: return __DRI_IMAGE_FOURCC_XRGB8888;
+ case __DRI_IMAGE_FORMAT_ARGB8888: return __DRI_IMAGE_FOURCC_ARGB8888;
+ case __DRI_IMAGE_FORMAT_ABGR8888: return __DRI_IMAGE_FOURCC_ABGR8888;
+ case __DRI_IMAGE_FORMAT_XBGR8888: return __DRI_IMAGE_FOURCC_XBGR8888;
+ }
+ return 0;
+}
+
+/** dri3_get_pixmap_buffer
+ *
+ * Get the DRM object for a pixmap from the X server and
+ * wrap that with a __DRIimage structure using createImageFromFds
+ */
+static struct dri3_buffer *
+dri3_get_pixmap_buffer(__DRIdrawable *driDrawable,
+ unsigned int format,
+ enum dri3_buffer_type buffer_type,
+ void *loaderPrivate)
+{
+ struct dri3_drawable *pdraw = loaderPrivate;
+ int buf_id = dri3_pixmap_buf_id(buffer_type);
+ struct dri3_buffer *buffer = pdraw->buffers[buf_id];
+ Pixmap pixmap;
+ xcb_dri3_buffer_from_pixmap_cookie_t bp_cookie;
+ xcb_dri3_buffer_from_pixmap_reply_t *bp_reply;
+ int *fds;
+ Display *dpy;
+ struct dri3_screen *psc;
+ xcb_connection_t *c;
+ xcb_sync_fence_t sync_fence;
+ struct xshmfence *shm_fence;
+ int fence_fd;
+ __DRIimage *image_planar;
+ int stride, offset;
+
+ if (buffer)
+ return buffer;
+
+ pixmap = pdraw->base.xDrawable;
+ psc = (struct dri3_screen *) pdraw->base.psc;
+ dpy = psc->base.dpy;
+ c = XGetXCBConnection(dpy);
+
+ buffer = calloc(1, sizeof (struct dri3_buffer));
+ if (!buffer)
+ goto no_buffer;
+
+ fence_fd = xshmfence_alloc_shm();
+ if (fence_fd < 0)
+ goto no_fence;
+ shm_fence = xshmfence_map_shm(fence_fd);
+ if (shm_fence == NULL) {
+ close (fence_fd);
+ goto no_fence;
+ }
+
+ xcb_dri3_fence_from_fd(c,
+ pixmap,
+ (sync_fence = xcb_generate_id(c)),
+ false,
+ fence_fd);
+
+ /* Get an FD for the pixmap object
+ */
+ bp_cookie = xcb_dri3_buffer_from_pixmap(c, pixmap);
+ bp_reply = xcb_dri3_buffer_from_pixmap_reply(c, bp_cookie, NULL);
+ if (!bp_reply)
+ goto no_image;
+ fds = xcb_dri3_buffer_from_pixmap_reply_fds(c, bp_reply);
+
+ stride = bp_reply->stride;
+ offset = 0;
+
+ /* createImageFromFds creates a wrapper __DRIimage structure which
+ * can deal with multiple planes for things like Yuv images. So, once
+ * we've gotten the planar wrapper, pull the single plane out of it and
+ * discard the wrapper.
+ */
+ image_planar = (*psc->image->createImageFromFds) (psc->driScreen,
+ bp_reply->width,
+ bp_reply->height,
+ image_format_to_fourcc(format),
+ fds, 1,
+ &stride, &offset, buffer);
+ close(fds[0]);
+ if (!image_planar)
+ goto no_image;
+
+ buffer->image = (*psc->image->fromPlanar)(image_planar, 0, buffer);
+
+ (*psc->image->destroyImage)(image_planar);
+
+ if (!buffer->image)
+ goto no_image;
+
+ buffer->pixmap = pixmap;
+ buffer->own_pixmap = false;
+ buffer->width = bp_reply->width;
+ buffer->height = bp_reply->height;
+ buffer->buffer_type = buffer_type;
+ buffer->shm_fence = shm_fence;
+ buffer->sync_fence = sync_fence;
+
+ pdraw->buffers[buf_id] = buffer;
+ return buffer;
+
+no_image:
+ xcb_sync_destroy_fence(c, sync_fence);
+ xshmfence_unmap_shm(shm_fence);
+no_fence:
+ free(buffer);
+no_buffer:
+ return NULL;
+}
+
+/** dri3_find_back
+ *
+ * Find an idle back buffer. If there isn't one, then
+ * wait for a present idle notify event from the X server
+ */
+static int
+dri3_find_back(xcb_connection_t *c, struct dri3_drawable *priv)
+{
+ int b;
+ xcb_generic_event_t *ev;
+ xcb_present_generic_event_t *ge;
+
+ for (;;) {
+ for (b = 0; b < priv->num_back; b++) {
+ int id = DRI3_BACK_ID((b + priv->cur_back) % priv->num_back);
+ struct dri3_buffer *buffer = priv->buffers[id];
+
+ if (!buffer || !buffer->busy) {
+ priv->cur_back = id;
+ return id;
+ }
+ }
+ xcb_flush(c);
+ ev = xcb_wait_for_special_event(c, priv->special_event);
+ if (!ev)
+ return -1;
+ ge = (void *) ev;
+ dri3_handle_present_event(priv, ge);
+ }
+}
+
+/** dri3_get_buffer
+ *
+ * Find a front or back buffer, allocating new ones as necessary
+ */
+static struct dri3_buffer *
+dri3_get_buffer(__DRIdrawable *driDrawable,
+ unsigned int format,
+ enum dri3_buffer_type buffer_type,
+ void *loaderPrivate)
+{
+ struct dri3_context *pcp = (struct dri3_context *) __glXGetCurrentContext();
+ struct dri3_drawable *priv = loaderPrivate;
+ struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc;
+ xcb_connection_t *c = XGetXCBConnection(priv->base.psc->dpy);
+ struct dri3_buffer *buffer;
+ int buf_id;
+
+ if (buffer_type == dri3_buffer_back) {
+ buf_id = dri3_find_back(c, priv);
+
+ if (buf_id < 0)
+ return NULL;
+ } else {
+ buf_id = DRI3_FRONT_ID;
+ }
+
+ buffer = priv->buffers[buf_id];
+
+ /* Allocate a new buffer if there isn't an old one, or if that
+ * old one is the wrong size
+ */
+ if (!buffer || buffer->width != priv->width || buffer->height != priv->height) {
+ struct dri3_buffer *new_buffer;
+
+ /* Allocate the new buffers
+ */
+ new_buffer = dri3_alloc_render_buffer(priv->base.psc,
+ priv->base.xDrawable,
+ format, priv->width, priv->height, priv->depth);
+ if (!new_buffer)
+ return NULL;
+
+ /* When resizing, copy the contents of the old buffer, waiting for that
+ * copy to complete using our fences before proceeding
+ */
+ switch (buffer_type) {
+ case dri3_buffer_back:
+ if (buffer) {
+ if (!buffer->linear_buffer) {
+ dri3_fence_reset(c, new_buffer);
+ dri3_fence_await(c, buffer);
+ dri3_copy_area(c,
+ buffer->pixmap,
+ new_buffer->pixmap,
+ dri3_drawable_gc(priv),
+ 0, 0, 0, 0, priv->width, priv->height);
+ dri3_fence_trigger(c, new_buffer);
+ } else if ((&pcp->base != &dummyContext) && pcp->base.psc == &psc->base) {
+ psc->image->blitImage(pcp->driContext,
+ new_buffer->image,
+ buffer->image,
+ 0, 0, priv->width,
+ priv->height,
+ 0, 0, priv->width,
+ priv->height, 0);
+ }
+ dri3_free_render_buffer(priv, buffer);
+ }
+ break;
+ case dri3_buffer_front:
+ dri3_fence_reset(c, new_buffer);
+ dri3_copy_area(c,
+ priv->base.xDrawable,
+ new_buffer->pixmap,
+ dri3_drawable_gc(priv),
+ 0, 0, 0, 0, priv->width, priv->height);
+ dri3_fence_trigger(c, new_buffer);
+
+ if (new_buffer->linear_buffer && (&pcp->base != &dummyContext) && pcp->base.psc == &psc->base) {
+ dri3_fence_await(c, new_buffer);
+ psc->image->blitImage(pcp->driContext,
+ new_buffer->image,
+ new_buffer->linear_buffer,
+ 0, 0, priv->width,
+ priv->height,
+ 0, 0, priv->width,
+ priv->height, 0);
+ }
+ break;
+ }
+ buffer = new_buffer;
+ buffer->buffer_type = buffer_type;
+ priv->buffers[buf_id] = buffer;
+ }
+ dri3_fence_await(c, buffer);
+
+ /* Return the requested buffer */
+ return buffer;
+}
+
+/** dri3_free_buffers
+ *
+ * Free the front bufffer or all of the back buffers. Used
+ * when the application changes which buffers it needs
+ */
static void
-dri_set_background_context(void *loaderPrivate)
+dri3_free_buffers(__DRIdrawable *driDrawable,
+ enum dri3_buffer_type buffer_type,
+ void *loaderPrivate)
{
- struct dri3_context *pcp = (struct dri3_context *)loaderPrivate;
- __glXSetCurrentContext(&pcp->base);
+ struct dri3_drawable *priv = loaderPrivate;
+ struct dri3_buffer *buffer;
+ int first_id;
+ int n_id;
+ int buf_id;
+
+ switch (buffer_type) {
+ case dri3_buffer_back:
+ first_id = DRI3_BACK_ID(0);
+ n_id = DRI3_MAX_BACK;
+ break;
+ case dri3_buffer_front:
+ first_id = DRI3_FRONT_ID;
+ n_id = 1;
+ }
+
+ for (buf_id = first_id; buf_id < first_id + n_id; buf_id++) {
+ buffer = priv->buffers[buf_id];
+ if (buffer) {
+ dri3_free_render_buffer(priv, buffer);
+ priv->buffers[buf_id] = NULL;
+ }
+ }
+}
+
+/** dri3_get_buffers
+ *
+ * The published buffer allocation API.
+ * Returns all of the necessary buffers, allocating
+ * as needed.
+ */
+static int
+dri3_get_buffers(__DRIdrawable *driDrawable,
+ unsigned int format,
+ uint32_t *stamp,
+ void *loaderPrivate,
+ uint32_t buffer_mask,
+ struct __DRIimageList *buffers)
+{
+ struct dri3_drawable *priv = loaderPrivate;
+ struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc;
+ struct dri3_buffer *front, *back;
+
+ buffers->image_mask = 0;
+ buffers->front = NULL;
+ buffers->back = NULL;
+
+ front = NULL;
+ back = NULL;
+
+ if (!dri3_update_drawable(driDrawable, loaderPrivate))
+ return false;
+
+ /* pixmaps always have front buffers */
+ if (priv->is_pixmap)
+ buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
+
+ if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
+ /* All pixmaps are owned by the server gpu.
+ * When we use a different gpu, we can't use the pixmap
+ * as buffer since it is potentially tiled a way
+ * our device can't understand. In this case, use
+ * a fake front buffer. Hopefully the pixmap
+ * content will get synced with the fake front
+ * buffer.
+ */
+ if (priv->is_pixmap && !psc->is_different_gpu)
+ front = dri3_get_pixmap_buffer(driDrawable,
+ format,
+ dri3_buffer_front,
+ loaderPrivate);
+ else
+ front = dri3_get_buffer(driDrawable,
+ format,
+ dri3_buffer_front,
+ loaderPrivate);
+
+ if (!front)
+ return false;
+ } else {
+ dri3_free_buffers(driDrawable, dri3_buffer_front, loaderPrivate);
+ priv->have_fake_front = 0;
+ }
+
+ if (buffer_mask & __DRI_IMAGE_BUFFER_BACK) {
+ back = dri3_get_buffer(driDrawable,
+ format,
+ dri3_buffer_back,
+ loaderPrivate);
+ if (!back)
+ return false;
+ priv->have_back = 1;
+ } else {
+ dri3_free_buffers(driDrawable, dri3_buffer_back, loaderPrivate);
+ priv->have_back = 0;
+ }
+
+ if (front) {
+ buffers->image_mask |= __DRI_IMAGE_BUFFER_FRONT;
+ buffers->front = front->image;
+ priv->have_fake_front = psc->is_different_gpu || !priv->is_pixmap;
+ }
+
+ if (back) {
+ buffers->image_mask |= __DRI_IMAGE_BUFFER_BACK;
+ buffers->back = back->image;
+ }
+
+ priv->stamp = stamp;
+
+ return true;
}
/* The image loader extension record for DRI3
@@ -514,7 +1496,7 @@ dri_set_background_context(void *loaderPrivate)
static const __DRIimageLoaderExtension imageLoaderExtension = {
.base = { __DRI_IMAGE_LOADER, 1 },
- .getBuffers = loader_dri3_get_buffers,
+ .getBuffers = dri3_get_buffers,
.flushFrontBuffer = dri3_flush_front_buffer,
};
@@ -522,16 +1504,10 @@ const __DRIuseInvalidateExtension dri3UseInvalidate = {
.base = { __DRI_USE_INVALIDATE, 1 }
};
-static const __DRIbackgroundCallableExtension driBackgroundCallable = {
- .base = { __DRI_BACKGROUND_CALLABLE, 1 },
-
- .setBackgroundContext = dri_set_background_context,
-};
-
static const __DRIextension *loader_extensions[] = {
&imageLoaderExtension.base,
+ &systemTimeExtension.base,
&dri3UseInvalidate.base,
- &driBackgroundCallable.base,
NULL
};
@@ -543,25 +1519,172 @@ static int64_t
dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
int64_t remainder, Bool flush)
{
+ struct dri3_context *pcp = (struct dri3_context *) __glXGetCurrentContext();
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
- unsigned flags = __DRI2_FLUSH_DRAWABLE;
+ struct dri3_screen *psc = (struct dri3_screen *) priv->base.psc;
+ Display *dpy = priv->base.psc->dpy;
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ struct dri3_buffer *back;
+ int64_t ret = 0;
+ uint32_t options = XCB_PRESENT_OPTION_NONE;
+ unsigned flags = __DRI2_FLUSH_DRAWABLE;
if (flush)
flags |= __DRI2_FLUSH_CONTEXT;
+ dri3_flush(psc, priv, flags, __DRI2_THROTTLE_SWAPBUFFER);
+
+ back = priv->buffers[DRI3_BACK_ID(priv->cur_back)];
+ if (psc->is_different_gpu && back) {
+ /* Update the linear buffer before presenting the pixmap */
+ psc->image->blitImage(pcp->driContext,
+ back->linear_buffer,
+ back->image,
+ 0, 0, back->width,
+ back->height,
+ 0, 0, back->width,
+ back->height, __BLIT_FLAG_FLUSH);
+ /* Update the fake front */
+ if (priv->have_fake_front)
+ psc->image->blitImage(pcp->driContext,
+ priv->buffers[DRI3_FRONT_ID]->image,
+ back->image,
+ 0, 0, priv->width,
+ priv->height,
+ 0, 0, priv->width,
+ priv->height, __BLIT_FLAG_FLUSH);
+ }
+
+ dri3_flush_present_events(priv);
+
+ if (back && !priv->is_pixmap) {
+ dri3_fence_reset(c, back);
- return loader_dri3_swap_buffers_msc(&priv->loader_drawable,
- target_msc, divisor, remainder,
- flags, false);
+ /* Compute when we want the frame shown by taking the last known successful
+ * MSC and adding in a swap interval for each outstanding swap request.
+ * target_msc=divisor=remainder=0 means "Use glXSwapBuffers() semantic"
+ */
+ ++priv->send_sbc;
+ if (target_msc == 0 && divisor == 0 && remainder == 0)
+ target_msc = priv->msc + priv->swap_interval * (priv->send_sbc - priv->recv_sbc);
+ else if (divisor == 0 && remainder > 0) {
+ /* From the GLX_OML_sync_control spec:
+ *
+ * "If <divisor> = 0, the swap will occur when MSC becomes
+ * greater than or equal to <target_msc>."
+ *
+ * Note that there's no mention of the remainder. The Present extension
+ * throws BadValue for remainder != 0 with divisor == 0, so just drop
+ * the passed in value.
+ */
+ remainder = 0;
+ }
+
+ /* From the GLX_EXT_swap_control spec:
+ *
+ * "If <interval> is set to a value of 0, buffer swaps are not
+ * synchronized to a video frame."
+ *
+ * Implementation note: It is possible to enable triple buffering behaviour
+ * by not using XCB_PRESENT_OPTION_ASYNC, but this should not be the default.
+ */
+ if (priv->swap_interval == 0)
+ options |= XCB_PRESENT_OPTION_ASYNC;
+
+ back->busy = 1;
+ back->last_swap = priv->send_sbc;
+ xcb_present_pixmap(c,
+ priv->base.xDrawable,
+ back->pixmap,
+ (uint32_t) priv->send_sbc,
+ 0, /* valid */
+ 0, /* update */
+ 0, /* x_off */
+ 0, /* y_off */
+ None, /* target_crtc */
+ None,
+ back->sync_fence,
+ options,
+ target_msc,
+ divisor,
+ remainder, 0, NULL);
+ ret = (int64_t) priv->send_sbc;
+
+ /* If there's a fake front, then copy the source back buffer
+ * to the fake front to keep it up to date. This needs
+ * to reset the fence and make future users block until
+ * the X server is done copying the bits
+ */
+ if (priv->have_fake_front && !psc->is_different_gpu) {
+ dri3_fence_reset(c, priv->buffers[DRI3_FRONT_ID]);
+ dri3_copy_area(c,
+ back->pixmap,
+ priv->buffers[DRI3_FRONT_ID]->pixmap,
+ dri3_drawable_gc(priv),
+ 0, 0, 0, 0, priv->width, priv->height);
+ dri3_fence_trigger(c, priv->buffers[DRI3_FRONT_ID]);
+ }
+ xcb_flush(c);
+ if (priv->stamp)
+ ++(*priv->stamp);
+ }
+
+ (*psc->f->invalidate)(priv->driDrawable);
+
+ return ret;
}
static int
dri3_get_buffer_age(__GLXDRIdrawable *pdraw)
{
- struct dri3_drawable *priv = (struct dri3_drawable *)pdraw;
+ xcb_connection_t *c = XGetXCBConnection(pdraw->psc->dpy);
+ struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
+ int back_id = DRI3_BACK_ID(dri3_find_back(c, priv));
+
+ if (back_id < 0 || !priv->buffers[back_id])
+ return 0;
- return loader_dri3_query_buffer_age(&priv->loader_drawable);
+ if (priv->buffers[back_id]->last_swap != 0)
+ return priv->send_sbc - priv->buffers[back_id]->last_swap + 1;
+ else
+ return 0;
}
+/** dri3_open
+ *
+ * Wrapper around xcb_dri3_open
+ */
+static int
+dri3_open(Display *dpy,
+ Window root,
+ CARD32 provider)
+{
+ xcb_dri3_open_cookie_t cookie;
+ xcb_dri3_open_reply_t *reply;
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ int fd;
+
+ cookie = xcb_dri3_open(c,
+ root,
+ provider);
+
+ reply = xcb_dri3_open_reply(c, cookie, NULL);
+ if (!reply)
+ return -1;
+
+ if (reply->nfd != 1) {
+ free(reply);
+ return -1;
+ }
+
+ fd = xcb_dri3_open_reply_fds(c, reply)[0];
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+
+ free(reply);
+
+ return fd;
+}
+
+
/** dri3_destroy_screen
*/
static void
@@ -583,8 +1706,6 @@ dri3_destroy_screen(struct glx_screen *base)
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;
@@ -606,7 +1727,8 @@ dri3_set_swap_interval(__GLXDRIdrawable *pdraw, int interval)
break;
}
- loader_dri3_set_swap_interval(&priv->loader_drawable, interval);
+ priv->swap_interval = interval;
+ dri3_update_num_back(priv);
return 0;
}
@@ -618,8 +1740,6 @@ dri3_set_swap_interval(__GLXDRIdrawable *pdraw, int interval)
static int
dri3_get_swap_interval(__GLXDRIdrawable *pdraw)
{
- assert(pdraw != NULL);
-
struct dri3_drawable *priv = (struct dri3_drawable *) pdraw;
return priv->swap_interval;
@@ -639,14 +1759,14 @@ dri3_bind_tex_image(Display * dpy,
if (pdraw != NULL) {
psc = (struct dri3_screen *) base->psc;
- (*psc->f->invalidate)(pdraw->loader_drawable.dri_drawable);
+ (*psc->f->invalidate)(pdraw->driDrawable);
XSync(dpy, false);
(*psc->texBuffer->setTexBuffer2) (pcp->driContext,
pdraw->base.textureTarget,
pdraw->base.textureFormat,
- pdraw->loader_drawable.dri_drawable);
+ pdraw->driDrawable);
}
}
@@ -666,7 +1786,7 @@ dri3_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
psc->texBuffer->releaseTexBuffer != NULL)
(*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
pdraw->base.textureTarget,
- pdraw->loader_drawable.dri_drawable);
+ pdraw->driDrawable);
}
}
@@ -680,8 +1800,6 @@ static const struct glx_context_vtable dri3_context_vtable = {
.bind_tex_image = dri3_bind_tex_image,
.release_tex_image = dri3_release_tex_image,
.get_proc_address = NULL,
- .interop_query_device_info = dri3_interop_query_device_info,
- .interop_export_object = dri3_interop_export_object
};
/** dri3_bind_extensions
@@ -709,14 +1827,9 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv,
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
- if ((mask & ((1 << __DRI_API_GLES) |
- (1 << __DRI_API_GLES2) |
- (1 << __DRI_API_GLES3))) != 0) {
- __glXEnableDirectExtension(&psc->base,
- "GLX_EXT_create_context_es_profile");
+ if ((mask & (1 << __DRI_API_GLES2)) != 0)
__glXEnableDirectExtension(&psc->base,
"GLX_EXT_create_context_es2_profile");
- }
for (i = 0; extensions[i]; i++) {
/* when on a different gpu than the server, the server pixmaps
@@ -748,9 +1861,6 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv,
psc->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
__glXEnableDirectExtension(&psc->base, "GLX_MESA_query_renderer");
}
-
- if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0)
- psc->interop = (__DRI2interopExtension*)extensions[i];
}
}
@@ -798,7 +1908,7 @@ dri3_create_screen(int screen, struct glx_display * priv)
return NULL;
}
- psc->fd = loader_dri3_open(c, RootWindow(priv->dpy, screen), None);
+ psc->fd = dri3_open(priv->dpy, RootWindow(priv->dpy, screen), None);
if (psc->fd < 0) {
int conn_error = xcb_connection_has_error(c);
@@ -815,7 +1925,7 @@ dri3_create_screen(int screen, struct glx_display * priv)
psc->fd = loader_get_user_preferred_fd(psc->fd, &psc->is_different_gpu);
deviceName = NULL;
- driverName = loader_get_driver_for_fd(psc->fd);
+ driverName = loader_get_driver_for_fd(psc->fd, 0);
if (!driverName) {
ErrorMessageF("No driver found\n");
goto handle_error;
@@ -890,13 +2000,6 @@ dri3_create_screen(int screen, struct glx_display * priv)
goto handle_error;
}
- psc->loader_dri3_ext.core = psc->core;
- psc->loader_dri3_ext.image_driver = psc->image_driver;
- psc->loader_dri3_ext.flush = psc->f;
- psc->loader_dri3_ext.tex_buffer = psc->texBuffer;
- psc->loader_dri3_ext.image = psc->image;
- psc->loader_dri3_ext.config = psc->config;
-
configs = driConvertConfigs(psc->core, psc->base.configs, driver_configs);
visuals = driConvertConfigs(psc->core, psc->base.visuals, driver_configs);
diff --git a/lib/mesa/src/glx/dri_glx.c b/lib/mesa/src/glx/dri_glx.c
index ae7e11c17..d08775193 100644
--- a/lib/mesa/src/glx/dri_glx.c
+++ b/lib/mesa/src/glx/dri_glx.c
@@ -148,7 +148,7 @@ driGetDriverName(Display * dpy, int scrNum, char **driverName)
* The returned char pointer points to a static array that will be
* overwritten by subsequent calls.
*/
-_GLX_PUBLIC const char *
+_X_EXPORT const char *
glXGetScreenDriver(Display * dpy, int scrNum)
{
static char ret[32];
@@ -178,7 +178,7 @@ glXGetScreenDriver(Display * dpy, int scrNum)
*
* Note: The driver remains opened after this function returns.
*/
-_GLX_PUBLIC const char *
+_X_EXPORT const char *
glXGetDriverConfig(const char *driverName)
{
void *handle = driOpenDriver(driverName);
@@ -199,6 +199,8 @@ glXGetDriverConfig(const char *driverName)
return dlsym(handle, "__driConfigOptions");
}
+#ifdef XDAMAGE_1_1_INTERFACE
+
static GLboolean
has_damage_post(Display * dpy)
{
@@ -272,6 +274,8 @@ static const __DRIdamageExtension damageExtension = {
.reportDamage = __glXReportDamage,
};
+#endif
+
static GLboolean
__glXDRIGetDrawableInfo(__DRIdrawable * drawable,
unsigned int *index, unsigned int *stamp,
diff --git a/lib/mesa/src/glx/drisw_glx.c b/lib/mesa/src/glx/drisw_glx.c
index 110b7f8d9..749ceb08a 100644
--- a/lib/mesa/src/glx/drisw_glx.c
+++ b/lib/mesa/src/glx/drisw_glx.c
@@ -177,9 +177,9 @@ swrastPutImage(__DRIdrawable * draw, int op,
}
static void
-swrastGetImage2(__DRIdrawable * read,
- int x, int y, int w, int h, int stride,
- char *data, void *loaderPrivate)
+swrastGetImage(__DRIdrawable * read,
+ int x, int y, int w, int h,
+ char *data, void *loaderPrivate)
{
struct drisw_drawable *prp = loaderPrivate;
__GLXDRIdrawable *pread = &(prp->base);
@@ -193,32 +193,24 @@ swrastGetImage2(__DRIdrawable * read,
ximage->data = data;
ximage->width = w;
ximage->height = h;
- ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32);
+ ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32);
XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
ximage->data = NULL;
}
-static void
-swrastGetImage(__DRIdrawable * read,
- int x, int y, int w, int h,
- char *data, void *loaderPrivate)
-{
- swrastGetImage2(read, x, y, w, h, 0, data, loaderPrivate);
-}
-
static const __DRIswrastLoaderExtension swrastLoaderExtension = {
- .base = {__DRI_SWRAST_LOADER, 3 },
+ .base = {__DRI_SWRAST_LOADER, 2 },
.getDrawableInfo = swrastGetDrawableInfo,
.putImage = swrastPutImage,
.getImage = swrastGetImage,
.putImage2 = swrastPutImage2,
- .getImage2 = swrastGetImage2,
};
static const __DRIextension *loader_extensions[] = {
+ &systemTimeExtension.base,
&swrastLoaderExtension.base,
NULL
};
@@ -622,11 +614,9 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context");
__glXEnableDirectExtension(&psc->base, "GLX_ARB_create_context_profile");
- /* DRISW version >= 2 implies support for OpenGL ES.
+ /* DRISW version >= 2 implies support for OpenGL ES 2.0.
*/
__glXEnableDirectExtension(&psc->base,
- "GLX_EXT_create_context_es_profile");
- __glXEnableDirectExtension(&psc->base,
"GLX_EXT_create_context_es2_profile");
}
diff --git a/lib/mesa/src/glx/glx_pbuffer.c b/lib/mesa/src/glx/glx_pbuffer.c
index 933b5d9ec..231ab2060 100644
--- a/lib/mesa/src/glx/glx_pbuffer.c
+++ b/lib/mesa/src/glx/glx_pbuffer.c
@@ -328,7 +328,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
* the calling thread's current context a GLXBadDrawable error is
* generated."
*/
- if (pdraw == NULL || gc == &dummyContext || gc->currentDpy != dpy ||
+ if (pdraw == NULL || gc == NULL || gc->currentDpy != dpy ||
(gc->currentDrawable != drawable &&
gc->currentReadable != drawable)) {
__glXSendError(dpy, GLXBadDrawable, drawable,
@@ -679,7 +679,7 @@ DestroyPbuffer(Display * dpy, GLXDrawable drawable)
/**
* Create a new pbuffer.
*/
-_GLX_PUBLIC GLXPbufferSGIX
+_X_EXPORT GLXPbufferSGIX
glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config,
unsigned int width, unsigned int height,
int *attrib_list)
@@ -694,7 +694,7 @@ glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config,
/**
* Create a new pbuffer.
*/
-_GLX_PUBLIC GLXPbuffer
+_X_EXPORT GLXPbuffer
glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list)
{
int i, width, height;
@@ -769,7 +769,7 @@ glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list)
/**
* Destroy an existing pbuffer.
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf)
{
#ifdef GLX_USE_APPLEGL
@@ -785,7 +785,7 @@ glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf)
/**
* Query an attribute of a drawable.
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXQueryDrawable(Display * dpy, GLXDrawable drawable,
int attribute, unsigned int *value)
{
@@ -834,7 +834,7 @@ glXQueryDrawable(Display * dpy, GLXDrawable drawable,
/**
* Query an attribute of a pbuffer.
*/
-_GLX_PUBLIC int
+_X_EXPORT int
glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable,
int attribute, unsigned int *value)
{
@@ -845,7 +845,7 @@ glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable,
/**
* Select the event mask for a drawable.
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask)
{
#ifdef GLX_USE_APPLEGL
@@ -878,7 +878,7 @@ glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask)
/**
* Get the selected event mask for a drawable.
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
{
#ifdef GLX_USE_APPLEGL
@@ -901,7 +901,7 @@ glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
__glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes,
true);
#else
- unsigned int value = 0;
+ unsigned int value;
/* The non-sense with value is required because on LP64 platforms
@@ -915,7 +915,7 @@ glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
}
-_GLX_PUBLIC GLXPixmap
+_X_EXPORT GLXPixmap
glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
const int *attrib_list)
{
@@ -935,7 +935,7 @@ glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
}
-_GLX_PUBLIC GLXWindow
+_X_EXPORT GLXWindow
glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
const int *attrib_list)
{
@@ -970,7 +970,7 @@ glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
}
-_GLX_PUBLIC void
+_X_EXPORT void
glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
{
WARN_ONCE_GLX_1_3(dpy, __func__);
@@ -983,7 +983,7 @@ glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
}
-_GLX_PUBLIC void
+_X_EXPORT void
glXDestroyWindow(Display * dpy, GLXWindow win)
{
WARN_ONCE_GLX_1_3(dpy, __func__);
@@ -992,18 +992,20 @@ glXDestroyWindow(Display * dpy, GLXWindow win)
#endif
}
-_GLX_PUBLIC
+#ifndef GLX_USE_APPLEGL
+_X_EXPORT
GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
(Display * dpy, GLXPbufferSGIX pbuf),
(dpy, pbuf), glXDestroyPbuffer)
-_GLX_PUBLIC
+_X_EXPORT
GLX_ALIAS_VOID(glXSelectEventSGIX,
(Display * dpy, GLXDrawable drawable,
unsigned long mask), (dpy, drawable, mask), glXSelectEvent)
-_GLX_PUBLIC
+_X_EXPORT
GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
(Display * dpy, GLXDrawable drawable,
unsigned long *mask), (dpy, drawable, mask),
glXGetSelectedEvent)
+#endif
diff --git a/lib/mesa/src/glx/glxclient.h b/lib/mesa/src/glx/glxclient.h
index 0d29e5635..2776b44a9 100644
--- a/lib/mesa/src/glx/glxclient.h
+++ b/lib/mesa/src/glx/glxclient.h
@@ -56,16 +56,6 @@
#include "glxextensions.h"
-#if defined(USE_LIBGLVND)
-#define _GLX_PUBLIC _X_HIDDEN
-#else
-#define _GLX_PUBLIC _X_EXPORT
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define GLX_MAJOR_VERSION 1 /* current version numbers */
#define GLX_MINOR_VERSION 4
@@ -154,15 +144,11 @@ struct __GLXDRIdrawableRec
extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *driCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
-extern __GLXDRIdisplay *dri3_create_display(Display * dpy);
-extern __GLXDRIdisplay *driwindowsCreateDisplay(Display * dpy);
-
-/*
-**
-*/
extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable);
+extern __GLXDRIdisplay *dri3_create_display(Display * dpy);
+
/*
** Functions to obtain driver configuration information from a direct
** rendering client application
@@ -222,10 +208,6 @@ typedef struct __GLXattributeMachineRec
__GLXattribute **stackPointer;
} __GLXattributeMachine;
-struct mesa_glinterop_device_info;
-struct mesa_glinterop_export_in;
-struct mesa_glinterop_export_out;
-
struct glx_context_vtable {
void (*destroy)(struct glx_context *ctx);
int (*bind)(struct glx_context *context, struct glx_context *old,
@@ -240,11 +222,6 @@ struct glx_context_vtable {
int buffer, const int *attrib_list);
void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer);
void * (*get_proc_address)(const char *symbol);
- int (*interop_query_device_info)(struct glx_context *ctx,
- struct mesa_glinterop_device_info *out);
- int (*interop_export_object)(struct glx_context *ctx,
- struct mesa_glinterop_export_in *in,
- struct mesa_glinterop_export_out *out);
};
/**
@@ -610,9 +587,6 @@ struct glx_display
__GLXDRIdisplay *dri2Display;
__GLXDRIdisplay *dri3Display;
#endif
-#ifdef GLX_USE_WINDOWSGL
- __GLXDRIdisplay *windowsdriDisplay;
-#endif
};
struct glx_drawable {
@@ -841,8 +815,4 @@ indirect_create_context_attribs(struct glx_screen *base,
const uint32_t *attribs,
unsigned *error);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* !__GLX_client_h__ */
diff --git a/lib/mesa/src/glx/glxcmds.c b/lib/mesa/src/glx/glxcmds.c
index a3af417a6..93e8db5a3 100644
--- a/lib/mesa/src/glx/glxcmds.c
+++ b/lib/mesa/src/glx/glxcmds.c
@@ -54,7 +54,6 @@
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/glx.h>
-#include "GL/mesa_glinterop.h"
static const char __glXGLXClientVendorName[] = "Mesa Project and SGI";
static const char __glXGLXClientVersion[] = "1.4";
@@ -374,7 +373,7 @@ CreateContext(Display *dpy, int generic_id, struct glx_config *config,
return (GLXContext) gc;
}
-_GLX_PUBLIC GLXContext
+_X_EXPORT GLXContext
glXCreateContext(Display * dpy, XVisualInfo * vis,
GLXContext shareList, Bool allowDirect)
{
@@ -451,7 +450,7 @@ glx_send_destroy_context(Display *dpy, XID xid)
** Destroy the named context
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXDestroyContext(Display * dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
@@ -479,7 +478,7 @@ glXDestroyContext(Display * dpy, GLXContext ctx)
/*
** Return the major and minor version #s for the GLX extension
*/
-_GLX_PUBLIC Bool
+_X_EXPORT Bool
glXQueryVersion(Display * dpy, int *major, int *minor)
{
struct glx_display *priv;
@@ -499,7 +498,7 @@ glXQueryVersion(Display * dpy, int *major, int *minor)
/*
** Query the existence of the GLX extension
*/
-_GLX_PUBLIC Bool
+_X_EXPORT Bool
glXQueryExtension(Display * dpy, int *errorBase, int *eventBase)
{
int major_op, erb, evb;
@@ -519,12 +518,12 @@ glXQueryExtension(Display * dpy, int *errorBase, int *eventBase)
** Put a barrier in the token stream that forces the GL to finish its
** work before X can proceed.
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXWaitGL(void)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc != &dummyContext && gc->vtable->wait_gl)
+ if (gc && gc->vtable->wait_gl)
gc->vtable->wait_gl(gc);
}
@@ -532,21 +531,21 @@ glXWaitGL(void)
** Put a barrier in the token stream that forces X to finish its
** work before GL can proceed.
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXWaitX(void)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc != &dummyContext && gc->vtable->wait_x)
+ if (gc && gc->vtable->wait_x)
gc->vtable->wait_x(gc);
}
-_GLX_PUBLIC void
+_X_EXPORT void
glXUseXFont(Font font, int first, int count, int listBase)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc != &dummyContext && gc->vtable->use_x_font)
+ if (gc && gc->vtable->use_x_font)
gc->vtable->use_x_font(gc, font, first, count, listBase);
}
@@ -556,7 +555,7 @@ glXUseXFont(Font font, int first, int count, int listBase)
** Copy the source context to the destination context using the
** attribute "mask".
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXCopyContext(Display * dpy, GLXContext source_user,
GLXContext dest_user, unsigned long mask)
{
@@ -657,7 +656,7 @@ __glXIsDirect(Display * dpy, GLXContextID contextID)
* \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with
* the GLX protocol here at all?
*/
-_GLX_PUBLIC Bool
+_X_EXPORT Bool
glXIsDirect(Display * dpy, GLXContext gc_user)
{
struct glx_context *gc = (struct glx_context *) gc_user;
@@ -675,7 +674,7 @@ glXIsDirect(Display * dpy, GLXContext gc_user)
#endif
}
-_GLX_PUBLIC GLXPixmap
+_X_EXPORT GLXPixmap
glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
{
#ifdef GLX_USE_APPLEGL
@@ -775,7 +774,7 @@ glXCreateGLXPixmap(Display * dpy, XVisualInfo * vis, Pixmap pixmap)
/*
** Destroy the named pixmap
*/
-_GLX_PUBLIC void
+_X_EXPORT void
glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
{
#ifdef GLX_USE_APPLEGL
@@ -815,12 +814,12 @@ glXDestroyGLXPixmap(Display * dpy, GLXPixmap glxpixmap)
#endif /* GLX_USE_APPLEGL */
}
-_GLX_PUBLIC void
+_X_EXPORT void
glXSwapBuffers(Display * dpy, GLXDrawable drawable)
{
#ifdef GLX_USE_APPLEGL
struct glx_context * gc = __glXGetCurrentContext();
- if(gc != &DummyContext && apple_glx_is_current_drawable(dpy, gc->driContext, drawable)) {
+ if(gc && apple_glx_is_current_drawable(dpy, gc->driContext, drawable)) {
apple_glx_swap_buffers(gc->driContext);
} else {
__glXSendError(dpy, GLXBadCurrentWindow, 0, X_GLXSwapBuffers, false);
@@ -838,7 +837,7 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
if (pdraw != NULL) {
- Bool flush = gc != &dummyContext && drawable == gc->currentDrawable;
+ Bool flush = gc && drawable == gc->currentDrawable;
(*pdraw->psc->driScreen->swapBuffers)(pdraw, 0, 0, 0, flush);
return;
@@ -855,7 +854,7 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
** The calling thread may or may not have a current context. If it
** does, send the context tag so the server can do a flush.
*/
- if ((gc != &dummyContext) && (dpy == gc->currentDpy) &&
+ if ((gc != NULL) && (dpy == gc->currentDpy) &&
((drawable == gc->currentDrawable)
|| (drawable == gc->currentReadable))) {
tag = gc->currentContextTag;
@@ -875,7 +874,7 @@ glXSwapBuffers(Display * dpy, GLXDrawable drawable)
** Return configuration information for the given display, screen and
** visual combination.
*/
-_GLX_PUBLIC int
+_X_EXPORT int
glXGetConfig(Display * dpy, XVisualInfo * vis, int attribute,
int *value_return)
{
@@ -1162,8 +1161,8 @@ fbconfig_compare(struct glx_config **a, struct glx_config **b)
/**
* Selects and sorts a subset of the supplied configs based on the attributes.
- * This function forms to basis of \c glXChooseFBConfig and
- * \c glXChooseFBConfigSGIX.
+ * This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig,
+ * and \c glXChooseFBConfigSGIX.
*
* \param configs Array of pointers to possible configs. The elements of
* this array that do not meet the criteria will be set to
@@ -1171,16 +1170,20 @@ fbconfig_compare(struct glx_config **a, struct glx_config **b)
* the various visual / FBConfig selection rules.
* \param num_configs Number of elements in the \c configs array.
* \param attribList Attributes used select from \c configs. This array is
- * terminated by a \c None tag. The array is of the form
- * expected by \c glXChooseFBConfig (where every tag has a
- * value).
+ * terminated by a \c None tag. The array can either take
+ * the form expected by \c glXChooseVisual (where boolean
+ * tags do not have a value) or by \c glXChooseFBConfig
+ * (where every tag has a value).
+ * \param fbconfig_style_tags Selects whether \c attribList is in
+ * \c glXChooseVisual style or
+ * \c glXChooseFBConfig style.
* \returns The number of valid elements left in \c configs.
*
- * \sa glXChooseFBConfig, glXChooseFBConfigSGIX
+ * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
*/
static int
-choose_fbconfig(struct glx_config ** configs, int num_configs,
- const int *attribList)
+choose_visual(struct glx_config ** configs, int num_configs,
+ const int *attribList, GLboolean fbconfig_style_tags)
{
struct glx_config test_config;
int base;
@@ -1192,10 +1195,10 @@ choose_fbconfig(struct glx_config ** configs, int num_configs,
* list.
*/
- init_fbconfig_for_chooser(&test_config, GL_TRUE);
+ init_fbconfig_for_chooser(&test_config, fbconfig_style_tags);
__glXInitializeVisualConfigFromTags(&test_config, 512,
(const INT32 *) attribList,
- GL_TRUE, GL_TRUE);
+ GL_TRUE, fbconfig_style_tags);
base = 0;
for (i = 0; i < num_configs; i++) {
@@ -1230,7 +1233,7 @@ choose_fbconfig(struct glx_config ** configs, int num_configs,
** Return the visual that best matches the template. Return None if no
** visual matches the template.
*/
-_GLX_PUBLIC XVisualInfo *
+_X_EXPORT XVisualInfo *
glXChooseVisual(Display * dpy, int screen, int *attribList)
{
XVisualInfo *visualList = NULL;
@@ -1296,7 +1299,7 @@ glXChooseVisual(Display * dpy, int screen, int *attribList)
}
-_GLX_PUBLIC const char *
+_X_EXPORT const char *
glXQueryExtensionsString(Display * dpy, int screen)
{
struct glx_screen *psc;
@@ -1325,7 +1328,7 @@ glXQueryExtensionsString(Display * dpy, int screen)
return psc->effectiveGLXexts;
}
-_GLX_PUBLIC const char *
+_X_EXPORT const char *
glXGetClientString(Display * dpy, int name)
{
(void) dpy;
@@ -1342,7 +1345,7 @@ glXGetClientString(Display * dpy, int name)
}
}
-_GLX_PUBLIC const char *
+_X_EXPORT const char *
glXQueryServerString(Display * dpy, int screen, int name)
{
struct glx_screen *psc;
@@ -1380,21 +1383,21 @@ glXQueryServerString(Display * dpy, int screen, int name)
** EXT_import_context
*/
-_GLX_PUBLIC Display *
+_X_EXPORT Display *
glXGetCurrentDisplay(void)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == &dummyContext)
+ if (NULL == gc)
return NULL;
return gc->currentDpy;
}
-_GLX_PUBLIC
+_X_EXPORT
GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
glXGetCurrentDisplay)
#ifndef GLX_USE_APPLEGL
-_GLX_PUBLIC GLXContext
+_X_EXPORT GLXContext
glXImportContextEXT(Display *dpy, GLXContextID contextID)
{
struct glx_display *priv = __glXInitialize(dpy);
@@ -1533,7 +1536,7 @@ glXImportContextEXT(Display *dpy, GLXContextID contextID)
#endif
-_GLX_PUBLIC int
+_X_EXPORT int
glXQueryContext(Display * dpy, GLXContext ctx_user, int attribute, int *value)
{
struct glx_context *ctx = (struct glx_context *) ctx_user;
@@ -1560,19 +1563,19 @@ glXQueryContext(Display * dpy, GLXContext ctx_user, int attribute, int *value)
return Success;
}
-_GLX_PUBLIC
+_X_EXPORT
GLX_ALIAS(int, glXQueryContextInfoEXT,
(Display * dpy, GLXContext ctx, int attribute, int *value),
(dpy, ctx, attribute, value), glXQueryContext)
-_GLX_PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx_user)
+_X_EXPORT GLXContextID glXGetContextIDEXT(const GLXContext ctx_user)
{
struct glx_context *ctx = (struct glx_context *) ctx_user;
return (ctx == NULL) ? None : ctx->xid;
}
-_GLX_PUBLIC void
+_X_EXPORT void
glXFreeContextEXT(Display *dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
@@ -1597,7 +1600,7 @@ glXFreeContextEXT(Display *dpy, GLXContext ctx)
__glXUnlock();
}
-_GLX_PUBLIC GLXFBConfig *
+_X_EXPORT GLXFBConfig *
glXChooseFBConfig(Display * dpy, int screen,
const int *attribList, int *nitems)
{
@@ -1609,7 +1612,7 @@ glXChooseFBConfig(Display * dpy, int screen,
glXGetFBConfigs(dpy, screen, &list_size);
if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) {
- list_size = choose_fbconfig(config_list, list_size, attribList);
+ list_size = choose_visual(config_list, list_size, attribList, GL_TRUE);
if (list_size == 0) {
free(config_list);
config_list = NULL;
@@ -1621,33 +1624,11 @@ glXChooseFBConfig(Display * dpy, int screen,
}
-_GLX_PUBLIC GLXContext
+_X_EXPORT GLXContext
glXCreateNewContext(Display * dpy, GLXFBConfig fbconfig,
int renderType, GLXContext shareList, Bool allowDirect)
{
struct glx_config *config = (struct glx_config *) fbconfig;
- struct glx_config **config_list;
- int list_size;
- unsigned i;
-
- if (!config) {
- __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateNewContext, false);
- return NULL;
- }
-
- config_list = (struct glx_config **)
- glXGetFBConfigs(dpy, config->screen, &list_size);
-
- for (i = 0; i < list_size; i++) {
- if (config_list[i] == config)
- break;
- }
- free(config_list);
-
- if (i == list_size) {
- __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateNewContext, false);
- return NULL;
- }
return CreateContext(dpy, config->fbconfigID, config, shareList,
allowDirect, X_GLXCreateNewContext, renderType,
@@ -1655,7 +1636,7 @@ glXCreateNewContext(Display * dpy, GLXFBConfig fbconfig,
}
-_GLX_PUBLIC GLXDrawable
+_X_EXPORT GLXDrawable
glXGetCurrentReadDrawable(void)
{
struct glx_context *gc = __glXGetCurrentContext();
@@ -1664,7 +1645,7 @@ glXGetCurrentReadDrawable(void)
}
-_GLX_PUBLIC GLXFBConfig *
+_X_EXPORT GLXFBConfig *
glXGetFBConfigs(Display * dpy, int screen, int *nelements)
{
struct glx_display *priv = __glXInitialize(dpy);
@@ -1675,7 +1656,7 @@ glXGetFBConfigs(Display * dpy, int screen, int *nelements)
*nelements = 0;
if (priv && (priv->screens != NULL)
- && (screen >= 0) && (screen < ScreenCount(dpy))
+ && (screen >= 0) && (screen <= ScreenCount(dpy))
&& (priv->screens[screen]->configs != NULL)
&& (priv->screens[screen]->configs->fbconfigID
!= (int) GLX_DONT_CARE)) {
@@ -1705,7 +1686,7 @@ glXGetFBConfigs(Display * dpy, int screen, int *nelements)
}
-_GLX_PUBLIC int
+_X_EXPORT int
glXGetFBConfigAttrib(Display * dpy, GLXFBConfig fbconfig,
int attribute, int *value)
{
@@ -1718,7 +1699,7 @@ glXGetFBConfigAttrib(Display * dpy, GLXFBConfig fbconfig,
}
-_GLX_PUBLIC XVisualInfo *
+_X_EXPORT XVisualInfo *
glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig fbconfig)
{
XVisualInfo visualTemplate;
@@ -1746,7 +1727,7 @@ __glXSwapIntervalSGI(int interval)
CARD32 *interval_ptr;
CARD8 opcode;
- if (gc == &dummyContext) {
+ if (gc == NULL) {
return GLX_BAD_CONTEXT;
}
@@ -1761,11 +1742,7 @@ __glXSwapIntervalSGI(int interval)
psc->driScreen->setSwapInterval) {
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
- /* Simply ignore the command if the GLX drawable has been destroyed but
- * the context is still bound.
- */
- if (pdraw)
- psc->driScreen->setSwapInterval(pdraw, interval);
+ psc->driScreen->setSwapInterval(pdraw, interval);
return 0;
}
#endif
@@ -1804,21 +1781,14 @@ __glXSwapIntervalMESA(unsigned int interval)
#ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext();
- if (gc != &dummyContext && gc->isDirect) {
+ if (gc != NULL && gc->isDirect) {
struct glx_screen *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
if (psc && psc->driScreen && psc->driScreen->setSwapInterval) {
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
-
- /* Simply ignore the command if the GLX drawable has been destroyed but
- * the context is still bound.
- */
- if (!pdraw)
- return 0;
-
- return psc->driScreen->setSwapInterval(pdraw, interval);
+ return psc->driScreen->setSwapInterval(pdraw, interval);
}
}
#endif
@@ -1833,15 +1803,14 @@ __glXGetSwapIntervalMESA(void)
#ifdef GLX_DIRECT_RENDERING
struct glx_context *gc = __glXGetCurrentContext();
- if (gc != &dummyContext && gc->isDirect) {
+ if (gc != NULL && gc->isDirect) {
struct glx_screen *psc;
psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen);
if (psc && psc->driScreen && psc->driScreen->getSwapInterval) {
__GLXDRIdrawable *pdraw =
GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
- if (pdraw)
- return psc->driScreen->getSwapInterval(pdraw);
+ return psc->driScreen->getSwapInterval(pdraw);
}
}
#endif
@@ -1864,7 +1833,7 @@ __glXGetVideoSyncSGI(unsigned int *count)
__GLXDRIdrawable *pdraw;
#endif
- if (gc == &dummyContext)
+ if (!gc)
return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -1906,7 +1875,7 @@ __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
if (divisor <= 0 || remainder < 0)
return GLX_BAD_VALUE;
- if (gc == &dummyContext)
+ if (!gc)
return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -1939,21 +1908,21 @@ __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
** GLX_functions table.
*/
-_GLX_PUBLIC
+_X_EXPORT
GLX_ALIAS(int, glXGetFBConfigAttribSGIX,
(Display * dpy, GLXFBConfigSGIX config, int attribute, int *value),
(dpy, config, attribute, value), glXGetFBConfigAttrib)
-_GLX_PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
+_X_EXPORT GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
(Display * dpy, int screen, int *attrib_list,
int *nelements), (dpy, screen, attrib_list, nelements),
glXChooseFBConfig)
-_GLX_PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
+_X_EXPORT GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
(Display * dpy, GLXFBConfigSGIX config),
(dpy, config), glXGetVisualFromFBConfig)
-_GLX_PUBLIC GLXPixmap
+_X_EXPORT GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display * dpy,
GLXFBConfigSGIX fbconfig,
Pixmap pixmap)
@@ -2006,7 +1975,7 @@ glXCreateGLXPixmapWithConfigSGIX(Display * dpy,
#endif
}
-_GLX_PUBLIC GLXContext
+_X_EXPORT GLXContext
glXCreateContextWithConfigSGIX(Display * dpy,
GLXFBConfigSGIX fbconfig, int renderType,
GLXContext shareList, Bool allowDirect)
@@ -2033,7 +2002,7 @@ glXCreateContextWithConfigSGIX(Display * dpy,
}
-_GLX_PUBLIC GLXFBConfigSGIX
+_X_EXPORT GLXFBConfigSGIX
glXGetFBConfigFromVisualSGIX(Display * dpy, XVisualInfo * vis)
{
struct glx_display *priv;
@@ -2219,7 +2188,7 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
struct glx_screen *psc = pdraw ? pdraw->psc : NULL;
#endif
- if (gc == &dummyContext) /* no GLX for this */
+ if (!gc) /* no GLX for this */
return -1;
#ifdef GLX_DIRECT_RENDERING
@@ -2349,7 +2318,7 @@ __glXReleaseBuffersMESA(Display * dpy, GLXDrawable d)
}
-_GLX_PUBLIC GLXPixmap
+_X_EXPORT GLXPixmap
glXCreateGLXPixmapMESA(Display * dpy, XVisualInfo * visual,
Pixmap pixmap, Colormap cmap)
{
@@ -2399,7 +2368,7 @@ __glXCopySubBufferMESA(Display * dpy, GLXDrawable drawable,
** does, send the context tag so the server can do a flush.
*/
gc = __glXGetCurrentContext();
- if ((gc != &dummyContext) && (dpy == gc->currentDpy) &&
+ if ((gc != NULL) && (dpy == gc->currentDpy) &&
((drawable == gc->currentDrawable) ||
(drawable == gc->currentReadable))) {
tag = gc->currentContextTag;
@@ -2438,7 +2407,7 @@ __glXBindTexImageEXT(Display * dpy,
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == &dummyContext || gc->vtable->bind_tex_image == NULL)
+ if (gc == NULL || gc->vtable->bind_tex_image == NULL)
return;
gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list);
@@ -2449,7 +2418,7 @@ __glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == &dummyContext || gc->vtable->release_tex_image == NULL)
+ if (gc == NULL || gc->vtable->release_tex_image == NULL)
return;
gc->vtable->release_tex_image(dpy, drawable, buffer);
@@ -2636,7 +2605,7 @@ get_glx_proc_address(const char *funcName)
*
* \sa glXGetProcAddress
*/
-_GLX_PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
+_X_EXPORT void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
{
typedef void (*gl_function) (void);
gl_function f;
@@ -2651,7 +2620,7 @@ _GLX_PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
f = (gl_function) get_glx_proc_address((const char *) procName);
if ((f == NULL) && (procName[0] == 'g') && (procName[1] == 'l')
&& (procName[2] != 'X')) {
-#ifdef GLX_INDIRECT_RENDERING
+#ifdef GLX_SHARED_GLAPI
f = (gl_function) __indirect_get_proc_address((const char *) procName);
#endif
if (!f)
@@ -2675,10 +2644,19 @@ _GLX_PUBLIC void (*glXGetProcAddressARB(const GLubyte * procName)) (void)
*
* \sa glXGetProcAddressARB
*/
-_GLX_PUBLIC
-GLX_ALIAS(__GLXextFuncPtr, glXGetProcAddress,
- (const GLubyte * procName),
- (procName), glXGetProcAddressARB)
+_X_EXPORT void (*glXGetProcAddress(const GLubyte * procName)) (void)
+#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
+# if defined(USE_MGL_NAMESPACE)
+ __attribute__ ((alias("mglXGetProcAddressARB")));
+# else
+ __attribute__ ((alias("glXGetProcAddressARB")));
+# endif
+#else
+{
+ return glXGetProcAddressARB(procName);
+}
+#endif /* __GNUC__ */
+
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
/**
@@ -2713,56 +2691,3 @@ __glXGetUST(int64_t * ust)
}
}
#endif /* GLX_DIRECT_RENDERING */
-
-#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
-
-PUBLIC int
-MesaGLInteropGLXQueryDeviceInfo(Display *dpy, GLXContext context,
- struct mesa_glinterop_device_info *out)
-{
- struct glx_context *gc = (struct glx_context*)context;
- int ret;
-
- __glXLock();
-
- if (!gc || gc->xid == None || !gc->isDirect) {
- __glXUnlock();
- return MESA_GLINTEROP_INVALID_CONTEXT;
- }
-
- if (!gc->vtable->interop_query_device_info) {
- __glXUnlock();
- return MESA_GLINTEROP_UNSUPPORTED;
- }
-
- ret = gc->vtable->interop_query_device_info(gc, out);
- __glXUnlock();
- return ret;
-}
-
-PUBLIC int
-MesaGLInteropGLXExportObject(Display *dpy, GLXContext context,
- struct mesa_glinterop_export_in *in,
- struct mesa_glinterop_export_out *out)
-{
- struct glx_context *gc = (struct glx_context*)context;
- int ret;
-
- __glXLock();
-
- if (!gc || gc->xid == None || !gc->isDirect) {
- __glXUnlock();
- return MESA_GLINTEROP_INVALID_CONTEXT;
- }
-
- if (!gc->vtable->interop_export_object) {
- __glXUnlock();
- return MESA_GLINTEROP_UNSUPPORTED;
- }
-
- ret = gc->vtable->interop_export_object(gc, in, out);
- __glXUnlock();
- return ret;
-}
-
-#endif /* defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) */
diff --git a/lib/mesa/src/glx/glxconfig.c b/lib/mesa/src/glx/glxconfig.c
index 0e1643fcd..e5718b143 100644
--- a/lib/mesa/src/glx/glxconfig.c
+++ b/lib/mesa/src/glx/glxconfig.c
@@ -32,6 +32,7 @@
*/
#include <GL/glx.h>
+#include "GL/glxint.h"
#include <stdlib.h>
#include <string.h>
diff --git a/lib/mesa/src/glx/glxextensions.h b/lib/mesa/src/glx/glxextensions.h
index 21ad02a44..3a9bc8230 100644
--- a/lib/mesa/src/glx/glxextensions.h
+++ b/lib/mesa/src/glx/glxextensions.h
@@ -31,10 +31,6 @@
#ifndef GLX_GLXEXTENSIONS_H
#define GLX_GLXEXTENSIONS_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
enum
{
ARB_create_context_bit = 0,
@@ -49,7 +45,6 @@ enum
EXT_import_context_bit,
EXT_framebuffer_sRGB_bit,
EXT_fbconfig_packed_float_bit,
- EXT_create_context_es_profile_bit,
EXT_create_context_es2_profile_bit,
MESA_copy_sub_buffer_bit,
MESA_depth_float_bit,
@@ -281,7 +276,11 @@ typedef void (*PFNGLXDISABLEEXTENSIONPROC) (const char *name);
/* GLX_ALIAS should be used for functions with a non-void return type.
GLX_ALIAS_VOID is for functions with a void return type. */
-# ifdef HAVE_FUNC_ATTRIBUTE_ALIAS
+#ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS
+# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func)
+# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func)
+#else
+# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
/* GLX_ALIAS and GLX_ALIAS_VOID both expand to the macro GLX_ALIAS2. Using the
* extra expansion means that the name mangling macros in glx_mangle.h will
* apply before stringification, so the alias attribute will have a string like
@@ -300,10 +299,7 @@ typedef void (*PFNGLXDISABLEEXTENSIONPROC) (const char *name);
# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
void real_func proto_args \
{ aliased_func args ; }
-# endif /* HAVE_FUNC_ATTRIBUTE_ALIAS */
-
-#ifdef __cplusplus
-}
-#endif
+# endif /* __GNUC__ */
+#endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */
#endif /* GLX_GLXEXTENSIONS_H */
diff --git a/lib/mesa/src/glx/indirect.c b/lib/mesa/src/glx/indirect.c
index 1f345c6ee..52ee9fd8d 100644
--- a/lib/mesa/src/glx/indirect.c
+++ b/lib/mesa/src/glx/indirect.c
@@ -3,18 +3,18 @@
/*
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
@@ -35,52 +35,20 @@
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/glx.h>
-#include <limits.h>
+
+#define __GLX_PAD(n) (((n) + 3) & ~3)
#if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
#define FASTCALL __attribute__((fastcall))
#else
#define FASTCALL
#endif
-#if defined(__GNUC__)
+#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
#define NOINLINE __attribute__((noinline))
#else
#define NOINLINE
#endif
-static _X_INLINE int
-safe_add(int a, int b)
-{
- if (a < 0 || b < 0)
- return -1;
- if (INT_MAX - a < b)
- return -1;
- return a + b;
-}
-
-static _X_INLINE int
-safe_mul(int a, int b)
-{
- if (a < 0 || b < 0)
- return -1;
- if (a == 0 || b == 0)
- return 0;
- if (a > INT_MAX / b)
- return -1;
- return a * b;
-}
-
-static _X_INLINE int
-safe_pad(int a)
-{
- int ret;
- if (a < 0)
- return -1;
- if ((ret = safe_add(a, 3)) < 0)
- return -1;
- return ret & (GLuint) ~ 3;
-}
-
#ifndef __GNUC__
#define __builtin_expect(x, y) x
#endif
@@ -391,11 +359,7 @@ __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glCallLists_size(type);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, n));
- if (0 + safe_pad(safe_mul(compsize, n)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * n));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -409,7 +373,7 @@ __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists)
(void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&type), 4);
(void) memcpy((void *) (gc->pc + 12), (void *) (lists),
- safe_mul(compsize, n));
+ (compsize * n));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -422,7 +386,7 @@ __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists)
(void) memcpy((void *) (pc + 4), (void *) (&op), 4);
(void) memcpy((void *) (pc + 8), (void *) (&n), 4);
(void) memcpy((void *) (pc + 12), (void *) (&type), 4);
- __glXSendLargeCommand(gc, pc, 16, lists, safe_mul(compsize, n));
+ __glXSendLargeCommand(gc, pc, 16, lists, (compsize * n));
}
}
}
@@ -524,11 +488,7 @@ __indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig,
const GLuint compsize =
(bitmap != NULL) ? __glImageSize(width, height, 1, GL_COLOR_INDEX,
GL_BITMAP, 0) : 0;
- const GLuint cmdlen = 48 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 48 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -542,8 +502,8 @@ __indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig,
(void) memcpy((void *) (gc->pc + 40), (void *) (&xmove), 4);
(void) memcpy((void *) (gc->pc + 44), (void *) (&ymove), 4);
if (compsize > 0) {
- gc->fillImage(gc, 2, width, height, 1, GL_COLOR_INDEX,
- GL_BITMAP, bitmap, gc->pc + 48, gc->pc + 4);
+ (*gc->fillImage) (gc, 2, width, height, 1, GL_COLOR_INDEX,
+ GL_BITMAP, bitmap, gc->pc + 48, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_2D,
default_pixel_store_2D_size);
@@ -2308,15 +2268,10 @@ __indirect_glFogfv(GLenum pname, const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glFogfv_size(pname);
- const GLuint cmdlen = 8 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_Fogfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2344,15 +2299,10 @@ __indirect_glFogiv(GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glFogiv_size(pname);
- const GLuint cmdlen = 8 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_Fogiv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2410,16 +2360,11 @@ __indirect_glLightfv(GLenum light, GLenum pname, const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glLightfv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_Lightfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2448,16 +2393,11 @@ __indirect_glLightiv(GLenum light, GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glLightiv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_Lightiv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&light), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2485,15 +2425,10 @@ __indirect_glLightModelfv(GLenum pname, const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glLightModelfv_size(pname);
- const GLuint cmdlen = 8 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_LightModelfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2521,15 +2456,10 @@ __indirect_glLightModeliv(GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glLightModeliv_size(pname);
- const GLuint cmdlen = 8 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_LightModeliv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2587,16 +2517,11 @@ __indirect_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glMaterialfv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_Materialfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2625,16 +2550,11 @@ __indirect_glMaterialiv(GLenum face, GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glMaterialiv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_Materialiv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&face), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2678,15 +2598,11 @@ __indirect_glPolygonStipple(const GLubyte *mask)
const GLuint compsize =
(mask != NULL) ? __glImageSize(32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
0) : 0;
- const GLuint cmdlen = 24 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 24 + __GLX_PAD(compsize);
emit_header(gc->pc, X_GLrop_PolygonStipple, cmdlen);
if (compsize > 0) {
- gc->fillImage(gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, mask,
- gc->pc + 24, gc->pc + 4);
+ (*gc->fillImage) (gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, mask,
+ gc->pc + 24, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_2D,
default_pixel_store_2D_size);
@@ -2751,16 +2667,11 @@ __indirect_glTexParameterfv(GLenum target, GLenum pname,
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glTexParameterfv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_TexParameterfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2789,16 +2700,11 @@ __indirect_glTexParameteriv(GLenum target, GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glTexParameteriv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_TexParameteriv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2814,11 +2720,7 @@ __glx_TexImage_1D2D(unsigned opcode, unsigned dim, GLenum target, GLint level,
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize =
__glImageSize(width, height, 1, format, type, target);
- const GLuint cmdlen = 56 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 56 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -2835,8 +2737,8 @@ __glx_TexImage_1D2D(unsigned opcode, unsigned dim, GLenum target, GLint level,
(void) memcpy((void *) (gc->pc + 48), (void *) (&format), 4);
(void) memcpy((void *) (gc->pc + 52), (void *) (&type), 4);
if ((compsize > 0) && (pixels != NULL)) {
- gc->fillImage(gc, dim, width, height, 1, format, type, pixels,
- gc->pc + 56, gc->pc + 4);
+ (*gc->fillImage) (gc, dim, width, height, 1, format, type,
+ pixels, gc->pc + 56, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_2D,
default_pixel_store_2D_size);
@@ -2907,16 +2809,11 @@ __indirect_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glTexEnvfv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_TexEnvfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2945,16 +2842,11 @@ __indirect_glTexEnviv(GLenum target, GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glTexEnviv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_TexEnviv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -2983,16 +2875,11 @@ __indirect_glTexGendv(GLenum coord, GLenum pname, const GLdouble * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glTexGendv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 8));
- if (0 + safe_pad(safe_mul(compsize, 8)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 8));
emit_header(gc->pc, X_GLrop_TexGendv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 8));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -3021,16 +2908,11 @@ __indirect_glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glTexGenfv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_TexGenfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -3059,16 +2941,11 @@ __indirect_glTexGeniv(GLenum coord, GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glTexGeniv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_TexGeniv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&coord), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -3712,11 +3589,7 @@ void
__indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(mapsize, 4));
- if (0 + safe_pad(safe_mul(mapsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4));
if (mapsize < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -3730,7 +3603,7 @@ __indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values)
(void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4);
(void) memcpy((void *) (gc->pc + 12), (void *) (values),
- safe_mul(mapsize, 4));
+ (mapsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -3743,7 +3616,7 @@ __indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values)
(void) memcpy((void *) (pc + 4), (void *) (&op), 4);
(void) memcpy((void *) (pc + 8), (void *) (&map), 4);
(void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4);
- __glXSendLargeCommand(gc, pc, 16, values, safe_mul(mapsize, 4));
+ __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4));
}
}
}
@@ -3753,11 +3626,7 @@ void
__indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(mapsize, 4));
- if (0 + safe_pad(safe_mul(mapsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4));
if (mapsize < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -3771,7 +3640,7 @@ __indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values)
(void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4);
(void) memcpy((void *) (gc->pc + 12), (void *) (values),
- safe_mul(mapsize, 4));
+ (mapsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -3784,7 +3653,7 @@ __indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values)
(void) memcpy((void *) (pc + 4), (void *) (&op), 4);
(void) memcpy((void *) (pc + 8), (void *) (&map), 4);
(void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4);
- __glXSendLargeCommand(gc, pc, 16, values, safe_mul(mapsize, 4));
+ __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4));
}
}
}
@@ -3794,11 +3663,7 @@ void
__indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(mapsize, 2));
- if (0 + safe_pad(safe_mul(mapsize, 2)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 2));
if (mapsize < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -3812,7 +3677,7 @@ __indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values)
(void) memcpy((void *) (gc->pc + 4), (void *) (&map), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&mapsize), 4);
(void) memcpy((void *) (gc->pc + 12), (void *) (values),
- safe_mul(mapsize, 2));
+ (mapsize * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -3825,7 +3690,7 @@ __indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values)
(void) memcpy((void *) (pc + 4), (void *) (&op), 4);
(void) memcpy((void *) (pc + 8), (void *) (&map), 4);
(void) memcpy((void *) (pc + 12), (void *) (&mapsize), 4);
- __glXSendLargeCommand(gc, pc, 16, values, safe_mul(mapsize, 2));
+ __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 2));
}
}
}
@@ -3920,11 +3785,7 @@ __indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
const GLuint compsize =
(pixels != NULL) ? __glImageSize(width, height, 1, format, type,
0) : 0;
- const GLuint cmdlen = 40 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 40 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -3936,8 +3797,8 @@ __indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format,
(void) memcpy((void *) (gc->pc + 32), (void *) (&format), 4);
(void) memcpy((void *) (gc->pc + 36), (void *) (&type), 4);
if (compsize > 0) {
- gc->fillImage(gc, 2, width, height, 1, format, type, pixels,
- gc->pc + 40, gc->pc + 4);
+ (*gc->fillImage) (gc, 2, width, height, 1, format, type,
+ pixels, gc->pc + 40, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_2D,
default_pixel_store_2D_size);
@@ -5346,12 +5207,8 @@ __indirect_glDeleteTextures(GLsizei n, const GLuint * textures)
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
#ifndef USE_XCB
- const GLuint cmdlen = 4 + safe_pad(safe_mul(n, 4));
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
#endif
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -5365,7 +5222,7 @@ __indirect_glDeleteTextures(GLsizei n, const GLuint * textures)
GLubyte const *pc =
__glXSetupSingleRequest(gc, X_GLsop_DeleteTextures, cmdlen);
(void) memcpy((void *) (pc + 0), (void *) (&n), 4);
- (void) memcpy((void *) (pc + 4), (void *) (textures), safe_mul(n, 4));
+ (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
UnlockDisplay(dpy);
SyncHandle();
#endif /* USE_XCB */
@@ -5390,11 +5247,7 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures)
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
- const GLuint cmdlen = 4 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -5404,8 +5257,7 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures)
__glXSetupVendorRequest(gc, X_GLXVendorPrivate,
X_GLvop_DeleteTexturesEXT, cmdlen);
(void) memcpy((void *) (pc + 0), (void *) (&n), 4);
- (void) memcpy((void *) (pc + 4), (void *) (textures),
- safe_mul(n, 4));
+ (void) memcpy((void *) (pc + 4), (void *) (textures), (n * 4));
UnlockDisplay(dpy);
SyncHandle();
}
@@ -5556,12 +5408,7 @@ __indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures,
const GLclampf * priorities)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen =
- 8 + safe_pad(safe_mul(n, 4)) + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4)) + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -5569,10 +5416,9 @@ __indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures,
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_PrioritizeTextures, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (textures),
- safe_mul(n, 4));
- (void) memcpy((void *) (gc->pc + 8 + safe_mul(n, 4)),
- (void *) (priorities), safe_mul(n, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (textures), (n * 4));
+ (void) memcpy((void *) (gc->pc + 8 + (n * 4)), (void *) (priorities),
+ (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -5590,11 +5436,7 @@ __glx_TexSubImage_1D2D(unsigned opcode, unsigned dim, GLenum target,
const GLuint compsize =
(pixels != NULL) ? __glImageSize(width, height, 1, format, type,
target) : 0;
- const GLuint cmdlen = 60 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 60 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -5611,8 +5453,8 @@ __glx_TexSubImage_1D2D(unsigned opcode, unsigned dim, GLenum target,
(void) memcpy((void *) (gc->pc + 52), (void *) (&type), 4);
(void) memset((void *) (gc->pc + 56), 0, 4);
if (compsize > 0) {
- gc->fillImage(gc, dim, width, height, 1, format, type, pixels,
- gc->pc + 60, gc->pc + 4);
+ (*gc->fillImage) (gc, dim, width, height, 1, format, type,
+ pixels, gc->pc + 60, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_2D,
default_pixel_store_2D_size);
@@ -5703,11 +5545,7 @@ __indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width,
const GLuint compsize =
(table != NULL) ? __glImageSize(width, 1, 1, format, type,
target) : 0;
- const GLuint cmdlen = 44 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 44 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -5721,8 +5559,8 @@ __indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width,
(void) memcpy((void *) (gc->pc + 36), (void *) (&format), 4);
(void) memcpy((void *) (gc->pc + 40), (void *) (&type), 4);
if (compsize > 0) {
- gc->fillImage(gc, 1, width, 1, 1, format, type, table,
- gc->pc + 44, gc->pc + 4);
+ (*gc->fillImage) (gc, 1, width, 1, 1, format, type, table,
+ gc->pc + 44, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_1D,
default_pixel_store_1D_size);
@@ -5755,16 +5593,11 @@ __indirect_glColorTableParameterfv(GLenum target, GLenum pname,
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glColorTableParameterfv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_ColorTableParameterfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -5778,16 +5611,11 @@ __indirect_glColorTableParameteriv(GLenum target, GLenum pname,
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glColorTableParameteriv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_ColorTableParameteriv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -6060,11 +5888,7 @@ __indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count,
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize =
(data != NULL) ? __glImageSize(count, 1, 1, format, type, target) : 0;
- const GLuint cmdlen = 44 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 44 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -6077,8 +5901,8 @@ __indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count,
(void) memcpy((void *) (gc->pc + 36), (void *) (&format), 4);
(void) memcpy((void *) (gc->pc + 40), (void *) (&type), 4);
if (compsize > 0) {
- gc->fillImage(gc, 1, count, 1, 1, format, type, data,
- gc->pc + 44, gc->pc + 4);
+ (*gc->fillImage) (gc, 1, count, 1, 1, format, type, data,
+ gc->pc + 44, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_1D,
default_pixel_store_1D_size);
@@ -6133,11 +5957,7 @@ __glx_ConvolutionFilter_1D2D(unsigned opcode, unsigned dim, GLenum target,
const GLuint compsize =
(image != NULL) ? __glImageSize(width, height, 1, format, type,
target) : 0;
- const GLuint cmdlen = 48 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 48 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -6152,8 +5972,8 @@ __glx_ConvolutionFilter_1D2D(unsigned opcode, unsigned dim, GLenum target,
(void) memcpy((void *) (gc->pc + 40), (void *) (&format), 4);
(void) memcpy((void *) (gc->pc + 44), (void *) (&type), 4);
if (compsize > 0) {
- gc->fillImage(gc, dim, width, height, 1, format, type, image,
- gc->pc + 48, gc->pc + 4);
+ (*gc->fillImage) (gc, dim, width, height, 1, format, type,
+ image, gc->pc + 48, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_2D,
default_pixel_store_2D_size);
@@ -6226,16 +6046,11 @@ __indirect_glConvolutionParameterfv(GLenum target, GLenum pname,
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glConvolutionParameterfv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_ConvolutionParameterfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -6265,16 +6080,11 @@ __indirect_glConvolutionParameteriv(GLenum target, GLenum pname,
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glConvolutionParameteriv_size(pname);
- const GLuint cmdlen = 12 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_ConvolutionParameteriv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -7098,11 +6908,7 @@ __glx_TexImage_3D4D(unsigned opcode, unsigned dim, GLenum target, GLint level,
const GLuint compsize =
(pixels != NULL) ? __glImageSize(width, height, depth, format, type,
target) : 0;
- const GLuint cmdlen = 84 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 84 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -7123,8 +6929,8 @@ __glx_TexImage_3D4D(unsigned opcode, unsigned dim, GLenum target, GLint level,
(void) memcpy((void *) (gc->pc + 80),
(void *) ((pixels == NULL) ? one : zero), 4);
if (compsize > 0) {
- gc->fillImage(gc, dim, width, height, depth, format, type,
- pixels, gc->pc + 84, gc->pc + 4);
+ (*gc->fillImage) (gc, dim, width, height, depth, format, type,
+ pixels, gc->pc + 84, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_4D,
default_pixel_store_4D_size);
@@ -7179,11 +6985,7 @@ __glx_TexSubImage_3D4D(unsigned opcode, unsigned dim, GLenum target,
const GLuint compsize =
(pixels != NULL) ? __glImageSize(width, height, depth, format, type,
target) : 0;
- const GLuint cmdlen = 92 + safe_pad(compsize);
- if (0 + safe_pad(compsize) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 92 + __GLX_PAD(compsize);
if (__builtin_expect(gc->currentDpy != NULL, 1)) {
if (cmdlen <= gc->maxSmallRenderCommandSize) {
if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -7204,8 +7006,8 @@ __glx_TexSubImage_3D4D(unsigned opcode, unsigned dim, GLenum target,
(void) memcpy((void *) (gc->pc + 84), (void *) (&type), 4);
(void) memset((void *) (gc->pc + 88), 0, 4);
if (compsize > 0) {
- gc->fillImage(gc, dim, width, height, depth, format, type,
- pixels, gc->pc + 92, gc->pc + 4);
+ (*gc->fillImage) (gc, dim, width, height, depth, format, type,
+ pixels, gc->pc + 92, gc->pc + 4);
} else {
(void) memcpy(gc->pc + 4, default_pixel_store_4D,
default_pixel_store_4D_size);
@@ -7874,15 +7676,10 @@ __indirect_glPointParameterfv(GLenum pname, const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glPointParameterfv_size(pname);
- const GLuint cmdlen = 8 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_PointParameterfv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -7910,15 +7707,10 @@ __indirect_glPointParameteriv(GLenum pname, const GLint * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
const GLuint compsize = __glPointParameteriv_size(pname);
- const GLuint cmdlen = 8 + safe_pad(safe_mul(compsize, 4));
- if (0 + safe_pad(safe_mul(compsize, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
emit_header(gc->pc, X_GLrop_PointParameteriv, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&pname), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (params),
- safe_mul(compsize, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (params), (compsize * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -8131,12 +7923,8 @@ __indirect_glDeleteQueries(GLsizei n, const GLuint * ids)
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
#ifndef USE_XCB
- const GLuint cmdlen = 4 + safe_pad(safe_mul(n, 4));
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
#endif
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -8150,7 +7938,7 @@ __indirect_glDeleteQueries(GLsizei n, const GLuint * ids)
GLubyte const *pc =
__glXSetupSingleRequest(gc, X_GLsop_DeleteQueries, cmdlen);
(void) memcpy((void *) (pc + 0), (void *) (&n), 4);
- (void) memcpy((void *) (pc + 4), (void *) (ids), safe_mul(n, 4));
+ (void) memcpy((void *) (pc + 4), (void *) (ids), (n * 4));
UnlockDisplay(dpy);
SyncHandle();
#endif /* USE_XCB */
@@ -8391,11 +8179,7 @@ void
__indirect_glDrawBuffers(GLsizei n, const GLenum * bufs)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 8 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -8407,8 +8191,7 @@ __indirect_glDrawBuffers(GLsizei n, const GLenum * bufs)
}
emit_header(gc->pc, X_GLrop_DrawBuffers, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (bufs),
- safe_mul(n, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (bufs), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -8420,7 +8203,7 @@ __indirect_glDrawBuffers(GLsizei n, const GLenum * bufs)
(void) memcpy((void *) (pc + 0), (void *) (&cmdlenLarge), 4);
(void) memcpy((void *) (pc + 4), (void *) (&op), 4);
(void) memcpy((void *) (pc + 8), (void *) (&n), 4);
- __glXSendLargeCommand(gc, pc, 12, bufs, safe_mul(n, 4));
+ __glXSendLargeCommand(gc, pc, 12, bufs, (n * 4));
}
}
}
@@ -8899,11 +8682,7 @@ __indirect_glDeleteProgramsARB(GLsizei n, const GLuint * programs)
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
- const GLuint cmdlen = 4 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -8913,7 +8692,7 @@ __indirect_glDeleteProgramsARB(GLsizei n, const GLuint * programs)
__glXSetupVendorRequest(gc, X_GLXVendorPrivate,
X_GLvop_DeleteProgramsARB, cmdlen);
(void) memcpy((void *) (pc + 0), (void *) (&n), 4);
- (void) memcpy((void *) (pc + 4), (void *) (programs), safe_mul(n, 4));
+ (void) memcpy((void *) (pc + 4), (void *) (programs), (n * 4));
UnlockDisplay(dpy);
SyncHandle();
}
@@ -9159,11 +8938,7 @@ __indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len,
const GLvoid * string)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 16 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 16 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -9404,11 +9179,7 @@ void
__indirect_glDeleteFramebuffers(GLsizei n, const GLuint * framebuffers)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 8 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -9417,7 +9188,7 @@ __indirect_glDeleteFramebuffers(GLsizei n, const GLuint * framebuffers)
emit_header(gc->pc, X_GLrop_DeleteFramebuffers, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (framebuffers),
- safe_mul(n, 4));
+ (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -9430,11 +9201,7 @@ void
__indirect_glDeleteRenderbuffers(GLsizei n, const GLuint * renderbuffers)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 8 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -9443,7 +9210,7 @@ __indirect_glDeleteRenderbuffers(GLsizei n, const GLuint * renderbuffers)
emit_header(gc->pc, X_GLrop_DeleteRenderbuffers, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (renderbuffers),
- safe_mul(n, 4));
+ (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -9815,11 +9582,7 @@ __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids,
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
GLboolean retval = (GLboolean) 0;
- const GLuint cmdlen = 4 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return 0;
- }
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return 0;
@@ -9829,7 +9592,7 @@ __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids,
__glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
X_GLvop_AreProgramsResidentNV, cmdlen);
(void) memcpy((void *) (pc + 0), (void *) (&n), 4);
- (void) memcpy((void *) (pc + 4), (void *) (ids), safe_mul(n, 4));
+ (void) memcpy((void *) (pc + 4), (void *) (ids), (n * 4));
retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_FALSE);
UnlockDisplay(dpy);
SyncHandle();
@@ -10027,11 +9790,7 @@ __indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len,
const GLubyte *program)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 16 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 16 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10055,11 +9814,7 @@ __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLsizei num,
const GLdouble * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 16 + safe_pad(safe_mul(num, 32));
- if (0 + safe_pad(safe_mul(num, 32)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 16 + __GLX_PAD((num * 32));
if (num < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10069,8 +9824,7 @@ __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLsizei num,
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 12), (void *) (&num), 4);
- (void) memcpy((void *) (gc->pc + 16), (void *) (params),
- safe_mul(num, 32));
+ (void) memcpy((void *) (gc->pc + 16), (void *) (params), (num * 32));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10084,11 +9838,7 @@ __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLsizei num,
const GLfloat * params)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 16 + safe_pad(safe_mul(num, 16));
- if (0 + safe_pad(safe_mul(num, 16)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 16 + __GLX_PAD((num * 16));
if (num < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10098,8 +9848,7 @@ __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLsizei num,
(void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 12), (void *) (&num), 4);
- (void) memcpy((void *) (gc->pc + 16), (void *) (params),
- safe_mul(num, 16));
+ (void) memcpy((void *) (gc->pc + 16), (void *) (params), (num * 16));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10112,11 +9861,7 @@ void
__indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 8 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10124,7 +9869,7 @@ __indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids)
if (__builtin_expect(n >= 0, 1)) {
emit_header(gc->pc, X_GLrop_RequestResidentProgramsNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 8), (void *) (ids), safe_mul(n, 4));
+ (void) memcpy((void *) (gc->pc + 8), (void *) (ids), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10571,11 +10316,7 @@ void
__indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 8));
- if (0 + safe_pad(safe_mul(n, 8)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10584,7 +10325,7 @@ __indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v)
emit_header(gc->pc, X_GLrop_VertexAttribs1dvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 8));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10597,11 +10338,7 @@ void
__indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10610,7 +10347,7 @@ __indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v)
emit_header(gc->pc, X_GLrop_VertexAttribs1fvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10623,11 +10360,7 @@ void
__indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 2));
- if (0 + safe_pad(safe_mul(n, 2)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10636,7 +10369,7 @@ __indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v)
emit_header(gc->pc, X_GLrop_VertexAttribs1svNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 2));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 2));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10649,11 +10382,7 @@ void
__indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 16));
- if (0 + safe_pad(safe_mul(n, 16)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 16));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10662,7 +10391,7 @@ __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v)
emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 16));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 16));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10675,11 +10404,7 @@ void
__indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 8));
- if (0 + safe_pad(safe_mul(n, 8)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10688,7 +10413,7 @@ __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v)
emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 8));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10701,11 +10426,7 @@ void
__indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10714,7 +10435,7 @@ __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v)
emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10727,11 +10448,7 @@ void
__indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 24));
- if (0 + safe_pad(safe_mul(n, 24)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 24));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10740,7 +10457,7 @@ __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v)
emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 24));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 24));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10753,11 +10470,7 @@ void
__indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 12));
- if (0 + safe_pad(safe_mul(n, 12)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 12));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10766,7 +10479,7 @@ __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v)
emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 12));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 12));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10779,11 +10492,7 @@ void
__indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 6));
- if (0 + safe_pad(safe_mul(n, 6)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 6));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10792,7 +10501,7 @@ __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v)
emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 6));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 6));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10805,11 +10514,7 @@ void
__indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 32));
- if (0 + safe_pad(safe_mul(n, 32)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 32));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10818,7 +10523,7 @@ __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v)
emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 32));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 32));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10831,11 +10536,7 @@ void
__indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 16));
- if (0 + safe_pad(safe_mul(n, 16)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 16));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10844,7 +10545,7 @@ __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v)
emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 16));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 16));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10857,11 +10558,7 @@ void
__indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 8));
- if (0 + safe_pad(safe_mul(n, 8)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10870,7 +10567,7 @@ __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v)
emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 8));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 8));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10883,11 +10580,7 @@ void
__indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 12 + safe_pad(safe_mul(n, 4));
- if (0 + safe_pad(safe_mul(n, 4)) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
if (n < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10896,7 +10589,7 @@ __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v)
emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen);
(void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
(void) memcpy((void *) (gc->pc + 8), (void *) (&n), 4);
- (void) memcpy((void *) (gc->pc + 12), (void *) (v), safe_mul(n, 4));
+ (void) memcpy((void *) (gc->pc + 12), (void *) (v), (n * 4));
gc->pc += cmdlen;
if (__builtin_expect(gc->pc > gc->limit, 0)) {
(void) __glXFlushRenderBuffer(gc, gc->pc);
@@ -10926,11 +10619,7 @@ __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len,
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
- const GLuint cmdlen = 8 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10958,11 +10647,7 @@ __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len,
{
struct glx_context *const gc = __glXGetCurrentContext();
Display *const dpy = gc->currentDpy;
- const GLuint cmdlen = 8 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 8 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -10989,11 +10674,7 @@ __indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len,
GLdouble y, GLdouble z, GLdouble w)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 44 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 44 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -11021,11 +10702,7 @@ __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len,
const GLdouble * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 44 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 44 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -11050,11 +10727,7 @@ __indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len,
GLfloat y, GLfloat z, GLfloat w)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 28 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 28 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -11082,11 +10755,7 @@ __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len,
const GLfloat * v)
{
struct glx_context *const gc = __glXGetCurrentContext();
- const GLuint cmdlen = 28 + safe_pad(len);
- if (0 + safe_pad(len) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ const GLuint cmdlen = 28 + __GLX_PAD(len);
if (len < 0) {
__glXSetError(gc, GL_INVALID_VALUE);
return;
@@ -11135,7 +10804,7 @@ __indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer)
}
-#ifdef GLX_INDIRECT_RENDERING
+#ifdef GLX_SHARED_GLAPI
static const struct proc_pair {
const char *name;
@@ -11188,7 +10857,7 @@ __indirect_get_proc_address(const char *name)
return (pair) ? pair->proc : NULL;
}
-#endif /* GLX_INDIRECT_RENDERING */
+#endif /* GLX_SHARED_GLAPI */
#undef FASTCALL
diff --git a/lib/mesa/src/glx/indirect.h b/lib/mesa/src/glx/indirect.h
index ef2cc5c59..1a6e91535 100644
--- a/lib/mesa/src/glx/indirect.h
+++ b/lib/mesa/src/glx/indirect.h
@@ -4,18 +4,18 @@
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
@@ -42,7 +42,7 @@
# else
# define FASTCALL
# endif
-# if defined(__GNUC__)
+# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define NOINLINE __attribute__((noinline))
# else
# define NOINLINE
@@ -714,7 +714,7 @@ extern _X_HIDDEN void __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei
extern _X_HIDDEN void __indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer);
extern _X_HIDDEN void __indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer);
-#ifdef GLX_INDIRECT_RENDERING
+#ifdef GLX_SHARED_GLAPI
extern _X_HIDDEN void (*__indirect_get_proc_address(const char *name))(void);
#endif
diff --git a/lib/mesa/src/glx/indirect_size.c b/lib/mesa/src/glx/indirect_size.c
index 2644eef07..1aa423155 100644
--- a/lib/mesa/src/glx/indirect_size.c
+++ b/lib/mesa/src/glx/indirect_size.c
@@ -3,18 +3,18 @@
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
@@ -43,7 +43,10 @@
#endif
-#ifdef HAVE_FUNC_ATTRIBUTE_ALIAS
+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(GLX_USE_APPLEGL)
+#undef HAVE_ALIAS
+#endif
+#ifdef HAVE_ALIAS
#define ALIAS2(from,to) \
_X_INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \
__attribute__ ((alias( # to )));
diff --git a/lib/mesa/src/glx/tests/Makefile.am b/lib/mesa/src/glx/tests/Makefile.am
index a41759b86..b02a9e377 100644
--- a/lib/mesa/src/glx/tests/Makefile.am
+++ b/lib/mesa/src/glx/tests/Makefile.am
@@ -10,11 +10,10 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/include/GL/internal \
$(DEFINES) \
$(LIBDRM_CFLAGS) \
- $(X11_INCLUDES)
+ $(X11_CFLAGS)
-TESTS = glx-test dispatch-index-check
+TESTS = glx-test
check_PROGRAMS = glx-test
-EXTRA_DIST = dispatch-index-check
glx_test_SOURCES = \
clientinfo_unittest.cpp \