diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs index 1417c2d1..a5a07d24 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs @@ -163,7 +163,6 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader return Hlsl.Max(shade, 0.0f); } - // I keep a collection of occlusion routines... OK, that sounded really nerdy. :) // Anyway, I like this one. I'm assuHlsl.Ming it's based on IQ's original. private float CalculateAO(in float3 p, in float3 n) diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs index 4a3663e9..bdb9db97 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/FourColorGradient.cs @@ -72,7 +72,6 @@ internal readonly partial struct FourColorGradient : IPixelShader return 0.5f + (0.5f * n); } - /// public float4 Execute() { diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs index 03a1f168..9c5946c5 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs @@ -81,7 +81,9 @@ internal readonly partial struct MengerJourney : IPixelShader z = Hlsl.Abs(z); if (z.X < z.Y) { z.XY = z.YX; } + if (z.X < z.Z) { z.XZ = z.ZX; } + if (z.Y < z.Z) { z.YZ = z.ZY; } z = (Scale * z) - (Offset * (Scale - 1.0f)); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs index ce8609b7..b4ea047f 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs @@ -109,7 +109,6 @@ internal readonly partial struct PyramidPattern : IPixelShader return 1.0f - Hlsl.Max(p.X, p.Y); } - // Standard function-based bump mapping function, with an edge value included for good measure private float3 DoBumpMap(in float2 p, in float3 n, float bumpfactor, ref float edge) { @@ -131,7 +130,6 @@ internal readonly partial struct PyramidPattern : IPixelShader return Hlsl.Normalize(n + (grad * bumpfactor)); } - // A hatch-like algorithm, or a stipple... or some kind of textured pattern private float DoHatch(float2 p, float res) { diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs index 8b57b371..d86344ad 100644 --- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs +++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs @@ -185,6 +185,7 @@ internal static unsafe class Win32ApplicationRunner { isPaused = false; } + return 0; } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs index 919d5b31..0c1a3598 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs @@ -124,6 +124,7 @@ partial class ID2D1ShaderGenerator ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})"), ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))")))); } + break; } } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs index 15faf4b4..381e0b6d 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs @@ -149,6 +149,7 @@ partial class ID2D1ShaderGenerator ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))"), ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})")))); } + break; } } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs index 382e7bb4..55821ef0 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadInputDescriptionsMethod.cs @@ -49,6 +49,7 @@ partial class ID2D1ShaderGenerator inputDescriptionsBuilder.Add(new InputDescription((uint)index, filter, levelOfDetailCount)); } + break; default: break; diff --git a/src/ComputeSharp.D2D1/Shaders/Translation/Headers/d2d1effecthelpers.hlsli.cs b/src/ComputeSharp.D2D1/Shaders/Translation/Headers/d2d1effecthelpers.hlsli.cs index 8101f31b..c1dc408d 100644 --- a/src/ComputeSharp.D2D1/Shaders/Translation/Headers/d2d1effecthelpers.hlsli.cs +++ b/src/ComputeSharp.D2D1/Shaders/Translation/Headers/d2d1effecthelpers.hlsli.cs @@ -1,5 +1,7 @@ using System; +#pragma warning disable IDE0025 + namespace ComputeSharp.D2D1.Shaders.Translation; /// diff --git a/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.cs b/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.cs index d926683c..64a5d7a0 100644 --- a/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.cs +++ b/src/ComputeSharp.Dynamic/Attributes/__Internals/ShaderMethodSourceAttribute.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Reflection; using ComputeSharp.Core.Extensions; +#pragma warning disable IDE0052 + namespace ComputeSharp.__Internals; /// diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs index 13ce4c18..db297fe4 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs @@ -26,26 +26,6 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// private static readonly char[] FloatLiteralSpecialCharacters = { '.', 'E' }; - /// - /// The instance with semantic info on the target syntax tree. - /// - protected readonly SemanticModelProvider SemanticModel; - - /// - /// The collection of discovered custom types. - /// - protected readonly ICollection DiscoveredTypes; - - /// - /// The collection of discovered constant definitions. - /// - protected readonly IDictionary ConstantDefinitions; - - /// - /// The collection of produced instances. - /// - protected readonly ImmutableArrayBuilder Diagnostics; - /// /// Creates a new instance with the specified parameters. /// @@ -65,6 +45,26 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter Diagnostics = diagnostics; } + /// + /// Gets the instance with semantic info on the target syntax tree. + /// + protected SemanticModelProvider SemanticModel { get; } + + /// + /// Gets the collection of discovered custom types. + /// + protected ICollection DiscoveredTypes { get; } + + /// + /// Gets the collection of discovered constant definitions. + /// + protected IDictionary ConstantDefinitions { get; } + + /// + /// Gets the collection of produced instances. + /// + protected ImmutableArrayBuilder Diagnostics { get; } + /// public override SyntaxNode VisitCastExpression(CastExpressionSyntax node) { diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index 2268a700..2aadf4cb 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -560,8 +560,6 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter return updatedNode; } - - /// /// Rewrites a sampled texture access. /// diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs index 2f704033..7a52ad3f 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs @@ -234,6 +234,7 @@ partial class IShaderGenerator ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.As(ref global::System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref r0, (nint){matrix.Offsets[j]}))"), ParseExpression($"global::System.Runtime.CompilerServices.Unsafe.Add(ref {rowLocalName}, {j})")))); } + break; } } diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchMetadataMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchMetadataMethod.Syntax.cs index 6e0be3b1..9af3d88d 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchMetadataMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchMetadataMethod.Syntax.cs @@ -44,7 +44,7 @@ partial class IShaderGenerator .WithType(IdentifierName("TLoader")), Parameter(Identifier("result")) .AddModifiers(Token(SyntaxKind.OutKeyword)) - .WithType(IdentifierName($"global::System.{typeof(IntPtr).Name}"))) + .WithType(IdentifierName($"global::System.{nameof(IntPtr)}"))) .WithBody(Block(GetDispatchMetadataLoadingStatements(metadataInfo))); } @@ -122,7 +122,6 @@ partial class IShaderGenerator statements.Add(ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 0), {metadataInfo.Root32BitConstantCount});")); statements.Add(ParseStatement($"global::System.Runtime.CompilerServices.Unsafe.WriteUnaligned(ref global::System.Runtime.CompilerServices.Unsafe.Add(ref r0, 4), {metadataInfo.IsSamplerUsed.ToString(CultureInfo.InvariantCulture).ToLowerInvariant()});")); - // Populate the sequence of resource descriptors foreach (ResourceDescriptor descriptor in metadataInfo.ResourceDescriptors) { diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs index 59f3eb56..0d85be99 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs @@ -92,7 +92,7 @@ partial class HlslKnownProperties // Programmatically load mappings for the normalized thread ids foreach (PropertyInfo? property in typeof(ThreadIds.Normalized).GetProperties(BindingFlags.Static | BindingFlags.Public)) { - string key = $"{typeof(ThreadIds).FullName}{Type.Delimiter}{typeof(ThreadIds.Normalized).Name}{Type.Delimiter}{property.Name}"; + string key = $"{typeof(ThreadIds).FullName}{Type.Delimiter}{nameof(ThreadIds.Normalized)}{Type.Delimiter}{property.Name}"; // The normalized value must be in the [0, 1] range, inclusive. As such, the expression is rewritten to be: // 1D: (float)ThreadIds. / (float)(max(1, __ - 1)); @@ -105,11 +105,11 @@ partial class HlslKnownProperties switch (property.Name) { case string name when name.Length == 1: - knownProperties.Add(key, $"(float){typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[0])} / (float)(max(1, __{char.ToLowerInvariant(name[0])} - 1))"); + knownProperties.Add(key, $"(float){nameof(ThreadIds)}.{char.ToLowerInvariant(name[0])} / (float)(max(1, __{char.ToLowerInvariant(name[0])} - 1))"); break; case string name when name.Length == 2: { - string numerator = $"float2({typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[0])}, {typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[1])})"; + string numerator = $"float2({nameof(ThreadIds)}.{char.ToLowerInvariant(name[0])}, {nameof(ThreadIds)}.{char.ToLowerInvariant(name[1])})"; string denominator = $"float2(max(1, int2(__{char.ToLowerInvariant(name[0])}, __{char.ToLowerInvariant(name[1])}) - 1))"; knownProperties.Add(key, $"{numerator} / {denominator}"); @@ -117,7 +117,7 @@ partial class HlslKnownProperties } case string name when name.Length == 3: { - string numerator = $"float3({typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[0])}, {typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[1])}, {typeof(ThreadIds).Name}.{char.ToLowerInvariant(name[2])})"; + string numerator = $"float3({nameof(ThreadIds)}.{char.ToLowerInvariant(name[0])}, {nameof(ThreadIds)}.{char.ToLowerInvariant(name[1])}, {nameof(ThreadIds)}.{char.ToLowerInvariant(name[2])})"; string denominator = $"float3(max(1, int3(__{char.ToLowerInvariant(name[0])}, __{char.ToLowerInvariant(name[1])}, __{char.ToLowerInvariant(name[2])}) - 1))"; knownProperties.Add(key, $"{numerator} / {denominator}"); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs index fbec8370..2c6e9cfa 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs @@ -170,6 +170,7 @@ public abstract unsafe class TransferBuffer : NativeObject, IGraphicsResource /// public override Memory Memory { + [MethodImpl(MethodImplOptions.AggressiveInlining)] get => CreateMemory(this.buffer.Length); } diff --git a/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs index ab5b708f..74881bb5 100644 --- a/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs +++ b/tests/ComputeSharp.Tests.NativeLibrariesResolver/Helpers/NativeLibrariesResolverTestsBase.cs @@ -105,7 +105,6 @@ public abstract class NativeLibrariesResolverTestsBase Assert.AreEqual(0, Exec(pathToAppHostDirectory, $"{SampleProjectName}.exe", "")); } - [TestMethod] [DataRow(PublishMode.SelfContained, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)] [DataRow(PublishMode.FrameworkDependent, DeploymentMode.Multiassembly, NativeLibrariesDeploymentMode.NotApplicable)] diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs index d2a9d18f..07ee6ba8 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs @@ -151,7 +151,6 @@ internal readonly partial struct ExtrudedTruchetPattern : IComputeShader return Hlsl.Max(shade, 0.0f); } - // I keep a collection of occlusion routines... OK, that sounded really nerdy. :) // Anyway, I like this one. I'm assuHlsl.Ming it's based on IQ's original. private float CalculateAO(in float3 p, in float3 n) diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs b/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs index a6792cf1..03901a66 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/FourColorGradient.cs @@ -76,7 +76,6 @@ internal readonly partial struct FourColorGradient : IComputeShader return 0.5f + 0.5f * n; } - /// public void Execute() { diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs b/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs index 0212a685..d5ee7d5e 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs @@ -85,7 +85,9 @@ internal readonly partial struct MengerJourney : IComputeShader z = Hlsl.Abs(z); if (z.X < z.Y) { z.XY = z.YX; } + if (z.X < z.Z) { z.XZ = z.ZX; } + if (z.Y < z.Z) { z.YZ = z.ZY; } z = Scale * z - Offset * (Scale - 1.0f); diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs b/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs index 75f81a8d..e895170d 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs @@ -101,7 +101,6 @@ internal readonly partial struct PyramidPattern : IComputeShader return 1.0f - Hlsl.Max(p.X, p.Y); } - // Standard function-based bump mapping function, with an edge value included for good measure private float3 DoBumpMap(in float2 p, in float3 n, float bumpfactor, ref float edge) { @@ -123,7 +122,6 @@ internal readonly partial struct PyramidPattern : IComputeShader return Hlsl.Normalize(n + grad * bumpfactor); } - // A hatch-like algorithm, or a stipple... or some kind of textured pattern private float DoHatch(float2 p, float res) { diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs index 8821b980..ed6dd8bf 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs @@ -64,7 +64,6 @@ internal readonly partial struct TriangleGridContouring : IComputeShader return Hlsl.Lerp(Hlsl.Lerp(v.X, v.Y, p.X), Hlsl.Lerp(v.Z, v.W, p.X), p.Y); } - // The isofunction. Just a Hlsl.Single noise function, but it can be more elaborate. private float IsoFunction(in float2 p) {