From c6745901f02d5e9633c32d96b8be375957882339 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Thu, 21 Oct 2021 21:46:44 +0000 Subject: [PATCH] dawn_node: add "dlldir=" flag Only used on Windows builds for now, this flag adds the input path to the DLL search paths. The main purpose is to ensure we load the right version of D3D dlls, such as d3dcompiler_47.dll from the Chrome output dir, rather than the default one in the Systems directory. Bug: dawn:1163 Change-Id: I8e696dd877ec715e1e54d8589af8275e62c90937 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/66962 Commit-Queue: Antonio Maiorano Reviewed-by: Ben Clayton --- src/dawn_node/binding/GPU.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dawn_node/binding/GPU.cpp b/src/dawn_node/binding/GPU.cpp index e6e03c4bcc..5f1d4e7ba0 100644 --- a/src/dawn_node/binding/GPU.cpp +++ b/src/dawn_node/binding/GPU.cpp @@ -18,6 +18,10 @@ #include +#if defined(_WIN32) +# include +#endif + namespace { std::string GetEnvVar(const char* varName) { #if defined(_WIN32) @@ -37,6 +41,14 @@ namespace { return ""; #endif } + + void SetDllDir(const char* dir) { + (void)dir; +#if defined(_WIN32) + ::SetDllDirectory(dir); +#endif + } + } // namespace namespace wgpu { namespace binding { @@ -49,6 +61,10 @@ namespace wgpu { namespace binding { instance_.EnableBackendValidation(true); instance_.SetBackendValidationLevel(dawn_native::BackendValidationLevel::Full); + // Setting the DllDir changes where we load adapter DLLs from (e.g. d3dcompiler_47.dll) + if (auto dir = flags_.Get("dlldir")) { + SetDllDir(dir->c_str()); + } instance_.DiscoverDefaultAdapters(); }