diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj
index 28237fe0..1644d727 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ComputeSharp.D2D1.SourceGenerators.csproj
@@ -65,7 +65,7 @@
-
+
@@ -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
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxProcessors/ConstantBufferSyntaxProcessor.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxProcessors/ConstantBufferSyntaxProcessor.cs
index 3d24fa41..d346273d 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxProcessors/ConstantBufferSyntaxProcessor.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxProcessors/ConstantBufferSyntaxProcessor.cs
@@ -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;
diff --git a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.ConstantBuffer.cs b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.ConstantBuffer.cs
index 8ec40690..13c7dd4e 100644
--- a/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.ConstantBuffer.cs
+++ b/src/ComputeSharp.SourceGenerators/ComputeShaderDescriptorGenerator.ConstantBuffer.cs
@@ -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;
diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj
index 541a27ee..bdd7240f 100644
--- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj
+++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj
@@ -59,17 +59,17 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ComputeSharp/Core/Attributes/CompileOptionsAttribute.cs b/src/ComputeSharp/Attributes/CompileOptionsAttribute.cs
similarity index 100%
rename from src/ComputeSharp/Core/Attributes/CompileOptionsAttribute.cs
rename to src/ComputeSharp/Attributes/CompileOptionsAttribute.cs
diff --git a/src/ComputeSharp/Core/Attributes/Enums/CompileOptions.cs b/src/ComputeSharp/Attributes/Enums/CompileOptions.cs
similarity index 100%
rename from src/ComputeSharp/Core/Attributes/Enums/CompileOptions.cs
rename to src/ComputeSharp/Attributes/Enums/CompileOptions.cs
diff --git a/src/ComputeSharp/Core/Attributes/Enums/DefaultThreadGroupSizes.cs b/src/ComputeSharp/Attributes/Enums/DefaultThreadGroupSizes.cs
similarity index 100%
rename from src/ComputeSharp/Core/Attributes/Enums/DefaultThreadGroupSizes.cs
rename to src/ComputeSharp/Attributes/Enums/DefaultThreadGroupSizes.cs
diff --git a/src/ComputeSharp/Core/Attributes/GeneratedComputeShaderDescriptorAttribute.cs b/src/ComputeSharp/Attributes/GeneratedComputeShaderDescriptorAttribute.cs
similarity index 100%
rename from src/ComputeSharp/Core/Attributes/GeneratedComputeShaderDescriptorAttribute.cs
rename to src/ComputeSharp/Attributes/GeneratedComputeShaderDescriptorAttribute.cs
diff --git a/src/ComputeSharp/Core/Attributes/GloballyCoherentAttribute.cs b/src/ComputeSharp/Attributes/GloballyCoherentAttribute.cs
similarity index 100%
rename from src/ComputeSharp/Core/Attributes/GloballyCoherentAttribute.cs
rename to src/ComputeSharp/Attributes/GloballyCoherentAttribute.cs
diff --git a/src/ComputeSharp/Core/Attributes/GroupSharedAttribute.cs b/src/ComputeSharp/Attributes/GroupSharedAttribute.cs
similarity index 100%
rename from src/ComputeSharp/Core/Attributes/GroupSharedAttribute.cs
rename to src/ComputeSharp/Attributes/GroupSharedAttribute.cs
diff --git a/src/ComputeSharp/Core/Attributes/ThreadGroupSizeAttribute.cs b/src/ComputeSharp/Attributes/ThreadGroupSizeAttribute.cs
similarity index 100%
rename from src/ComputeSharp/Core/Attributes/ThreadGroupSizeAttribute.cs
rename to src/ComputeSharp/Attributes/ThreadGroupSizeAttribute.cs
diff --git a/src/ComputeSharp/Core/Dispatch/DispatchSize.cs b/src/ComputeSharp/Dispatch/DispatchSize.cs
similarity index 100%
rename from src/ComputeSharp/Core/Dispatch/DispatchSize.cs
rename to src/ComputeSharp/Dispatch/DispatchSize.cs
diff --git a/src/ComputeSharp/Core/Dispatch/GridIds.cs b/src/ComputeSharp/Dispatch/GridIds.cs
similarity index 100%
rename from src/ComputeSharp/Core/Dispatch/GridIds.cs
rename to src/ComputeSharp/Dispatch/GridIds.cs
diff --git a/src/ComputeSharp/Core/Dispatch/GroupIds.cs b/src/ComputeSharp/Dispatch/GroupIds.cs
similarity index 100%
rename from src/ComputeSharp/Core/Dispatch/GroupIds.cs
rename to src/ComputeSharp/Dispatch/GroupIds.cs
diff --git a/src/ComputeSharp/Core/Dispatch/GroupSize.cs b/src/ComputeSharp/Dispatch/GroupSize.cs
similarity index 100%
rename from src/ComputeSharp/Core/Dispatch/GroupSize.cs
rename to src/ComputeSharp/Dispatch/GroupSize.cs
diff --git a/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs b/src/ComputeSharp/Dispatch/ThreadIds.Normalized.cs
similarity index 100%
rename from src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs
rename to src/ComputeSharp/Dispatch/ThreadIds.Normalized.cs
diff --git a/src/ComputeSharp/Core/Dispatch/ThreadIds.cs b/src/ComputeSharp/Dispatch/ThreadIds.cs
similarity index 100%
rename from src/ComputeSharp/Core/Dispatch/ThreadIds.cs
rename to src/ComputeSharp/Dispatch/ThreadIds.cs
diff --git a/src/ComputeSharp/Core/Extensions/FloatExtensions.cs b/src/ComputeSharp/Extensions/FloatExtensions.cs
similarity index 100%
rename from src/ComputeSharp/Core/Extensions/FloatExtensions.cs
rename to src/ComputeSharp/Extensions/FloatExtensions.cs
diff --git a/src/ComputeSharp/Core/Extensions/VectorExtensions.cs b/src/ComputeSharp/Extensions/VectorExtensions.cs
similarity index 100%
rename from src/ComputeSharp/Core/Extensions/VectorExtensions.cs
rename to src/ComputeSharp/Extensions/VectorExtensions.cs
diff --git a/src/ComputeSharp/Core/Helpers/AlignmentHelper.cs b/src/ComputeSharp/Graphics/Helpers/AlignmentHelper.cs
similarity index 88%
rename from src/ComputeSharp/Core/Helpers/AlignmentHelper.cs
rename to src/ComputeSharp/Graphics/Helpers/AlignmentHelper.cs
index 6751bde4..ef5eb411 100644
--- a/src/ComputeSharp/Core/Helpers/AlignmentHelper.cs
+++ b/src/ComputeSharp/Graphics/Helpers/AlignmentHelper.cs
@@ -1,6 +1,6 @@
using System.Runtime.CompilerServices;
-namespace ComputeSharp.Core.Helpers;
+namespace ComputeSharp.Graphics.Helpers;
///
/// A 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
///
/// Aligns a given offset to a specified boundary, if a given size increment would have crossed it.
///
@@ -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
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
index d3b30619..72d6f599 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
@@ -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;
diff --git a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs
index 75f4ae58..f0f05414 100644
--- a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs
@@ -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;
diff --git a/src/ComputeSharp/Core/Imaging/Bgra32.cs b/src/ComputeSharp/Imaging/Bgra32.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/Bgra32.cs
rename to src/ComputeSharp/Imaging/Bgra32.cs
diff --git a/src/ComputeSharp/Core/Imaging/Formats/ImageFormat.cs b/src/ComputeSharp/Imaging/Formats/ImageFormat.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/Formats/ImageFormat.cs
rename to src/ComputeSharp/Imaging/Formats/ImageFormat.cs
diff --git a/src/ComputeSharp/Core/Imaging/Interfaces/IPixel{T,TPixel}.cs b/src/ComputeSharp/Imaging/Interfaces/IPixel{T,TPixel}.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/Interfaces/IPixel{T,TPixel}.cs
rename to src/ComputeSharp/Imaging/Interfaces/IPixel{T,TPixel}.cs
diff --git a/src/ComputeSharp/Core/Imaging/R16.cs b/src/ComputeSharp/Imaging/R16.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/R16.cs
rename to src/ComputeSharp/Imaging/R16.cs
diff --git a/src/ComputeSharp/Core/Imaging/R8.cs b/src/ComputeSharp/Imaging/R8.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/R8.cs
rename to src/ComputeSharp/Imaging/R8.cs
diff --git a/src/ComputeSharp/Core/Imaging/Rg16.cs b/src/ComputeSharp/Imaging/Rg16.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/Rg16.cs
rename to src/ComputeSharp/Imaging/Rg16.cs
diff --git a/src/ComputeSharp/Core/Imaging/Rg32.cs b/src/ComputeSharp/Imaging/Rg32.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/Rg32.cs
rename to src/ComputeSharp/Imaging/Rg32.cs
diff --git a/src/ComputeSharp/Core/Imaging/Rgba32.cs b/src/ComputeSharp/Imaging/Rgba32.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/Rgba32.cs
rename to src/ComputeSharp/Imaging/Rgba32.cs
diff --git a/src/ComputeSharp/Core/Imaging/Rgba64.cs b/src/ComputeSharp/Imaging/Rgba64.cs
similarity index 100%
rename from src/ComputeSharp/Core/Imaging/Rgba64.cs
rename to src/ComputeSharp/Imaging/Rgba64.cs
diff --git a/src/ComputeSharp/Core/Interfaces/Descriptors/IComputeShaderDescriptor{T}.cs b/src/ComputeSharp/Interfaces/Descriptors/IComputeShaderDescriptor{T}.cs
similarity index 100%
rename from src/ComputeSharp/Core/Interfaces/Descriptors/IComputeShaderDescriptor{T}.cs
rename to src/ComputeSharp/Interfaces/Descriptors/IComputeShaderDescriptor{T}.cs
diff --git a/src/ComputeSharp/Core/Interfaces/Descriptors/IConstantBufferLoader.cs b/src/ComputeSharp/Interfaces/Descriptors/IConstantBufferLoader.cs
similarity index 100%
rename from src/ComputeSharp/Core/Interfaces/Descriptors/IConstantBufferLoader.cs
rename to src/ComputeSharp/Interfaces/Descriptors/IConstantBufferLoader.cs
diff --git a/src/ComputeSharp/Core/Interfaces/Descriptors/IGraphicsResourceLoader.cs b/src/ComputeSharp/Interfaces/Descriptors/IGraphicsResourceLoader.cs
similarity index 100%
rename from src/ComputeSharp/Core/Interfaces/Descriptors/IGraphicsResourceLoader.cs
rename to src/ComputeSharp/Interfaces/Descriptors/IGraphicsResourceLoader.cs
diff --git a/src/ComputeSharp/Core/Interfaces/IComputeShader.cs b/src/ComputeSharp/Interfaces/IComputeShader.cs
similarity index 100%
rename from src/ComputeSharp/Core/Interfaces/IComputeShader.cs
rename to src/ComputeSharp/Interfaces/IComputeShader.cs
diff --git a/src/ComputeSharp/Core/Interfaces/IComputeShader{TPixel}.cs b/src/ComputeSharp/Interfaces/IComputeShader{TPixel}.cs
similarity index 100%
rename from src/ComputeSharp/Core/Interfaces/IComputeShader{TPixel}.cs
rename to src/ComputeSharp/Interfaces/IComputeShader{TPixel}.cs
diff --git a/tests/ComputeSharp.Tests.Internals/AlignmentHelperTests.cs b/tests/ComputeSharp.Tests.Internals/AlignmentHelperTests.cs
index 91b6604c..2968a15f 100644
--- a/tests/ComputeSharp.Tests.Internals/AlignmentHelperTests.cs
+++ b/tests/ComputeSharp.Tests.Internals/AlignmentHelperTests.cs
@@ -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);
}