diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs index 5ffc98bd..6f69b9a8 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs @@ -165,7 +165,7 @@ internal readonly partial struct ContouredLayers : IPixelShader float4 c = MapLayer(new float3(uv, 1.0f), fi); float4 cSh = MapLayer(new float3(uv - (new float2(0.03f, -0.03f) * (((flNum - fi) / flNum * 0.5f) + 0.5f)), 1.0f), fi); - float sh = (fi + 1.0f) / (flNum); + float sh = (fi + 1.0f) / flNum; float3 lCol = GetColor(uv, sh, fi + 1.0f); float3 ld = Hlsl.Normalize(new float3(-1, 1, -0.25f)); float3 n = Hlsl.Normalize(new float3(0.0f, 0.0f, -1.0f) + c.YZW); @@ -181,8 +181,8 @@ internal readonly partial struct ContouredLayers : IPixelShader col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfLSh, Hlsl.Max(cSh.X, pL))) * shF); col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfL * 3.0f, c.X)) * 0.25f); col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X)) * 0.85f); - col = Hlsl.Lerp(col, eCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.003f)))); - col = Hlsl.Lerp(col, lCol * hatch, (1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.006f)))); + col = Hlsl.Lerp(col, eCol * hatch, 1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.003f))); + col = Hlsl.Lerp(col, lCol * hatch, 1.0f - Hlsl.SmoothStep(0.0f, sfL, c.X + (Hlsl.Length(c.YZX) * 0.006f))); pL = c.X; } diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs index 311fe47e..03a1f168 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs @@ -55,8 +55,8 @@ internal readonly partial struct MengerJourney : IPixelShader float diffuse2 = Hlsl.Max(0.0f, Hlsl.Dot(-normal, lightDir2)); return - ((diffuse * Diffuse) * (LightColor * color)) + - ((diffuse2 * Diffuse) * (LightColor2 * color)); + (diffuse * Diffuse * (LightColor * color)) + + (diffuse2 * Diffuse * (LightColor2 * color)); } /// diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs index 246cb97f..6be31f8f 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs @@ -84,7 +84,7 @@ internal readonly partial struct ProteanClouds : IPixelShader float3 pos = ro + (t * rd); float2 mpv = Map(pos, prm1, bsMo); float den = Hlsl.Clamp(mpv.X - 0.3f, 0.0f, 1.0f) * 1.12f; - float dn = Hlsl.Clamp((mpv.X + 2.0f), 0.0f, 3.0f); + float dn = Hlsl.Clamp(mpv.X + 2.0f, 0.0f, 3.0f); float4 col = 0f; if (mpv.X > 0.6f) diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs index 59b1a349..ce8609b7 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs @@ -84,7 +84,7 @@ internal readonly partial struct PyramidPattern : IPixelShader p -= ip + 0.5f; - float ang = (-3.14159f * 3.0f / 5.0f) + ((FBM((ip / 8.0f) + (time / 3.0f))) * 6.2831f * 2.0f); + float ang = (-3.14159f * 3.0f / 5.0f) + (FBM((ip / 8.0f) + (time / 3.0f)) * 6.2831f * 2.0f); float2 offs = new float2(Hlsl.Cos(ang), Hlsl.Sin(ang)) * 0.35f; @@ -121,7 +121,7 @@ internal readonly partial struct PyramidPattern : IPixelShader float fx2 = BMap(p + e.XY); float fy2 = BMap(p + e.YX); - float3 grad = (new float3(fx - fx2, fy - fx2, 0)) / e.X / 2.0f; + float3 grad = new float3(fx - fx2, fy - fx2, 0) / e.X / 2.0f; edge = Hlsl.Length(new float2(fx, fy) + new float2(fx2, fy2) - (f * 2.0f)); edge = Hlsl.SmoothStep(0.0f, 1.0f, edge / e.X); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs index 5c409ddc..02dd4a8d 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs @@ -205,7 +205,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader d = 0; } - d3 = Hlsl.Min(d3, DistLine((p - p0), (p - p1))); + d3 = Hlsl.Min(d3, DistLine(p - p0, p - p1)); d4 = Hlsl.Min(d4, Hlsl.Min(Hlsl.Length(p - p0), Hlsl.Length(p - p1))); float tri = Hlsl.Min(Hlsl.Min(DistLine(p - ip0, p - ip1), DistLine(p - ip1, p - ip2)), DistLine(p - ip2, p - ip0)); @@ -229,7 +229,7 @@ internal readonly partial struct TriangleGridContouring : IPixelShader } d2 = Hlsl.Max(d2, -d); - d3 = Hlsl.Min(d3, DistLine((p - p0), (p - p1))); + d3 = Hlsl.Min(d3, DistLine(p - p0, p - p1)); d4 = Hlsl.Min(d4, Hlsl.Min(Hlsl.Length(p - p0), Hlsl.Length(p - p1))); d4 -= 0.075f; d3 -= 0.0125f; @@ -249,12 +249,12 @@ internal readonly partial struct TriangleGridContouring : IPixelShader if (d > 0.0f) { - col = Hlsl.Lerp(col, new float3(1, 1.85f, 3) * 0.3f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d2 - 0.012f))); + col = Hlsl.Lerp(col, new float3(1, 1.85f, 3) * 0.3f, 1.0f - Hlsl.SmoothStep(0.0f, sf, d2 - 0.012f)); } - col = Hlsl.Lerp(col, new float3(1.1f, 0.85f, 0.6f), (1.0f - Hlsl.SmoothStep(0.0f, sf, d2))); - col = Hlsl.Lerp(col, new float3(1.5f, 0.9f, 0.6f) * 0.6f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d - 0.012f))); - col = Hlsl.Lerp(col, new float3(1, 0.8f, 0.6f) * new float3(0.7f, 1.0f, 0.75f) * 0.95f, (1.0f - Hlsl.SmoothStep(0.0f, sf, d))); + col = Hlsl.Lerp(col, new float3(1.1f, 0.85f, 0.6f), 1.0f - Hlsl.SmoothStep(0.0f, sf, d2)); + col = Hlsl.Lerp(col, new float3(1.5f, 0.9f, 0.6f) * 0.6f, 1.0f - Hlsl.SmoothStep(0.0f, sf, d - 0.012f)); + col = Hlsl.Lerp(col, new float3(1, 0.8f, 0.6f) * new float3(0.7f, 1.0f, 0.75f) * 0.95f, 1.0f - Hlsl.SmoothStep(0.0f, sf, d)); if (d2 > 0.0f) { @@ -269,9 +269,9 @@ internal readonly partial struct TriangleGridContouring : IPixelShader col *= (pat * 0.425f) + 0.75f; col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d5)) * 0.95f); - col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d3))); - col = Hlsl.Lerp(col, float3.Zero, (1.0f - Hlsl.SmoothStep(0.0f, sf, d4))); - col = Hlsl.Lerp(col, float3.One, (1.0f - Hlsl.SmoothStep(0.0f, sf, d4 + 0.005f))); + col = Hlsl.Lerp(col, float3.Zero, 1.0f - Hlsl.SmoothStep(0.0f, sf, d3)); + col = Hlsl.Lerp(col, float3.Zero, 1.0f - Hlsl.SmoothStep(0.0f, sf, d4)); + col = Hlsl.Lerp(col, float3.One, 1.0f - Hlsl.SmoothStep(0.0f, sf, d4 + 0.005f)); float2 q = oP * 1.5f; diff --git a/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs b/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs index 67e0cd58..df2d17c8 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs @@ -46,7 +46,7 @@ public sealed partial class App : Application // For good measure, also start a timer of one second. If the app is still alive by then (ie. if the timer callback is // executed at all), then just force the whole process to terminate, and exit with the E_APPLICATION_EXITING error code. - this.shutdownTimer = new Timer(_ => Environment.Exit(unchecked((int)(0x8000001A))), this, 1000, Timeout.Infinite); + this.shutdownTimer = new Timer(_ => Environment.Exit(unchecked((int)0x8000001A)), this, 1000, Timeout.Infinite); }; this.mainWindow.Activate(); diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index 266a41c2..2268a700 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -214,7 +214,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// public override SyntaxNode VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) { - LocalDeclarationStatementSyntax updatedNode = ((LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!); + LocalDeclarationStatementSyntax updatedNode = (LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!; if (SemanticModel.For(node).GetOperation(node) is IOperation { Kind: OperationKind.UsingDeclaration }) { diff --git a/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidComputeContextCopyAnalyzer.cs b/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidComputeContextCopyAnalyzer.cs index c166ede2..392f8d74 100644 --- a/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidComputeContextCopyAnalyzer.cs +++ b/src/ComputeSharp.SourceGenerators/Diagnostics/Analyzers/InvalidComputeContextCopyAnalyzer.cs @@ -63,7 +63,7 @@ public sealed class InvalidComputeContextCopyAnalyzer : DiagnosticAnalyzer { // In the absence of data flow analysis we can treat // return of a local variable or a parameter as a "move" - if (operation.ReturnedValue.Kind is (OperationKind.LocalReference or OperationKind.ParameterReference) && + if (operation.ReturnedValue.Kind is OperationKind.LocalReference or OperationKind.ParameterReference && operation.Kind == OperationKind.Return) { ISymbol? varScope = operation.ReturnedValue.Kind switch @@ -355,7 +355,7 @@ public sealed class InvalidComputeContextCopyAnalyzer : DiagnosticAnalyzer } return - kind is (OperationKind.ObjectCreation or OperationKind.DefaultValue or OperationKind.Literal or OperationKind.Invocation) || - (kind is (OperationKind.None or OperationKind.Invalid) && operation.Syntax is InvocationExpressionSyntax); // Workaround for https://github.com/dotnet/roslyn/issues/49751 + kind is OperationKind.ObjectCreation or OperationKind.DefaultValue or OperationKind.Literal or OperationKind.Invocation || + (kind is OperationKind.None or OperationKind.Invalid && operation.Syntax is InvocationExpressionSyntax); // Workaround for https://github.com/dotnet/roslyn/issues/49751 } } \ No newline at end of file diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs index 0266d4be..f29b22d4 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs @@ -396,8 +396,8 @@ internal sealed unsafe partial class SwapChainManager : NativeObject // Apply the necessary scale transform DXGI_MATRIX_3X2_F transformMatrix = default; - transformMatrix._11 = (1 / this.compositionScaleX) * (1 / targetResolutionScale); - transformMatrix._22 = (1 / this.compositionScaleY) * (1 / targetResolutionScale); + transformMatrix._11 = 1 / this.compositionScaleX * (1 / targetResolutionScale); + transformMatrix._22 = 1 / this.compositionScaleY * (1 / targetResolutionScale); this.dxgiSwapChain3.Get()->SetMatrixTransform(&transformMatrix).Assert(); diff --git a/src/ComputeSharp/Graphics/Interop/NativeObject.ReferenceTracking.cs b/src/ComputeSharp/Graphics/Interop/NativeObject.ReferenceTracking.cs index c4f7b450..5bd358fa 100644 --- a/src/ComputeSharp/Graphics/Interop/NativeObject.ReferenceTracking.cs +++ b/src/ComputeSharp/Graphics/Interop/NativeObject.ReferenceTracking.cs @@ -217,10 +217,7 @@ partial class NativeObject this.nativeObject = null; - if (nativeObject is not null) - { - nativeObject.ReturnReferenceTrackingLease(); - } + nativeObject?.ReturnReferenceTrackingLease(); } } } \ No newline at end of file diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs index c7bf4b0c..0a875935 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs @@ -794,7 +794,7 @@ public partial class D2D1ResourceTextureManagerTests for (int y = 0; y < updateLengthY; y++) { ReadOnlySpan source = data.AsSpan((z * updateLengthX * updateLengthY) + (y * updateLengthX), updateLengthX); - Span destination = texture.AsSpan(((startOffsetZ + z) * (width * height)) + ((startOffsetY + y) * width) + startOffsetX, updateLengthX); + Span destination = texture.AsSpan(((startOffsetZ + z) * width * height) + ((startOffsetY + y) * width) + startOffsetX, updateLengthX); source.CopyTo(destination); } diff --git a/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs b/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs index 4523e099..ca93425b 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs @@ -19,13 +19,13 @@ namespace TerraFX.Interop.DirectX [MethodImpl(MethodImplOptions.AggressiveInlining)] public uint Release() { - return ((delegate* unmanaged[Stdcall])(lpVtbl[2]))((ID3D12Device5*)Unsafe.AsPointer(ref this)); + return ((delegate* unmanaged[Stdcall])lpVtbl[2])((ID3D12Device5*)Unsafe.AsPointer(ref this)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void RemoveDevice() { - ((delegate* unmanaged[Stdcall])(lpVtbl[58]))((ID3D12Device5*)Unsafe.AsPointer(ref this)); + ((delegate* unmanaged[Stdcall])lpVtbl[58])((ID3D12Device5*)Unsafe.AsPointer(ref this)); } } } diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index 7410ca3a..0820dfd8 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -11,6 +11,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using SixLabors.ImageSharp; using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32; +#pragma warning disable IDE0047 + namespace ComputeSharp.Tests; [TestClass] diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs index 5d81c7cf..c6c642c9 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs @@ -1,4 +1,4 @@ -#pragma warning disable IDE0048, IDE0011 +#pragma warning disable IDE0048, IDE0011, IDE0047 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs b/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs index 522cf90b..0212a685 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs @@ -1,4 +1,4 @@ -#pragma warning disable IDE0048, IDE0011 +#pragma warning disable IDE0048, IDE0011, IDE0047 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs index bd1503bb..741cce84 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs @@ -1,4 +1,4 @@ -#pragma warning disable IDE0048, IDE0011 +#pragma warning disable IDE0048, IDE0011, IDE0047 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs b/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs index 8e36f013..75f81a8d 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs @@ -1,4 +1,4 @@ -#pragma warning disable IDE0048, IDE0011 +#pragma warning disable IDE0048, IDE0011, IDE0047 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs index ddf3ed25..8821b980 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs @@ -1,4 +1,4 @@ -#pragma warning disable IDE0048, IDE0011 +#pragma warning disable IDE0048, IDE0011, IDE0047 namespace ComputeSharp.SwapChain.Shaders.Compute;