diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs index 2dbc441f..5ffc98bd 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ContouredLayers.cs @@ -131,7 +131,10 @@ internal readonly partial struct ContouredLayers : IPixelShader float hatch = Hlsl.Clamp((Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f) + 0.5f, 0.0f, 1.0f); float hRnd = Hash21(Hlsl.Floor(p * 6.0f) + 0.73f); - if (hRnd > 0.66f) hatch = hRnd; + if (hRnd > 0.66f) + { + hatch = hRnd; + } hatch = (hatch * 0.75f) + 0.5f; diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs index b10a58d4..1417c2d1 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ExtrudedTruchetPattern.cs @@ -48,7 +48,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader { return Hlsl.Length(p); } - else p = Hlsl.Abs(p); + else + { + p = Hlsl.Abs(p); + } switch (SHAPE) { @@ -77,7 +80,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader float rnd = Hlsl.Frac(Hlsl.Sin(Hlsl.Dot(ip, new float2(1, 113))) * 45758.5453f); - if (rnd < 0.5f) p.Y = -p.Y; + if (rnd < 0.5f) + { + p.Y = -p.Y; + } float d = Hlsl.Min(Distance(p - (0.5f * sc)), Distance(p + (0.5f * sc))) - (0.5f * sc); @@ -86,8 +92,15 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader d += (0.5f - (0.5f / Hlsl.Sqrt(2.0f))) * sc; } - if (rnd < 0.5f) d = -d; - if (Mod(ip.X + ip.Y, 2.0f) < 0.5f) d = -d; + if (rnd < 0.5f) + { + d = -d; + } + + if (Mod(ip.X + ip.Y, 2.0f) < 0.5f) + { + d = -d; + } return d - 0.03f; } @@ -141,7 +154,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader shade = Hlsl.Min(shade, k * d / t); t += Hlsl.Clamp(d, 0.01f, 0.25f); - if (d < 0.0f || t > end) break; + if (d < 0.0f || t > end) + { + break; + } } return Hlsl.Max(shade, 0.0f); @@ -163,7 +179,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader occ += (hr - d) * sca; sca *= 0.7f; - if (sca > 1e5f) break; + if (sca > 1e5f) + { + break; + } } return Hlsl.Clamp(1.0f - occ, 0.0f, 1.0f); @@ -201,7 +220,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader { d = M(o + (r * t)); - if (Hlsl.Abs(d) < 0.001f) break; + if (Hlsl.Abs(d) < 0.001f) + { + break; + } t += d * 0.7f; glow += 0.2f / (1.0f + (Hlsl.Abs(d) * 5.0f)); @@ -244,7 +266,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader oCol = Hlsl.Lerp(col2, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, pat2)) * 0.35f); oCol = Hlsl.Lerp(oCol, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, bord)) * 0.8f); - if (Mod(iuv.X + iuv.Y, 2.0f) > 0.5f) oCol *= 0.8f; + if (Mod(iuv.X + iuv.Y, 2.0f) > 0.5f) + { + oCol *= 0.8f; + } oCol = Hlsl.Lerp(oCol, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, d - 0.015f)) * 0.8f); } @@ -254,7 +279,10 @@ internal readonly partial struct ExtrudedTruchetPattern : IPixelShader float4 fCol = Hlsl.Lerp(col1, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, pat)) * 0.35f); fCol = Hlsl.Lerp(fCol, 0, (1.0f - Hlsl.SmoothStep(0, 0.01f, bord)) * 0.8f); - if (Mod(iuv.X + iuv.Y, 2.0f) < 0.5f) fCol *= 0.8f; + if (Mod(iuv.X + iuv.Y, 2.0f) < 0.5f) + { + fCol *= 0.8f; + } oCol = Hlsl.Lerp(oCol, fCol, 1 - Hlsl.SmoothStep(0, 0.01f, d + 0.08f)); oCol = Hlsl.Lerp(oCol, 0, (1 - Hlsl.SmoothStep(0, 0.01f, Hlsl.Length(uv2) - 0.08f)) * 0.8f); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs index aa4d6c66..311fe47e 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/MengerJourney.cs @@ -134,7 +134,10 @@ internal readonly partial struct MengerJourney : IPixelShader distance = DE(pos) * FudgeFactor; totalDistance += distance; - if (distance < MinimumDistance) break; + if (distance < MinimumDistance) + { + break; + } steps = i; } diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs index ab438f68..246cb97f 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/ProteanClouds.cs @@ -76,7 +76,10 @@ internal readonly partial struct ProteanClouds : IPixelShader for (int i = 0; i < 130; i++) { - if (rez.A > 0.99f) break; + if (rez.A > 0.99f) + { + break; + } float3 pos = ro + (t * rd); float2 mpv = Map(pos, prm1, bsMo); diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs index 29b55cd3..59b1a349 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/PyramidPattern.cs @@ -88,11 +88,23 @@ internal readonly partial struct PyramidPattern : IPixelShader float2 offs = new float2(Hlsl.Cos(ang), Hlsl.Sin(ang)) * 0.35f; - if (p.X < offs.X) p.X = 1.0f - ((p.X + 0.5f) / Hlsl.Abs(offs.X + 0.5f)); - else p.X = (p.X - offs.X) / (0.5f - offs.X); + if (p.X < offs.X) + { + p.X = 1.0f - ((p.X + 0.5f) / Hlsl.Abs(offs.X + 0.5f)); + } + else + { + p.X = (p.X - offs.X) / (0.5f - offs.X); + } - if (p.Y < offs.Y) p.Y = 1.0f - ((p.Y + 0.5f) / Hlsl.Abs(offs.Y + 0.5f)); - else p.Y = (p.Y - offs.Y) / (0.5f - offs.Y); + if (p.Y < offs.Y) + { + p.Y = 1.0f - ((p.Y + 0.5f) / Hlsl.Abs(offs.Y + 0.5f)); + } + else + { + p.Y = (p.Y - offs.Y) / (0.5f - offs.Y); + } return 1.0f - Hlsl.Max(p.X, p.Y); } @@ -128,7 +140,10 @@ internal readonly partial struct PyramidPattern : IPixelShader float hatch = Hlsl.Clamp((Hlsl.Sin((p.X - p.Y) * 3.14159f * 200.0f) * 2.0f) + 0.5f, 0.0f, 1.0f); float hRnd = Hash21(Hlsl.Floor(p * 6.0f) + 0.73f); - if (hRnd > 0.66f) hatch = hRnd; + if (hRnd > 0.66f) + { + hatch = hRnd; + } return hatch; } diff --git a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs index bc14ad4e..5c409ddc 100644 --- a/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs +++ b/samples/ComputeSharp.SwapChain.Shaders.Shared/TriangleGridContouring.cs @@ -104,9 +104,20 @@ internal readonly partial struct TriangleGridContouring : IPixelShader int iTh = 0; - if (n3.X > isovalue) iTh += 4; - if (n3.Y > isovalue) iTh += 2; - if (n3.Z > isovalue) iTh += 1; + if (n3.X > isovalue) + { + iTh += 4; + } + + if (n3.Y > isovalue) + { + iTh += 2; + } + + if (n3.Z > isovalue) + { + iTh += 1; + } if (iTh == 1 || iTh == 6) { @@ -207,8 +218,15 @@ internal readonly partial struct TriangleGridContouring : IPixelShader d2 = Hlsl.Min(d2, DistEdge(p - p0, p - p1)); - if (iTh2 == 7) d2 = 0.0f; - if (iTh == 7) d2 = 1e5f; + if (iTh2 == 7) + { + d2 = 0.0f; + } + + if (iTh == 7) + { + d2 = 1e5f; + } d2 = Hlsl.Max(d2, -d); d3 = Hlsl.Min(d3, DistLine((p - p0), (p - p1))); @@ -224,15 +242,28 @@ internal readonly partial struct TriangleGridContouring : IPixelShader float3 col = new(1, 0.85f, 0.6f); float sf = 0.004f; - if (d > 0.0f && d2 > 0.0f) col = new float3(1, 1.8f, 3) * 0.45f; - 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))); + if (d > 0.0f && d2 > 0.0f) + { + col = new float3(1, 1.8f, 3) * 0.45f; + } + + 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.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) col *= ((Hlsl.Abs(Hlsl.Dot(n3, float3.One)) * 1.25f) + 1.25f) / 2.0f; - else col *= Hlsl.Max(2.0f - ((Hlsl.Dot(n3, float3.One) + 1.45f) / 1.25f), 0.0f); + if (d2 > 0.0f) + { + col *= ((Hlsl.Abs(Hlsl.Dot(n3, float3.One)) * 1.25f) + 1.25f) / 2.0f; + } + else + { + col *= Hlsl.Max(2.0f - ((Hlsl.Dot(n3, float3.One) + 1.45f) / 1.25f), 0.0f); + } float pat = Hlsl.Abs(Hlsl.Frac((tri * 12.5f) + 0.4f) - 0.5f) * 2.0f; diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs index a76be1a8..8b57b371 100644 --- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs +++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs @@ -259,29 +259,61 @@ internal static unsafe class Win32ApplicationRunner if (isAtTop) { - if (isAtRight) return Windows.HTTOPRIGHT; - if (isAtLeft) return Windows.HTTOPLEFT; + if (isAtRight) + { + return Windows.HTTOPRIGHT; + } + + if (isAtLeft) + { + return Windows.HTTOPLEFT; + } + return Windows.HTTOP; } if (isAtRight) { - if (isAtTop) return Windows.HTTOPRIGHT; - if (isAtBottom) return Windows.HTBOTTOMRIGHT; + if (isAtTop) + { + return Windows.HTTOPRIGHT; + } + + if (isAtBottom) + { + return Windows.HTBOTTOMRIGHT; + } + return Windows.HTRIGHT; } if (isAtBottom) { - if (isAtRight) return Windows.HTBOTTOMRIGHT; - if (isAtLeft) return Windows.HTBOTTOMLEFT; + if (isAtRight) + { + return Windows.HTBOTTOMRIGHT; + } + + if (isAtLeft) + { + return Windows.HTBOTTOMLEFT; + } + return Windows.HTBOTTOM; } if (isAtLeft) { - if (isAtTop) return Windows.HTTOPLEFT; - if (isAtBottom) return Windows.HTBOTTOMLEFT; + if (isAtTop) + { + return Windows.HTTOPLEFT; + } + + if (isAtBottom) + { + return Windows.HTBOTTOMLEFT; + } + return Windows.HTLEFT; } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs index b0c2afe9..8faf1d54 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -400,7 +400,10 @@ partial class ID2D1ShaderGenerator // Declare the fields of the current type foreach (IFieldSymbol field in type.GetMembers().OfType()) { - if (field.IsStatic) continue; + if (field.IsStatic) + { + continue; + } INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type; diff --git a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs index 8cc7bc12..7ec3bb05 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.LibraryLoading.cs @@ -22,7 +22,10 @@ unsafe partial class ShaderCompiler // This happens when doing eg. "dotnet bin\Debug\net5.0\MyApp.dll", which would crash at runtime. Windows.ResolveLibrary += static (libraryName, assembly, searchPath) => { - if (libraryName is not "dxcompiler") return IntPtr.Zero; + if (libraryName is not "dxcompiler") + { + return IntPtr.Zero; + } string rid = RuntimeInformation.ProcessArchitecture switch { diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs index 18f10dfa..58e6c35d 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs @@ -227,7 +227,10 @@ internal static partial class HlslKnownTypes return; } - if (KnownHlslTypes.ContainsKey(type.GetFullMetadataName())) return; + if (KnownHlslTypes.ContainsKey(type.GetFullMetadataName())) + { + return; + } // Check if the type is unsupported if (!type.IsUnmanagedType || @@ -241,11 +244,17 @@ internal static partial class HlslKnownTypes return; } - if (!customTypes.Add(type)) return; + if (!customTypes.Add(type)) + { + return; + } foreach (IFieldSymbol field in type.GetMembers().OfType()) { - if (field.IsStatic) continue; + if (field.IsStatic) + { + continue; + } ExploreTypes((INamedTypeSymbol)field.Type, customTypes, invalidTypes); } @@ -298,7 +307,10 @@ internal static partial class HlslKnownTypes // Only add other custom types as dependencies, and ignore HLSL types foreach (IFieldSymbol field in type.GetMembers().OfType()) { - if (field.IsStatic) continue; + if (field.IsStatic) + { + continue; + } INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type; @@ -327,7 +339,10 @@ internal static partial class HlslKnownTypes yield return entry.Type; } - else queue.Enqueue(entry); + else + { + queue.Enqueue(entry); + } } } } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index aecab263..d17e02e8 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -466,7 +466,10 @@ partial class IShaderGenerator // Declare the fields of the current type foreach (IFieldSymbol field in type.GetMembers().OfType()) { - if (field.IsStatic) continue; + if (field.IsStatic) + { + continue; + } INamedTypeSymbol fieldType = (INamedTypeSymbol)field.Type; diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs index ffb0235e..5456019b 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownTypes.cs @@ -136,7 +136,10 @@ partial class HlslKnownTypes { // Delegate types just return an empty string, as they're not actually // used in the generated shaders, but just mapped to a function at runtime. - if (typeSymbol.TypeKind == TypeKind.Delegate) return ""; + if (typeSymbol.TypeKind == TypeKind.Delegate) + { + return ""; + } string typeName = typeSymbol.GetFullMetadataName(); diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index ca7ba361..50a7c8aa 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -55,9 +55,18 @@ partial class ShaderSourceRewriter { string typeName = operation.Member.ContainingType.GetFullMetadataName(); - if (mappedName == $"__{nameof(GroupIds)}__get_Index") IsGroupIdsIndexUsed = true; - else if (typeName == typeof(GroupIds).FullName) IsGroupIdsUsed = true; - else if (typeName == typeof(GridIds).FullName) IsGridIdsUsed = true; + if (mappedName == $"__{nameof(GroupIds)}__get_Index") + { + IsGroupIdsIndexUsed = true; + } + else if (typeName == typeof(GroupIds).FullName) + { + IsGroupIdsUsed = true; + } + else if (typeName == typeof(GridIds).FullName) + { + IsGridIdsUsed = true; + } // Check that the dispatch info types are only used from the main shader body if (!this.isEntryPoint || this.localFunctionDepth > 0) diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs index 4be41123..0266d4be 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs @@ -240,6 +240,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject // Extract the ISwapChainPanelNative reference from the current panel, then query the // IDXGISwapChain reference just created and set that as the swap chain panel to use. fixed (ISwapChainPanelNative** swapChainPanelNative = this.swapChainPanelNative) + { using (ComPtr swapChainPanel = default) { #if WINDOWS_UWP @@ -254,6 +255,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject (void**)swapChainPanelNative).Assert(); #endif } + } // Get the underlying ID3D12Device in use fixed (ID3D12Device** d3D12Device = this.d3D12Device) diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs index fed46ff2..d48e7502 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Enumerator.cs @@ -111,7 +111,10 @@ partial class DeviceHelper } } - if (this.isCompleted) return false; + if (this.isCompleted) + { + return false; + } while (true) { diff --git a/src/ComputeSharp/Graphics/Helpers/TypeInfo{T}.cs b/src/ComputeSharp/Graphics/Helpers/TypeInfo{T}.cs index 4c86b466..77cc2a0a 100644 --- a/src/ComputeSharp/Graphics/Helpers/TypeInfo{T}.cs +++ b/src/ComputeSharp/Graphics/Helpers/TypeInfo{T}.cs @@ -25,9 +25,15 @@ internal static class TypeInfo [RequiresUnreferencedCode("This method reads type info of all fields of the input type (recursively).")] private static bool ChecksIsDoubleOrContainsDoubles(Type type) { - if (type == typeof(double)) return true; + if (type == typeof(double)) + { + return true; + } - if (type.IsPrimitive) return false; + if (type.IsPrimitive) + { + return false; + } foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs index 195b607d..d108ae07 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs @@ -139,7 +139,10 @@ public abstract class StructuredBuffer : Buffer copyCommandList.ExecuteAndWaitForCompletion(); } - else CopyToWithCpuBuffer(destination, sourceOffset, destinationOffset, count); + else + { + CopyToWithCpuBuffer(destination, sourceOffset, destinationOffset, count); + } } /// diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs index c6ec45ea..10e4263b 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs @@ -389,6 +389,7 @@ public abstract unsafe class Texture1D : NativeObject, IGraphicsResource, Gra #endif using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map()) + { fixed (void* sourcePointer = &source) { Buffer.MemoryCopy( @@ -397,6 +398,7 @@ public abstract unsafe class Texture1D : NativeObject, IGraphicsResource, Gra destinationSizeInBytes: rowSizeInBytes, sourceBytesToCopy: rowSizeInBytes); } + } using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs index 5b071189..d4889717 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs @@ -430,6 +430,7 @@ public abstract unsafe class Texture2D : NativeObject, IGraphicsResource, Gra #endif using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map()) + { fixed (void* sourcePointer = &source) { MemoryHelper.Copy( @@ -439,6 +440,7 @@ public abstract unsafe class Texture2D : NativeObject, IGraphicsResource, Gra rowSizeInBytes, d3D12PlacedSubresourceFootprintSource.Footprint.RowPitch); } + } using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs index 4f27b0b6..ef70c32f 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs @@ -472,6 +472,7 @@ public abstract unsafe class Texture3D : NativeObject, IGraphicsResource, Gra #endif using (ID3D12ResourceMap resource = d3D12Resource.Get()->Map()) + { fixed (void* sourcePointer = &source) { MemoryHelper.Copy( @@ -483,6 +484,7 @@ public abstract unsafe class Texture3D : NativeObject, IGraphicsResource, Gra d3D12PlacedSubresourceFootprintSource.Footprint.RowPitch, d3D12PlacedSubresourceFootprintSource.Footprint.RowPitch * (uint)height); } + } using CommandList copyCommandList = new(GraphicsDevice, this.d3D12CommandListType); diff --git a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs index ee6d2825..cd5dfed7 100644 --- a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs @@ -115,7 +115,10 @@ public sealed class ConstantBuffer : Buffer destinationElementPitchInBytes: (uint)GetPaddedSize(), count: (uint)length); } - else CopyToWithCpuBuffer(destination, sourceOffset, destinationOffset, length); + else + { + CopyToWithCpuBuffer(destination, sourceOffset, destinationOffset, length); + } } /// diff --git a/tests/ComputeSharp.Tests/InitializationTests.cs b/tests/ComputeSharp.Tests/InitializationTests.cs index 5c96a8af..c0407c13 100644 --- a/tests/ComputeSharp.Tests/InitializationTests.cs +++ b/tests/ComputeSharp.Tests/InitializationTests.cs @@ -35,7 +35,10 @@ public partial class InitializationTests foreach (GraphicsDevice device in GraphicsDevice.EnumerateDevices()) { - if (i++ == 0) Assert.AreSame(GraphicsDevice.GetDefault(), device); + if (i++ == 0) + { + Assert.AreSame(GraphicsDevice.GetDefault(), device); + } using ReadWriteBuffer buffer = device.AllocateReadWriteBuffer(128); @@ -54,7 +57,10 @@ public partial class InitializationTests foreach (GraphicsDevice device in GraphicsDevice.QueryDevices(info => info.DedicatedMemorySize >= 1024)) { - if (i++ == 0) Assert.AreSame(GraphicsDevice.GetDefault(), device); + if (i++ == 0) + { + Assert.AreSame(GraphicsDevice.GetDefault(), device); + } using ReadWriteBuffer buffer = device.AllocateReadWriteBuffer(128); diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ContouredLayers.cs index fc6deea6..5d81c7cf 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 +#pragma warning disable IDE0048, IDE0011 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs index e29ea08f..d2a9d18f 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/ExtrudedTruchetPattern.cs @@ -1,4 +1,4 @@ -#pragma warning disable IDE0048 +#pragma warning disable IDE0048, IDE0011 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs b/tests/ComputeSharp.Tests/Shaders/Compute/MengerJourney.cs index f62634a5..522cf90b 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 +#pragma warning disable IDE0048, IDE0011 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs b/tests/ComputeSharp.Tests/Shaders/Compute/ProteanClouds.cs index 44c3f447..bd1503bb 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 +#pragma warning disable IDE0048, IDE0011 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs b/tests/ComputeSharp.Tests/Shaders/Compute/PyramidPattern.cs index 02bbaf47..8e36f013 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 +#pragma warning disable IDE0048, IDE0011 namespace ComputeSharp.SwapChain.Shaders.Compute; diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs index b1af7575..ddf3ed25 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 +#pragma warning disable IDE0048, IDE0011 namespace ComputeSharp.SwapChain.Shaders.Compute;