From 0e51830adbc40a782a639b3e693e6102164c31a6 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 2 Sep 2019 13:47:41 +0200 Subject: [PATCH] Fixed dxil.dll loading --- src/ComputeSharp.Shaders/ShaderRunner.cs | 2 +- .../Translation/ShaderCompiler.cs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ComputeSharp.Shaders/ShaderRunner.cs b/src/ComputeSharp.Shaders/ShaderRunner.cs index 85bc2429..b962676d 100644 --- a/src/ComputeSharp.Shaders/ShaderRunner.cs +++ b/src/ComputeSharp.Shaders/ShaderRunner.cs @@ -87,7 +87,7 @@ namespace ComputeSharp.Shaders string shaderSource = ShaderRenderer.Instance.Render(shaderInfo); // Compile the loaded shader to HLSL bytecode - ShaderBytecode shaderBytecode = ShaderCompiler.Instance.CompileShader(shaderSource); + ShaderBytecode shaderBytecode = ShaderCompiler.CompileShader(shaderSource); // Cache for later use shaderData = (shaderLoader, shaderBytecode); diff --git a/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs b/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs index 639d6eee..0cedbcaf 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs @@ -8,23 +8,19 @@ namespace ComputeSharp.Shaders.Translation /// /// A that uses the APIs to compile compute shaders /// - internal sealed class ShaderCompiler + internal static class ShaderCompiler { // Loads the dxil.dll library, needed to create a pipeline state for a shader to dispatch static ShaderCompiler() { Dxil.LoadLibrary(); + Library = Dxc.CreateDxcLibrary(); // This needs to be loaded after dxil.dll } - /// - /// Gets the singleton instance to use - /// - public static ShaderCompiler Instance { get; } = new ShaderCompiler(); - /// /// The instance to use to create the bytecode for HLSL sources /// - private readonly IDxcLibrary Library = Dxc.CreateDxcLibrary(); + private static readonly IDxcLibrary Library; /// /// Compiles a new HLSL shader from the input source code @@ -32,7 +28,7 @@ namespace ComputeSharp.Shaders.Translation /// The HLSL source code to compile /// The bytecode for the compiled shader [Pure] - public ShaderBytecode CompileShader(string source) + public static ShaderBytecode CompileShader(string source) { var result = DxcCompiler.Compile(DxcShaderStage.ComputeShader, source, "CSMain", string.Empty, new DxcCompilerOptions { ShaderModel = DxcShaderModel.Model6_1 });