From 90b35cc3c9971845908ad1ab62f551443dff93da Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 17 Aug 2022 02:14:38 +0200 Subject: [PATCH] Use UTF8 literals in D3DCompiler constants --- .../Shaders/Translation/D3DCompiler.cs | 80 ++++--------------- 1 file changed, 15 insertions(+), 65 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs index c8856937..2dde77f8 100644 --- a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs +++ b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs @@ -214,77 +214,27 @@ internal static unsafe partial class D3DCompiler /// /// Gets a with the "D2D_FUNCTION" ASCII text. /// - public static ReadOnlySpan D2D_FUNCTION => new[] { (byte)'D', (byte)'2', (byte)'D', (byte)'_', (byte)'F', (byte)'U', (byte)'N', (byte)'C', (byte)'T', (byte)'I', (byte)'O', (byte)'N', (byte)'\0' }; + public static ReadOnlySpan D2D_FUNCTION => "D2D_FUNCTION"u8; /// /// Gets a with the "D2D_FULL_SHADER" ASCII text. /// - public static ReadOnlySpan D2D_FULL_SHADER => new[] { (byte)'D', (byte)'2', (byte)'D', (byte)'_', (byte)'F', (byte)'U', (byte)'L', (byte)'L', (byte)'_', (byte)'S', (byte)'H', (byte)'A', (byte)'D', (byte)'E', (byte)'R', (byte)'\0' }; + public static ReadOnlySpan D2D_FULL_SHADER => "D2D_FULL_SHADER"u8; /// /// Gets a with the '\0' ASCII character. /// - public static ReadOnlySpan NullTerminator => new[] { (byte)'\0' }; + public static ReadOnlySpan NullTerminator => ""u8; /// /// Gets a with the "D2D_ENTRY" ASCII text. /// - public static ReadOnlySpan D2D_ENTRY => new[] { (byte)'D', (byte)'2', (byte)'D', (byte)'_', (byte)'E', (byte)'N', (byte)'T', (byte)'R', (byte)'Y', (byte)'\0' }; + public static ReadOnlySpan D2D_ENTRY => "D2D_ENTRY"u8; /// /// Gets a with the "Execute" ASCII text. /// - public static ReadOnlySpan Execute => new[] { (byte)'E', (byte)'x', (byte)'e', (byte)'c', (byte)'u', (byte)'t', (byte)'e', (byte)'\0' }; - - /// - /// Gets a with the "lib_4_0_level_9_1" ASCII text. - /// - private static ReadOnlySpan lib_4_0_level_9_1 => new[] { (byte)'l', (byte)'i', (byte)'b', (byte)'_', (byte)'4', (byte)'_', (byte)'0', (byte)'_', (byte)'l', (byte)'e', (byte)'v', (byte)'e', (byte)'l', (byte)'_', (byte)'9', (byte)'_', (byte)'1', (byte)'\0' }; - - /// - /// Gets a with the "lib_4_0_level_9_3" ASCII text. - /// - private static ReadOnlySpan lib_4_0_level_9_3 => new[] { (byte)'l', (byte)'i', (byte)'b', (byte)'_', (byte)'4', (byte)'_', (byte)'0', (byte)'_', (byte)'l', (byte)'e', (byte)'v', (byte)'e', (byte)'l', (byte)'_', (byte)'9', (byte)'_', (byte)'3', (byte)'\0' }; - - /// - /// Gets a with the "lib_4_0" ASCII text. - /// - private static ReadOnlySpan lib_4_0 => new[] { (byte)'l', (byte)'i', (byte)'b', (byte)'_', (byte)'4', (byte)'_', (byte)'0', (byte)'\0' }; - - /// - /// Gets a with the "lib_4_1" ASCII text. - /// - private static ReadOnlySpan lib_4_1 => new[] { (byte)'l', (byte)'i', (byte)'b', (byte)'_', (byte)'4', (byte)'_', (byte)'1', (byte)'\0' }; - - /// - /// Gets a with the "lib_5_0" ASCII text. - /// - private static ReadOnlySpan lib_5_0 => new[] { (byte)'l', (byte)'i', (byte)'b', (byte)'_', (byte)'5', (byte)'_', (byte)'0', (byte)'\0' }; - - /// - /// Gets a with the "ps_4_0_level_9_1" ASCII text. - /// - private static ReadOnlySpan ps_4_0_level_9_1 => new[] { (byte)'p', (byte)'s', (byte)'_', (byte)'4', (byte)'_', (byte)'0', (byte)'_', (byte)'l', (byte)'e', (byte)'v', (byte)'e', (byte)'l', (byte)'_', (byte)'9', (byte)'_', (byte)'1', (byte)'\0' }; - - /// - /// Gets a with the "ps_4_0_level_9_3" ASCII text. - /// - private static ReadOnlySpan ps_4_0_level_9_3 => new[] { (byte)'p', (byte)'s', (byte)'_', (byte)'4', (byte)'_', (byte)'0', (byte)'_', (byte)'l', (byte)'e', (byte)'v', (byte)'e', (byte)'l', (byte)'_', (byte)'9', (byte)'_', (byte)'3', (byte)'\0' }; - - /// - /// Gets a with the "ps_4_0" ASCII text. - /// - private static ReadOnlySpan ps_4_0 => new[] { (byte)'p', (byte)'s', (byte)'_', (byte)'4', (byte)'_', (byte)'0', (byte)'\0' }; - - /// - /// Gets a with the "ps_4_1" ASCII text. - /// - private static ReadOnlySpan ps_4_1 => new[] { (byte)'p', (byte)'s', (byte)'_', (byte)'4', (byte)'_', (byte)'1', (byte)'\0' }; - - /// - /// Gets a with the "ps_5_0" ASCII text. - /// - private static ReadOnlySpan ps_5_0 => new[] { (byte)'p', (byte)'s', (byte)'_', (byte)'5', (byte)'_', (byte)'0', (byte)'\0' }; + public static ReadOnlySpan Execute => "Execute"u8; /// /// Gets a for a given shader profile, for a library. @@ -295,11 +245,11 @@ internal static unsafe partial class D3DCompiler { return shaderProfile switch { - D2D1ShaderProfile.PixelShader40Level91 => lib_4_0_level_9_1, - D2D1ShaderProfile.PixelShader40Level93 => lib_4_0_level_9_3, - D2D1ShaderProfile.PixelShader40 => lib_4_0, - D2D1ShaderProfile.PixelShader41 => lib_4_1, - _ => lib_5_0 + 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 }; } @@ -312,11 +262,11 @@ internal static unsafe partial class D3DCompiler { return shaderProfile switch { - D2D1ShaderProfile.PixelShader40Level91 => ps_4_0_level_9_1, - D2D1ShaderProfile.PixelShader40Level93 => ps_4_0_level_9_3, - D2D1ShaderProfile.PixelShader40 => ps_4_0, - D2D1ShaderProfile.PixelShader41 => ps_4_1, - _ => ps_5_0 + 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 }; } }