Merge pull request #679 from Sergio0694/dev/d2d-generator-tweaks

Refactor file organizations across projects
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2023-11-24 14:35:29 +01:00
コミット 6063761cb4
41ファイル変更
+110 -91

検索条件に一致するファイルはありません

+5 -4
ファイルの表示
@@ -65,7 +65,7 @@
<Compile Include="..\ComputeSharp.Core\Primitives\MatrixIndex.cs" Link="ComputeSharp.Core\Primitives\MatrixIndex.cs" />
<!-- ComputeSharp APIs -->
<Compile Include="..\ComputeSharp\Core\Helpers\AlignmentHelper.cs" Link="ComputeSharp\Core\Helpers\AlignmentHelper.cs" />
<Compile Include="..\ComputeSharp\Graphics\Helpers\AlignmentHelper.cs" Link="ComputeSharp\Graphics\Helpers\AlignmentHelper.cs" />
<!-- ComputeSharp.D2D1 APIs -->
<Compile Include="..\ComputeSharp.D2D1\Attributes\Enums\D2D1ShaderProfile.cs" Link="ComputeSharp.D2D1\Attributes\Enums\D2D1ShaderProfile.cs" />
@@ -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" />
+4 -4
ファイルの表示
@@ -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
+68
ファイルの表示
@@ -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
};
}
}
-65
ファイルの表示
@@ -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
};
}
}
}
@@ -1,7 +1,7 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
using ComputeSharp.Core.Helpers;
using ComputeSharp.Graphics.Helpers;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
using ComputeSharp.SourceGeneration.Mappings;
+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
using System.Collections.Immutable;
using ComputeSharp.Core.Helpers;
using ComputeSharp.Graphics.Helpers;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
using ComputeSharp.SourceGeneration.Models;
+11 -11
ファイルの表示
@@ -59,17 +59,17 @@
<Compile Include="..\ComputeSharp.Core\Primitives\MatrixIndex.cs" Link="ComputeSharp.Core\Primitives\MatrixIndex.cs" />
<!-- ComputeSharp APIs -->
<Compile Include="..\ComputeSharp\Core\Attributes\Enums\CompileOptions.cs" Link="ComputeSharp\Core\Attributes\Enums\CompileOptions.cs" />
<Compile Include="..\ComputeSharp\Core\Attributes\Enums\DefaultThreadGroupSizes.cs" Link="ComputeSharp\Core\Attributes\Enums\DefaultThreadGroupSizes.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\DispatchSize.cs" Link="ComputeSharp\Core\Dispatch\DispatchSize.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GridIds.cs" Link="ComputeSharp\Core\Dispatch\GridIds.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GroupIds.cs" Link="ComputeSharp\Core\Dispatch\GroupIds.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\GroupSize.cs" Link="ComputeSharp\Core\Dispatch\GroupSize.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\ThreadIds.cs" Link="ComputeSharp\Core\Dispatch\ThreadIds.cs" />
<Compile Include="..\ComputeSharp\Core\Dispatch\ThreadIds.Normalized.cs" Link="ComputeSharp\Core\Dispatch\ThreadIds.Normalized.cs" />
<Compile Include="..\ComputeSharp\Core\Helpers\AlignmentHelper.cs" Link="ComputeSharp\Core\Helpers\AlignmentHelper.cs" />
<Compile Include="..\ComputeSharp\Core\Interfaces\IComputeShader.cs" Link="ComputeSharp\Core\Interfaces\IComputeShader.cs" />
<Compile Include="..\ComputeSharp\Core\Interfaces\IComputeShader{TPixel}.cs" Link="ComputeSharp\Core\Interfaces\IComputeShader{TPixel}.cs" />
<Compile Include="..\ComputeSharp\Attributes\Enums\CompileOptions.cs" Link="ComputeSharp\Attributes\Enums\CompileOptions.cs" />
<Compile Include="..\ComputeSharp\Attributes\Enums\DefaultThreadGroupSizes.cs" Link="ComputeSharp\Attributes\Enums\DefaultThreadGroupSizes.cs" />
<Compile Include="..\ComputeSharp\Dispatch\DispatchSize.cs" Link="ComputeSharp\Dispatch\DispatchSize.cs" />
<Compile Include="..\ComputeSharp\Dispatch\GridIds.cs" Link="ComputeSharp\Dispatch\GridIds.cs" />
<Compile Include="..\ComputeSharp\Dispatch\GroupIds.cs" Link="ComputeSharp\Dispatch\GroupIds.cs" />
<Compile Include="..\ComputeSharp\Dispatch\GroupSize.cs" Link="ComputeSharp\Dispatch\GroupSize.cs" />
<Compile Include="..\ComputeSharp\Dispatch\ThreadIds.cs" Link="ComputeSharp\Dispatch\ThreadIds.cs" />
<Compile Include="..\ComputeSharp\Dispatch\ThreadIds.Normalized.cs" Link="ComputeSharp\Dispatch\ThreadIds.Normalized.cs" />
<Compile Include="..\ComputeSharp\Interfaces\IComputeShader.cs" Link="ComputeSharp\Interfaces\IComputeShader.cs" />
<Compile Include="..\ComputeSharp\Interfaces\IComputeShader{TPixel}.cs" Link="ComputeSharp\Interfaces\IComputeShader{TPixel}.cs" />
<Compile Include="..\ComputeSharp\Graphics\Helpers\AlignmentHelper.cs" Link="ComputeSharp\Graphics\Helpers\AlignmentHelper.cs" />
</ItemGroup>
<ItemGroup>
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
@@ -1,6 +1,6 @@
using System.Runtime.CompilerServices;
namespace ComputeSharp.Core.Helpers;
namespace ComputeSharp.Graphics.Helpers;
/// <summary>
/// A <see langword="class"/> with helper methods to work with alignment and padding.
@@ -31,6 +31,7 @@ internal static class AlignmentHelper
return (size + alignment - 1) & ~(alignment - 1);
}
#if SOURCE_GENERATOR
/// <summary>
/// Aligns a given offset to a specified boundary, if a given size increment would have crossed it.
/// </summary>
@@ -41,6 +42,8 @@ internal static class AlignmentHelper
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int AlignToBoundary(int offset, int size, int alignment)
{
// This method is mirrored in AlignmentHelperTests, so it can be tested individually
// as well. Any changes done here should be applied to that standalone copy as well.
if ((uint)offset / (uint)alignment == (uint)(offset + size - 1) / (uint)alignment)
{
return offset;
@@ -48,4 +51,5 @@ internal static class AlignmentHelper
return (offset + alignment - 1) & ~(alignment - 1);
}
#endif
}
-1
ファイルの表示
@@ -3,7 +3,6 @@ using System.Buffers;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.Core.Helpers;
using ComputeSharp.Graphics.Commands.Interop;
using ComputeSharp.Graphics.Extensions;
using ComputeSharp.Graphics.Helpers;
-1
ファイルの表示
@@ -2,7 +2,6 @@ using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using ComputeSharp.Core.Helpers;
using ComputeSharp.Graphics.Extensions;
using ComputeSharp.Graphics.Helpers;
using ComputeSharp.Graphics.Resources.Interop;
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
ファイルの表示
差分なしでファイル名を変更。
ファイルの表示
差分なしでファイル名を変更。
ファイルの表示
差分なしでファイル名を変更。
ファイルの表示
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
差分なしでファイル名を変更。
+15 -2
ファイルの表示
@@ -1,4 +1,4 @@
using ComputeSharp.Core.Helpers;
using ComputeSharp.Graphics.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ComputeSharp.Tests.Internals;
@@ -33,7 +33,20 @@ public class AlignmentHelperTests
[DataRow(24, 8, 16, 24)]
public void AlignToBoundary(int offset, int size, int alignment, int expected)
{
int result = AlignmentHelper.AlignToBoundary(offset, size, alignment);
// Note: this method is defined in AlignmentHelper, but it's only compiled when referenced
// by the source generator, so it's not available here. Just for the sake of the additional
// testing, and because the method is very small, it's just mirrored here for validation.
static int AlignToBoundary(int offset, int size, int alignment)
{
if ((uint)offset / (uint)alignment == (uint)(offset + size - 1) / (uint)alignment)
{
return offset;
}
return (offset + alignment - 1) & ~(alignment - 1);
}
int result = AlignToBoundary(offset, size, alignment);
Assert.AreEqual(result, expected);
}