[PATCH 1/5] wined3d: Explicitly document some more consequences of GL locking policy.
Henri Verbeet
hverbeet at codeweavers.com
Thu Sep 2 12:25:00 CDT 2010
The basic rule is that you can't call anything that takes the user32 / gdi32
lock while under the GL (winex11) lock. As a consequence, you can't call
anything like context_acquire() or context_destroy() either.
---
dlls/wined3d/buffer.c | 3 ++
dlls/wined3d/context.c | 54 +++++-----------------------------------
dlls/wined3d/cubetexture.c | 4 +++
dlls/wined3d/device.c | 8 +++++-
dlls/wined3d/directx.c | 3 ++
dlls/wined3d/shader.c | 3 ++
dlls/wined3d/surface.c | 3 ++
dlls/wined3d/swapchain.c | 4 ++-
dlls/wined3d/swapchain_base.c | 4 ++-
dlls/wined3d/texture.c | 4 +++
dlls/wined3d/volume.c | 3 ++
dlls/wined3d/volumetexture.c | 3 ++
dlls/wined3d/wined3d_main.c | 1 +
13 files changed, 47 insertions(+), 50 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 477ac14..166508a 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -686,6 +686,7 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, const struct wined3d_gl_inf
return This->resource.allocatedMemory;
}
+/* Do not call while under the GL lock. */
static void STDMETHODCALLTYPE buffer_UnLoad(IWineD3DBuffer *iface)
{
struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
@@ -724,6 +725,7 @@ static void STDMETHODCALLTYPE buffer_UnLoad(IWineD3DBuffer *iface)
resource_unload((IWineD3DResourceImpl *)This);
}
+/* Do not call while under the GL lock. */
static ULONG STDMETHODCALLTYPE buffer_Release(IWineD3DBuffer *iface)
{
struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
@@ -921,6 +923,7 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
LEAVE_GL();
}
+/* Do not call while under the GL lock. */
static void STDMETHODCALLTYPE buffer_PreLoad(IWineD3DBuffer *iface)
{
struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index fa12d10..6f9d9d7 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -833,6 +833,7 @@ err:
context->valid = 0;
}
+/* Do not call while under the GL lock. */
static void context_validate(struct wined3d_context *context)
{
HWND wnd = WindowFromDC(context->hdc);
@@ -848,6 +849,7 @@ static void context_validate(struct wined3d_context *context)
context_update_window(context);
}
+/* Do not call while under the GL lock. */
static void context_destroy_gl_resources(struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
@@ -980,6 +982,7 @@ struct wined3d_context *context_get_current(void)
return TlsGetValue(wined3d_context_tls_idx);
}
+/* Do not call while under the GL lock. */
BOOL context_set_current(struct wined3d_context *ctx)
{
struct wined3d_context *old = context_get_current();
@@ -1264,18 +1267,7 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
return iPixelFormat;
}
-/*****************************************************************************
- * context_create
- *
- * Creates a new context.
- *
- * * Params:
- * This: Device to activate the context for
- * target: Surface this context will render to
- * win_handle: handle to the window which we are drawing to
- * pPresentParameters: contains the pixelformats to use for onscreen rendering
- *
- *****************************************************************************/
+/* Do not call while under the GL lock. */
struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain,
IWineD3DSurfaceImpl *target, const struct wined3d_format *ds_format)
{
@@ -1597,16 +1589,7 @@ out:
return NULL;
}
-/*****************************************************************************
- * context_destroy
- *
- * Destroys a wined3d context
- *
- * Params:
- * This: Device to activate the context for
- * context: Context to destroy
- *
- *****************************************************************************/
+/* Do not call while under the GL lock. */
void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context)
{
BOOL destroy;
@@ -1883,18 +1866,7 @@ static struct wined3d_context *findThreadContextForSwapChain(IWineD3DSwapChain *
return swapchain_create_context_for_thread(swapchain);
}
-/*****************************************************************************
- * FindContext
- *
- * Finds a context for the current render target and thread
- *
- * Parameters:
- * target: Render target to find the context for
- * tid: Thread to activate the context for
- *
- * Returns: The needed context
- *
- *****************************************************************************/
+/* Do not call while under the GL lock. */
static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target)
{
struct wined3d_context *current_context = context_get_current();
@@ -2300,19 +2272,7 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
context_set_render_offscreen(context, StateTable, render_offscreen);
}
-/*****************************************************************************
- * context_acquire
- *
- * Finds a rendering context and drawable matching the device and render
- * target for the current thread, activates them and puts them into the
- * requested state.
- *
- * Params:
- * This: Device to activate the context for
- * target: Requested render target
- * usage: Prepares the context for blitting, drawing or other actions
- *
- *****************************************************************************/
+/* Do not call while under the GL lock. */
struct wined3d_context *context_acquire(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *target)
{
struct wined3d_context *current_context = context_get_current();
diff --git a/dlls/wined3d/cubetexture.c b/dlls/wined3d/cubetexture.c
index 728548f..519efbd 100644
--- a/dlls/wined3d/cubetexture.c
+++ b/dlls/wined3d/cubetexture.c
@@ -27,6 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
+/* Do not call while under the GL lock. */
static void cubetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource Preload method. */
@@ -161,6 +162,7 @@ static ULONG WINAPI IWineD3DCubeTextureImpl_AddRef(IWineD3DCubeTexture *iface) {
return InterlockedIncrement(&This->resource.ref);
}
+/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface) {
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
ULONG ref;
@@ -198,10 +200,12 @@ static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *ifa
return resource_get_priority((IWineD3DResource *)iface);
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
cubetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface)
{
IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 68a6d16..01e3e90 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1259,6 +1259,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface,
return WINED3D_OK;
}
+/* Do not call while under the GL lock. */
static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, WINED3DSURFTYPE surface_type,
void *parent, IWineD3DSwapChain **swapchain)
@@ -6079,6 +6080,7 @@ static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, const WINED3DPRE
return FALSE;
}
+/* Do not call while under the GL lock. */
static void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
@@ -6123,6 +6125,7 @@ static void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChainImpl
swapchain->num_contexts = 0;
}
+/* Do not call while under the GL lock. */
static HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChainImpl *swapchain)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
@@ -6187,7 +6190,10 @@ err:
return hr;
}
-static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters) {
+/* Do not call while under the GL lock. */
+static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
+ WINED3DPRESENT_PARAMETERS *pPresentationParameters)
+{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DSwapChainImpl *swapchain;
HRESULT hr;
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index fab9a08..158bdc2 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -243,6 +243,7 @@ static void WineD3D_ReleaseFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
}
}
+/* Do not call while under the GL lock. */
static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
{
PIXELFORMATDESCRIPTOR pfd;
@@ -5080,6 +5081,7 @@ static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info)
}
}
+/* Do not call while under the GL lock. */
static BOOL InitAdapters(IWineD3DImpl *This)
{
static HMODULE mod_gl;
@@ -5409,6 +5411,7 @@ const struct wined3d_parent_ops wined3d_null_parent_ops =
wined3d_null_wined3d_object_destroyed,
};
+/* Do not call while under the GL lock. */
HRESULT wined3d_init(IWineD3DImpl *wined3d, UINT version, void *parent)
{
wined3d->lpVtbl = &IWineD3D_Vtbl;
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 87c664f..2adb62d 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1630,6 +1630,7 @@ static ULONG STDMETHODCALLTYPE vertexshader_AddRef(IWineD3DVertexShader *iface)
return refcount;
}
+/* Do not call while under the GL lock. */
static ULONG STDMETHODCALLTYPE vertexshader_Release(IWineD3DVertexShader *iface)
{
IWineD3DVertexShaderImpl *shader = (IWineD3DVertexShaderImpl *)iface;
@@ -1925,6 +1926,7 @@ static ULONG STDMETHODCALLTYPE geometryshader_AddRef(IWineD3DGeometryShader *ifa
return refcount;
}
+/* Do not call while under the GL lock. */
static ULONG STDMETHODCALLTYPE geometryshader_Release(IWineD3DGeometryShader *iface)
{
struct wined3d_geometryshader *shader = (struct wined3d_geometryshader *)iface;
@@ -2020,6 +2022,7 @@ static ULONG STDMETHODCALLTYPE pixelshader_AddRef(IWineD3DPixelShader *iface)
return refcount;
}
+/* Do not call while under the GL lock. */
static ULONG STDMETHODCALLTYPE pixelshader_Release(IWineD3DPixelShader *iface)
{
IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)iface;
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 0c72c91..fe26fd5 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1040,6 +1040,7 @@ static BOOL surface_convert_color_to_float(IWineD3DSurfaceImpl *surface, DWORD c
return TRUE;
}
+/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
@@ -1062,6 +1063,7 @@ static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
IWineD3DSurface IWineD3DResource parts follow
**************************************************** */
+/* Do not call while under the GL lock. */
void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srgb)
{
IWineD3DDeviceImpl *device = surface->resource.device;
@@ -1161,6 +1163,7 @@ BOOL surface_init_sysmem(IWineD3DSurfaceImpl *surface)
return TRUE;
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index a4e18be..455eb47 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -33,7 +33,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(fps);
-/*IWineD3DSwapChain parts follow: */
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface)
{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
@@ -621,6 +621,7 @@ void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain)
}
+/* Do not call while under the GL lock. */
HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent)
{
@@ -917,6 +918,7 @@ err:
return hr;
}
+/* Do not call while under the GL lock. */
struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface)
{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
diff --git a/dlls/wined3d/swapchain_base.c b/dlls/wined3d/swapchain_base.c
index 5b5739c..4532d32 100644
--- a/dlls/wined3d/swapchain_base.c
+++ b/dlls/wined3d/swapchain_base.c
@@ -53,7 +53,9 @@ ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) {
return refCount;
}
-ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) {
+/* Do not call while under the GL lock. */
+ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface)
+{
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
DWORD refCount;
refCount = InterlockedDecrement(&This->ref);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 3fc616d..8e285f7 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -27,6 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
+/* Do not call while under the GL lock. */
static void texture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource PreLoad method. */
@@ -155,6 +156,7 @@ static ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface) {
return InterlockedIncrement(&This->resource.ref);
}
+/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
ULONG ref;
@@ -193,10 +195,12 @@ static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) {
return resource_get_priority((IWineD3DResource *)iface);
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
texture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
unsigned int i;
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index ea49e56..7a7eb32 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -123,6 +123,7 @@ static ULONG WINAPI IWineD3DVolumeImpl_AddRef(IWineD3DVolume *iface) {
return InterlockedIncrement(&This->resource.ref);
}
+/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
ULONG ref;
@@ -166,10 +167,12 @@ static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
return resource_get_priority((IWineD3DResource *)iface);
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
FIXME("iface %p stub!\n", iface);
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface)
{
TRACE("iface %p.\n", iface);
diff --git a/dlls/wined3d/volumetexture.c b/dlls/wined3d/volumetexture.c
index a2b706e..6abba41 100644
--- a/dlls/wined3d/volumetexture.c
+++ b/dlls/wined3d/volumetexture.c
@@ -26,6 +26,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
+/* Do not call while under the GL lock. */
static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
{
/* Override the IWineD3DResource Preload method. */
@@ -124,6 +125,7 @@ static ULONG WINAPI IWineD3DVolumeTextureImpl_AddRef(IWineD3DVolumeTexture *ifac
return InterlockedIncrement(&This->resource.ref);
}
+/* Do not call while under the GL lock. */
static ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
ULONG ref;
@@ -165,6 +167,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *ifac
volumetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
}
+/* Do not call while under the GL lock. */
static void WINAPI IWineD3DVolumeTextureImpl_UnLoad(IWineD3DVolumeTexture *iface) {
unsigned int i;
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index 56e78ad..2b06b36 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -76,6 +76,7 @@ wined3d_settings_t wined3d_settings =
FALSE, /* No strict draw ordering. */
};
+/* Do not call while under the GL lock. */
IWineD3D * WINAPI WineDirect3DCreate(UINT version, void *parent)
{
IWineD3DImpl *object;
--
1.7.1
More information about the wine-patches
mailing list