From fa2c74f7dbfb6840a06fe27bc0292cfe6560b13e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 29 Dec 2020 16:50:25 +0100 Subject: [PATCH] Skipped library loading fixup in publish mode --- .../Translation/ShaderCompiler.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs b/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs index 6eb47106..06b89783 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs @@ -62,13 +62,23 @@ namespace ComputeSharp.Shaders.Translation /// private static void InitializeDxcLibrariesLoading() { - FX.ResolveLibrary += ResolveLibrary; + string + dxcompilerPath = Path.GetFullPath(@$"runtimes\win-x64\native\dxcompiler.dll"), + dxilPath = Path.GetFullPath(@$"runtimes\win-x64\native\dxil.dll"); - fixed (char* p = @"runtimes\win-x64\native") + if (File.Exists(dxcompilerPath)) { - int result = FX.SetDllDirectoryW((ushort*)p); + FX.ResolveLibrary += ResolveLibrary; + } - if (result == 0) ThrowHelper.ThrowWin32Exception(); + if (File.Exists(dxilPath)) + { + fixed (char* p = @"runtimes\win-x64\native") + { + int result = FX.SetDllDirectoryW((ushort*)p); + + if (result == 0) ThrowHelper.ThrowWin32Exception(); + } } }