[PATCH 4/6] d3dcompiler: Move d3d10 reflection stubs into d3dcompiler.

Matteo Bruni mbruni at codeweavers.com
Wed Nov 6 03:06:32 CST 2019


From: Connor McAdams <conmanx360 at gmail.com>

Signed-off-by: Connor McAdams <conmanx360 at gmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
With the intention of reusing d3dcompiler's implementation for d3d10
in a bit.

After seeing it, I guess I like it better combined in one patch after
all... Sorry about that.

 dlls/d3d10/Makefile.in           |   7 +-
 dlls/d3d10/d3d10_main.c          |  22 -----
 dlls/d3d10/d3d10_private.h       |   8 --
 dlls/d3d10/shader.c              | 112 --------------------------
 dlls/d3dcompiler_43/reflection.c | 134 +++++++++++++++++++++++++++++++
 dlls/d3dcompiler_43/utils.c      |   2 +
 6 files changed, 141 insertions(+), 144 deletions(-)

diff --git a/dlls/d3d10/Makefile.in b/dlls/d3d10/Makefile.in
index dec11188c4d..50807a295a9 100644
--- a/dlls/d3d10/Makefile.in
+++ b/dlls/d3d10/Makefile.in
@@ -1,13 +1,16 @@
 MODULE    = d3d10.dll
 IMPORTLIB = d3d10
-IMPORTS   = dxguid uuid d3d10core d3dcompiler dxgi
+IMPORTS   = uuid d3d10core d3dcompiler dxgi
+PARENTSRC = ../d3dcompiler_43
 
 EXTRADLLFLAGS = -mno-cygwin
 
 C_SRCS = \
 	d3d10_main.c \
 	effect.c \
+	reflection.c \
 	shader.c \
-	stateblock.c
+	stateblock.c \
+	utils.c
 
 RC_SRCS = version.rc
diff --git a/dlls/d3d10/d3d10_main.c b/dlls/d3d10/d3d10_main.c
index a54c44bdbb9..2d08c82a3c4 100644
--- a/dlls/d3d10/d3d10_main.c
+++ b/dlls/d3d10/d3d10_main.c
@@ -316,25 +316,3 @@ const char * WINAPI D3D10GetPixelShaderProfile(ID3D10Device *device)
 
     return "ps_4_0";
 }
-
-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;
-
-    *reflector = &object->ID3D10ShaderReflection_iface;
-
-    TRACE("Created ID3D10ShaderReflection %p\n", object);
-
-    return S_OK;
-}
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h
index fadd027f7a9..96020cd4a0c 100644
--- a/dlls/d3d10/d3d10_private.h
+++ b/dlls/d3d10/d3d10_private.h
@@ -249,14 +249,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 52e3cc06bf4..d198689af64 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 b163fca9e73..2ea0b46a1c6 100644
--- a/dlls/d3dcompiler_43/reflection.c
+++ b/dlls/d3dcompiler_43/reflection.c
@@ -21,6 +21,7 @@
 #include "initguid.h"
 #include "d3dcompiler_private.h"
 #include "winternl.h"
+#include "d3d10.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
 
@@ -94,6 +95,7 @@ struct d3dcompiler_shader_reflection_constant_buffer
 struct d3dcompiler_shader_reflection
 {
     ID3D11ShaderReflection ID3D11ShaderReflection_iface;
+    ID3D10ShaderReflection ID3D10ShaderReflection_iface;
     LONG refcount;
 
     DWORD target;
@@ -1807,6 +1809,138 @@ err_out:
     return hr;
 }
 
+/* d3d10 reflection methods. */
+#ifndef D3D_COMPILER_VERSION
+static inline struct d3dcompiler_shader_reflection *impl_from_ID3D10ShaderReflection(ID3D10ShaderReflection *iface)
+{
+    return CONTAINING_RECORD(iface, struct d3dcompiler_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 d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
+    ULONG refcount = InterlockedIncrement(&reflection->refcount);
+
+    TRACE("%p increasing refcount to %u.\n", reflection, refcount);
+
+    return refcount;
+}
+
+static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_Release(ID3D10ShaderReflection *iface)
+{
+    struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
+    ULONG refcount = InterlockedDecrement(&reflection->refcount);
+
+    TRACE("%p decreasing refcount to %u.\n", reflection, refcount);
+
+    if (!refcount)
+        heap_free(reflection);
+
+    return refcount;
+}
+
+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;
+}
+
+static const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl =
+{
+    d3d10_shader_reflection_QueryInterface,
+    d3d10_shader_reflection_AddRef,
+    d3d10_shader_reflection_Release,
+    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 D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector)
+{
+    struct d3dcompiler_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;
+
+    *reflector = &object->ID3D10ShaderReflection_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;
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 079bd1c6bc2..27c0ba8c916 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -758,6 +758,7 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, __ms
     }
 }
 
+#ifdef D3D_COMPILER_VERSION
 BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var)
 {
     struct hlsl_ir_var *var;
@@ -2327,3 +2328,4 @@ void add_function_decl(struct wine_rb_tree *funcs, char *name, struct hlsl_ir_fu
     func->intrinsic = intrinsic;
     wine_rb_put(funcs, func->name, &func->entry);
 }
+#endif
-- 
2.21.0




More information about the wine-devel mailing list