Minor refactoring to D2D compiler files
このコミットが含まれているのは:
1 親
6237507238
コミット
c18f833c67
5ファイル変更
+76
-72
検索条件に一致するファイルはありません
@@ -77,9 +77,10 @@
|
||||
<Compile Include="..\ComputeSharp.D2D1\Intrinsics\D2D.cs" Link="ComputeSharp.D2D1\Intrinsics\D2D.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Exceptions\FxcCompilationException.cs" Link="ComputeSharp.D2D1\Shaders\Exceptions\FxcCompilationException.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Interop\Helpers\D2D1AssemblyAssociatedMemory.cs" Link="ComputeSharp.D2D1\Shaders\Interop\Helpers\D2D1AssemblyAssociatedMemory.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Translation\D3DCompiler.cs" Link="Fxc\D3DCompiler.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Translation\D3DCompiler.ID3DInclude.cs" Link="Fxc\D3DCompiler.ID3DInclude.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Translation\Headers\d2d1effecthelpers.hlsli.cs" Link="Fxc\Headers\d2d1effecthelpers.hlsli.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Translation\ASCII.cs" Link="ComputeSharp.D2D1\Shaders\Translation\ASCII.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Translation\D3DCompiler.cs" Link="ComputeSharp.D2D1\Shaders\Translation\D3DCompiler.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Translation\D3DCompiler.ID3DInclude.cs" Link="ComputeSharp.D2D1\Shaders\Translation\D3DCompiler.ID3DInclude.cs" />
|
||||
<Compile Include="..\ComputeSharp.D2D1\Shaders\Translation\Headers\D2D1EffectHelpers.cs" Link="ComputeSharp.D2D1\Shaders\Translation\Headers\D2D1EffectHelpers.cs" />
|
||||
|
||||
<!-- ComPtr<T> and HRESULT extension from D3D12 generator -->
|
||||
<Compile Include="..\ComputeSharp.SourceGenerators\Dxc\Windows.Win32\ComPtr{T}.cs" Link="Fxc\Windows.Win32\ComPtr{T}.cs" />
|
||||
|
||||
@@ -74,10 +74,10 @@ public static class D2D1ShaderCompiler
|
||||
// Compile the standalone D2D1 full shader
|
||||
using ComPtr<ID3DBlob> 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<ID3DBlob> 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
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.D2D1.Shaders.Translation;
|
||||
|
||||
/// <summary>
|
||||
/// A container for ASCII encoded, null-terminated constant strings.
|
||||
/// </summary>
|
||||
internal static class ASCII
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"D2D_FUNCTION"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> D2D_FUNCTION => "D2D_FUNCTION"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"D2D_FULL_SHADER"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> D2D_FULL_SHADER => "D2D_FULL_SHADER"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>'\0'</c> ASCII character.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> NullTerminator => ""u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"D2D_ENTRY"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> D2D_ENTRY => "D2D_ENTRY"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"Execute"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> Execute => "Execute"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a library.
|
||||
/// </summary>
|
||||
/// <param name="shaderProfile">The input shaader profile to use.</param>
|
||||
/// <returns>A <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a library.</returns>
|
||||
public static ReadOnlySpan<byte> 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
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a full shader.
|
||||
/// </summary>
|
||||
/// <param name="shaderProfile">The input shaader profile to use.</param>
|
||||
/// <returns>A <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a full shader.</returns>
|
||||
public static ReadOnlySpan<byte> 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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -278,69 +278,4 @@ internal static unsafe partial class D3DCompiler
|
||||
|
||||
throw new FxcCompilationException(updatedMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A container for ASCII encoded, null-terminated constant strings.
|
||||
/// </summary>
|
||||
public static class ASCII
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"D2D_FUNCTION"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> D2D_FUNCTION => "D2D_FUNCTION"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"D2D_FULL_SHADER"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> D2D_FULL_SHADER => "D2D_FULL_SHADER"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>'\0'</c> ASCII character.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> NullTerminator => ""u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"D2D_ENTRY"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> D2D_ENTRY => "D2D_ENTRY"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> with the <c>"Execute"</c> ASCII text.
|
||||
/// </summary>
|
||||
public static ReadOnlySpan<byte> Execute => "Execute"u8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a library.
|
||||
/// </summary>
|
||||
/// <param name="shaderProfile">The input shaader profile to use.</param>
|
||||
/// <returns>A <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a library.</returns>
|
||||
public static ReadOnlySpan<byte> 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
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a full shader.
|
||||
/// </summary>
|
||||
/// <param name="shaderProfile">The input shaader profile to use.</param>
|
||||
/// <returns>A <see cref="ReadOnlySpan{T}"/> for a given shader profile, for a full shader.</returns>
|
||||
public static ReadOnlySpan<byte> 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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする