diff --git a/dlls/d3d10/Makefile.in b/dlls/d3d10/Makefile.in index feca50ed415..6e3f3118c0e 100644 --- a/dlls/d3d10/Makefile.in +++ b/dlls/d3d10/Makefile.in @@ -6,6 +6,7 @@ C_SRCS = \ d3d10_main.c \ effect.c \ shader.c \ + stateblock.c \ utils.c RC_SRCS = version.rc diff --git a/dlls/d3d10/d3d10.spec b/dlls/d3d10/d3d10.spec index 94e24247dd3..16d2d5f822b 100644 --- a/dlls/d3d10/d3d10.spec +++ b/dlls/d3d10/d3d10.spec @@ -5,7 +5,7 @@ @ stdcall D3D10CreateDeviceAndSwapChain(ptr long ptr long long ptr ptr ptr) @ stdcall D3D10CreateEffectFromMemory(ptr long long ptr ptr ptr) @ stub D3D10CreateEffectPoolFromMemory -@ stub D3D10CreateStateBlock +@ stdcall D3D10CreateStateBlock(ptr ptr ptr) @ stub D3D10DisassembleEffect @ stub D3D10DisassembleShader @ stdcall D3D10GetGeometryShaderProfile(ptr) diff --git a/dlls/d3d10/stateblock.c b/dlls/d3d10/stateblock.c new file mode 100644 index 00000000000..a254704bf8c --- /dev/null +++ b/dlls/d3d10/stateblock.c @@ -0,0 +1,145 @@ +/* + * Copyright 2011 Henri Verbeet for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#include "config.h" +#include "wine/port.h" + +#include "d3d10_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3d10); + +struct d3d10_stateblock +{ + ID3D10StateBlock ID3D10StateBlock_iface; + LONG refcount; +}; + +static inline struct d3d10_stateblock *impl_from_ID3D10StateBlock(ID3D10StateBlock *iface) +{ + return CONTAINING_RECORD(iface, struct d3d10_stateblock, ID3D10StateBlock_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d10_stateblock_QueryInterface(ID3D10StateBlock *iface, REFIID iid, void **object) +{ + struct d3d10_stateblock *stateblock; + + TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object); + + stateblock = impl_from_ID3D10StateBlock(iface); + + if (IsEqualGUID(iid, &IID_ID3D10StateBlock) + || IsEqualGUID(iid, &IID_IUnknown)) + { + IUnknown_AddRef(&stateblock->ID3D10StateBlock_iface); + *object = &stateblock->ID3D10StateBlock_iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + *object = NULL; + + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d10_stateblock_AddRef(ID3D10StateBlock *iface) +{ + struct d3d10_stateblock *stateblock = impl_from_ID3D10StateBlock(iface); + ULONG refcount = InterlockedIncrement(&stateblock->refcount); + + TRACE("%p increasing refcount to %u.\n", stateblock, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d10_stateblock_Release(ID3D10StateBlock *iface) +{ + struct d3d10_stateblock *stateblock = impl_from_ID3D10StateBlock(iface); + ULONG refcount = InterlockedDecrement(&stateblock->refcount); + + TRACE("%p decreasing refcount to %u.\n", stateblock, refcount); + + if (!refcount) + HeapFree(GetProcessHeap(), 0, stateblock); + + return refcount; +} + +static HRESULT STDMETHODCALLTYPE d3d10_stateblock_Capture(ID3D10StateBlock *iface) +{ + FIXME("iface %p stub!\n", iface); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d10_stateblock_Apply(ID3D10StateBlock *iface) +{ + FIXME("iface %p stub!\n", iface); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d10_stateblock_ReleaseAllDeviceObjects(ID3D10StateBlock *iface) +{ + FIXME("iface %p stub!\n", iface); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d10_stateblock_GetDevice(ID3D10StateBlock *iface, ID3D10Device **device) +{ + FIXME("iface %p, device %p stub!\n", iface, device); + + return E_NOTIMPL; +} + +static const struct ID3D10StateBlockVtbl d3d10_stateblock_vtbl = +{ + /* IUnknown methods */ + d3d10_stateblock_QueryInterface, + d3d10_stateblock_AddRef, + d3d10_stateblock_Release, + /* ID3D10StateBlock methods */ + d3d10_stateblock_Capture, + d3d10_stateblock_Apply, + d3d10_stateblock_ReleaseAllDeviceObjects, + d3d10_stateblock_GetDevice, +}; + +HRESULT WINAPI D3D10CreateStateBlock(ID3D10Device *device, + D3D10_STATE_BLOCK_MASK *mask, ID3D10StateBlock **stateblock) +{ + struct d3d10_stateblock *object; + + FIXME("device %p, mask %p, stateblock %p stub!\n", device, mask, stateblock); + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate D3D10 stateblock object memory.\n"); + return E_OUTOFMEMORY; + } + + object->ID3D10StateBlock_iface.lpVtbl = &d3d10_stateblock_vtbl; + object->refcount = 1; + + TRACE("Created stateblock %p.\n", object); + *stateblock = &object->ID3D10StateBlock_iface; + + return S_OK; +}