diff --git a/src/broadcom/ci/piglit-v3d-rpi4-fails.txt b/src/broadcom/ci/piglit-v3d-rpi4-fails.txt index 7fce21085b752a2fcdf4199d1333b4429de91168..b0d74801f4d7fc41093360757eab155e9e066382 100644 --- a/src/broadcom/ci/piglit-v3d-rpi4-fails.txt +++ b/src/broadcom/ci/piglit-v3d-rpi4-fails.txt @@ -1,5 +1,3 @@ -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-multithread-buffer,Fail glx@glx-query-drawable-glx_fbconfig_id-window,Fail glx@glx-swap-pixmap-bad,Fail diff --git a/src/broadcom/ci/piglit-vc4-rpi3-fails.txt b/src/broadcom/ci/piglit-vc4-rpi3-fails.txt index ee6b54d0214556d00f4977424f190c4c62b28336..6ba0bebdfe9bf00063b404058a02514af412dfa8 100644 --- a/src/broadcom/ci/piglit-vc4-rpi3-fails.txt +++ b/src/broadcom/ci/piglit-vc4-rpi3-fails.txt @@ -4,7 +4,6 @@ spec@egl_ext_device_base@conformance,Crash spec@egl_khr_wait_sync@conformance,Crash glx@glx-copy-sub-buffer samples=2,Crash glx@glx-copy-sub-buffer samples=4,Crash -glx@glx-make-current,Crash glx@glx-multithread-buffer,Fail glx@glx-multithread-texture,Timeout glx@glx-query-drawable-glx_fbconfig_id-window,Fail diff --git a/src/broadcom/ci/piglit-vc4-rpi3-flakes.txt b/src/broadcom/ci/piglit-vc4-rpi3-flakes.txt index 9882c3f3966516c4bfd3a43d31031fa1c5a92a45..73abeff3955193206b0c557b3c0b998e47f6e80b 100644 --- a/src/broadcom/ci/piglit-vc4-rpi3-flakes.txt +++ b/src/broadcom/ci/piglit-vc4-rpi3-flakes.txt @@ -1,5 +1,4 @@ shaders@glsl-vs-loop spec@arb_framebuffer_srgb@blit renderbuffer srgb single_sampled enabled clear -glx@glx-multi-window-single-context glx@glx_arb_sync_control@timing spec@egl_chromium_sync_control@conformance diff --git a/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt b/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt index d2829a126ea93431ad374c5df2616a7b79cf6547..d3d2de567d8495b55e2adc0ce93fdbce3dac3070 100644 --- a/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt +++ b/src/gallium/drivers/freedreno/ci/piglit-freedreno-a530-fails.txt @@ -1,7 +1,5 @@ fast_color_clear@fcc-read-after-clear copy rb,Fail fast_color_clear@fcc-read-after-clear copy tex,Fail -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-query-drawable-glx_fbconfig_id-window,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Crash diff --git a/src/gallium/drivers/freedreno/ci/piglit-freedreno-a630-fails.txt b/src/gallium/drivers/freedreno/ci/piglit-freedreno-a630-fails.txt index a337805aac5ec63ea8686ae33bca320654f6442c..9b6686bab86d839f3d0e96a71fe7158c37d543c7 100644 --- a/src/gallium/drivers/freedreno/ci/piglit-freedreno-a630-fails.txt +++ b/src/gallium/drivers/freedreno/ci/piglit-freedreno-a630-fails.txt @@ -1,8 +1,6 @@ glx@glx_arb_sync_control@timing -fullscreen -msc-delta 1,Fail glx@glx_arb_sync_control@timing -waitformsc -msc-delta 2,Fail glx@glx-copy-sub-buffer samples=2,Fail -glx@glx-make-current,Crash -glx@glx-multi-window-single-context,Fail glx@glx-query-drawable-glx_fbconfig_id-window,Fail glx@glx-swap-pixmap-bad,Fail glx@glx-visuals-depth -pixmap,Crash diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt index c0e76e6d86976e092468d2866e0c6c43b81fad6a..d2273d2cc9353fbf9a47c7d57fcebab8943b757c 100644 --- a/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt +++ b/src/gallium/drivers/llvmpipe/ci/llvmpipe-quick_gl.txt @@ -9,8 +9,6 @@ glx/glx-copy-sub-buffer samples=32: skip glx/glx-copy-sub-buffer samples=4: skip glx/glx-copy-sub-buffer samples=6: skip glx/glx-copy-sub-buffer samples=8: skip -glx/glx-make-current: fail -glx/glx-multi-window-single-context: fail glx/glx-multithread-makecurrent-1: skip glx/glx-multithread-makecurrent-2: skip glx/glx-multithread-makecurrent-3: skip diff --git a/src/gallium/drivers/softpipe/ci/softpipe-quick.txt b/src/gallium/drivers/softpipe/ci/softpipe-quick.txt index 45de363170674bce724d290a0e88186b4a3b8a74..5db94e98d88c41a35c3a3a7037cfdd5658253cd9 100644 --- a/src/gallium/drivers/softpipe/ci/softpipe-quick.txt +++ b/src/gallium/drivers/softpipe/ci/softpipe-quick.txt @@ -10,9 +10,7 @@ glx/glx-copy-sub-buffer samples=32: skip glx/glx-copy-sub-buffer samples=4: skip glx/glx-copy-sub-buffer samples=6: skip glx/glx-copy-sub-buffer samples=8: skip -glx/glx-make-current: fail glx/glx-multi-context-front: fail -glx/glx-multi-window-single-context: fail glx/glx-multithread-makecurrent-1: skip glx/glx-multithread-makecurrent-2: skip glx/glx-multithread-makecurrent-3: skip diff --git a/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt b/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt index 35bdaf5cbc5c16d2643d5ccada718f8e72421065..88f2bc5531a4ec6f6a94ff9cf05056b62dc62fb0 100644 --- a/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt +++ b/src/gallium/drivers/zink/ci/piglit-zink-lvp-fails.txt @@ -1,6 +1,5 @@ glx@extension string sanity,Fail glx@glx-copy-sub-buffer,Fail -glx@glx-multi-window-single-context,Fail glx@glx-multithread-buffer,Fail glx@glx-multithread-texture,Fail glx@glx-query-drawable-glx_fbconfig_id-window,Fail diff --git a/src/glx/applegl_glx.c b/src/glx/applegl_glx.c index 31da9d0a3e6e7f8e63b3eddcf3c93e871e269d98..fed7b9f667c4ddc6a6cc8bb1f02343d5ea429dee 100644 --- a/src/glx/applegl_glx.c +++ b/src/glx/applegl_glx.c @@ -114,8 +114,6 @@ static const struct glx_context_vtable applegl_context_vtable = { .unbind = applegl_unbind_context, .wait_gl = applegl_wait_gl, .wait_x = applegl_wait_x, - .bind_tex_image = NULL, - .release_tex_image = NULL, }; struct glx_context * diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index ffc34ab925f2b4945f30352f2fe8599c312ffb93..5d0d3094cf134e3e49e59f3e7f488eba5acb0040 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -980,21 +980,16 @@ dri2InvalidateBuffers(Display *dpy, XID drawable) } static void -dri2_bind_tex_image(Display * dpy, - GLXDrawable drawable, +dri2_bind_tex_image(__GLXDRIdrawable *base, int buffer, const int *attrib_list) { struct glx_context *gc = __glXGetCurrentContext(); struct dri2_context *pcp = (struct dri2_context *) gc; - __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); - struct glx_display *dpyPriv = __glXInitialize(dpy); + struct glx_display *dpyPriv = __glXInitialize(gc->currentDpy); struct dri2_drawable *pdraw = (struct dri2_drawable *) base; struct dri2_display *pdp; struct dri2_screen *psc; - if (dpyPriv == NULL) - return; - pdp = (struct dri2_display *) dpyPriv->dri2Display; if (pdraw != NULL) { @@ -1020,16 +1015,14 @@ dri2_bind_tex_image(Display * dpy, } static void -dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) +dri2_release_tex_image(__GLXDRIdrawable *base, int buffer) { struct glx_context *gc = __glXGetCurrentContext(); struct dri2_context *pcp = (struct dri2_context *) gc; - __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); - struct glx_display *dpyPriv = __glXInitialize(dpy); struct dri2_drawable *pdraw = (struct dri2_drawable *) base; struct dri2_screen *psc; - if (dpyPriv != NULL && pdraw != NULL) { + if (pdraw != NULL) { psc = (struct dri2_screen *) base->psc; if (psc->texBuffer->base.version >= 3 && @@ -1047,8 +1040,6 @@ static const struct glx_context_vtable dri2_context_vtable = { .unbind = dri2_unbind_context, .wait_gl = dri2_wait_gl, .wait_x = dri2_wait_x, - .bind_tex_image = dri2_bind_tex_image, - .release_tex_image = dri2_release_tex_image, .interop_query_device_info = dri2_interop_query_device_info, .interop_export_object = dri2_interop_export_object }; @@ -1297,6 +1288,8 @@ dri2CreateScreen(int screen, struct glx_display * priv) psp->setSwapInterval = NULL; psp->getSwapInterval = NULL; psp->getBufferAge = NULL; + psp->bindTexImage = dri2_bind_tex_image; + psp->releaseTexImage = dri2_release_tex_image; if (pdp->driMinor >= 2) { psp->getDrawableMSC = dri2DrawableGetMSC; diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index c07844da2c04a0ab80e70508aa8ed7de9f9b1dea..3a1970027288192033197eb9e2f5bd2a2c49b72c 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -664,13 +664,11 @@ dri3_get_swap_interval(__GLXDRIdrawable *pdraw) } static void -dri3_bind_tex_image(Display * dpy, - GLXDrawable drawable, +dri3_bind_tex_image(__GLXDRIdrawable *base, int buffer, const int *attrib_list) { struct glx_context *gc = __glXGetCurrentContext(); struct dri3_context *pcp = (struct dri3_context *) gc; - __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); struct dri3_drawable *pdraw = (struct dri3_drawable *) base; struct dri3_screen *psc; @@ -679,7 +677,7 @@ dri3_bind_tex_image(Display * dpy, psc->f->invalidate(pdraw->loader_drawable.dri_drawable); - XSync(dpy, false); + XSync(gc->currentDpy, false); (*psc->texBuffer->setTexBuffer2) (pcp->driContext, pdraw->base.textureTarget, @@ -689,11 +687,10 @@ dri3_bind_tex_image(Display * dpy, } static void -dri3_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) +dri3_release_tex_image(__GLXDRIdrawable *base, int buffer) { struct glx_context *gc = __glXGetCurrentContext(); struct dri3_context *pcp = (struct dri3_context *) gc; - __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); struct dri3_drawable *pdraw = (struct dri3_drawable *) base; struct dri3_screen *psc; @@ -714,8 +711,6 @@ static const struct glx_context_vtable dri3_context_vtable = { .unbind = dri3_unbind_context, .wait_gl = dri3_wait_gl, .wait_x = dri3_wait_x, - .bind_tex_image = dri3_bind_tex_image, - .release_tex_image = dri3_release_tex_image, .interop_query_device_info = dri3_interop_query_device_info, .interop_export_object = dri3_interop_export_object }; @@ -971,6 +966,8 @@ dri3_create_screen(int screen, struct glx_display * priv) psp->waitForSBC = dri3_wait_for_sbc; psp->setSwapInterval = dri3_set_swap_interval; psp->getSwapInterval = dri3_get_swap_interval; + psp->bindTexImage = dri3_bind_tex_image; + psp->releaseTexImage = dri3_release_tex_image; __glXEnableDirectExtension(&psc->base, "GLX_OML_sync_control"); __glXEnableDirectExtension(&psc->base, "GLX_SGI_video_sync"); diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index f7a1a429a745be2c59676c6f035ec5848739d1a5..78bd074ea544c02e6e0b32a8f20e4aaff47fb3a0 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -138,22 +138,6 @@ static const struct __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode), __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode), __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers), -#if 0 - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue), - __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha), - __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask), - __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask), - __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask), - __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask), - __ATTRIB(__DRI_ATTRIB_RED_SHIFT, redShift), - __ATTRIB(__DRI_ATTRIB_GREEN_SHIFT, greenShift), - __ATTRIB(__DRI_ATTRIB_BLUE_SHIFT, blueShift), - __ATTRIB(__DRI_ATTRIB_ALPHA_SHIFT, alphaShift), -#endif __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod), __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb), __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba), diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 5fe911f92f9285b8526683711a3059fe66157903..8227b7d72fd4e1e5b659131d36846bf8444fe1ca 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -424,18 +424,14 @@ drisw_wait_x(struct glx_context *context) } static void -drisw_bind_tex_image(Display * dpy, - GLXDrawable drawable, - int buffer, const int *attrib_list) +drisw_bind_tex_image(__GLXDRIdrawable *base, + int buffer, const int *attrib_list) { struct glx_context *gc = __glXGetCurrentContext(); struct drisw_context *pcp = (struct drisw_context *) gc; - __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); struct drisw_drawable *pdraw = (struct drisw_drawable *) base; struct drisw_screen *psc; - __glXInitialize(dpy); - if (pdraw != NULL) { psc = (struct drisw_screen *) base->psc; @@ -458,16 +454,14 @@ drisw_bind_tex_image(Display * dpy, } static void -drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) +drisw_release_tex_image(__GLXDRIdrawable *base, int buffer) { struct glx_context *gc = __glXGetCurrentContext(); struct drisw_context *pcp = (struct drisw_context *) gc; - __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); - struct glx_display *dpyPriv = __glXInitialize(dpy); struct drisw_drawable *pdraw = (struct drisw_drawable *) base; struct drisw_screen *psc; - if (dpyPriv != NULL && pdraw != NULL) { + if (pdraw != NULL) { psc = (struct drisw_screen *) base->psc; if (!psc->texBuffer) @@ -488,8 +482,6 @@ static const struct glx_context_vtable drisw_context_vtable = { .unbind = drisw_unbind_context, .wait_gl = drisw_wait_gl, .wait_x = drisw_wait_x, - .bind_tex_image = drisw_bind_tex_image, - .release_tex_image = drisw_release_tex_image, }; static struct glx_context * @@ -901,6 +893,8 @@ driswCreateScreen(int screen, struct glx_display *priv) psp->destroyScreen = driswDestroyScreen; psp->createDrawable = driswCreateDrawable; psp->swapBuffers = driswSwapBuffers; + psp->bindTexImage = drisw_bind_tex_image; + psp->releaseTexImage = drisw_release_tex_image; if (psc->copySubBuffer) psp->copySubBuffer = driswCopySubBuffer; diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c index 73835b5cced9a67fc922e66e19c1f45c83ff1959..74b9b55c7185096f70e8b9323c2f1235584c6bed 100644 --- a/src/glx/glx_pbuffer.c +++ b/src/glx/glx_pbuffer.c @@ -455,6 +455,9 @@ CreateDrawable(Display *dpy, struct glx_config *config, CARD8 opcode; GLXDrawable xid; + if (!config) + return None; + i = 0; if (attrib_list) { while (attrib_list[i * 2] != None) diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 178b4cb982006be9218740e44ddc3371f370d8f8..77e07adb0cbe761be75cdaa2bb77eb818530e1b5 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -127,6 +127,8 @@ struct __GLXDRIscreenRec { int (*setSwapInterval)(__GLXDRIdrawable *pdraw, int interval); int (*getSwapInterval)(__GLXDRIdrawable *pdraw); int (*getBufferAge)(__GLXDRIdrawable *pdraw); + void (*bindTexImage)(__GLXDRIdrawable *pdraw, int buffer, const int *attribs); + void (*releaseTexImage)(__GLXDRIdrawable *pdraw, int buffer); }; struct __GLXDRIdrawableRec @@ -227,10 +229,6 @@ struct glx_context_vtable { void (*unbind)(struct glx_context *context, struct glx_context *new_ctx); void (*wait_gl)(struct glx_context *ctx); void (*wait_x)(struct glx_context *ctx); - void (*bind_tex_image)(Display * dpy, - GLXDrawable drawable, - int buffer, const int *attrib_list); - void (*release_tex_image)(Display * dpy, GLXDrawable drawable, int buffer); int (*interop_query_device_info)(struct glx_context *ctx, struct mesa_glinterop_device_info *out); int (*interop_export_object)(struct glx_context *ctx, diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 8cef528050275469afe1600061f222c980188f97..7a2a31ad26bb37928859d8bd10f8595f750f3fe1 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -1732,6 +1732,9 @@ glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig fbconfig) struct glx_config *config = (struct glx_config *) fbconfig; int count; + if (!config) + return NULL; + /* ** Get a list of all visuals, return if list is empty */ @@ -2436,23 +2439,103 @@ _X_HIDDEN void glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list) { + xGLXVendorPrivateReq *req; struct glx_context *gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD32 *num_attrib_ptr; + CARD32 *attrib_ptr; + CARD8 opcode; + unsigned int i = 0; + +#ifdef GLX_DIRECT_RENDERING + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable); + if (pdraw != NULL) { + struct glx_screen *psc = pdraw->psc; + if (psc->driScreen->bindTexImage != NULL) + (*psc->driScreen->bindTexImage) (pdraw, buffer, attrib_list); - if (gc->vtable->bind_tex_image == NULL) return; + } +#endif + + if (attrib_list) { + while (attrib_list[i * 2] != None) + i++; + } - gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list); + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_BindTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + num_attrib_ptr = (CARD32 *) (buffer_ptr + 1); + attrib_ptr = (CARD32 *) (num_attrib_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + *num_attrib_ptr = (CARD32) i; + + i = 0; + if (attrib_list) { + while (attrib_list[i * 2] != None) { + *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0]; + *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1]; + i++; + } + } + + UnlockDisplay(dpy); + SyncHandle(); } _X_HIDDEN void glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer) { + xGLXVendorPrivateReq *req; struct glx_context *gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD8 opcode; + +#ifdef GLX_DIRECT_RENDERING + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable); + if (pdraw != NULL) { + struct glx_screen *psc = pdraw->psc; + if (psc->driScreen->releaseTexImage != NULL) + (*psc->driScreen->releaseTexImage) (pdraw, buffer); + + return; + } +#endif - if (gc->vtable->release_tex_image == NULL) + opcode = __glXSetupForCommand(dpy); + if (!opcode) return; - gc->vtable->release_tex_image(dpy, drawable, buffer); + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_ReleaseTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + + UnlockDisplay(dpy); + SyncHandle(); } /*@}*/ diff --git a/src/glx/glxconfig.c b/src/glx/glxconfig.c index 6c4267c8f3952cdf454223b36b141635ca2f889b..925345567fb833cccc8e06af731d261e94710204 100644 --- a/src/glx/glxconfig.c +++ b/src/glx/glxconfig.c @@ -249,7 +249,7 @@ glx_config_create_list(unsigned count) (*next)->bindToMipmapTexture = GLX_DONT_CARE; (*next)->bindToTextureTargets = GLX_DONT_CARE; (*next)->yInverted = GLX_DONT_CARE; - (*next)->sRGBCapable = GLX_DONT_CARE; + (*next)->sRGBCapable = GL_FALSE; next = &((*next)->next); } diff --git a/src/glx/glxconfig.h b/src/glx/glxconfig.h index 75704737ef533511642c523b67aa969946e1ded3..132c5b28d45accf3d535b5561b29e7b114c37cc6 100644 --- a/src/glx/glxconfig.h +++ b/src/glx/glxconfig.h @@ -101,20 +101,6 @@ struct glx_config { GLint sRGBCapable; }; -#define __GLX_MIN_CONFIG_PROPS 18 -#define __GLX_MAX_CONFIG_PROPS 500 -#define __GLX_EXT_CONFIG_PROPS 10 - -/* -** Since we send all non-core visual properties as token, value pairs, -** we require 2 words across the wire. In order to maintain backwards -** compatibility, we need to send the total number of words that the -** VisualConfigs are sent back in so old libraries can simply "ignore" -** the new properties. -*/ -#define __GLX_TOTAL_CONFIG \ - (__GLX_MIN_CONFIG_PROPS + 2 * __GLX_EXT_CONFIG_PROPS) - extern GLint _gl_convert_from_x_visual_type(int visualType); extern int diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index a388df7a78dc9017f47448daa191ed1cb72a7bb8..7172009c34c0fc9451fc6439f04850ae5fb6121e 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -165,17 +165,100 @@ glXGetCurrentDrawable(void) return gc->currentDrawable; } -/** - * Make a particular context current. - * - * \note This is in this file so that it can access dummyContext. - */ +static Bool +SendMakeCurrentRequest(Display * dpy, GLXContextID gc_id, + GLXContextTag gc_tag, GLXDrawable draw, + GLXDrawable read, GLXContextTag *out_tag) +{ + xGLXMakeCurrentReply reply; + Bool ret; + int opcode = __glXSetupForCommand(dpy); + + LockDisplay(dpy); + + if (draw == read) { + xGLXMakeCurrentReq *req; + + GetReq(GLXMakeCurrent, req); + req->reqType = opcode; + req->glxCode = X_GLXMakeCurrent; + req->drawable = draw; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + else { + struct glx_display *priv = __glXInitialize(dpy); + + if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + xGLXMakeContextCurrentReq *req; + + GetReq(GLXMakeContextCurrent, req); + req->reqType = opcode; + req->glxCode = X_GLXMakeContextCurrent; + req->drawable = draw; + req->readdrawable = read; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + else { + xGLXVendorPrivateWithReplyReq *vpreq; + xGLXMakeCurrentReadSGIReq *req; + + GetReqExtra(GLXVendorPrivateWithReply, + sz_xGLXMakeCurrentReadSGIReq - + sz_xGLXVendorPrivateWithReplyReq, vpreq); + req = (xGLXMakeCurrentReadSGIReq *) vpreq; + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivateWithReply; + req->vendorCode = X_GLXvop_MakeCurrentReadSGI; + req->drawable = draw; + req->readable = read; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + } + + ret = _XReply(dpy, (xReply *) &reply, 0, False); + + + if (ret == 1) + *out_tag = reply.contextTag; + + UnlockDisplay(dpy); + SyncHandle(); + + return ret; +} + +static void +SetGC(struct glx_context *gc, Display *dpy, GLXDrawable draw, GLXDrawable read) +{ + gc->currentDpy = dpy; + gc->currentDrawable = draw; + gc->currentReadable = read; +} + +static Bool +should_send(Display *dpy, struct glx_context *gc) +{ + /* always send for indirect contexts */ + if (!gc->isDirect) + return 1; + + /* don't send for broken servers. */ + if (VendorRelease(dpy) < 12006000 || VendorRelease(dpy) >= 40000000) + return 0; + + return 1; +} + static Bool MakeContextCurrent(Display * dpy, GLXDrawable draw, GLXDrawable read, GLXContext gc_user) { struct glx_context *gc = (struct glx_context *) gc_user; struct glx_context *oldGC = __glXGetCurrentContext(); + Bool ret = GL_FALSE; /* Make sure that the new context has a nonzero ID. In the request, * a zero context ID is used only to mean that we bind to no current @@ -186,66 +269,97 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, } _glapi_check_multithread(); - __glXLock(); - if (oldGC == gc && - gc->currentDrawable == draw && gc->currentReadable == read) { - __glXUnlock(); - return True; - } - /* can't have only one be 0 */ - if (!!draw != !!read) { - __glXUnlock(); - __glXSendError(dpy, BadMatch, None, X_GLXMakeContextCurrent, True); - return False; + if (oldGC == gc && + gc->currentDrawable == draw && + gc->currentReadable == read) { + /* Same context and drawables: no op, just return */ + ret = GL_TRUE; } - if (oldGC != &dummyContext) { - if (--oldGC->thread_refcount == 0) { - oldGC->vtable->unbind(oldGC, gc); - oldGC->currentDpy = 0; + else if (oldGC == gc) { + /* Same context and new drawables: update drawable bindings */ + if (should_send(dpy, gc)) { + if (!SendMakeCurrentRequest(dpy, gc->xid, gc->currentContextTag, + draw, read, &gc->currentContextTag)) { + goto out; + } } - } - if (gc) { - /* Attempt to bind the context. We do this before mucking with - * gc and __glXSetCurrentContext to properly handle our state in - * case of an error. - * - * If an error occurs, set the Null context since we've already - * blown away our old context. The caller is responsible for - * figuring out how to handle setting a valid context. - */ - if (gc->vtable->bind(gc, oldGC, draw, read) != Success) { + if (gc->vtable->bind(gc, gc, draw, read) != Success) { __glXSetCurrentContextNull(); - __glXUnlock(); - __glXSendError(dpy, GLXBadContext, None, X_GLXMakeContextCurrent, - False); - return GL_FALSE; + goto out; } + } - if (gc->thread_refcount == 0) { - gc->currentDpy = dpy; - gc->currentDrawable = draw; - gc->currentReadable = read; + else { + /* Different contexts: release the old, bind the new */ + GLXContextTag oldTag = oldGC->currentContextTag; + + if (oldGC != &dummyContext) { + + if (--oldGC->thread_refcount == 0) { + if (oldGC->xid != None && + should_send(dpy, oldGC) && + !SendMakeCurrentRequest(dpy, None, oldTag, None, None, + &oldGC->currentContextTag)) { + goto out; + } + + oldGC->vtable->unbind(oldGC, gc); + + if (oldGC->xid == None) { + /* destroyed context, free it */ + oldGC->vtable->destroy(oldGC); + oldTag = 0; + } else { + SetGC(oldGC, NULL, None, None); + oldTag = oldGC->currentContextTag; + } + } } - gc->thread_refcount++; - __glXSetCurrentContext(gc); - } else { __glXSetCurrentContextNull(); - } - if (oldGC->thread_refcount == 0 && oldGC != &dummyContext && oldGC->xid == None) { - /* We are switching away from a context that was - * previously destroyed, so we need to free the memory - * for the old handle. */ - oldGC->vtable->destroy(oldGC); + if (gc) { + /* + * MESA_multithread_makecurrent makes this complicated. We need to + * send the request if the new context is + * + * a) indirect (may be current to another client), or + * b) (direct and) newly being made current, or + * c) (direct and) being bound to new drawables + */ + Bool new_drawables = gc->currentReadable != read || + gc->currentDrawable != draw; + + if (should_send(dpy, gc)) { + if (!gc->isDirect || !gc->thread_refcount || new_drawables) { + if (!SendMakeCurrentRequest(dpy, gc->xid, oldTag, draw, read, + &gc->currentContextTag)) { + goto out; + } + } + } + + if (gc->vtable->bind(gc, oldGC, draw, read) != Success) { + __glXSendError(dpy, GLXBadContext, None, X_GLXMakeContextCurrent, + False); + goto out; + } + + if (gc->thread_refcount == 0) { + SetGC(gc, dpy, draw, read); + } + gc->thread_refcount++; + __glXSetCurrentContext(gc); + } } + ret = GL_TRUE; +out: __glXUnlock(); - - return GL_TRUE; + return ret; } diff --git a/src/glx/glxext.c b/src/glx/glxext.c index ac664a4a113bb52494a5ddb8e21116d64242feb4..903a5441dd10514a7e15830f9fcb9629a49317b7 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -58,6 +58,18 @@ #include #include +#define __GLX_MIN_CONFIG_PROPS 18 +#define __GLX_EXT_CONFIG_PROPS 32 + +/* +** Since we send all non-core visual properties as token, value pairs, +** we require 2 words across the wire. In order to maintain backwards +** compatibility, we need to send the total number of words that the +** VisualConfigs are sent back in so old libraries can simply "ignore" +** the new properties. +*/ +#define __GLX_TOTAL_CONFIG \ + (__GLX_MIN_CONFIG_PROPS + 2 * __GLX_EXT_CONFIG_PROPS) #ifdef DEBUG void __glXDumpDrawBuffer(struct glx_context * ctx); @@ -619,10 +631,8 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, if (nprops == 0) return NULL; - /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */ - /* Check number of properties */ - if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS) + if (nprops < __GLX_MIN_CONFIG_PROPS) return NULL; /* Allocate memory for our config structure */ @@ -651,8 +661,6 @@ createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, */ m->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; #endif - /* Older X servers don't send this so we default it here. */ - m->sRGBCapable = GL_FALSE; __glXInitializeVisualConfigFromTags(m, nprops, props, tagged_only, GL_TRUE); m->screen = screen; diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index ce5277988dffa44dc076af8a195ed39081c7f3dc..d6466225561ed8917e1ad94f51661d1e7a83e0c6 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -61,135 +61,40 @@ indirect_destroy_context(struct glx_context *gc) free((char *) gc); } -static Bool -SendMakeCurrentRequest(Display * dpy, GLXContextID gc_id, - GLXContextTag gc_tag, GLXDrawable draw, - GLXDrawable read, GLXContextTag *out_tag) -{ - xGLXMakeCurrentReply reply; - Bool ret; - int opcode = __glXSetupForCommand(dpy); - - LockDisplay(dpy); - - if (draw == read) { - xGLXMakeCurrentReq *req; - - GetReq(GLXMakeCurrent, req); - req->reqType = opcode; - req->glxCode = X_GLXMakeCurrent; - req->drawable = draw; - req->context = gc_id; - req->oldContextTag = gc_tag; - } - else { - struct glx_display *priv = __glXInitialize(dpy); - - /* If the server can support the GLX 1.3 version, we should - * perfer that. Not only that, some servers support GLX 1.3 but - * not the SGI extension. - */ - - if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { - xGLXMakeContextCurrentReq *req; - - GetReq(GLXMakeContextCurrent, req); - req->reqType = opcode; - req->glxCode = X_GLXMakeContextCurrent; - req->drawable = draw; - req->readdrawable = read; - req->context = gc_id; - req->oldContextTag = gc_tag; - } - else { - xGLXVendorPrivateWithReplyReq *vpreq; - xGLXMakeCurrentReadSGIReq *req; - - GetReqExtra(GLXVendorPrivateWithReply, - sz_xGLXMakeCurrentReadSGIReq - - sz_xGLXVendorPrivateWithReplyReq, vpreq); - req = (xGLXMakeCurrentReadSGIReq *) vpreq; - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivateWithReply; - req->vendorCode = X_GLXvop_MakeCurrentReadSGI; - req->drawable = draw; - req->readable = read; - req->context = gc_id; - req->oldContextTag = gc_tag; - } - } - - ret = _XReply(dpy, (xReply *) &reply, 0, False); - - if (out_tag) - *out_tag = reply.contextTag; - - UnlockDisplay(dpy); - SyncHandle(); - - return ret; -} - static int indirect_bind_context(struct glx_context *gc, struct glx_context *old, GLXDrawable draw, GLXDrawable read) { - GLXContextTag tag; - Display *dpy = gc->psc->dpy; - Bool sent; - - if (old != &dummyContext && !old->isDirect && old->psc->dpy == dpy) { - tag = old->currentContextTag; - old->currentContextTag = 0; - } else { - tag = 0; + __GLXattribute *state = gc->client_state_private; + + if (!IndirectAPI) + IndirectAPI = __glXNewIndirectAPI(); + _glapi_set_dispatch(IndirectAPI); + + /* The indirect vertex array state must to be initialised after we + * have setup the context, as it needs to query server attributes. + * + * At the point this is called gc->currentDpy is not initialized + * nor is the thread's current context actually set. Hence the + * cleverness before the GetString calls. + */ + if (state && state->array_state == NULL) { + gc->currentDpy = gc->psc->dpy; + __glXSetCurrentContext(gc); + __indirect_glGetString(GL_EXTENSIONS); + __indirect_glGetString(GL_VERSION); + __glXInitVertexArrayState(gc); } - sent = SendMakeCurrentRequest(dpy, gc->xid, tag, draw, read, - &gc->currentContextTag); - - if (sent) { - if (!IndirectAPI) - IndirectAPI = __glXNewIndirectAPI(); - _glapi_set_dispatch(IndirectAPI); + if (state != NULL && state->array_state != NULL) + return Success; - /* The indirect vertex array state must to be initialised after we - * have setup the context, as it needs to query server attributes. - * - * At the point this is called gc->currentDpy is not initialized - * nor is the thread's current context actually set. Hence the - * cleverness before the GetString calls. - */ - __GLXattribute *state = gc->client_state_private; - if (state && state->array_state == NULL) { - gc->currentDpy = gc->psc->dpy; - __glXSetCurrentContext(gc); - __indirect_glGetString(GL_EXTENSIONS); - __indirect_glGetString(GL_VERSION); - __glXInitVertexArrayState(gc); - } - } - - return !sent; + return BadAlloc; } static void indirect_unbind_context(struct glx_context *gc, struct glx_context *new) { - Display *dpy = gc->psc->dpy; - - if (gc == new) - return; - - /* We are either switching to no context, away from an indirect - * context to a direct context or from one dpy to another and have - * to send a request to the dpy to unbind the previous context. - */ - if (!new || new->isDirect || new->psc->dpy != dpy) { - SendMakeCurrentRequest(dpy, None, gc->currentContextTag, None, None, - NULL); - gc->currentContextTag = 0; - } } static void @@ -229,97 +134,12 @@ indirect_wait_x(struct glx_context *gc) SyncHandle(); } -static void -indirect_bind_tex_image(Display * dpy, - GLXDrawable drawable, - int buffer, const int *attrib_list) -{ - xGLXVendorPrivateReq *req; - struct glx_context *gc = __glXGetCurrentContext(); - CARD32 *drawable_ptr; - INT32 *buffer_ptr; - CARD32 *num_attrib_ptr; - CARD32 *attrib_ptr; - CARD8 opcode; - unsigned int i; - - i = 0; - if (attrib_list) { - while (attrib_list[i * 2] != None) - i++; - } - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, 12 + 8 * i, req); - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivate; - req->vendorCode = X_GLXvop_BindTexImageEXT; - req->contextTag = gc->currentContextTag; - - drawable_ptr = (CARD32 *) (req + 1); - buffer_ptr = (INT32 *) (drawable_ptr + 1); - num_attrib_ptr = (CARD32 *) (buffer_ptr + 1); - attrib_ptr = (CARD32 *) (num_attrib_ptr + 1); - - *drawable_ptr = drawable; - *buffer_ptr = buffer; - *num_attrib_ptr = (CARD32) i; - - i = 0; - if (attrib_list) { - while (attrib_list[i * 2] != None) { - *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0]; - *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1]; - i++; - } - } - - UnlockDisplay(dpy); - SyncHandle(); -} - -static void -indirect_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) -{ - xGLXVendorPrivateReq *req; - struct glx_context *gc = __glXGetCurrentContext(); - CARD32 *drawable_ptr; - INT32 *buffer_ptr; - CARD8 opcode; - - opcode = __glXSetupForCommand(dpy); - if (!opcode) - return; - - LockDisplay(dpy); - GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32), req); - req->reqType = opcode; - req->glxCode = X_GLXVendorPrivate; - req->vendorCode = X_GLXvop_ReleaseTexImageEXT; - req->contextTag = gc->currentContextTag; - - drawable_ptr = (CARD32 *) (req + 1); - buffer_ptr = (INT32 *) (drawable_ptr + 1); - - *drawable_ptr = drawable; - *buffer_ptr = buffer; - - UnlockDisplay(dpy); - SyncHandle(); -} - static const struct glx_context_vtable indirect_context_vtable = { .destroy = indirect_destroy_context, .bind = indirect_bind_context, .unbind = indirect_unbind_context, .wait_gl = indirect_wait_gl, .wait_x = indirect_wait_x, - .bind_tex_image = indirect_bind_tex_image, - .release_tex_image = indirect_release_tex_image, }; _X_HIDDEN struct glx_context * diff --git a/src/glx/meson.build b/src/glx/meson.build index 58f9e1aa896c50c5b7160b09b0d56b96ade6b7fe..8f642d5e14b9c6f10d463e945674c061d0ebf393 100644 --- a/src/glx/meson.build +++ b/src/glx/meson.build @@ -122,16 +122,11 @@ else ) endif -gl_lib_cargs = [ - '-D_REENTRANT', -] - libglx = static_library( 'glx', [files_libglx, glx_generated], include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_glapi, inc_loader], c_args : [ - gl_lib_cargs, '-DGL_LIB_NAME="lib@0@.so.@1@"'.format(gl_lib_name, gl_lib_version.split('.')[0]), ], gnu_symbol_visibility : 'hidden', diff --git a/src/glx/tests/fake_glx_screen.cpp b/src/glx/tests/fake_glx_screen.cpp index e0f0b7c0db0a0884da98456166164d6aff403d4f..1b29bb9d0875c41648c6c08308f5507a65167998 100644 --- a/src/glx/tests/fake_glx_screen.cpp +++ b/src/glx/tests/fake_glx_screen.cpp @@ -44,8 +44,6 @@ const struct glx_context_vtable fake_glx_context::vt = { NULL, NULL, NULL, - NULL, - NULL, }; int fake_glx_context::contexts_allocated = 0;