winex11: Make sure that all glX functions are called under the X11 lock.
This commit is contained in:
parent
2fba300cef
commit
ed37174a71
|
@ -1471,7 +1471,9 @@ static BOOL internal_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
wine_tsx11_lock();
|
||||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
|
||||
wine_tsx11_unlock();
|
||||
|
||||
hwnd = WindowFromDC(physDev->hdc);
|
||||
if(hwnd) {
|
||||
|
@ -1506,6 +1508,7 @@ static BOOL internal_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
|||
if (TRACE_ON(wgl)) {
|
||||
int gl_test = 0;
|
||||
|
||||
wine_tsx11_lock();
|
||||
gl_test = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_FBCONFIG_ID, &value);
|
||||
if (gl_test) {
|
||||
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
|
||||
|
@ -1517,6 +1520,7 @@ static BOOL internal_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
|||
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
|
||||
TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
|
||||
}
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2371,7 +2375,9 @@ static HPBUFFERARB WINAPI X11DRV_wglCreatePbufferARB(HDC hdc, int iPixelFormat,
|
|||
}
|
||||
|
||||
PUSH1(attribs, None);
|
||||
wine_tsx11_lock();
|
||||
object->drawable = pglXCreatePbuffer(gdi_display, fmt->fbconfig, attribs);
|
||||
wine_tsx11_unlock();
|
||||
TRACE("new Pbuffer drawable as %p\n", (void*) object->drawable);
|
||||
if (!object->drawable) {
|
||||
SetLastError(ERROR_NO_SYSTEM_RESOURCES);
|
||||
|
@ -2399,7 +2405,9 @@ static GLboolean WINAPI X11DRV_wglDestroyPbufferARB(HPBUFFERARB hPbuffer)
|
|||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
return GL_FALSE;
|
||||
}
|
||||
wine_tsx11_lock();
|
||||
pglXDestroyPbuffer(object->display, object->drawable);
|
||||
wine_tsx11_unlock();
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@ -2446,10 +2454,14 @@ static GLboolean WINAPI X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer, int iAtt
|
|||
}
|
||||
switch (iAttribute) {
|
||||
case WGL_PBUFFER_WIDTH_ARB:
|
||||
wine_tsx11_lock();
|
||||
pglXQueryDrawable(object->display, object->drawable, GLX_WIDTH, (unsigned int*) piValue);
|
||||
wine_tsx11_unlock();
|
||||
break;
|
||||
case WGL_PBUFFER_HEIGHT_ARB:
|
||||
wine_tsx11_lock();
|
||||
pglXQueryDrawable(object->display, object->drawable, GLX_HEIGHT, (unsigned int*) piValue);
|
||||
wine_tsx11_unlock();
|
||||
break;
|
||||
|
||||
case WGL_PBUFFER_LOST_ARB:
|
||||
|
@ -2464,7 +2476,9 @@ static GLboolean WINAPI X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer, int iAtt
|
|||
if (use_render_texture_ati) {
|
||||
unsigned int tmp;
|
||||
int type = WGL_NO_TEXTURE_ARB;
|
||||
wine_tsx11_lock();
|
||||
pglXQueryDrawable(object->display, object->drawable, GLX_TEXTURE_FORMAT_ATI, &tmp);
|
||||
wine_tsx11_unlock();
|
||||
switch (tmp) {
|
||||
case GLX_NO_TEXTURE_ATI: type = WGL_NO_TEXTURE_ARB; break ;
|
||||
case GLX_TEXTURE_RGB_ATI: type = WGL_TEXTURE_RGB_ARB; break ;
|
||||
|
@ -2510,7 +2524,9 @@ static GLboolean WINAPI X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer, int iAtt
|
|||
if (use_render_texture_ati) {
|
||||
unsigned int tmp;
|
||||
int type = WGL_NO_TEXTURE_ARB;
|
||||
wine_tsx11_lock();
|
||||
pglXQueryDrawable(object->display, object->drawable, GLX_TEXTURE_TARGET_ATI, &tmp);
|
||||
wine_tsx11_unlock();
|
||||
switch (tmp) {
|
||||
case GLX_NO_TEXTURE_ATI: type = WGL_NO_TEXTURE_ARB; break ;
|
||||
case GLX_TEXTURE_CUBE_MAP_ATI: type = WGL_TEXTURE_CUBE_MAP_ARB; break ;
|
||||
|
@ -2538,7 +2554,9 @@ static GLboolean WINAPI X11DRV_wglQueryPbufferARB(HPBUFFERARB hPbuffer, int iAtt
|
|||
|
||||
case WGL_MIPMAP_TEXTURE_ARB:
|
||||
if (use_render_texture_ati) {
|
||||
wine_tsx11_lock();
|
||||
pglXQueryDrawable(object->display, object->drawable, GLX_MIPMAP_TEXTURE_ATI, (unsigned int*) piValue);
|
||||
wine_tsx11_unlock();
|
||||
} else {
|
||||
*piValue = GL_FALSE; /** don't support that */
|
||||
FIXME("unsupported WGL_ARB_render_texture attribute query for 0x%x\n", iAttribute);
|
||||
|
@ -2572,6 +2590,8 @@ static int WINAPI X11DRV_wglReleasePbufferDCARB(HPBUFFERARB hPbuffer, HDC hdc)
|
|||
static GLboolean WINAPI X11DRV_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer, const int *piAttribList)
|
||||
{
|
||||
Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
|
||||
GLboolean ret = GL_FALSE;
|
||||
|
||||
WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer, piAttribList);
|
||||
if (NULL == object) {
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
|
@ -2588,9 +2608,11 @@ static GLboolean WINAPI X11DRV_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer, cons
|
|||
if (use_render_texture_ati) {
|
||||
FIXME("Need conversion for GLX_ATI_render_texture\n");
|
||||
}
|
||||
return pglXDrawableAttribATI(object->display, object->drawable, piAttribList);
|
||||
wine_tsx11_lock();
|
||||
ret = pglXDrawableAttribATI(object->display, object->drawable, piAttribList);
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
return GL_FALSE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2624,8 +2646,10 @@ static GLboolean WINAPI X11DRV_wglChoosePixelFormatARB(HDC hdc, const int *piAtt
|
|||
PUSH1(attribs, None);
|
||||
|
||||
/* Search for FB configurations matching the requirements in attribs */
|
||||
wine_tsx11_lock();
|
||||
cfgs = pglXChooseFBConfig(gdi_display, DefaultScreen(gdi_display), attribs, &nCfgs);
|
||||
if (NULL == cfgs) {
|
||||
wine_tsx11_unlock();
|
||||
WARN("Compatible Pixel Format not found\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
@ -2661,6 +2685,7 @@ static GLboolean WINAPI X11DRV_wglChoosePixelFormatARB(HDC hdc, const int *piAtt
|
|||
*nNumFormats = pfmt_it;
|
||||
/** free list */
|
||||
XFree(cfgs);
|
||||
wine_tsx11_unlock();
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -2693,6 +2718,7 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
|||
WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat);
|
||||
}
|
||||
|
||||
wine_tsx11_lock();
|
||||
for (i = 0; i < nAttributes; ++i) {
|
||||
const int curWGLAttr = piAttributes[i];
|
||||
TRACE("pAttr[%d] = %x\n", i, curWGLAttr);
|
||||
|
@ -2900,13 +2926,16 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
|||
piValues[i] = GL_FALSE;
|
||||
}
|
||||
}
|
||||
wine_tsx11_unlock();
|
||||
return GL_TRUE;
|
||||
|
||||
get_error:
|
||||
wine_tsx11_unlock();
|
||||
ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc, curGLXAttr);
|
||||
return GL_FALSE;
|
||||
|
||||
pix_error:
|
||||
wine_tsx11_unlock();
|
||||
ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc, iPixelFormat, nWGLFormats);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
@ -2953,6 +2982,8 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribfvARB(HDC hdc, int iPixelF
|
|||
static GLboolean WINAPI X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuffer)
|
||||
{
|
||||
Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
|
||||
GLboolean ret = GL_FALSE;
|
||||
|
||||
TRACE("(%p, %d)\n", hPbuffer, iBuffer);
|
||||
if (NULL == object) {
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
|
@ -2966,10 +2997,14 @@ static GLboolean WINAPI X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuf
|
|||
if (!use_render_texture_ati && 1 == use_render_texture_emulation) {
|
||||
static int init = 0;
|
||||
int prev_binded_texture = 0;
|
||||
GLXContext prev_context = pglXGetCurrentContext();
|
||||
Drawable prev_drawable = pglXGetCurrentDrawable();
|
||||
GLXContext prev_context;
|
||||
Drawable prev_drawable;
|
||||
GLXContext tmp_context;
|
||||
|
||||
wine_tsx11_lock();
|
||||
prev_context = pglXGetCurrentContext();
|
||||
prev_drawable = pglXGetCurrentDrawable();
|
||||
|
||||
/* Our render_texture emulation is basic and lacks some features (1D/Cube support).
|
||||
This is mostly due to lack of demos/games using them. Further the use of glReadPixels
|
||||
isn't ideal performance wise but I wasn't able to get other ways working.
|
||||
|
@ -2995,6 +3030,7 @@ static GLboolean WINAPI X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuf
|
|||
/* Switch back to the original drawable and upload the pbuffer-texture */
|
||||
pglXMakeCurrent(object->display, prev_drawable, prev_context);
|
||||
pglXDestroyContext(gdi_display, tmp_context);
|
||||
wine_tsx11_unlock();
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -3026,9 +3062,11 @@ static GLboolean WINAPI X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuf
|
|||
* fixed the program. I don't know what the correct behavior is. On the other hand that demo
|
||||
* works fine using our pbuffer emulation path.
|
||||
*/
|
||||
return pglXBindTexImageATI(object->display, object->drawable, buffer);
|
||||
wine_tsx11_lock();
|
||||
ret = pglXBindTexImageATI(object->display, object->drawable, buffer);
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
return GL_FALSE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3039,6 +3077,8 @@ static GLboolean WINAPI X11DRV_wglBindTexImageARB(HPBUFFERARB hPbuffer, int iBuf
|
|||
static GLboolean WINAPI X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer, int iBuffer)
|
||||
{
|
||||
Wine_GLPBuffer* object = (Wine_GLPBuffer*) hPbuffer;
|
||||
GLboolean ret = GL_FALSE;
|
||||
|
||||
TRACE("(%p, %d)\n", hPbuffer, iBuffer);
|
||||
if (NULL == object) {
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
|
@ -3072,9 +3112,11 @@ static GLboolean WINAPI X11DRV_wglReleaseTexImageARB(HPBUFFERARB hPbuffer, int i
|
|||
ERR("Unknown iBuffer=%#x\n", iBuffer);
|
||||
return FALSE;
|
||||
}
|
||||
return pglXReleaseTexImageATI(object->display, object->drawable, buffer);
|
||||
wine_tsx11_lock();
|
||||
ret = pglXReleaseTexImageATI(object->display, object->drawable, buffer);
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
return GL_FALSE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3103,13 +3145,17 @@ static int WINAPI X11DRV_wglGetSwapIntervalEXT(VOID) {
|
|||
* WGL_EXT_swap_control: wglSwapIntervalEXT
|
||||
*/
|
||||
static BOOL WINAPI X11DRV_wglSwapIntervalEXT(int interval) {
|
||||
BOOL ret = TRUE;
|
||||
|
||||
TRACE("(%d)\n", interval);
|
||||
swap_interval = interval;
|
||||
if (NULL != pglXSwapIntervalSGI) {
|
||||
return 0 == pglXSwapIntervalSGI(interval);
|
||||
wine_tsx11_lock();
|
||||
ret = !pglXSwapIntervalSGI(interval);
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
WARN("(): GLX_SGI_swap_control extension seems not supported\n");
|
||||
return TRUE;
|
||||
else WARN("(): GLX_SGI_swap_control extension seems not supported\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3118,11 +3164,16 @@ static BOOL WINAPI X11DRV_wglSwapIntervalEXT(int interval) {
|
|||
* WGL_NV_vertex_array_range: wglAllocateMemoryNV
|
||||
*/
|
||||
static void* WINAPI X11DRV_wglAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority) {
|
||||
void *ret = NULL;
|
||||
TRACE("(%d, %f, %f, %f)\n", size, readfreq, writefreq, priority );
|
||||
if (pglXAllocateMemoryNV == NULL)
|
||||
return NULL;
|
||||
|
||||
return pglXAllocateMemoryNV(size, readfreq, writefreq, priority);
|
||||
if (pglXAllocateMemoryNV)
|
||||
{
|
||||
wine_tsx11_lock();
|
||||
ret = pglXAllocateMemoryNV(size, readfreq, writefreq, priority);
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3135,7 +3186,9 @@ static void WINAPI X11DRV_wglFreeMemoryNV(GLvoid* pointer) {
|
|||
if (pglXFreeMemoryNV == NULL)
|
||||
return;
|
||||
|
||||
wine_tsx11_lock();
|
||||
pglXFreeMemoryNV(pointer);
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3477,11 +3530,16 @@ BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev)
|
|||
XVisualInfo *visual_from_fbconfig_id( XID fbconfig_id )
|
||||
{
|
||||
WineGLPixelFormat *fmt;
|
||||
XVisualInfo *ret;
|
||||
|
||||
fmt = ConvertPixelFormatGLXtoWGL(gdi_display, fbconfig_id);
|
||||
if(fmt == NULL)
|
||||
return NULL;
|
||||
return pglXGetVisualFromFBConfig(gdi_display, fmt->fbconfig);
|
||||
|
||||
wine_tsx11_lock();
|
||||
ret = pglXGetVisualFromFBConfig(gdi_display, fmt->fbconfig);
|
||||
wine_tsx11_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* no OpenGL includes */
|
||||
|
|
|
@ -423,10 +423,7 @@ BOOL X11DRV_set_win_format( HWND hwnd, XID fbconfig_id )
|
|||
if (!(data = X11DRV_get_win_data(hwnd)) &&
|
||||
!(data = X11DRV_create_win_data(hwnd))) return FALSE;
|
||||
|
||||
wine_tsx11_lock();
|
||||
vis = visual_from_fbconfig_id(fbconfig_id);
|
||||
wine_tsx11_unlock();
|
||||
if (!vis) return FALSE;
|
||||
if (!(vis = visual_from_fbconfig_id(fbconfig_id))) return FALSE;
|
||||
|
||||
if (data->whole_window)
|
||||
{
|
||||
|
@ -559,15 +556,9 @@ static void sync_gl_drawable(struct x11drv_win_data *data)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!(vis = visual_from_fbconfig_id(data->fbconfig_id))) return;
|
||||
|
||||
wine_tsx11_lock();
|
||||
|
||||
vis = visual_from_fbconfig_id(data->fbconfig_id);
|
||||
if(!vis)
|
||||
{
|
||||
wine_tsx11_unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
pix = XCreatePixmap(gdi_display, root_window, w, h, vis->depth);
|
||||
if(!pix)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue