diff --git a/dlls/d3dcompiler_43/Makefile.in b/dlls/d3dcompiler_43/Makefile.in index 2510af47af2..806cb08567a 100644 --- a/dlls/d3dcompiler_43/Makefile.in +++ b/dlls/d3dcompiler_43/Makefile.in @@ -4,8 +4,10 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = d3dcompiler_43.dll IMPORTLIB = d3dcompiler +IMPORTS = dxguid uuid C_SRCS = \ + blob.c \ d3dcompiler_43_main.c RC_SRCS = version.rc diff --git a/dlls/d3dcompiler_43/blob.c b/dlls/d3dcompiler_43/blob.c new file mode 100644 index 00000000000..e5d11e58adb --- /dev/null +++ b/dlls/d3dcompiler_43/blob.c @@ -0,0 +1,117 @@ +/* + * Direct3D blob file + * + * Copyright 2010 Rico Schüller + * + * 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 "d3dcompiler_private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler); + +/* IUnknown methods */ + +static HRESULT STDMETHODCALLTYPE d3dcompiler_blob_QueryInterface(ID3DBlob *iface, REFIID riid, void **object) +{ + TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D10Blob) + || IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *object = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3dcompiler_blob_AddRef(ID3DBlob *iface) +{ + struct d3dcompiler_blob *blob = (struct d3dcompiler_blob *)iface; + ULONG refcount = InterlockedIncrement(&blob->refcount); + + TRACE("%p increasing refcount to %u\n", blob, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3dcompiler_blob_Release(ID3DBlob *iface) +{ + struct d3dcompiler_blob *blob = (struct d3dcompiler_blob *)iface; + ULONG refcount = InterlockedDecrement(&blob->refcount); + + TRACE("%p decreasing refcount to %u\n", blob, refcount); + + if (!refcount) + { + HeapFree(GetProcessHeap(), 0, blob->data); + HeapFree(GetProcessHeap(), 0, blob); + } + + return refcount; +} + +/* ID3DBlob methods */ + +static void * STDMETHODCALLTYPE d3dcompiler_blob_GetBufferPointer(ID3DBlob *iface) +{ + FIXME("iface %p stub!\n", iface); + + return NULL; +} + +static SIZE_T STDMETHODCALLTYPE d3dcompiler_blob_GetBufferSize(ID3DBlob *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +const struct ID3D10BlobVtbl d3dcompiler_blob_vtbl = +{ + /* IUnknown methods */ + d3dcompiler_blob_QueryInterface, + d3dcompiler_blob_AddRef, + d3dcompiler_blob_Release, + /* ID3DBlob methods */ + d3dcompiler_blob_GetBufferPointer, + d3dcompiler_blob_GetBufferSize, +}; + +HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_size) +{ + blob->vtbl = &d3dcompiler_blob_vtbl; + blob->refcount = 1; + blob->size = data_size; + + blob->data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, data_size); + if (!blob->data) + { + ERR("Failed to allocate D3D blob data memory\n"); + return E_OUTOFMEMORY; + } + + return S_OK; +} diff --git a/dlls/d3dcompiler_43/d3dcompiler_43.spec b/dlls/d3dcompiler_43/d3dcompiler_43.spec index ab6e1d78ae3..13c13a68095 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_43.spec +++ b/dlls/d3dcompiler_43/d3dcompiler_43.spec @@ -2,7 +2,7 @@ @ stub DebugSetMute @ stub D3DCompile @ stub D3DCompressShaders -@ stub D3DCreateBlob +@ stdcall D3DCreateBlob(long ptr) @ stub D3DDecompressShaders @ stub D3DDisassemble10Effect @ stub D3DDisassemble diff --git a/dlls/d3dcompiler_43/d3dcompiler_43_main.c b/dlls/d3dcompiler_43/d3dcompiler_43_main.c index cdf69b7ce4c..fa331b9bb29 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_43_main.c +++ b/dlls/d3dcompiler_43/d3dcompiler_43_main.c @@ -27,6 +27,8 @@ #include "winbase.h" #include "wine/debug.h" +#include "d3dcompiler_private.h" + WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler); BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) @@ -43,3 +45,38 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) } return TRUE; } + +HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob) +{ + struct d3dcompiler_blob *object; + HRESULT hr; + + TRACE("data_size %lu, blob %p\n", data_size, blob); + + if (!blob) + { + WARN("Invalid blob specified.\n"); + return D3DERR_INVALIDCALL; + } + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate D3D blob object memory\n"); + return E_OUTOFMEMORY; + } + + hr = d3dcompiler_blob_init(object, data_size); + if (FAILED(hr)) + { + WARN("Failed to initialize blob, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + *blob = (ID3DBlob *)object; + + TRACE("Created ID3DBlob %p\n", object); + + return S_OK; +} diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h new file mode 100644 index 00000000000..0c7cba1dab2 --- /dev/null +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -0,0 +1,50 @@ +/* + * Copyright 2010 Rico Schüller + * + * 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 + */ + +#ifndef __WINE_D3DCOMPILER_PRIVATE_H +#define __WINE_D3DCOMPILER_PRIVATE_H + +#include + +#define COBJMACROS +#include "windef.h" +#include "winbase.h" +#include "objbase.h" + +#include "d3dcompiler.h" + +/* + * This doesn't belong here, but for some functions it is possible to return that value, + * see http://msdn.microsoft.com/en-us/library/bb205278%28v=VS.85%29.aspx + * The original definition is in D3DX10core.h. + */ +#define D3DERR_INVALIDCALL 0x8876086c + +/* ID3DBlob */ +struct d3dcompiler_blob +{ + const struct ID3D10BlobVtbl *vtbl; + LONG refcount; + + SIZE_T size; + void *data; +}; + +HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_size) DECLSPEC_HIDDEN; + +#endif /* __WINE_D3DCOMPILER_PRIVATE_H */