For React Native. React Native applications use HLSL shader linking extensively. Obviously, these two functions are not enough because they are just stubs. But I think it's good to get them in the tree so they don't get lost. Currently, React Native applications need to rely on the bundled native d3dcompiler.
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/d3dcompiler_43/compiler.c | 99 +++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 58f3e3a4358..81d1b7b93a0 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -21,6 +21,7 @@ #define COBJMACROS #include <stdarg.h> #include <time.h> +#include <d3d11shader.h> #include "wine/debug.h"
#include "d3dcompiler_private.h" @@ -489,12 +490,106 @@ end: return hr; }
-HRESULT WINAPI D3DCreateLinker(ID3D11Linker **linker) +struct d3d11_linker +{ + ID3D11Linker ID3D11Linker_iface; + LONG refcount; +}; + +static inline struct d3d11_linker *impl_from_ID3D11Linker(ID3D11Linker *iface) +{ + return CONTAINING_RECORD(iface, struct d3d11_linker, ID3D11Linker_iface); +} + +static HRESULT WINAPI d3d11_linker_QueryInterface(ID3D11Linker *iface, REFIID riid, void **object) +{ + struct d3d11_linker *linker = impl_from_ID3D11Linker(iface); + + TRACE("linker %p, riid %s, object %p.\n", linker, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D11Linker) + || 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 WINAPI d3d11_linker_AddRef(ID3D11Linker *iface) +{ + struct d3d11_linker *linker = impl_from_ID3D11Linker(iface); + ULONG refcount = InterlockedIncrement(&linker->refcount); + + TRACE("%p increasing refcount to %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG WINAPI d3d11_linker_Release(ID3D11Linker *iface) { - FIXME("linker %p stub!\n", linker); + struct d3d11_linker *linker = impl_from_ID3D11Linker(iface); + ULONG refcount = InterlockedDecrement(&linker->refcount); + + TRACE("%p decreasing refcount to %lu.\n", iface, refcount); + + if (!refcount) + free(linker); + + return refcount; +} + +static HRESULT WINAPI d3d11_linker_Link(ID3D11Linker *iface, ID3D11ModuleInstance *instance, + LPCSTR instance_name, LPCSTR target_name, UINT flags, ID3DBlob **shader, ID3DBlob **error) +{ + FIXME("iface %p, instance %p, instance_name %s, target_name %s, flags %#x, shader %p, error %p stub!\n", + iface, instance, debugstr_a(instance_name), debugstr_a(target_name), flags, shader, error); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_linker_UseLibrary(ID3D11Linker *iface, ID3D11ModuleInstance *instance) +{ + FIXME("iface %p, instance %p stub!\n", iface, instance); return E_NOTIMPL; }
+static HRESULT WINAPI d3d11_linker_AddClipPlaneFromCBuffer(ID3D11Linker *iface, UINT buffer_slot, + UINT buffer_entry) +{ + FIXME("iface %p, buffer_slot %u, buffer_entry %u stub!\n", iface, buffer_slot, buffer_entry); + return E_NOTIMPL; +} + +static const struct ID3D11LinkerVtbl d3d11_linker_vtbl = +{ + d3d11_linker_QueryInterface, + d3d11_linker_AddRef, + d3d11_linker_Release, + d3d11_linker_Link, + d3d11_linker_UseLibrary, + d3d11_linker_AddClipPlaneFromCBuffer, +}; + +HRESULT WINAPI D3DCreateLinker(ID3D11Linker **linker) +{ + struct d3d11_linker *object; + + TRACE("linker %p.\n", linker); + + if (!(object = calloc(1, sizeof(*object)))) + return E_OUTOFMEMORY; + + object->ID3D11Linker_iface.lpVtbl = &d3d11_linker_vtbl; + object->refcount = 1; + + *linker = &object->ID3D11Linker_iface; + return S_OK; +} + HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module) { FIXME("data %p, size %Iu, module %p stub!\n", data, size, module);
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/d3dcompiler_43/compiler.c | 148 ++++++++++++++++++++++++ dlls/d3dcompiler_47/d3dcompiler_47.spec | 2 +- include/d3dcompiler.h | 1 + 3 files changed, 150 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 81d1b7b93a0..ce43e12c3c7 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -490,6 +490,154 @@ end: return hr; }
+struct d3d11_function_linking_graph +{ + ID3D11FunctionLinkingGraph ID3D11FunctionLinkingGraph_iface; + LONG refcount; +}; + +static inline struct d3d11_function_linking_graph *impl_from_ID3D11FunctionLinkingGraph(ID3D11FunctionLinkingGraph *iface) +{ + return CONTAINING_RECORD(iface, struct d3d11_function_linking_graph, ID3D11FunctionLinkingGraph_iface); +} + +static HRESULT WINAPI d3d11_function_linking_graph_QueryInterface(ID3D11FunctionLinkingGraph *iface, REFIID riid, void **object) +{ + struct d3d11_function_linking_graph *graph = impl_from_ID3D11FunctionLinkingGraph(iface); + + TRACE("graph %p, riid %s, object %p.\n", graph, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D11FunctionLinkingGraph) + || 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 WINAPI d3d11_function_linking_graph_AddRef(ID3D11FunctionLinkingGraph *iface) +{ + struct d3d11_function_linking_graph *graph = impl_from_ID3D11FunctionLinkingGraph(iface); + ULONG refcount = InterlockedIncrement(&graph->refcount); + + TRACE("%p increasing refcount to %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG WINAPI d3d11_function_linking_graph_Release(ID3D11FunctionLinkingGraph *iface) +{ + struct d3d11_function_linking_graph *graph = impl_from_ID3D11FunctionLinkingGraph(iface); + ULONG refcount = InterlockedDecrement(&graph->refcount); + + TRACE("%p decreasing refcount to %lu.\n", iface, refcount); + + if (!refcount) + free(graph); + + return refcount; +} + +static HRESULT WINAPI d3d11_function_linking_graph_CreateModuleInstance(ID3D11FunctionLinkingGraph *iface, + ID3D11ModuleInstance **instance, ID3DBlob **error) +{ + FIXME("iface %p, instance %p, error %p stub!\n", iface, instance, error); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_function_linking_graph_SetInputSignature(ID3D11FunctionLinkingGraph *iface, + const D3D11_PARAMETER_DESC *parameter_desc, UINT parameter_count, ID3D11LinkingNode **input_node) +{ + FIXME("iface %p, parameter_desc %p, parameter_count %u, input_node %p stub!\n", iface, + parameter_desc, parameter_count, input_node); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_function_linking_graph_SetOutputSignature(ID3D11FunctionLinkingGraph *iface, + const D3D11_PARAMETER_DESC *parameter_desc, UINT parameter_count, ID3D11LinkingNode **output_node) +{ + FIXME("iface %p, parameter_desc %p, parameter_count %u, output_node %p stub!\n", iface, + parameter_desc, parameter_count, output_node); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_function_linking_graph_CallFunction(ID3D11FunctionLinkingGraph *iface, + LPCSTR namespace, ID3D11Module *module, LPCSTR function_name, ID3D11LinkingNode **call_node) +{ + FIXME("iface %p, namespace %s, module %p, function_name %s, call_node %p stub!\n", iface, + wine_dbgstr_a(namespace), module, wine_dbgstr_a(function_name), call_node); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_function_linking_graph_PassValue(ID3D11FunctionLinkingGraph *iface, + ID3D11LinkingNode *src_node, INT src_parameter_index, ID3D11LinkingNode *dst_node, + INT dst_parameter_index) +{ + FIXME("iface %p, src_node %p, src_parameter_index %d, dst_node %p, dst_parameter_index %d stub!\n", + iface, src_node, src_parameter_index, dst_node, dst_parameter_index); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_function_linking_graph_PassValueWithSwizzle(ID3D11FunctionLinkingGraph *iface, + ID3D11LinkingNode *src_node, INT src_parameter_index, LPCSTR src_swizzle, + ID3D11LinkingNode *dst_node, INT dst_parameter_index, LPCSTR dst_swizzle) +{ + FIXME("iface %p, src_node %p, src_parameter_index %d, src_swizzle %s, dst_node %p, " + "dst_parameter_index %d, dst_swizzle %s stub!\n", iface, src_node, src_parameter_index, + wine_dbgstr_a(src_swizzle), dst_node, dst_parameter_index, wine_dbgstr_a(dst_swizzle)); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_function_linking_graph_GetLastError(ID3D11FunctionLinkingGraph *iface, + ID3DBlob **error) +{ + FIXME("iface %p, error %p stub!\n", iface, error); + return E_NOTIMPL; +} + +static HRESULT WINAPI d3d11_function_linking_graph_GenerateHlsl(ID3D11FunctionLinkingGraph *iface, + UINT flags, ID3DBlob **buffer) +{ + FIXME("iface %p, flags %#x, buffer %p stub!\n", iface, flags, buffer); + return E_NOTIMPL; +} + +static const struct ID3D11FunctionLinkingGraphVtbl d3d11_function_linking_graph_vtbl = +{ + d3d11_function_linking_graph_QueryInterface, + d3d11_function_linking_graph_AddRef, + d3d11_function_linking_graph_Release, + d3d11_function_linking_graph_CreateModuleInstance, + d3d11_function_linking_graph_SetInputSignature, + d3d11_function_linking_graph_SetOutputSignature, + d3d11_function_linking_graph_CallFunction, + d3d11_function_linking_graph_PassValue, + d3d11_function_linking_graph_PassValueWithSwizzle, + d3d11_function_linking_graph_GetLastError, + d3d11_function_linking_graph_GenerateHlsl, +}; + +HRESULT WINAPI D3DCreateFunctionLinkingGraph(UINT flags, ID3D11FunctionLinkingGraph **graph) +{ + struct d3d11_function_linking_graph *object; + + TRACE("flags %#x, graph %p.\n", flags, graph); + + if (!(object = calloc(1, sizeof(*object)))) + return E_OUTOFMEMORY; + + object->ID3D11FunctionLinkingGraph_iface.lpVtbl = &d3d11_function_linking_graph_vtbl; + object->refcount = 1; + + *graph = &object->ID3D11FunctionLinkingGraph_iface; + return S_OK; +} + struct d3d11_linker { ID3D11Linker ID3D11Linker_iface; diff --git a/dlls/d3dcompiler_47/d3dcompiler_47.spec b/dlls/d3dcompiler_47/d3dcompiler_47.spec index 3ed049e6ab8..333dde2979c 100644 --- a/dlls/d3dcompiler_47/d3dcompiler_47.spec +++ b/dlls/d3dcompiler_47/d3dcompiler_47.spec @@ -4,7 +4,7 @@ @ stdcall D3DCompileFromFile(wstr ptr ptr str str long long ptr ptr) @ stub D3DCompressShaders @ stdcall D3DCreateBlob(long ptr) -@ stub D3DCreateFunctionLinkingGraph +@ stdcall D3DCreateFunctionLinkingGraph(long ptr) @ stdcall D3DCreateLinker(ptr) @ stub D3DDecompressShaders @ stdcall D3DDisassemble(ptr long long ptr ptr) diff --git a/include/d3dcompiler.h b/include/d3dcompiler.h index 87821a9031a..14e599081d8 100644 --- a/include/d3dcompiler.h +++ b/include/d3dcompiler.h @@ -153,6 +153,7 @@ typedef HRESULT (WINAPI *pD3DPreprocess)(const void *data, SIZE_T size, const ch const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **shader, ID3DBlob **error_messages);
+HRESULT WINAPI D3DCreateFunctionLinkingGraph(UINT flags, ID3D11FunctionLinkingGraph **graph); HRESULT WINAPI D3DCreateLinker(ID3D11Linker **linker); HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module);
Matteo Bruni (@Mystral) commented about dlls/d3dcompiler_43/compiler.c:
- return E_NOTIMPL;
+}
+static HRESULT WINAPI d3d11_function_linking_graph_SetOutputSignature(ID3D11FunctionLinkingGraph *iface,
const D3D11_PARAMETER_DESC *parameter_desc, UINT parameter_count, ID3D11LinkingNode **output_node)
+{
- FIXME("iface %p, parameter_desc %p, parameter_count %u, output_node %p stub!\n", iface,
parameter_desc, parameter_count, output_node);
- return E_NOTIMPL;
+}
+static HRESULT WINAPI d3d11_function_linking_graph_CallFunction(ID3D11FunctionLinkingGraph *iface,
LPCSTR namespace, ID3D11Module *module, LPCSTR function_name, ID3D11LinkingNode **call_node)
+{
- FIXME("iface %p, namespace %s, module %p, function_name %s, call_node %p stub!\n", iface,
wine_dbgstr_a(namespace), module, wine_dbgstr_a(function_name), call_node);
Absolute nitpick: in the other patch you use `debugstr_a()` for these.
Could I ask you to include a barebone test? Just creating and destroying the objects would do. There are a couple of caveats I can see (i.e. I think you'll need some `#if D3D_COMPILER_VERSION >= 47` since only _47 exports those functions and you probably want to put those in a separate linker.c file) and there could be more, so take this as a suggestion that can be revised with more data :smile: