Ignore first patch series, it was missing memcpy for GetInputParameterDesc/GetOutputParameterDesc.
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.
Signed-off-by: Connor McAdams conmanx360@gmail.com
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 | 123 ++++++++++++++++++++++++------- include/d3dcompiler.h | 4 + 8 files changed, 131 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.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- 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"
Hi Connor,
C_SRCS = \
asmparser.c \
blob.c \
bytecodewriter.c \
compiler.c \
preproc.c \
reflection.c \
../d3dcompiler_43/utils.c \
Since you have PARENTSRC set, have the path doesn't make sense.
d3d10_main.c \ effect.c \ shader.c \ stateblock.c \ utils.c
^^^^^^^^^^^^^^ Is there a reason you are including two utils.c files? Wouldn't they compile to the same place?
Regards Alistair.
Although, I see what you're saying... it would overwrite the utils.c file within the folder in the order they are compiled. Guess a name change might be in order.
On Thu, Oct 24, 2019 at 5:50 PM Alistair Leslie-Hughes leslie_alistair@hotmail.com wrote:
Hi Connor,
C_SRCS = \
asmparser.c \
blob.c \
bytecodewriter.c \
compiler.c \
preproc.c \
reflection.c \
../d3dcompiler_43/utils.c \
Since you have PARENTSRC set, have the path doesn't make sense.
d3d10_main.c \ effect.c \ shader.c \ stateblock.c \ utils.c
^^^^^^^^^^^^^^
Is there a reason you are including two utils.c files? Wouldn't they compile to the same place?
Regards Alistair.
On Thu, Oct 24, 2019 at 9:49 PM Connor McAdams conmanx360@gmail.com wrote:
Adds PARENTSRC of d3dcompiler_43 to eventually use the reflection functionality from it. Fixes conflicts of GUID declarations and functions with the same names.
Signed-off-by: Connor McAdams conmanx360@gmail.com
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
For the time being you shouldn't need any of those source files from d3dcompiler_43 except reflection.c. If that in turn needs d3dcompiler's utils.c, it will need to be handled in some way. It's not clear at a glance what's the best course of action but some (not necessarily mutually exclusive) options are: - rename d3d10's utils.c to something else so that there is no name clash - replace functions in d3d10's utils.c with the equivalent functions from d3dcompiler - move functions currently in d3d10's utils.c into their users or inline them into d3d10_private.h - merge some d3d10 source files together
I.e. d3d10 will probably need some work to be able to share code with d3dcompiler. It should be possible to do that in small incremental steps over a number of patches though.
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;
This should be mostly the same as the d3dcompiler version so either drop this change (if you can do without utils.c from d3dcompiler) or just drop the d3d10 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"
I think you don't want that. FWIW for these kind of #ifdefs instead of adding a new define you can use D3D_COMPILER_VERSION.
Use ifdefs to change the type of the reflection iface, and change the name of the variable throughout.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- 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)) {
On Thu, Oct 24, 2019 at 9:57 PM Connor McAdams conmanx360@gmail.com wrote:
Use ifdefs to change the type of the reflection iface, and change the name of the variable throughout.
Signed-off-by: Connor McAdams conmanx360@gmail.com
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
I'd keep the standard names for the interface fields. They will be different between the two versions but I think that's actually a positive.
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 */
Stray whitespace change.
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
You're not calling D3DReflect() from D3D10ReflectShader() anymore, right?
I had to do an #ifndef inside of D3DReflect because when it was defined as an ID3D10 interface, it would throw a warning to an incompatible vtbl. But, reconfiguring it to be separate methods will fix this, so I'll do that instead.
Going to take your suggestions and rework things. Thanks for the review.
On Fri, Oct 25, 2019 at 4:43 AM Matteo Bruni matteo.mystral@gmail.com wrote:
On Thu, Oct 24, 2019 at 9:57 PM Connor McAdams conmanx360@gmail.com wrote:
Use ifdefs to change the type of the reflection iface, and change the name of the variable throughout.
Signed-off-by: Connor McAdams conmanx360@gmail.com
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
I'd keep the standard names for the interface fields. They will be different between the two versions but I think that's actually a positive.
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 */
Stray whitespace change.
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
You're not calling D3DReflect() from D3D10ReflectShader() anymore, right?
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.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/d3d10_main.c | 19 ++---- dlls/d3d10/d3d10_private.h | 8 --- dlls/d3d10/shader.c | 112 ------------------------------- dlls/d3dcompiler_43/reflection.c | 102 ++++++++++++++++++++++------ include/d3dcompiler.h | 4 ++ 5 files changed, 89 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..696b842dfc 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);
@@ -489,7 +494,11 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameter return E_INVALIDARG; }
+#ifndef D3D10REFLECT *desc = This->isgn->elements[index]; +#else + memcpy(desc, &This->isgn->elements[index], sizeof(D3D10_SIGNATURE_PARAMETER_DESC)); +#endif
return S_OK; } @@ -497,7 +506,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);
@@ -507,15 +516,20 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetOutputParamete return E_INVALIDARG; }
+#ifndef D3D10REFLECT *desc = This->osgn->elements[index]; +#else + memcpy(desc, &This->osgn->elements[index], sizeof(D3D10_SIGNATURE_PARAMETER_DESC)); +#endif
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 +547,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 +582,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 +613,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 +631,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 +693,7 @@ static UINT64 STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetRequiresFlags(
return 0; } +#endif
static const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl = { @@ -693,6 +708,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 +722,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 +1826,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 +1842,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
On Thu, Oct 24, 2019 at 9:50 PM Connor McAdams conmanx360@gmail.com wrote:
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.
Signed-off-by: Connor McAdams conmanx360@gmail.com
dlls/d3d10/d3d10_main.c | 19 ++---- dlls/d3d10/d3d10_private.h | 8 --- dlls/d3d10/shader.c | 112 ------------------------------- dlls/d3dcompiler_43/reflection.c | 102 ++++++++++++++++++++++------ include/d3dcompiler.h | 4 ++ 5 files changed, 89 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);
Hiding away the interface difference here is NOT okay. Also there is no need to, you should have a d3dcompiler_shader_reflection_init() function that takes a struct d3dcompiler_shader_reflection * and is called by both D3D10ReflectShader and D3DReflect(). More on this below. Also it seems nicer to just move the function to d3dcompiler_43/reflection.c.
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 5faea4c8e6..696b842dfc 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); }
I don't like this. There is no reason to change the function name and I'd still use the full name for the interface field in the struct definition (as mentioned in the previous patch).
@@ -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;
I had mentioned it on IRC but it was probably missed in the midst of the discussion: in general I'd prefer full "duplicate" functions rather than this kind of #ifdefing inside functions. This also doesn't work when exposing proper vtables.
@@ -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; }
Taking this function as an example, what I had in mind was to effectively change this function to d3dcompiler_shader_reflection_get_desc(struct d3dcompiler_shader_reflection *, ...) and have separate ID3D10ShaderReflection / ID3D11ShaderReflection methods that simply recover the object via impl_from_*() and call into the new helper. Most of the methods are trivial and it should be fine to simply duplicate them (i.e. without need of a common helper).
static struct ID3D11ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3dcompiler_shader_reflection_G @@ -489,7 +494,11 @@ static HRESULT STDMETHODCALLTYPE d3dcompiler_shader_reflection_GetInputParameter return E_INVALIDARG; }
+#ifndef D3D10REFLECT *desc = This->isgn->elements[index]; +#else
- memcpy(desc, &This->isgn->elements[index], sizeof(D3D10_SIGNATURE_PARAMETER_DESC));
+#endif
With separate implementations you can write this as "...sizeof(*desc));" (and you won't need an #ifdef).
- object->ID3DShaderReflection_iface.lpVtbl = (const struct ID3D10ShaderReflectionVtbl *)&d3dcompiler_shader_reflection_vtbl;
This is not okay. You have to have a proper vtbl for ID3D10ShaderReflection, with correct method signatures.
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
You can't add Wine-only functions to public headers. This won't be necessary once you move D3D10ReflectShader() to reflection.c.
In general, I was expecting this to be structured differently, like I tried to explain here. Let me know if I haven't been clear enough.