This series of patches moves the reflection interface for d3d10 into the already existing d3d11 reflection interface within d3dcompiler_43. This is done using ifdef's. If this is not preferable, please let me know, and I'll change it to whatever considered the best option.
Connor McAdams (3): D3D10: Add d3dcompiler_43 PARENTSRC to d3d10 d3dcompiler: unify d3d11 + d3d10 reflection ifaces d3d10+d3dcompiler: Move d3d10 reflection into d3dcompiler
dlls/d3d10/Makefile.in | 19 +++++ dlls/d3d10/d3d10_main.c | 19 ++--- dlls/d3d10/d3d10_private.h | 10 +-- dlls/d3d10/effect.c | 12 ++-- dlls/d3d10/shader.c | 112 ------------------------------ dlls/d3d10/utils.c | 4 +- dlls/d3dcompiler_43/reflection.c | 115 +++++++++++++++++++++++-------- include/d3dcompiler.h | 4 ++ 8 files changed, 123 insertions(+), 172 deletions(-)
Adds PARENTSRC of d3dcompiler_43 to eventually use the reflection functionality from it. Fixes conflicts of GUID declarations and functions with the same names. --- dlls/d3d10/Makefile.in | 19 +++++++++++++++++++ dlls/d3d10/d3d10_private.h | 2 +- dlls/d3d10/effect.c | 12 ++++++------ dlls/d3d10/utils.c | 4 ++-- dlls/d3dcompiler_43/reflection.c | 3 ++- 5 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/dlls/d3d10/Makefile.in b/dlls/d3d10/Makefile.in index e76f3c5f19..2d79dd53e0 100644 --- a/dlls/d3d10/Makefile.in +++ b/dlls/d3d10/Makefile.in @@ -1,14 +1,33 @@ MODULE = d3d10.dll IMPORTLIB = d3d10 IMPORTS = dxguid uuid d3d10core d3dcompiler dxgi +EXTRADEFS = -DD3D10REFLECT +PARENTSRC = ../d3dcompiler_43
EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + asmparser.c \ + blob.c \ + bytecodewriter.c \ + compiler.c \ + preproc.c \ + reflection.c \ + ../d3dcompiler_43/utils.c \ d3d10_main.c \ effect.c \ shader.c \ stateblock.c \ utils.c
+LEX_SRCS = \ + asmshader.l \ + hlsl.l \ + ppl.l + +BISON_SRCS = \ + asmshader.y \ + hlsl.y \ + ppy.y + RC_SRCS = version.rc diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index f3fce9c569..bd149f0b41 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -298,7 +298,7 @@ static inline BOOL require_space(size_t offset, size_t count, size_t size, size_ return !count || (data_size - offset) / count >= size; }
-void skip_dword_unknown(const char *location, const char **ptr, unsigned int count) DECLSPEC_HIDDEN; +void d3d10_skip_dword_unknown(const char *location, const char **ptr, unsigned int count) DECLSPEC_HIDDEN; void write_dword_unknown(char **ptr, DWORD d) DECLSPEC_HIDDEN;
#endif /* __WINE_D3D10_PRIVATE_H */ diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 439833485d..031b907955 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -343,7 +343,7 @@ static HRESULT shader_parse_signature(const char *data, DWORD data_size, struct read_dword(&ptr, &count); TRACE("%u elements\n", count);
- skip_dword_unknown("shader signature", &ptr, 1); + d3d10_skip_dword_unknown("shader signature", &ptr, 1);
if (!require_space(ptr - data, count, 6 * sizeof(DWORD), data_size)) { @@ -1063,7 +1063,7 @@ static HRESULT parse_fx10_annotation(const char *data, size_t data_size, if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, a))) return hr;
- skip_dword_unknown("annotation", ptr, 1); + d3d10_skip_dword_unknown("annotation", ptr, 1);
/* mark the variable as annotation */ a->flag = D3D10_EFFECT_VARIABLE_ANNOTATION; @@ -1292,7 +1292,7 @@ static BOOL parse_fx10_state_group(const char *data, size_t data_size, { read_dword(ptr, &id); read_dword(ptr, &idx); - skip_dword_unknown("read property", ptr, 1); + d3d10_skip_dword_unknown("read property", ptr, 1); read_dword(ptr, &value_offset);
if (!(property_info = get_property_info(id))) @@ -1708,7 +1708,7 @@ static HRESULT parse_fx10_variable(const char *data, size_t data_size, read_dword(ptr, &v->buffer_offset); TRACE("Variable offset in buffer: %#x.\n", v->buffer_offset);
- skip_dword_unknown("variable", ptr, 1); + d3d10_skip_dword_unknown("variable", ptr, 1);
read_dword(ptr, &v->flag); TRACE("Variable flag: %#x.\n", v->flag); @@ -1795,7 +1795,7 @@ static HRESULT parse_fx10_local_variable(const char *data, size_t data_size, } TRACE("Variable semantic: %s.\n", debugstr_a(v->semantic));
- skip_dword_unknown("local variable", ptr, 1); + d3d10_skip_dword_unknown("local variable", ptr, 1);
switch (v->type->basetype) { @@ -1973,7 +1973,7 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, read_dword(ptr, &l->type->member_count); TRACE("Local buffer member count: %#x.\n", l->type->member_count);
- skip_dword_unknown("local buffer", ptr, 1); + d3d10_skip_dword_unknown("local buffer", ptr, 1);
read_dword(ptr, &l->annotation_count); TRACE("Local buffer has %u annotations.\n", l->annotation_count); diff --git a/dlls/d3d10/utils.c b/dlls/d3d10/utils.c index 3b51868488..3c9935a8ab 100644 --- a/dlls/d3d10/utils.c +++ b/dlls/d3d10/utils.c @@ -129,7 +129,7 @@ const char *debug_d3d10_device_state_types(D3D10_DEVICE_STATE_TYPES t)
#undef WINE_D3D10_TO_STR
-void skip_dword_unknown(const char *location, const char **ptr, unsigned int count) +void d3d10_skip_dword_unknown(const char *location, const char **ptr, unsigned int count) { unsigned int i; DWORD d; @@ -175,7 +175,7 @@ HRESULT parse_dxbc(const char *data, SIZE_T data_size, }
/* checksum? */ - skip_dword_unknown("DXBC header", &ptr, 4); + d3d10_skip_dword_unknown("DXBC header", &ptr, 4);
read_dword(&ptr, &version); TRACE("version: %#x.\n", version); diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index b163fca9e7..ce634ac95a 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -17,8 +17,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * */ - +#ifndef D3D10REFLECT #include "initguid.h" +#endif #include "d3dcompiler_private.h" #include "winternl.h"
Use ifdefs to change the type of the reflection iface, and change the name of the variable throughout. --- dlls/d3dcompiler_43/reflection.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index ce634ac95a..5faea4c8e6 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -22,6 +22,7 @@ #endif #include "d3dcompiler_private.h" #include "winternl.h" +#include "d3d10.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
@@ -94,7 +95,11 @@ struct d3dcompiler_shader_reflection_constant_buffer /* ID3D11ShaderReflection */ struct d3dcompiler_shader_reflection { - ID3D11ShaderReflection ID3D11ShaderReflection_iface; +#ifdef D3D10REFLECT + ID3D10ShaderReflection ID3DShaderReflection_iface; +#else + ID3D11ShaderReflection ID3DShaderReflection_iface; +#endif LONG refcount;
DWORD target; @@ -304,7 +309,7 @@ static void reflection_cleanup(struct d3dcompiler_shader_reflection *ref)
static inline struct d3dcompiler_shader_reflection *impl_from_ID3D11ShaderReflection(ID3D11ShaderReflection *iface) { - return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection, ID3D11ShaderReflection_iface); + return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection, ID3DShaderReflection_iface); }
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_QueryInterface(ID3D11ShaderReflection *iface, REFIID riid, void **object) @@ -702,7 +707,6 @@ static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtb d3dcompiler_shader_reflection_GetThreadGroupSize, d3dcompiler_shader_reflection_GetRequiresFlags, }; - /* ID3D11ShaderReflectionConstantBuffer methods */
static inline struct d3dcompiler_shader_reflection_constant_buffer *impl_from_ID3D11ShaderReflectionConstantBuffer(ID3D11ShaderReflectionConstantBuffer *iface) @@ -1693,9 +1697,6 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl HRESULT hr; unsigned int i;
- reflection->ID3D11ShaderReflection_iface.lpVtbl = &d3dcompiler_shader_reflection_vtbl; - reflection->refcount = 1; - wine_rb_init(&reflection->types, d3dcompiler_shader_reflection_type_compare);
hr = dxbc_parse(data, data_size, &src_dxbc); @@ -1838,6 +1839,11 @@ HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void if (!object) return E_OUTOFMEMORY;
+#ifndef D3D10REFLECT + object->ID3DShaderReflection_iface.lpVtbl = &d3dcompiler_shader_reflection_vtbl; + object->refcount = 1; +#endif + hr = d3dcompiler_shader_reflection_init(object, data, data_size); if (FAILED(hr)) {
This patch moves the implementation of d3d10 shader reflection into the existing d3dcompiler reflection code, and uses ifdefs to make the interface methods conform to the size of d3d10 structures. In the case of the methods GetResourceBindingDesc and GetConstantBuffer, no changes are needed, as the data structures and interfaces are the same between d3d10 and d3d11. --- dlls/d3d10/d3d10_main.c | 19 ++---- dlls/d3d10/d3d10_private.h | 8 --- dlls/d3d10/shader.c | 112 ------------------------------- dlls/d3dcompiler_43/reflection.c | 94 ++++++++++++++++++++------ include/d3dcompiler.h | 4 ++ 5 files changed, 81 insertions(+), 156 deletions(-)
diff --git a/dlls/d3d10/d3d10_main.c b/dlls/d3d10/d3d10_main.c index e3d1c57e44..7c7500e045 100644 --- a/dlls/d3d10/d3d10_main.c +++ b/dlls/d3d10/d3d10_main.c @@ -300,22 +300,11 @@ const char * WINAPI D3D10GetPixelShaderProfile(ID3D10Device *device)
HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector) { - struct d3d10_shader_reflection *object; - - FIXME("data %p, data_size %lu, reflector %p stub!\n", data, data_size, reflector); - - if (!(object = heap_alloc_zero(sizeof(*object)))) - { - ERR("Failed to allocate D3D10 shader reflection object memory\n"); - return E_OUTOFMEMORY; - } - - object->ID3D10ShaderReflection_iface.lpVtbl = &d3d10_shader_reflection_vtbl; - object->refcount = 1; + HRESULT hr;
- *reflector = &object->ID3D10ShaderReflection_iface; + TRACE("data %p, data_size %lu, reflector %p stub!\n", data, data_size, reflector);
- TRACE("Created ID3D10ShaderReflection %p\n", object); + hr = d3dcompiler_d3d10_reflection_init(data, data_size, (void **)reflector);
- return S_OK; + return hr; } diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index bd149f0b41..9e8fb77a77 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -255,14 +255,6 @@ struct d3d10_effect struct d3d10_effect_technique *techniques; };
-/* ID3D10ShaderReflection */ -extern const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl DECLSPEC_HIDDEN; -struct d3d10_shader_reflection -{ - ID3D10ShaderReflection ID3D10ShaderReflection_iface; - LONG refcount; -}; - HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size) DECLSPEC_HIDDEN;
/* D3D10Core */ diff --git a/dlls/d3d10/shader.c b/dlls/d3d10/shader.c index 52e3cc06bf..d198689af6 100644 --- a/dlls/d3d10/shader.c +++ b/dlls/d3d10/shader.c @@ -22,118 +22,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
-/* IUnknown methods */ - -static inline struct d3d10_shader_reflection *impl_from_ID3D10ShaderReflection(ID3D10ShaderReflection *iface) -{ - return CONTAINING_RECORD(iface, struct d3d10_shader_reflection, ID3D10ShaderReflection_iface); -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_QueryInterface(ID3D10ShaderReflection *iface, REFIID riid, void **object) -{ - TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); - - if (IsEqualGUID(riid, &IID_ID3D10ShaderReflection) - || 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 d3d10_shader_reflection_AddRef(ID3D10ShaderReflection *iface) -{ - struct d3d10_shader_reflection *This = impl_from_ID3D10ShaderReflection(iface); - ULONG refcount = InterlockedIncrement(&This->refcount); - - TRACE("%p increasing refcount to %u\n", This, refcount); - - return refcount; -} - -static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_Release(ID3D10ShaderReflection *iface) -{ - struct d3d10_shader_reflection *This = impl_from_ID3D10ShaderReflection(iface); - ULONG refcount = InterlockedDecrement(&This->refcount); - - TRACE("%p decreasing refcount to %u\n", This, refcount); - - if (!refcount) - heap_free(This); - - return refcount; -} - -/* ID3D10ShaderReflection methods */ - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetDesc(ID3D10ShaderReflection *iface, D3D10_SHADER_DESC *desc) -{ - FIXME("iface %p, desc %p stub!\n", iface, desc); - - return E_NOTIMPL; -} - -static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByIndex( - ID3D10ShaderReflection *iface, UINT index) -{ - FIXME("iface %p, index %u stub!\n", iface, index); - - return NULL; -} - -static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByName( - ID3D10ShaderReflection *iface, const char *name) -{ - FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name)); - - return NULL; -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetResourceBindingDesc( - ID3D10ShaderReflection *iface, UINT index, D3D10_SHADER_INPUT_BIND_DESC *desc) -{ - FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); - - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetInputParameterDesc( - ID3D10ShaderReflection *iface, UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc) -{ - FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); - - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetOutputParameterDesc( - ID3D10ShaderReflection *iface, UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc) -{ - FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); - - return E_NOTIMPL; -} - -const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl = -{ - /* IUnknown methods */ - d3d10_shader_reflection_QueryInterface, - d3d10_shader_reflection_AddRef, - d3d10_shader_reflection_Release, - /* ID3D10ShaderReflection methods */ - d3d10_shader_reflection_GetDesc, - d3d10_shader_reflection_GetConstantBufferByIndex, - d3d10_shader_reflection_GetConstantBufferByName, - d3d10_shader_reflection_GetResourceBindingDesc, - d3d10_shader_reflection_GetInputParameterDesc, - d3d10_shader_reflection_GetOutputParameterDesc, -}; - HRESULT WINAPI D3D10CompileShader(const char *data, SIZE_T data_size, const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *entrypoint, const char *profile, UINT flags, ID3D10Blob **shader, ID3D10Blob **error_messages) diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 5faea4c8e6..1658922f9a 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -307,7 +307,7 @@ static void reflection_cleanup(struct d3dcompiler_shader_reflection *ref)
/* IUnknown methods */
-static inline struct d3dcompiler_shader_reflection *impl_from_ID3D11ShaderReflection(ID3D11ShaderReflection *iface) +static inline struct d3dcompiler_shader_reflection *impl_from_ID3DShaderReflection(ID3D11ShaderReflection *iface) { return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection, ID3DShaderReflection_iface); } @@ -315,9 +315,13 @@ static inline struct d3dcompiler_shader_reflection *impl_from_ID3D11ShaderReflec 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); - +#ifndef D3D10REFLECT if (IsEqualGUID(riid, &IID_ID3D11ShaderReflection) || IsEqualGUID(riid, &IID_IUnknown)) +#else + if (IsEqualGUID(riid, &IID_ID3D10ShaderReflection) + || IsEqualGUID(riid, &IID_IUnknown)) +#endif { IUnknown_AddRef(iface); *object = iface; @@ -332,7 +336,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_QueryInterface(ID
static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_AddRef(ID3D11ShaderReflection *iface) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface); ULONG refcount = InterlockedIncrement(&This->refcount);
TRACE("%p increasing refcount to %u\n", This, refcount); @@ -342,7 +346,7 @@ static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_AddRef(ID3D11Shader
static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release(ID3D11ShaderReflection *iface) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface); ULONG refcount = InterlockedDecrement(&This->refcount);
TRACE("%p decreasing refcount to %u\n", This, refcount); @@ -360,7 +364,7 @@ static ULONG STDMETHODCALLTYPE d3dcompiler_shader_reflection_Release(ID3D11Shade
static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11ShaderReflection *iface, D3D11_SHADER_DESC *desc) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
FIXME("iface %p, desc %p partial stub!\n", iface, desc);
@@ -398,6 +402,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11Sha desc->EmitInstructionCount = This->emit_instruction_count; desc->GSOutputTopology = This->gs_output_topology; desc->GSMaxOutputVertexCount = This->gs_max_output_vertex_count; +#ifndef D3D10REFLECT desc->InputPrimitive = This->input_primitive; desc->PatchConstantParameters = This->pcsg ? This->pcsg->element_count : 0; desc->cGSInstanceCount = 0; @@ -408,14 +413,14 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetDesc(ID3D11Sha desc->cBarrierInstructions = 0; desc->cInterlockedInstructions = 0; desc->cTextureStoreInstructions = 0; - +#endif return S_OK; }
static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByIndex( ID3D11ShaderReflection *iface, UINT index) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
TRACE("iface %p, index %u\n", iface, index);
@@ -431,7 +436,7 @@ static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompil static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConstantBufferByName( ID3D11ShaderReflection *iface, const char *name) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface); unsigned int i;
TRACE("iface %p, name %s\n", iface, debugstr_a(name)); @@ -461,7 +466,7 @@ static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompil static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDesc( ID3D11ShaderReflection *iface, UINT index, D3D11_SHADER_INPUT_BIND_DESC *desc) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
@@ -479,7 +484,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindin static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameterDesc( ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
@@ -497,7 +502,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameter static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParameterDesc( ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
@@ -512,10 +517,11 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParamete return S_OK; }
+#ifndef D3D10REFLECT static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetPatchConstantParameterDesc( ID3D11ShaderReflection *iface, UINT index, D3D11_SIGNATURE_PARAMETER_DESC *desc) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
TRACE("iface %p, index %u, desc %p\n", iface, index, desc);
@@ -533,7 +539,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetPatchConstantP static struct ID3D11ShaderReflectionVariable * STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetVariableByName( ID3D11ShaderReflection *iface, const char *name) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface); unsigned int i, k;
TRACE("iface %p, name %s\n", iface, debugstr_a(name)); @@ -568,7 +574,7 @@ static struct ID3D11ShaderReflectionVariable * STDMETHODCALLTYPE d3dcompiler_sha static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindingDescByName( ID3D11ShaderReflection *iface, const char *name, D3D11_SHADER_INPUT_BIND_DESC *desc) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface); unsigned int i;
TRACE("iface %p, name %s, desc %p\n", iface, debugstr_a(name), desc); @@ -599,7 +605,7 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetResourceBindin static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMovInstructionCount( ID3D11ShaderReflection *iface) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
TRACE("iface %p\n", iface);
@@ -617,7 +623,7 @@ static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetMovcInstructionCo static UINT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetConversionInstructionCount( ID3D11ShaderReflection *iface) { - struct d3dcompiler_shader_reflection *This = impl_from_ID3D11ShaderReflection(iface); + struct d3dcompiler_shader_reflection *This = impl_from_ID3DShaderReflection(iface);
TRACE("iface %p\n", iface);
@@ -679,6 +685,7 @@ static UINT64 STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetRequiresFlags(
return 0; } +#endif
static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl = { @@ -693,6 +700,7 @@ static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtb d3dcompiler_shader_reflection_GetResourceBindingDesc, d3dcompiler_shader_reflection_GetInputParameterDesc, d3dcompiler_shader_reflection_GetOutputParameterDesc, +#ifndef D3D10REFLECT d3dcompiler_shader_reflection_GetPatchConstantParameterDesc, d3dcompiler_shader_reflection_GetVariableByName, d3dcompiler_shader_reflection_GetResourceBindingDescByName, @@ -706,6 +714,7 @@ static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtb d3dcompiler_shader_reflection_GetMinFeatureLevel, d3dcompiler_shader_reflection_GetThreadGroupSize, d3dcompiler_shader_reflection_GetRequiresFlags, +#endif }; /* ID3D11ShaderReflectionConstantBuffer methods */
@@ -1809,14 +1818,10 @@ err_out: return hr; }
-HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void **reflector) +static HRESULT d3dcompiler_check_bytecode_data(const void *data, SIZE_T data_size) { - struct d3dcompiler_shader_reflection *object; - HRESULT hr; const DWORD *temp = data;
- TRACE("data %p, data_size %lu, riid %s, blob %p\n", data, data_size, debugstr_guid(riid), reflector); - if (!data || data_size < 32) { WARN("Invalid argument supplied.\n"); @@ -1829,6 +1834,53 @@ HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void return E_FAIL; }
+ return S_OK; +} + +#ifdef D3D10REFLECT +HRESULT d3dcompiler_d3d10_reflection_init(const void *data, SIZE_T data_size, void **reflector) +{ + struct d3dcompiler_shader_reflection *object; + HRESULT hr; + + hr = d3dcompiler_check_bytecode_data(data, data_size); + if (hr != S_OK) + return hr; + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); + if (!object) + return E_OUTOFMEMORY; + + object->ID3DShaderReflection_iface.lpVtbl = (const struct ID3D10ShaderReflectionVtbl *)&d3dcompiler_shader_reflection_vtbl; + object->refcount = 1; + + hr = d3dcompiler_shader_reflection_init(object, data, data_size); + if (FAILED(hr)) + { + WARN("Failed to initialize shader reflection\n"); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + *reflector = &object->ID3DShaderReflection_iface; + + TRACE("Created ID3D10ShaderReflection %p\n", object); + + return S_OK; +} +#endif + +HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void **reflector) +{ + struct d3dcompiler_shader_reflection *object; + HRESULT hr; + + TRACE("data %p, data_size %lu, riid %s, blob %p\n", data, data_size, debugstr_guid(riid), reflector); + + hr = d3dcompiler_check_bytecode_data(data, data_size); + if (hr != S_OK) + return hr; + if (!IsEqualGUID(riid, &IID_ID3D11ShaderReflection)) { WARN("Wrong riid %s, accept only %s!\n", debugstr_guid(riid), debugstr_guid(&IID_ID3D11ShaderReflection)); diff --git a/include/d3dcompiler.h b/include/d3dcompiler.h index 5151f94510..c602d05e76 100644 --- a/include/d3dcompiler.h +++ b/include/d3dcompiler.h @@ -148,6 +148,10 @@ typedef HRESULT (WINAPI *pD3DPreprocess)(const void *data, SIZE_T size, const ch
HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module);
+#ifdef D3D10REFLECT +HRESULT d3dcompiler_d3d10_reflection_init(const void *data, SIZE_T data_size, void **reflector); +#endif + #ifdef __cplusplus } #endif