diff --git a/GameKit.slnx b/GameKit.slnx index 91a42df..d00fdcb 100644 --- a/GameKit.slnx +++ b/GameKit.slnx @@ -10,7 +10,6 @@ - diff --git a/docs/shaders.md b/docs/shaders.md index f91f909..ee93fad 100644 --- a/docs/shaders.md +++ b/docs/shaders.md @@ -41,9 +41,7 @@ The targets file compiles every `SdlangShader` item before `CoreCompile` and exp Generated shaders are runtime content. See [Content distribution](content-distribution.md) for the loose-directory, embedded-resource, and ZIP policies, with runnable tutorials for embedding generated shaders in an assembly and publishing content in a ZIP archive. -The Slang compiler is downloaded from [`stanoddly/slang-dxc-bundle`](https://github.com/stanoddly/slang-dxc-bundle) into `GameKit.SdlangCompileLib`'s `obj/` directory and stays there. The distribution includes the DXC downstream compiler required for DXIL output and provides bundles for every supported shader-compilation host: Linux x64/ARM64, Windows x64, and macOS x64/ARM64. DXIL generation is therefore required on every supported host and is never silently omitted. `GameKit.SdlangCompileLib` alone owns the shared download and extraction. Slang and DXC are build-host tooling and are never copied into the output or publish directory of a project that only compiles shaders. A project that needs Slang next to its own binaries opts in with `true` and imports `GameKit.SdlangCompileLib`'s props and targets directly. The property copies the complete Slang distribution, including DXC, to build and publish outputs. They remain external when publishing a single-file application because `slangc` must be executable by path. - -Standalone applications should call `SdlangCompiler.CreateFromApplicationDirectory()`. It locates Slang relative to the application directory and supports single-file publishing. `SdlangCompiler.CreateFromAssemblyDirectory()` locates Slang relative to `GameKit.SdlangCompileLib.dll` and requires assembly files on disk, so it is not compatible with single-file applications. Build integrations should pass `$(SlangCompilerPath)` to the `SdlangCompiler` constructor instead of using either factory. +The Slang compiler is downloaded from [`stanoddly/slang-dxc-bundle`](https://github.com/stanoddly/slang-dxc-bundle) into `GameKit.SdlangCompileLib`'s `obj/` directory and stays there. The distribution includes the DXC downstream compiler required for DXIL output and provides bundles for every supported shader-compilation host: Linux x64/ARM64, Windows x64, and macOS x64/ARM64. DXIL generation is therefore required on every supported host and is never silently omitted. `GameKit.SdlangCompileLib` alone owns the shared download and extraction. Slang and DXC are build-host tooling and are never copied into application build or publish output. Build integrations pass `$(SlangCompilerPath)` to `SdlangCompiler`. ### Custom compilation targets diff --git a/src/GameKit.SdlangCompileLib/SdlangCompiler.cs b/src/GameKit.SdlangCompileLib/SdlangCompiler.cs index a7b67ec..aef6211 100644 --- a/src/GameKit.SdlangCompileLib/SdlangCompiler.cs +++ b/src/GameKit.SdlangCompileLib/SdlangCompiler.cs @@ -1,6 +1,5 @@ using System.Buffers.Binary; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Security.Cryptography; using System.Text; @@ -63,37 +62,6 @@ public SdlangCompiler(string slangCompilerPath) _slangCompilerPath = slangCompilerPath; } - /// - /// Creates a compiler that uses the Slang distribution shipped next to the executing assembly. - /// Intended for standalone tools that carry their own copy of Slang; build integrations should - /// pass the path explicitly instead. - /// - [RequiresAssemblyFiles("Use CreateFromApplicationDirectory() for single-file applications.")] - public static SdlangCompiler CreateFromAssemblyDirectory() - { - string? assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - if (string.IsNullOrEmpty(assemblyDir)) - { - throw new InvalidOperationException("Unable to determine assembly directory"); - } - - string slangExe = OperatingSystem.IsWindows() ? "slangc.exe" : "slangc"; - - return new SdlangCompiler(Path.Combine(assemblyDir, "bin", slangExe)); - } - - /// - /// Creates a compiler that uses the Slang distribution shipped next to the application. - /// Compatible with single-file applications because the distribution remains external to the - /// application bundle. - /// - public static SdlangCompiler CreateFromApplicationDirectory() - { - string slangExe = OperatingSystem.IsWindows() ? "slangc.exe" : "slangc"; - - return new SdlangCompiler(Path.Combine(AppContext.BaseDirectory, "bin", slangExe)); - } - private static string GetSlangVersion() { AssemblyMetadataAttribute? attribute = typeof(SdlangCompiler).Assembly diff --git a/src/GameKit.SdlangCompileLib/build/GameKit.SdlangCompileLib.targets b/src/GameKit.SdlangCompileLib/build/GameKit.SdlangCompileLib.targets index 8c7fa74..6cf6c0b 100644 --- a/src/GameKit.SdlangCompileLib/build/GameKit.SdlangCompileLib.targets +++ b/src/GameKit.SdlangCompileLib/build/GameKit.SdlangCompileLib.targets @@ -42,45 +42,4 @@ - - - - - - - - - - - - - - - - - - - bin/%(SlangBinPublishFile.RecursiveDir)%(Filename)%(Extension) - PreserveNewest - true - - - lib/%(SlangLibPublishFile.RecursiveDir)%(Filename)%(Extension) - PreserveNewest - true - - - - diff --git a/src/GameKit.SdlangCompilerCli/GameKit.SdlangCompilerCli.csproj b/src/GameKit.SdlangCompilerCli/GameKit.SdlangCompilerCli.csproj deleted file mode 100644 index 2e39e3c..0000000 --- a/src/GameKit.SdlangCompilerCli/GameKit.SdlangCompilerCli.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - net10.0 - enable - enable - 14 - - true - - - - - - - - - - - - - - diff --git a/src/GameKit.SdlangCompilerCli/Program.cs b/src/GameKit.SdlangCompilerCli/Program.cs deleted file mode 100644 index 2a7f002..0000000 --- a/src/GameKit.SdlangCompilerCli/Program.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.CommandLine; -using GameKit.SdlangCompileLib; - -namespace GameKit.SdlangCompilerCli; - -class Program -{ - static int Main(string[] args) - { - Argument filenamesOption = new Argument( - name: "filenames") - { - Arity = ArgumentArity.OneOrMore, - Description = "The shader file(s) or directory to process" - }; - - var forceOption = new Option( - name: "--force") - { - Description = "Force compilation even if source file hash hasn't changed" - }; - - var rootCommand = new RootCommand("Compile Slang shaders to various targets") - { - filenamesOption, - forceOption - }; - - var parseResult = rootCommand.Parse(args); - - try - { - SdlangCompiler sdlangCompiler = SdlangCompiler.CreateFromApplicationDirectory(); - string[] filenames = parseResult.GetValue(filenamesOption) ?? []; - sdlangCompiler.Compile(filenames, parseResult.GetValue(forceOption)); - return 0; - } - catch (Exception ex) - { - Console.Error.WriteLine($"Error: {ex.Message}"); - return 1; - } - } -} diff --git a/tests/GameKit.SdlangCompileLib.Tests/GameKit.SdlangCompileLib.Tests.csproj b/tests/GameKit.SdlangCompileLib.Tests/GameKit.SdlangCompileLib.Tests.csproj index 25564ca..0475822 100644 --- a/tests/GameKit.SdlangCompileLib.Tests/GameKit.SdlangCompileLib.Tests.csproj +++ b/tests/GameKit.SdlangCompileLib.Tests/GameKit.SdlangCompileLib.Tests.csproj @@ -6,13 +6,18 @@ enable enable false - - true + + + <_Parameter1>SlangCompilerPath + <_Parameter2>$(SlangCompilerPath) + + + diff --git a/tests/GameKit.SdlangCompileLib.Tests/GraphicsShaderProgramCompilerTests.cs b/tests/GameKit.SdlangCompileLib.Tests/GraphicsShaderProgramCompilerTests.cs index 19cf84a..68abcc0 100644 --- a/tests/GameKit.SdlangCompileLib.Tests/GraphicsShaderProgramCompilerTests.cs +++ b/tests/GameKit.SdlangCompileLib.Tests/GraphicsShaderProgramCompilerTests.cs @@ -231,7 +231,7 @@ private GraphicsShaderProgramMetadataDto Compile(string source) { string shaderPath = Path.Combine(_testDirectory, "program.slang"); File.WriteAllText(shaderPath, source); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metadataPath = Path.Combine(_testDirectory, ".generated", "program.metadata.json"); diff --git a/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerPublishTests.cs b/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerPublishTests.cs deleted file mode 100644 index 4d5a3e7..0000000 --- a/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerPublishTests.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace GameKit.SdlangCompileLib.Tests; - -public sealed class SdlangCompilerPublishTests -{ - private const string ShaderContent = """ - struct VertexInput - { - float3 Position : POSITION; - }; - - struct VertexToFragment - { - float4 Position : SV_Position; - }; - - [shader("vertex")] - VertexToFragment vertexMain(VertexInput input) - { - VertexToFragment output; - output.Position = float4(input.Position, 1.0); - return output; - } - - [shader("fragment")] - float4 fragmentMain(VertexToFragment input) : SV_Target0 - { - return float4(1.0); - } - """; - - [Test] - [NonParallelizable] - public async Task SingleFileCli_PublishesExternalSlangDistributionAndCompilesShader() - { - string repositoryDirectory = GetRepositoryDirectory(); - string temporaryDirectory = Path.Combine( - Path.GetTempPath(), - "SdlangCompilerPublishTests_" + Guid.NewGuid()); - string publishDirectory = Path.Combine(temporaryDirectory, "publish"); - string shaderPath = Path.Combine(temporaryDirectory, "test.slang"); - - Directory.CreateDirectory(temporaryDirectory); - - try - { - string projectPath = Path.Combine( - repositoryDirectory, - "src", - "GameKit.SdlangCompilerCli", - "GameKit.SdlangCompilerCli.csproj"); - string runtimeIdentifier = GetRuntimeIdentifier(); - - await RunProcessAsync( - "dotnet", - repositoryDirectory, - "publish", - projectPath, - "-c", - "Release", - "-r", - runtimeIdentifier, - "--self-contained", - "false", - "-p:PublishSingleFile=true", - "-p:TreatWarningsAsErrors=true", - "-o", - publishDirectory); - - string executableName = OperatingSystem.IsWindows() - ? "GameKit.SdlangCompilerCli.exe" - : "GameKit.SdlangCompilerCli"; - string slangCompilerName = OperatingSystem.IsWindows() ? "slangc.exe" : "slangc"; - string executablePath = Path.Combine(publishDirectory, executableName); - string dxCompilerPath = OperatingSystem.IsWindows() - ? Path.Combine(publishDirectory, "bin", "dxcompiler.dll") - : Path.Combine( - publishDirectory, - "lib", - OperatingSystem.IsMacOS() ? "libdxcompiler.dylib" : "libdxcompiler.so"); - - Assert.Multiple(() => - { - Assert.That(File.Exists(executablePath), Is.True); - Assert.That(File.Exists(Path.Combine(publishDirectory, "bin", slangCompilerName)), Is.True); - Assert.That(File.Exists(dxCompilerPath), Is.True); - Assert.That(Directory.Exists(Path.Combine(publishDirectory, "lib")), Is.True); - Assert.That( - File.Exists(Path.Combine(publishDirectory, "GameKit.SdlangCompileLib.dll")), - Is.False); - }); - - File.WriteAllText(shaderPath, ShaderContent); - - await RunProcessAsync( - executablePath, - temporaryDirectory, - shaderPath, - "--force"); - - string generatedDirectory = Path.Combine(temporaryDirectory, ".generated"); - Assert.Multiple(() => - { - Assert.That(File.Exists(Path.Combine(generatedDirectory, "test.vertex.spv")), Is.True); - Assert.That(File.Exists(Path.Combine(generatedDirectory, "test.vertex.dxil")), Is.True); - Assert.That(File.Exists(Path.Combine(generatedDirectory, "test.vertex.metal")), Is.True); - Assert.That(File.Exists(Path.Combine(generatedDirectory, "test.fragment.spv")), Is.True); - Assert.That(File.Exists(Path.Combine(generatedDirectory, "test.fragment.dxil")), Is.True); - Assert.That(File.Exists(Path.Combine(generatedDirectory, "test.fragment.metal")), Is.True); - Assert.That(File.Exists(Path.Combine(generatedDirectory, "test.metadata.json")), Is.True); - }); - } - finally - { - if (Directory.Exists(temporaryDirectory)) - { - Directory.Delete(temporaryDirectory, recursive: true); - } - } - } - - private static string GetRuntimeIdentifier() - { - Architecture architecture = RuntimeInformation.OSArchitecture; - - if (OperatingSystem.IsLinux() && architecture == Architecture.X64) - { - return "linux-x64"; - } - - if (OperatingSystem.IsLinux() && architecture == Architecture.Arm64) - { - return "linux-arm64"; - } - - if (OperatingSystem.IsWindows() && architecture == Architecture.X64) - { - return "win-x64"; - } - - if (OperatingSystem.IsMacOS() && architecture == Architecture.X64) - { - return "osx-x64"; - } - - if (OperatingSystem.IsMacOS() && architecture == Architecture.Arm64) - { - return "osx-arm64"; - } - - throw new PlatformNotSupportedException( - $"Single-file Slang publishing is not supported on {RuntimeInformation.OSDescription} {architecture}."); - } - - private static async Task RunProcessAsync( - string executablePath, - string workingDirectory, - params string[] arguments) - { - ProcessStartInfo startInfo = new ProcessStartInfo(executablePath) - { - WorkingDirectory = workingDirectory, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false - }; - - foreach (string argument in arguments) - { - startInfo.ArgumentList.Add(argument); - } - - startInfo.Environment["MSBUILDDISABLENODEREUSE"] = "1"; - - using Process process = Process.Start(startInfo) - ?? throw new InvalidOperationException($"Failed to start {executablePath}."); - Task standardOutputTask = process.StandardOutput.ReadToEndAsync(); - Task standardErrorTask = process.StandardError.ReadToEndAsync(); - - await process.WaitForExitAsync(); - - string standardOutput = await standardOutputTask; - string standardError = await standardErrorTask; - - Assert.That( - process.ExitCode, - Is.Zero, - $"{executablePath} {string.Join(' ', arguments)} failed.{Environment.NewLine}" + - standardOutput + - standardError); - } - - private static string GetRepositoryDirectory() - { - DirectoryInfo? directory = new DirectoryInfo(TestContext.CurrentContext.TestDirectory); - while (directory != null) - { - if (File.Exists(Path.Combine(directory.FullName, "GameKit.slnx"))) - { - return directory.FullName; - } - - directory = directory.Parent; - } - - throw new DirectoryNotFoundException("Could not locate the GameKit repository."); - } -} diff --git a/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerTestFactory.cs b/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerTestFactory.cs new file mode 100644 index 0000000..87a1284 --- /dev/null +++ b/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerTestFactory.cs @@ -0,0 +1,17 @@ +using System.Reflection; + +namespace GameKit.SdlangCompileLib.Tests; + +internal static class SdlangCompilerTestFactory +{ + public static SdlangCompiler Create() + { + AssemblyMetadataAttribute? compilerPathAttribute = typeof(SdlangCompilerTestFactory).Assembly + .GetCustomAttributes() + .FirstOrDefault(attribute => attribute.Key == "SlangCompilerPath"); + string compilerPath = compilerPathAttribute?.Value + ?? throw new InvalidOperationException("SlangCompilerPath not found in assembly metadata"); + + return new SdlangCompiler(compilerPath); + } +} diff --git a/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerTests.cs b/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerTests.cs index c9cebd5..20367dc 100644 --- a/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerTests.cs +++ b/tests/GameKit.SdlangCompileLib.Tests/SdlangCompilerTests.cs @@ -396,7 +396,7 @@ public void CompileShader_CreatesMetadataFile() string shaderPath = Path.Combine(_testDir, "test_shader.slang"); File.WriteAllText(shaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); // Act compiler.Compile([shaderPath], force: true); @@ -433,7 +433,7 @@ public void CompileShader_ObsoleteGeneratedFiles_RemovesThem() File.WriteAllText(shaderPath, ShaderContent); File.WriteAllText(otherShaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath, otherShaderPath], force: true); string generatedDirectory = Path.Combine(_testDir, ".generated"); @@ -484,7 +484,7 @@ public void CompileShader_MissingGeneratedShader_Recompiles() string shaderPath = Path.Combine(_testDir, "missing_output.slang"); File.WriteAllText(shaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string generatedShaderPath = Path.Combine(_testDir, ".generated", "missing_output.vertex.spv"); @@ -501,7 +501,7 @@ public void CompileShader_MissingSourceDependencies_Recompiles() string shaderPath = Path.Combine(_testDir, "legacy_metadata.slang"); File.WriteAllText(shaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string generatedDirectory = Path.Combine(_testDir, ".generated"); @@ -523,7 +523,7 @@ public void CompileShader_LegacyMetadataFormat_Recompiles() string shaderPath = Path.Combine(_testDir, "legacy_format.slang"); File.WriteAllText(shaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string generatedDirectory = Path.Combine(_testDir, ".generated"); @@ -546,7 +546,7 @@ public void CompileShader_LegacyTargetSet_RecompilesWithDxil() string shaderPath = Path.Combine(_testDir, "legacy_targets.slang"); File.WriteAllText(shaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string generatedDirectory = Path.Combine(_testDir, ".generated"); @@ -574,7 +574,7 @@ public void CompileShader_LegacyGraphicsEntryPointNames_Recompiles() string shaderPath = Path.Combine(_testDir, "legacy_entry_points.slang"); File.WriteAllText(shaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string generatedDirectory = Path.Combine(_testDir, ".generated"); @@ -600,7 +600,7 @@ public void CompileShader_StageEntryPointsInMetadata_Recompiles() string shaderPath = Path.Combine(_testDir, "stage_entry_points.slang"); File.WriteAllText(shaderPath, ShaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string generatedDirectory = Path.Combine(_testDir, ".generated"); @@ -635,7 +635,7 @@ public void CompileShader_SourceDependencyChanges_RecompilesGeneratedShaders() File.WriteAllText(includedShaderPath, IncludedShaderSource); File.WriteAllText(importedShaderPath, ImportedShaderSource); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string generatedDirectory = Path.Combine(_testDir, ".generated"); @@ -680,7 +680,7 @@ public void CompileShader_VertexShaderWithSystemValueInputs_CreatesSystemValueMe string shaderPath = Path.Combine(_testDir, "system_values.slang"); File.WriteAllText(shaderPath, VertexShaderWithSystemValueInputs); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metadataPath = Path.Combine(_testDir, ".generated", "system_values.metadata.json"); @@ -701,7 +701,7 @@ public void CompileShader_ValidVertexShaderWithBindings_Succeeds() string shaderPath = Path.Combine(_testDir, "valid_vertex.slang"); File.WriteAllText(shaderPath, ValidVertexShaderWithBindings); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metadataPath = Path.Combine(_testDir, ".generated", "valid_vertex.metadata.json"); @@ -717,7 +717,7 @@ public void CompileShader_ValidFragmentShaderWithBindings_Succeeds() string shaderPath = Path.Combine(_testDir, "valid_fragment.slang"); File.WriteAllText(shaderPath, ValidFragmentShaderWithBindings); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metadataPath = Path.Combine(_testDir, ".generated", "valid_fragment.metadata.json"); @@ -733,7 +733,7 @@ public void CompileShader_ValidComputeShaderWithBindings_CreatesComputeMetadata( string shaderPath = Path.Combine(_testDir, "valid_compute.slang"); File.WriteAllText(shaderPath, ValidComputeShaderWithBindings); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metadataPath = Path.Combine(_testDir, ".generated", "valid_compute.metadata.json"); @@ -756,7 +756,7 @@ public void CompileShader_FragmentShaderWrongUniformSpace_ThrowsValidationExcept string shaderPath = Path.Combine(_testDir, "invalid_fragment.slang"); File.WriteAllText(shaderPath, FragmentShaderWrongUniformSpace); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); ShaderBindingValidationException? ex = Assert.Throws(() => compiler.Compile([shaderPath], force: true)); @@ -772,7 +772,7 @@ public void CompileShader_VertexShaderWrongUniformSpace_ThrowsValidationExceptio string shaderPath = Path.Combine(_testDir, "invalid_vertex.slang"); File.WriteAllText(shaderPath, VertexShaderWrongUniformSpace); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); ShaderBindingValidationException? ex = Assert.Throws(() => compiler.Compile([shaderPath], force: true)); @@ -788,7 +788,7 @@ public void CompileShader_FragmentShaderWrongTextureSpace_ThrowsValidationExcept string shaderPath = Path.Combine(_testDir, "invalid_texture.slang"); File.WriteAllText(shaderPath, FragmentShaderWrongTextureSpace); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); ShaderBindingValidationException? ex = Assert.Throws(() => compiler.Compile([shaderPath], force: true)); @@ -803,7 +803,7 @@ public void CompileShader_FragmentShaderWrongIndexOrder_ThrowsValidationExceptio string shaderPath = Path.Combine(_testDir, "invalid_order.slang"); File.WriteAllText(shaderPath, FragmentShaderWrongIndexOrder); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); ShaderBindingValidationException? ex = Assert.Throws(() => compiler.Compile([shaderPath], force: true)); @@ -818,7 +818,7 @@ public void CompileShader_MismatchedSamplerTextureIndex_ThrowsValidationExceptio { string shaderPath = CreateTemporaryShaderFile(shaderContent); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); ShaderBindingValidationException? ex = Assert.Throws(() => compiler.Compile([shaderPath], force: true)); @@ -885,7 +885,7 @@ float4 fragmentMain(FragmentInput input) : SV_Target { public void CompileShader_FragmentShaderWithStructStorageBuffer_StoresElementSize() { string shaderPath = CreateTemporaryShaderFile(FragmentShaderWithStructStorageBuffer); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metadataPath = Path.ChangeExtension( @@ -907,7 +907,7 @@ public void CompileShader_FragmentShaderWithStructStorageBuffer_StoresElementSiz public void CompileShader_FragmentShaderWithPrimitiveStorageBuffer_StoresElementSize() { string shaderPath = CreateTemporaryShaderFile(FragmentShaderWithPrimitiveStorageBuffer); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metadataPath = Path.ChangeExtension( @@ -967,7 +967,7 @@ public void CompileShader_VertexWithStorageAndUniformBuffers_MetalHasNonConflict { string shaderPath = CreateTemporaryShaderFile(VertexShaderWithStorageAndUniformBuffers); - SdlangCompiler compiler = SdlangCompiler.CreateFromAssemblyDirectory(); + SdlangCompiler compiler = SdlangCompilerTestFactory.Create(); compiler.Compile([shaderPath], force: true); string metalPath = Path.Combine(