From a7cf4d16fada5d76ba3c570e2eb21543f7249794 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rico=20Sch=C3=BCller?= Date: Mon, 1 Nov 2010 22:18:56 +0100 Subject: [PATCH] d3dcompiler: Add stub ID3D11ShaderReflection interface. --- dlls/d3dcompiler_43/Makefile.in | 1 + dlls/d3dcompiler_43/d3dcompiler_43_main.c | 18 ++- dlls/d3dcompiler_43/d3dcompiler_private.h | 8 + dlls/d3dcompiler_43/reflection.c | 243 ++++++++++++++++++++++++++++++ 4 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 dlls/d3dcompiler_43/reflection.c diff --git a/dlls/d3dcompiler_43/Makefile.in b/dlls/d3dcompiler_43/Makefile.in index 02259f87c77..f69eb770684 100644 --- a/dlls/d3dcompiler_43/Makefile.in +++ b/dlls/d3dcompiler_43/Makefile.in @@ -9,6 +9,7 @@ C_SRCS = \ bytecodewriter.c \ compiler.c \ d3dcompiler_43_main.c \ + reflection.c \ utils.c LEX_SRCS = asmshader.l diff --git a/dlls/d3dcompiler_43/d3dcompiler_43_main.c b/dlls/d3dcompiler_43/d3dcompiler_43_main.c index 90960365d18..e4f8f997d8a 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_43_main.c +++ b/dlls/d3dcompiler_43/d3dcompiler_43_main.c @@ -126,7 +126,23 @@ HRESULT WINAPI D3DStripShader(const void *data, SIZE_T data_size, UINT flags, ID HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void **reflector) { + struct d3dcompiler_shader_reflection *object; + FIXME("data %p, data_size %lu, riid %s, blob %p stub!\n", data, data_size, debugstr_guid(riid), reflector); - return E_NOTIMPL; + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + { + ERR("Failed to allocate D3D compiler shader reflection object memory\n"); + return E_OUTOFMEMORY; + } + + object->vtbl = &d3dcompiler_shader_reflection_vtbl; + object->refcount = 1; + + *reflector = (ID3D11ShaderReflection *)object; + + TRACE("Created ID3D11ShaderReflection %p\n", object); + + return S_OK; } diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index a5af78828a0..0b9962951fd 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -57,6 +57,14 @@ HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_size) D HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN; HRESULT d3dcompiler_strip_shader(const void *data, SIZE_T data_size, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN; +/* ID3D11ShaderReflection */ +extern const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl DECLSPEC_HIDDEN; +struct d3dcompiler_shader_reflection +{ + const struct ID3D11ShaderReflectionVtbl *vtbl; + LONG refcount; +}; + /* Shader assembler definitions */ typedef enum _shader_type { ST_VERTEX, diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c new file mode 100644 index 00000000000..f92c98655d2 --- /dev/null +++ b/dlls/d3dcompiler_43/reflection.c @@ -0,0 +1,243 @@ +/* + * Copyright 2009 Henri Verbeet for CodeWeavers + * 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" + +WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler); + +/* IUnknown methods */ + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_QueryInterface(ID3D11ShaderReflection *iface, REFIID riid, void **object) +{ + TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D11ShaderReflection) + || 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_shader_reflection_AddRef(ID3D11ShaderReflection *iface) +{ + struct d3dcompiler_shader_reflection *This = (struct d3dcompiler_shader_reflection *)iface; + ULONG refcount = InterlockedIncrement(&This->refcount); + + TRACE("%p increasing refcount to %u\n", This, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release(ID3D11ShaderReflection *iface) +{ + struct d3dcompiler_shader_reflection *This = (struct d3dcompiler_shader_reflection *)iface; + ULONG refcount = InterlockedDecrement(&This->refcount); + + TRACE("%p decreasing refcount to %u\n", This, refcount); + + if (!refcount) + { + HeapFree(GetProcessHeap(), 0, This); + } + + return refcount; +} + +/* ID3D11ShaderReflection methods */ + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11ShaderReflection *iface, D3D11_SHADER_DESC *desc) +{ + FIXME("iface %p, desc %p stub!\n", iface, desc); + + return E_NOTIMPL; +} + +static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByIndex( + ID3D11ShaderReflection *iface, UINT index) +{ + FIXME("iface %p, index %u stub!\n", iface, index); + + return NULL; +} + +static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByName( + ID3D11ShaderReflection *iface, LPCSTR name) +{ + FIXME("iface %p, name \"%s\" stub!\n", iface, name); + + return NULL; +} + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDesc( + ID3D11ShaderReflection *iface, UINT index, D3D11_SHADER_INPUT_BIND_DESC *desc) +{ + FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameterDesc( + ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc) +{ + FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParameterDesc( + ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc) +{ + FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetPatchConstantParameterDesc( + ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc) +{ + FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + + return E_NOTIMPL; +} + +static struct ID3D11ShaderReflectionVariable * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetVariableByName( + ID3D11ShaderReflection *iface, LPCSTR name) +{ + FIXME("iface %p, name %s stub!\n", iface, name); + + return NULL; +} + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDescByName( + ID3D11ShaderReflection *iface, LPCSTR name, D3D11_SHADER_INPUT_BIND_DESC *desc) +{ + FIXME("iface %p, name %s, desc %p stub!\n", iface, name, desc); + + return E_NOTIMPL; +} + +static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMovInstructionCount( + ID3D11ShaderReflection *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMovcInstructionCount( + ID3D11ShaderReflection *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConversionInstructionCount( + ID3D11ShaderReflection *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetBitwiseInstructionCount( + ID3D11ShaderReflection *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static D3D_PRIMITIVE STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetGSInputPrimitive( + ID3D11ShaderReflection *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static BOOL STDMETHODCALLTYPE d3dcompiler_shader_reflection_IsSampleFrequencyShader( + ID3D11ShaderReflection *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetNumInterfaceSlots( + ID3D11ShaderReflection *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMinFeatureLevel( + ID3D11ShaderReflection *iface, D3D_FEATURE_LEVEL *level) +{ + FIXME("iface %p, level %p stub!\n", iface, level); + + return E_NOTIMPL; +} + +static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetThreadGroupSize( + ID3D11ShaderReflection *iface, UINT *sizex, UINT *sizey, UINT *sizez) +{ + FIXME("iface %p, sizex %p, sizey %p, sizez %p stub!\n", iface, sizex, sizey, sizez); + + return 0; +} + +const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl = +{ + /* IUnknown methods */ + d3dcompiler_shader_reflection_QueryInterface, + d3dcompiler_shader_reflection_AddRef, + d3dcompiler_shader_reflection_Release, + /* ID3D11ShaderReflection methods */ + d3dcompiler_shader_reflection_GetDesc, + d3dcompiler_shader_reflection_GetConstantBufferByIndex, + d3dcompiler_shader_reflection_GetConstantBufferByName, + d3dcompiler_shader_reflection_GetResourceBindingDesc, + d3dcompiler_shader_reflection_GetInputParameterDesc, + d3dcompiler_shader_reflection_GetOutputParameterDesc, + d3dcompiler_shader_reflection_GetPatchConstantParameterDesc, + d3dcompiler_shader_reflection_GetVariableByName, + d3dcompiler_shader_reflection_GetResourceBindingDescByName, + d3dcompiler_shader_reflection_GetMovInstructionCount, + d3dcompiler_shader_reflection_GetMovcInstructionCount, + d3dcompiler_shader_reflection_GetConversionInstructionCount, + d3dcompiler_shader_reflection_GetBitwiseInstructionCount, + d3dcompiler_shader_reflection_GetGSInputPrimitive, + d3dcompiler_shader_reflection_IsSampleFrequencyShader, + d3dcompiler_shader_reflection_GetNumInterfaceSlots, + d3dcompiler_shader_reflection_GetMinFeatureLevel, + d3dcompiler_shader_reflection_GetThreadGroupSize, +}; -- 2.11.4.GIT