diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj index 28237fe0..86a86264 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj +++ b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj @@ -77,9 +77,10 @@ - - - + + + + diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs index a00ea0af..9480ecee 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs @@ -74,10 +74,10 @@ public static class D2D1ShaderCompiler // Compile the standalone D2D1 full shader using ComPtr d3DBlobFullShader = D3DCompiler.Compile( source: hlslSourceAscii, - macro: D3DCompiler.ASCII.D2D_FULL_SHADER, + macro: ASCII.D2D_FULL_SHADER, d2DEntry: entryPointAscii, entryPoint: entryPointAscii, - target: D3DCompiler.ASCII.GetPixelShaderProfile(shaderProfile), + target: ASCII.GetPixelShaderProfile(shaderProfile), flags: (uint)options); if (!enableLinking) @@ -91,10 +91,10 @@ public static class D2D1ShaderCompiler // Compile the export function using ComPtr d3DBlobFunction = D3DCompiler.Compile( source: hlslSourceAscii, - macro: D3DCompiler.ASCII.D2D_FUNCTION, + macro: ASCII.D2D_FUNCTION, d2DEntry: entryPointAscii, entryPoint: default, - target: D3DCompiler.ASCII.GetLibraryProfile(shaderProfile), + target: ASCII.GetLibraryProfile(shaderProfile), flags: (uint)options); // Embed it as private data if requested diff --git a/src/ComputeSharp.D2D1/Shaders/Translation/ASCII.cs b/src/ComputeSharp.D2D1/Shaders/Translation/ASCII.cs new file mode 100644 index 00000000..6059f08a --- /dev/null +++ b/src/ComputeSharp.D2D1/Shaders/Translation/ASCII.cs @@ -0,0 +1,68 @@ +using System; + +namespace ComputeSharp.D2D1.Shaders.Translation; + +/// +/// A container for ASCII encoded, null-terminated constant strings. +/// +internal static class ASCII +{ + /// + /// Gets a with the "D2D_FUNCTION" ASCII text. + /// + public static ReadOnlySpan D2D_FUNCTION => "D2D_FUNCTION"u8; + + /// + /// Gets a with the "D2D_FULL_SHADER" ASCII text. + /// + public static ReadOnlySpan D2D_FULL_SHADER => "D2D_FULL_SHADER"u8; + + /// + /// Gets a with the '\0' ASCII character. + /// + public static ReadOnlySpan NullTerminator => ""u8; + + /// + /// Gets a with the "D2D_ENTRY" ASCII text. + /// + public static ReadOnlySpan D2D_ENTRY => "D2D_ENTRY"u8; + + /// + /// Gets a with the "Execute" ASCII text. + /// + public static ReadOnlySpan Execute => "Execute"u8; + + /// + /// Gets a for a given shader profile, for a library. + /// + /// The input shaader profile to use. + /// A for a given shader profile, for a library. + public static ReadOnlySpan GetLibraryProfile(D2D1ShaderProfile shaderProfile) + { + return shaderProfile switch + { + D2D1ShaderProfile.PixelShader40Level91 => "lib_4_0_level_9_1"u8, + D2D1ShaderProfile.PixelShader40Level93 => "lib_4_0_level_9_3"u8, + D2D1ShaderProfile.PixelShader40 => "lib_4_0"u8, + D2D1ShaderProfile.PixelShader41 => "lib_4_1"u8, + _ => "lib_5_0"u8 + }; + } + + /// + /// Gets a for a given shader profile, for a full shader. + /// + /// The input shaader profile to use. + /// A for a given shader profile, for a full shader. + public static ReadOnlySpan GetPixelShaderProfile(D2D1ShaderProfile shaderProfile) + { + return shaderProfile switch + { + D2D1ShaderProfile.PixelShader40Level91 => "ps_4_0_level_9_1"u8, + D2D1ShaderProfile.PixelShader40Level93 => "ps_4_0_level_9_3"u8, + D2D1ShaderProfile.PixelShader40 => "ps_4_0"u8, + D2D1ShaderProfile.PixelShader41 => "ps_4_1"u8, + _ => "ps_5_0"u8 + }; + } +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs index ca1be541..e550bad5 100644 --- a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs +++ b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs @@ -278,69 +278,4 @@ internal static unsafe partial class D3DCompiler throw new FxcCompilationException(updatedMessage); } - - /// - /// A container for ASCII encoded, null-terminated constant strings. - /// - public static class ASCII - { - /// - /// Gets a with the "D2D_FUNCTION" ASCII text. - /// - public static ReadOnlySpan D2D_FUNCTION => "D2D_FUNCTION"u8; - - /// - /// Gets a with the "D2D_FULL_SHADER" ASCII text. - /// - public static ReadOnlySpan D2D_FULL_SHADER => "D2D_FULL_SHADER"u8; - - /// - /// Gets a with the '\0' ASCII character. - /// - public static ReadOnlySpan NullTerminator => ""u8; - - /// - /// Gets a with the "D2D_ENTRY" ASCII text. - /// - public static ReadOnlySpan D2D_ENTRY => "D2D_ENTRY"u8; - - /// - /// Gets a with the "Execute" ASCII text. - /// - public static ReadOnlySpan Execute => "Execute"u8; - - /// - /// Gets a for a given shader profile, for a library. - /// - /// The input shaader profile to use. - /// A for a given shader profile, for a library. - public static ReadOnlySpan GetLibraryProfile(D2D1ShaderProfile shaderProfile) - { - return shaderProfile switch - { - D2D1ShaderProfile.PixelShader40Level91 => "lib_4_0_level_9_1"u8, - D2D1ShaderProfile.PixelShader40Level93 => "lib_4_0_level_9_3"u8, - D2D1ShaderProfile.PixelShader40 => "lib_4_0"u8, - D2D1ShaderProfile.PixelShader41 => "lib_4_1"u8, - _ => "lib_5_0"u8 - }; - } - - /// - /// Gets a for a given shader profile, for a full shader. - /// - /// The input shaader profile to use. - /// A for a given shader profile, for a full shader. - public static ReadOnlySpan GetPixelShaderProfile(D2D1ShaderProfile shaderProfile) - { - return shaderProfile switch - { - D2D1ShaderProfile.PixelShader40Level91 => "ps_4_0_level_9_1"u8, - D2D1ShaderProfile.PixelShader40Level93 => "ps_4_0_level_9_3"u8, - D2D1ShaderProfile.PixelShader40 => "ps_4_0"u8, - D2D1ShaderProfile.PixelShader41 => "ps_4_1"u8, - _ => "ps_5_0"u8 - }; - } - } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Translation/Headers/d2d1effecthelpers.hlsli.cs b/src/ComputeSharp.D2D1/Shaders/Translation/Headers/D2D1EffectHelpers.cs similarity index 100% rename from src/ComputeSharp.D2D1/Shaders/Translation/Headers/d2d1effecthelpers.hlsli.cs rename to src/ComputeSharp.D2D1/Shaders/Translation/Headers/D2D1EffectHelpers.cs