Commit 4b109ff1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Remove COM from the stateblock.

parent a538d28f
......@@ -1401,7 +1401,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_BeginStateBlock(IDirect3DDevice8 *ifa
static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(IDirect3DDevice8 *iface, DWORD *pToken)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DStateBlock *stateblock;
struct wined3d_stateblock *stateblock;
HRESULT hr;
TRACE("iface %p, token %p.\n", iface, pToken);
......@@ -1424,7 +1424,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(IDirect3DDevice8 *iface
{
ERR("Failed to create a handle\n");
wined3d_mutex_lock();
IWineD3DStateBlock_Release(stateblock);
wined3d_stateblock_decref(stateblock);
wined3d_mutex_unlock();
return E_FAIL;
}
......@@ -1437,8 +1437,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(IDirect3DDevice8 *iface
static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(IDirect3DDevice8 *iface, DWORD Token)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DStateBlock *stateblock;
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
struct wined3d_stateblock *stateblock;
HRESULT hr;
TRACE("iface %p, token %#x.\n", iface, Token);
......@@ -1453,7 +1453,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(IDirect3DDevice8 *ifa
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
hr = IWineD3DStateBlock_Apply(stateblock);
hr = wined3d_stateblock_apply(stateblock);
wined3d_mutex_unlock();
return hr;
......@@ -1462,7 +1462,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ApplyStateBlock(IDirect3DDevice8 *ifa
static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(IDirect3DDevice8 *iface, DWORD Token)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DStateBlock *stateblock;
struct wined3d_stateblock *stateblock;
HRESULT hr;
TRACE("iface %p, token %#x.\n", iface, Token);
......@@ -1475,7 +1475,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(IDirect3DDevice8 *i
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
hr = IWineD3DStateBlock_Capture(stateblock);
hr = wined3d_stateblock_capture(stateblock);
wined3d_mutex_unlock();
return hr;
......@@ -1484,7 +1484,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CaptureStateBlock(IDirect3DDevice8 *i
static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(IDirect3DDevice8 *iface, DWORD Token)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DStateBlock *stateblock;
struct wined3d_stateblock *stateblock;
TRACE("iface %p, token %#x.\n", iface, Token);
......@@ -1498,7 +1498,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_DeleteStateBlock(IDirect3DDevice8 *if
return D3DERR_INVALIDCALL;
}
if (IWineD3DStateBlock_Release((IUnknown *)stateblock))
if (wined3d_stateblock_decref(stateblock))
{
ERR("Stateblock %p has references left, this shouldn't happen.\n", stateblock);
}
......@@ -1511,7 +1511,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *if
D3DSTATEBLOCKTYPE Type, DWORD *handle)
{
IDirect3DDevice8Impl *This = impl_from_IDirect3DDevice8(iface);
IWineD3DStateBlock *stateblock;
struct wined3d_stateblock *stateblock;
HRESULT hr;
TRACE("iface %p, type %#x, handle %p.\n", iface, Type, handle);
......@@ -1540,7 +1540,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateStateBlock(IDirect3DDevice8 *if
{
ERR("Failed to allocate a handle.\n");
wined3d_mutex_lock();
IWineD3DStateBlock_Release(stateblock);
wined3d_stateblock_decref(stateblock);
wined3d_mutex_unlock();
return E_FAIL;
}
......
......@@ -411,14 +411,14 @@ typedef struct IDirect3DStateBlock9Impl {
LONG ref;
/* IDirect3DStateBlock9 fields */
IWineD3DStateBlock *wineD3DStateBlock;
struct wined3d_stateblock *wined3d_stateblock;
/* Parent reference */
LPDIRECT3DDEVICE9EX parentDevice;
} IDirect3DStateBlock9Impl;
HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device,
D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock) DECLSPEC_HIDDEN;
D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock) DECLSPEC_HIDDEN;
/* --------------------------- */
/* IDirect3DVertexDeclaration9 */
......
......@@ -1533,7 +1533,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(IDirect3DDevice9Ex *i
static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *iface, IDirect3DStateBlock9 **stateblock)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DStateBlock *wined3d_stateblock;
struct wined3d_stateblock *wined3d_stateblock;
IDirect3DStateBlock9Impl *object;
HRESULT hr;
......@@ -1553,7 +1553,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *ifa
{
ERR("Failed to allocate stateblock memory.\n");
wined3d_mutex_lock();
IWineD3DStateBlock_Release(wined3d_stateblock);
wined3d_stateblock_decref(wined3d_stateblock);
wined3d_mutex_unlock();
return E_OUTOFMEMORY;
}
......@@ -1563,7 +1563,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(IDirect3DDevice9Ex *ifa
{
WARN("Failed to initialize stateblock, hr %#x.\n", hr);
wined3d_mutex_lock();
IWineD3DStateBlock_Release(wined3d_stateblock);
wined3d_stateblock_decref(wined3d_stateblock);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, object);
return hr;
......
......@@ -60,7 +60,7 @@ static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface
if (ref == 0) {
wined3d_mutex_lock();
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
wined3d_stateblock_decref(This->wined3d_stateblock);
wined3d_mutex_unlock();
IDirect3DDevice9Ex_Release(This->parentDevice);
......@@ -91,7 +91,7 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 ifa
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
hr = wined3d_stateblock_capture(This->wined3d_stateblock);
wined3d_mutex_unlock();
return hr;
......@@ -104,7 +104,7 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface
TRACE("iface %p.\n", iface);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
hr = wined3d_stateblock_apply(This->wined3d_stateblock);
wined3d_mutex_unlock();
return hr;
......@@ -124,7 +124,7 @@ static const IDirect3DStateBlock9Vtbl Direct3DStateBlock9_Vtbl =
};
HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Impl *device,
D3DSTATEBLOCKTYPE type, IWineD3DStateBlock *wined3d_stateblock)
D3DSTATEBLOCKTYPE type, struct wined3d_stateblock *wined3d_stateblock)
{
HRESULT hr;
......@@ -133,13 +133,13 @@ HRESULT stateblock_init(IDirect3DStateBlock9Impl *stateblock, IDirect3DDevice9Im
if (wined3d_stateblock)
{
stateblock->wineD3DStateBlock = wined3d_stateblock;
stateblock->wined3d_stateblock = wined3d_stateblock;
}
else
{
wined3d_mutex_lock();
hr = IWineD3DDevice_CreateStateBlock(device->WineD3DDevice,
(WINED3DSTATEBLOCKTYPE)type, &stateblock->wineD3DStateBlock);
(WINED3DSTATEBLOCKTYPE)type, &stateblock->wined3d_stateblock);
wined3d_mutex_unlock();
if (FAILED(hr))
{
......
......@@ -5484,7 +5484,7 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
DWORD *BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IWineD3DStateBlock *wined3d_sb;
struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
DWORD h;
......@@ -5511,7 +5511,7 @@ IDirect3DDeviceImpl_7_EndStateBlock(IDirect3DDevice7 *iface,
if (h == DDRAW_INVALID_HANDLE)
{
ERR("Failed to allocate a stateblock handle.\n");
IWineD3DStateBlock_Release(wined3d_sb);
wined3d_stateblock_decref(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
*BlockHandle = 0;
return DDERR_OUTOFMEMORY;
......@@ -5617,7 +5617,7 @@ IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
DWORD BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IWineD3DStateBlock *wined3d_sb;
struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
......@@ -5632,7 +5632,7 @@ IDirect3DDeviceImpl_7_ApplyStateBlock(IDirect3DDevice7 *iface,
return D3DERR_INVALIDSTATEBLOCK;
}
hr = IWineD3DStateBlock_Apply(wined3d_sb);
hr = wined3d_stateblock_apply(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
......@@ -5680,7 +5680,7 @@ IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
DWORD BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IWineD3DStateBlock *wined3d_sb;
struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
......@@ -5695,7 +5695,7 @@ IDirect3DDeviceImpl_7_CaptureStateBlock(IDirect3DDevice7 *iface,
return D3DERR_INVALIDSTATEBLOCK;
}
hr = IWineD3DStateBlock_Capture(wined3d_sb);
hr = wined3d_stateblock_capture(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
return hr_ddraw_from_wined3d(hr);
}
......@@ -5741,7 +5741,7 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
DWORD BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IWineD3DStateBlock *wined3d_sb;
struct wined3d_stateblock *wined3d_sb;
ULONG ref;
TRACE("iface %p, stateblock %#x.\n", iface, BlockHandle);
......@@ -5756,7 +5756,7 @@ IDirect3DDeviceImpl_7_DeleteStateBlock(IDirect3DDevice7 *iface,
return D3DERR_INVALIDSTATEBLOCK;
}
if ((ref = IWineD3DStateBlock_Release(wined3d_sb)))
if ((ref = wined3d_stateblock_decref(wined3d_sb)))
{
ERR("Something is still holding stateblock %p (refcount %u).\n", wined3d_sb, ref);
}
......@@ -5808,7 +5808,7 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
DWORD *BlockHandle)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
IWineD3DStateBlock *wined3d_sb;
struct wined3d_stateblock *wined3d_sb;
HRESULT hr;
DWORD h;
......@@ -5840,7 +5840,7 @@ IDirect3DDeviceImpl_7_CreateStateBlock(IDirect3DDevice7 *iface,
if (h == DDRAW_INVALID_HANDLE)
{
ERR("Failed to allocate stateblock handle.\n");
IWineD3DStateBlock_Release(wined3d_sb);
wined3d_stateblock_decref(wined3d_sb);
LeaveCriticalSection(&ddraw_cs);
return DDERR_OUTOFMEMORY;
}
......
......@@ -1894,7 +1894,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
}
TRACE("(%p) : Created stateblock (%p)\n", This, This->stateBlock);
This->updateStateBlock = This->stateBlock;
IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
wined3d_stateblock_incref(This->updateStateBlock);
This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(*This->render_targets) * gl_info->limits.buffers);
......@@ -2052,8 +2052,9 @@ err_out:
if(swapchain) {
IWineD3DSwapChain_Release( (IWineD3DSwapChain *) swapchain);
}
if(This->stateBlock) {
IWineD3DStateBlock_Release((IWineD3DStateBlock *) This->stateBlock);
if (This->stateBlock)
{
wined3d_stateblock_decref(This->stateBlock);
This->stateBlock = NULL;
}
if (This->blit_priv) {
......@@ -2175,22 +2176,20 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
}
/* Release the update stateblock */
if(IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock) > 0){
if(This->updateStateBlock != This->stateBlock)
FIXME("(%p) Something's still holding the Update stateblock\n",This);
if (wined3d_stateblock_decref(This->updateStateBlock))
{
if (This->updateStateBlock != This->stateBlock)
FIXME("Something's still holding the update stateblock.\n");
}
This->updateStateBlock = NULL;
{ /* because were not doing proper internal refcounts releasing the primary state block
causes recursion with the extra checks in ResourceReleased, to avoid this we have
to set this->stateBlock = NULL; first */
IWineD3DStateBlock *stateBlock = (IWineD3DStateBlock *)This->stateBlock;
{
struct wined3d_stateblock *stateblock = This->stateBlock;
This->stateBlock = NULL;
/* Release the stateblock */
if(IWineD3DStateBlock_Release(stateBlock) > 0){
FIXME("(%p) Something's still holding the Update stateblock\n",This);
}
if (wined3d_stateblock_decref(stateblock))
FIXME("Something's still holding the stateblock.\n");
}
/* Destroy the shader backend. Note that this has to happen after all shaders are destroyed. */
......@@ -4650,7 +4649,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface)
hr = IWineD3DDeviceImpl_CreateStateBlock(iface, WINED3DSBT_RECORDED, &stateblock);
if (FAILED(hr)) return hr;
IWineD3DStateBlock_Release((IWineD3DStateBlock*)This->updateStateBlock);
wined3d_stateblock_decref(This->updateStateBlock);
This->updateStateBlock = (IWineD3DStateBlockImpl *)stateblock;
This->isRecordingState = TRUE;
......@@ -4674,7 +4673,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
*ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE;
This->updateStateBlock = This->stateBlock;
IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
wined3d_stateblock_incref(This->updateStateBlock);
/* IWineD3DStateBlock_AddRef(*ppStateBlock); don't need to do this, since we should really just release UpdateStateBlock first */
TRACE("(%p) returning token (ptr to stateblock) of %p\n", This, *ppStateBlock);
return WINED3D_OK;
......@@ -6404,8 +6403,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
IWineD3DDevice_SetDepthStencilSurface(iface, NULL);
TRACE("Resetting stateblock\n");
IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock);
IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
wined3d_stateblock_decref(This->updateStateBlock);
wined3d_stateblock_decref(This->stateBlock);
delete_opengl_contexts(This, swapchain);
......@@ -6526,7 +6525,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
if (FAILED(hr)) ERR("Resetting the stateblock failed with error 0x%08x\n", hr);
else TRACE("Created stateblock %p\n", This->stateBlock);
This->updateStateBlock = This->stateBlock;
IWineD3DStateBlock_AddRef((IWineD3DStateBlock *)This->updateStateBlock);
wined3d_stateblock_incref(This->updateStateBlock);
stateblock_init_default_state(This->stateBlock);
......
......@@ -2,3 +2,8 @@
@ stdcall WineDirect3DCreateClipper()
@ stdcall wined3d_mutex_lock()
@ stdcall wined3d_mutex_unlock()
@ cdecl wined3d_stateblock_apply(ptr)
@ cdecl wined3d_stateblock_capture(ptr)
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
......@@ -52,7 +52,8 @@
#define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
#define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
typedef struct wined3d_stateblock IWineD3DStateBlockImpl;
typedef struct wined3d_stateblock IWineD3DStateBlock;
typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
......@@ -2432,10 +2433,9 @@ struct wined3d_state
DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
};
struct IWineD3DStateBlockImpl
struct wined3d_stateblock
{
/* IUnknown fields */
const IWineD3DStateBlockVtbl *lpVtbl;
LONG ref; /* Note: Ref counting not required */
/* IWineD3DStateBlock information */
......
......@@ -2110,6 +2110,7 @@ interface IWineD3DSurface;
interface IWineD3DVolume;
interface IWineD3DSwapChain;
interface IWineD3DDevice;
struct wined3d_stateblock;
[
object,
......@@ -2614,19 +2615,6 @@ interface IWineD3DVertexDeclaration : IWineD3DBase
[
object,
local,
uuid(83b073ce-6f30-11d9-c687-00046142c14f)
]
interface IWineD3DStateBlock : IUnknown
{
HRESULT Capture(
);
HRESULT Apply(
);
}
[
object,
local,
uuid(905ddbac-6f30-11d9-c687-00046142c14f)
]
interface IWineD3DQuery : IUnknown
......@@ -2790,7 +2778,7 @@ interface IWineD3DDevice : IUnknown
);
HRESULT CreateStateBlock(
[in] WINED3DSTATEBLOCKTYPE type,
[out] IWineD3DStateBlock **stateblock
[out] struct wined3d_stateblock **stateblock
);
HRESULT CreateSurface(
[in] UINT width,
......@@ -3245,7 +3233,7 @@ interface IWineD3DDevice : IUnknown
HRESULT BeginStateBlock(
);
HRESULT EndStateBlock(
[out] IWineD3DStateBlock **stateblock
[out] struct wined3d_stateblock **stateblock
);
HRESULT BeginScene(
);
......@@ -3365,3 +3353,8 @@ IWineD3D * __stdcall WineDirect3DCreate(UINT dxVersion, void *parent);
IWineD3DClipper * __stdcall WineDirect3DCreateClipper(void);
void __stdcall wined3d_mutex_lock(void);
void __stdcall wined3d_mutex_unlock(void);
HRESULT __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment