From 5c4479a0e17ba10011f4ff6e572418e95772f609 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 15 Oct 2022 17:47:48 +0200 Subject: [PATCH] Resolve remaining build warnings --- .../HlslBokehBlurProcessor{TPixel}.cs | 24 +++++++-------- .../ComputeSharp.SwapChain.Uwp.csproj | 1 + .../ComputeSharp.SwapChain.WinUI/App.xaml.cs | 2 +- .../ComputeSharp.SwapChain.WinUI.csproj | 3 +- .../Backend/Win32ApplicationRunner.cs | 2 +- .../Buffers/ArrayPoolBinaryWriter{T}.cs | 2 +- .../Shaders/Interop/Helpers/Point64.cs | 6 ++-- .../Helpers/SwapChainManager.cs | 15 +++++----- .../D2D1EffectRegistrationDataTests.cs | 4 +-- .../D2D1PixelShaderEffectTests.cs | 2 +- .../D2D1PixelShaderTests.cs | 2 ++ .../D2D1ResourceTextureManagerTests.cs | 6 ++-- .../Effects/BokehBlurEffect.cs | 18 +++++++----- .../Extensions/HRESULTExtensions.cs | 2 ++ .../Helpers/D2D1Helper.cs | 20 +++++++------ .../Helpers/D2D1TestRunner.cs | 4 ++- .../Extensions/DeviceExtensions.cs | 1 - .../GetDefaultDeviceTests.cs | 2 +- .../TerraFX.Interop.Windows/ID3D12Device5.cs | 29 +++++++++---------- .../ShaderCompilerTests.cs | 2 +- .../Extensions/DeviceExtensions.cs | 1 - .../ComputeSharp.Tests/ShaderCompilerTests.cs | 2 +- .../Shaders/Compute/TriangleGridContouring.cs | 2 -- .../Texture1DTests.Pixels.cs | 19 ++++++------ .../Texture2DTests.Pixels.cs | 19 ++++++------ .../Texture3DTests.Pixels.cs | 19 ++++++------ 26 files changed, 106 insertions(+), 103 deletions(-) diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index 69027eaf..cb4a3949 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -314,12 +314,12 @@ public sealed partial class HlslBokehBlurProcessor /// Kernel for the vertical convolution pass. /// [AutoConstructor] - internal partial struct VerticalConvolutionProcessor : IComputeShader + internal readonly partial struct VerticalConvolutionProcessor : IComputeShader { - private IReadWriteNormalizedTexture2D source; - private ReadWriteTexture2D reals; - private ReadWriteTexture2D imaginaries; - private ReadOnlyBuffer kernel; + private readonly IReadWriteNormalizedTexture2D source; + private readonly ReadWriteTexture2D reals; + private readonly ReadWriteTexture2D imaginaries; + private readonly ReadOnlyBuffer kernel; /// public void Execute() @@ -351,15 +351,15 @@ public sealed partial class HlslBokehBlurProcessor /// Kernel for the horizontal convolution pass. /// [AutoConstructor] - internal partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader + internal readonly partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader { - private float z; - private float w; + private readonly float z; + private readonly float w; - private ReadWriteTexture2D reals; - private ReadWriteTexture2D imaginaries; - private ReadWriteTexture2D target; - private ReadOnlyBuffer kernel; + private readonly ReadWriteTexture2D reals; + private readonly ReadWriteTexture2D imaginaries; + private readonly ReadWriteTexture2D target; + private readonly ReadOnlyBuffer kernel; /// public void Execute() diff --git a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj index d1cedf87..0c24c4cd 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj +++ b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj @@ -19,6 +19,7 @@ true false x64;ARM64 + $(NoWarn);IDE0240 true diff --git a/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs b/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs index df2d17c8..c4a547d4 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/App.xaml.cs @@ -3,7 +3,7 @@ using System.Threading; using ComputeSharp.SwapChain.WinUI.Views; using Microsoft.UI.Xaml; -#pragma warning disable CA1001 +#pragma warning disable CA1001, IDE0052 namespace ComputeSharp.SwapChain.WinUI; diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index b1a2f94d..c93fd788 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -1,4 +1,4 @@ - + WinExe net6.0-windows10.0.19041.0 @@ -11,6 +11,7 @@ true true $(DefineConstants);SAMPLE_APP + $(NoWarn);IDE0240 diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs index d86344ad..6856b27f 100644 --- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs +++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationRunner.cs @@ -230,7 +230,7 @@ internal static unsafe class Win32ApplicationRunner // Size update case WM.WM_SIZE: { - if (!isResizing && wParam != (byte)Windows.SIZE_MINIMIZED) + if (!isResizing && wParam != Windows.SIZE_MINIMIZED) { application.OnResize(); } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs index cc76dc2b..3d56598d 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Buffers/ArrayPoolBinaryWriter{T}.cs @@ -35,7 +35,7 @@ internal ref struct ArrayPoolBufferWriter /// /// The starting offset within . /// - private int index; + private readonly int index; /// /// Initializes a new instance of the class. diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs index f2aa05f4..53352867 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/Point64.cs @@ -8,17 +8,17 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Helpers; /// /// A 64-bit version of the type. /// -internal struct Point64 +internal readonly struct Point64 { /// /// The left coordinate of the current point. /// - private long x; + private readonly long x; /// /// The top coordinate of the current point. /// - private long y; + private readonly long y; /// /// Creates a new instance with the specified parameters. diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs index 5e9e2b08..dacf5b5f 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs @@ -110,7 +110,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject /// /// The awaitable object for calls. /// - private HANDLE frameLatencyWaitableObject; + private readonly HANDLE frameLatencyWaitableObject; /// /// The first buffer within . @@ -241,20 +241,19 @@ internal sealed unsafe partial class SwapChainManager : NativeObject // IDXGISwapChain reference just created and set that as the swap chain panel to use. fixed (ISwapChainPanelNative** swapChainPanelNative = this.swapChainPanelNative) { - using (ComPtr swapChainPanel = default) - { + using ComPtr swapChainPanel = default; + #if WINDOWS_UWP swapChainPanel.Attach((IUnknown*)Marshal.GetIUnknownForObject(owner)); swapChainPanel.CopyTo(swapChainPanelNative).Assert(); #else - swapChainPanel.Attach((IUnknown*)((IWinRTObject)owner).NativeObject.GetRef()); + swapChainPanel.Attach((IUnknown*)((IWinRTObject)owner).NativeObject.GetRef()); - swapChainPanel.CopyTo( - (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(new Guid(0x63AAD0B8, 0x7C24, 0x40FF, 0x85, 0xA8, 0x64, 0x0D, 0x94, 0x4C, 0xC3, 0x25))), - (void**)swapChainPanelNative).Assert(); + swapChainPanel.CopyTo( + (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(new Guid(0x63AAD0B8, 0x7C24, 0x40FF, 0x85, 0xA8, 0x64, 0x0D, 0x94, 0x4C, 0xC3, 0x25))), + (void**)swapChainPanelNative).Assert(); #endif - } } // Get the underlying ID3D12Device in use diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1EffectRegistrationDataTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1EffectRegistrationDataTests.cs index 712eab69..31c16d92 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1EffectRegistrationDataTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1EffectRegistrationDataTests.cs @@ -111,9 +111,9 @@ public partial class D2D1EffectRegistrationDataTests [D2DInputCount(2)] [D2DRequiresScenePosition] [AutoConstructor] - private partial struct TestRegistrationBlobShader : ID2D1PixelShader + private readonly partial struct TestRegistrationBlobShader : ID2D1PixelShader { - private float a; + private readonly float a; public float4 Execute() { diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs index d5a05cd0..49e06915 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderEffectTests.cs @@ -8,7 +8,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Win32; using Win32.Graphics.Direct2D; -#pragma warning disable IDE0022 +#pragma warning disable IDE0022, IDE0044 namespace ComputeSharp.D2D1.Tests; diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs index 5c574592..336f47b4 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs @@ -5,6 +5,8 @@ using ComputeSharp.D2D1.Interop; using ComputeSharp.D2D1.Tests.Effects; using Microsoft.VisualStudio.TestTools.UnitTesting; +#pragma warning disable IDE0059, IDE0044 + namespace ComputeSharp.D2D1.Tests; [TestClass] diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs index eeaa1b5b..9f304859 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ResourceTextureManagerTests.cs @@ -13,12 +13,12 @@ using SixLabors.ImageSharp.PixelFormats; using Win32; using Win32.Graphics.Direct2D; -#pragma warning disable CS0649 +#pragma warning disable CS0649, IDE0044, IDE0065 namespace ComputeSharp.D2D1.Tests; -using HRESULT = Win32.HResult; -using D2D1_MAPPED_RECT = Win32.Graphics.Direct2D.MappedRect; +using HRESULT = HResult; +using D2D1_MAPPED_RECT = MappedRect; [TestClass] [TestCategory("D2D1ResourceTextureManager")] diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs index b01879ee..ab224b80 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs @@ -13,17 +13,19 @@ using SixLabors.ImageSharp; using Win32; using Win32.Graphics.Direct2D; +#pragma warning disable IDE0065 + namespace ComputeSharp.BokehBlur.Processors; -using D2D1_BORDER_EDGE_MODE = Win32.Graphics.Direct2D.BorderEdgeMode; -using D2D1_BORDER_PROP = Win32.Graphics.Direct2D.BorderProp; -using D2D1_BUFFER_PRECISION = Win32.Graphics.Direct2D.BufferPrecision; +using D2D1_BORDER_EDGE_MODE = BorderEdgeMode; +using D2D1_BORDER_PROP = BorderProp; +using D2D1_BUFFER_PRECISION = BufferPrecision; using D2D1_COMPOSITE_MODE = Win32.Graphics.Direct2D.Common.CompositeMode; -using D2D1_COMPOSITE_PROP = Win32.Graphics.Direct2D.CompositeProp; -using D2D1_INTERPOLATION_MODE = Win32.Graphics.Direct2D.InterpolationMode; -using D2D1_PROPERTY = Win32.Graphics.Direct2D.Property; -using D2D1_MAPPED_RECT = Win32.Graphics.Direct2D.MappedRect; -using D2D1_RENDERING_CONTROLS = Win32.Graphics.Direct2D.RenderingControls; +using D2D1_COMPOSITE_PROP = CompositeProp; +using D2D1_INTERPOLATION_MODE = InterpolationMode; +using D2D1_PROPERTY = Property; +using D2D1_MAPPED_RECT = MappedRect; +using D2D1_RENDERING_CONTROLS = RenderingControls; using D2D1 = Win32.Graphics.Direct2D.Apis; /// diff --git a/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs b/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs index 392b79e5..273b8957 100644 --- a/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs +++ b/tests/ComputeSharp.D2D1.Tests/Extensions/HRESULTExtensions.cs @@ -5,6 +5,8 @@ using System.Diagnostics.CodeAnalysis; #endif using System.Runtime.CompilerServices; +#pragma warning disable IDE0065 + namespace ComputeSharp.D2D1.Tests.Extensions; using HRESULT = Win32.HResult; diff --git a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs index 199de1ce..e6c764d9 100644 --- a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs +++ b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1Helper.cs @@ -6,23 +6,25 @@ using Win32.Graphics.Direct2D; using Win32.Graphics.Direct3D11; using Win32.Graphics.Dxgi; +#pragma warning disable IDE0065 + namespace ComputeSharp.D2D1.Tests.Helpers; using D2D1_ALPHA_MODE = Win32.Graphics.Direct2D.Common.AlphaMode; -using D2D1_BITMAP_OPTIONS = Win32.Graphics.Direct2D.BitmapOptions; -using D2D1_DEVICE_CONTEXT_OPTIONS = Win32.Graphics.Direct2D.DeviceContextOptions; -using D2D1_FACTORY_OPTIONS = Win32.Graphics.Direct2D.FactoryOptions; -using D2D1_FACTORY_TYPE = Win32.Graphics.Direct2D.FactoryType; -using D2D1_INTERPOLATION_MODE = Win32.Graphics.Direct2D.InterpolationMode; +using D2D1_BITMAP_OPTIONS = BitmapOptions; +using D2D1_DEVICE_CONTEXT_OPTIONS = DeviceContextOptions; +using D2D1_FACTORY_OPTIONS = FactoryOptions; +using D2D1_FACTORY_TYPE = FactoryType; +using D2D1_INTERPOLATION_MODE = InterpolationMode; using D2D1_COMPOSITE_MODE = Win32.Graphics.Direct2D.Common.CompositeMode; -using D2D1_MAP_OPTIONS = Win32.Graphics.Direct2D.MapOptions; +using D2D1_MAP_OPTIONS = MapOptions; using D2D_RECT_U = Win32.Graphics.Direct2D.Common.RectU; using D2D1_MAPPED_RECT = Win32.Graphics.Direct2D.MappedRect; -using D2D1_BITMAP_PROPERTIES = Win32.Graphics.Direct2D.BitmapProperties; -using D2D1_BITMAP_PROPERTIES1 = Win32.Graphics.Direct2D.BitmapProperties1; +using D2D1_BITMAP_PROPERTIES = BitmapProperties; +using D2D1_BITMAP_PROPERTIES1 = BitmapProperties1; using D3D_FEATURE_LEVEL = Win32.Graphics.Direct3D.FeatureLevel; using D3D_DRIVER_TYPE = Win32.Graphics.Direct3D.DriverType; -using D3D11_CREATE_DEVICE_FLAG = Win32.Graphics.Direct3D11.CreateDeviceFlags; +using D3D11_CREATE_DEVICE_FLAG = CreateDeviceFlags; using DXGI_FORMAT = Win32.Graphics.Dxgi.Common.Format; using Win32 = Win32.Apis; using D2D1 = Win32.Graphics.Direct2D.Apis; diff --git a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs index f40e5af6..6cc264f7 100644 --- a/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs +++ b/tests/ComputeSharp.D2D1.Tests/Helpers/D2D1TestRunner.cs @@ -7,9 +7,11 @@ using ComputeSharp.Tests.Helpers; using Win32; using Win32.Graphics.Direct2D; +#pragma warning disable IDE0065 + namespace ComputeSharp.D2D1.Tests.Helpers; -using D2D1_MAPPED_RECT = Win32.Graphics.Direct2D.MappedRect; +using D2D1_MAPPED_RECT = MappedRect; /// /// A test helper for D2D1 pixel shaders. diff --git a/tests/ComputeSharp.Tests.DeviceLost/Extensions/DeviceExtensions.cs b/tests/ComputeSharp.Tests.DeviceLost/Extensions/DeviceExtensions.cs index a15bd748..d3910436 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/Extensions/DeviceExtensions.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/Extensions/DeviceExtensions.cs @@ -33,7 +33,6 @@ public static class DeviceExtensions case Device.Discrete: Assert.Inconclusive(); break; case Device.Warp: Assert.Fail(); break; } - } return device!; diff --git a/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs b/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs index 1b719435..0f20decd 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/GetDefaultDeviceTests.cs @@ -79,7 +79,7 @@ public class GetDefaultDeviceTests } // Calling GraphicsDevice.GetDefault() will now throw, because the native device has not been disposed properly - _ = Assert.ThrowsException(() => GraphicsDevice.GetDefault()); + _ = Assert.ThrowsException(GraphicsDevice.GetDefault); } } diff --git a/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs b/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs index 8ebba14b..6f0fa4ea 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/TerraFX.Interop.Windows/ID3D12Device5.cs @@ -9,24 +9,23 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -namespace TerraFX.Interop.DirectX +namespace TerraFX.Interop.DirectX; + +[Guid("8B4F173B-2FEA-4B80-8F58-4307191AB95D")] +public unsafe partial struct ID3D12Device5 { - [Guid("8B4F173B-2FEA-4B80-8F58-4307191AB95D")] - public unsafe partial struct ID3D12Device5 + public void** lpVtbl; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public uint Release() { - public void** lpVtbl; + return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID3D12Device5*)Unsafe.AsPointer(ref this)); + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public uint Release() - { - return ((delegate* unmanaged[Stdcall])this.lpVtbl[2])((ID3D12Device5*)Unsafe.AsPointer(ref this)); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void RemoveDevice() - { - ((delegate* unmanaged[Stdcall])this.lpVtbl[58])((ID3D12Device5*)Unsafe.AsPointer(ref this)); - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void RemoveDevice() + { + ((delegate* unmanaged[Stdcall])this.lpVtbl[58])((ID3D12Device5*)Unsafe.AsPointer(ref this)); } } diff --git a/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs index 66cf1829..9afe217a 100644 --- a/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs @@ -41,7 +41,7 @@ public class ShaderCompilerTests [ExpectedException(typeof(DxcCompilationException))] public void CompileTest_Fail() { - var faultyShader = ShaderSource.Replace("ids.x", "ids.X"); + string faultyShader = ShaderSource.Replace("ids.x", "ids.X"); using ComPtr dxcBlob = ShaderCompiler.Instance.Compile(faultyShader.AsSpan()); } diff --git a/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs b/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs index b85b6645..111bf9e8 100644 --- a/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs +++ b/tests/ComputeSharp.Tests/Extensions/DeviceExtensions.cs @@ -52,7 +52,6 @@ public static class DeviceExtensions case Device.Discrete: Assert.Inconclusive(); break; case Device.Warp: Assert.Fail(); break; } - } return device!; diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs index 867795b7..9893e27b 100644 --- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs @@ -68,7 +68,7 @@ namespace ComputeSharp.Tests float log = Hlsl.Log(1 + exp); float temp = log + cellData.dword + cellData.int2x2; - row_major[ThreadIds.X] = (log / dword) + float2 + int2x2 + cbuffer.float2; + row_major[ThreadIds.X] = (log / dword) + float2 + int2x2 + cbuffer.float2 + temp; } } diff --git a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs index 4ed47840..74f9d9a8 100644 --- a/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs +++ b/tests/ComputeSharp.Tests/Shaders/Compute/TriangleGridContouring.cs @@ -211,8 +211,6 @@ internal readonly partial struct TriangleGridContouring : IComputeShader d2 = Hlsl.Min(d2, DistEdge(p - p0, p - p1)); - float oldD2 = d2; - if (iTh2 == 7) d2 = 0.0f; if (iTh == 7) d2 = 1e5f; diff --git a/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs index 87697508..522f8af8 100644 --- a/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs @@ -117,21 +117,20 @@ partial class Texture1DTests { using ReadWriteTexture1D texture = device.Get().AllocateReadWriteTexture1D(64); - using (ComputeContext context = device.Get().CreateComputeContext()) - { - context.Transition(texture, ResourceState.ReadOnly); + using ComputeContext context = device.Get().CreateComputeContext(); - IReadOnlyNormalizedTexture1D wrapper1 = texture.AsReadOnly(); + context.Transition(texture, ResourceState.ReadOnly); - Assert.IsNotNull(wrapper1); + IReadOnlyNormalizedTexture1D wrapper1 = texture.AsReadOnly(); - IReadOnlyNormalizedTexture1D wrapper2 = texture.AsReadOnly(); + Assert.IsNotNull(wrapper1); - Assert.IsNotNull(wrapper2); - Assert.AreSame(wrapper1, wrapper2); + IReadOnlyNormalizedTexture1D wrapper2 = texture.AsReadOnly(); - context.Transition(texture, ResourceState.ReadWrite); - } + Assert.IsNotNull(wrapper2); + Assert.AreSame(wrapper1, wrapper2); + + context.Transition(texture, ResourceState.ReadWrite); } TestHelper.Run(Test, t, tPixel, device); diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs index bd9a9e49..5fe9fec1 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs @@ -132,21 +132,20 @@ partial class Texture2DTests { using ReadWriteTexture2D texture = device.Get().AllocateReadWriteTexture2D(64, 64); - using (ComputeContext context = device.Get().CreateComputeContext()) - { - context.Transition(texture, ResourceState.ReadOnly); + using ComputeContext context = device.Get().CreateComputeContext(); - IReadOnlyNormalizedTexture2D wrapper1 = texture.AsReadOnly(); + context.Transition(texture, ResourceState.ReadOnly); - Assert.IsNotNull(wrapper1); + IReadOnlyNormalizedTexture2D wrapper1 = texture.AsReadOnly(); - IReadOnlyNormalizedTexture2D wrapper2 = texture.AsReadOnly(); + Assert.IsNotNull(wrapper1); - Assert.IsNotNull(wrapper2); - Assert.AreSame(wrapper1, wrapper2); + IReadOnlyNormalizedTexture2D wrapper2 = texture.AsReadOnly(); - context.Transition(texture, ResourceState.ReadWrite); - } + Assert.IsNotNull(wrapper2); + Assert.AreSame(wrapper1, wrapper2); + + context.Transition(texture, ResourceState.ReadWrite); } TestHelper.Run(Test, t, tPixel, device); diff --git a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs index 42ff6ee9..5c36116d 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs @@ -64,21 +64,20 @@ partial class Texture3DTests { using ReadWriteTexture3D texture = device.Get().AllocateReadWriteTexture3D(32, 32, 2); - using (ComputeContext context = device.Get().CreateComputeContext()) - { - context.Transition(texture, ResourceState.ReadOnly); + using ComputeContext context = device.Get().CreateComputeContext(); - IReadOnlyNormalizedTexture3D wrapper1 = texture.AsReadOnly(); + context.Transition(texture, ResourceState.ReadOnly); - Assert.IsNotNull(wrapper1); + IReadOnlyNormalizedTexture3D wrapper1 = texture.AsReadOnly(); - IReadOnlyNormalizedTexture3D wrapper2 = texture.AsReadOnly(); + Assert.IsNotNull(wrapper1); - Assert.IsNotNull(wrapper2); - Assert.AreSame(wrapper1, wrapper2); + IReadOnlyNormalizedTexture3D wrapper2 = texture.AsReadOnly(); - context.Transition(texture, ResourceState.ReadWrite); - } + Assert.IsNotNull(wrapper2); + Assert.AreSame(wrapper1, wrapper2); + + context.Transition(texture, ResourceState.ReadWrite); } TestHelper.Run(Test, t, tPixel, device);