From 16c0fc9aaba2c365abe7cf2d2f07de6993e4dcfe Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 15 Oct 2022 15:48:05 +0200 Subject: [PATCH] Use explicit types everywhere --- .../Processors/HlslBokehBlurProcessor.cs | 2 +- .../HlslBokehBlurProcessor{TPixel}.cs | 11 +-- .../Processors/HlslGaussianBlurProcessor.cs | 2 +- .../HlslGaussianBlurProcessor{TPixel}.cs | 2 +- .../ComputeSharp.ImageProcessing/Program.cs | 2 +- .../ComputeSharp.Sample/Helpers/Formatting.cs | 4 +- .../Services/DebugAnalyticsService.cs | 4 +- .../Views/MainWindow.xaml.cs | 2 +- ...erGenerator.CreateBuildHlslSourceMethod.cs | 50 +++++++------- ...rGenerator.CreateLoadDispatchDataMethod.cs | 4 +- ...teLoadResourceTextureDescriptionsMethod.cs | 2 +- .../Mappings/HlslKnownKeywords.cs | 2 +- .../Mappings/HlslKnownMethods.cs | 2 +- .../D2D1AffineTransformMapperFactory.cs | 8 +-- .../Mappings/HlslKnownKeywords.cs | 5 +- .../Mappings/HlslKnownMethods.cs | 4 +- .../Mappings/HlslKnownOperators.cs | 2 +- .../Mappings/HlslKnownProperties.cs | 6 +- .../Mappings/HlslKnownSizes.cs | 3 +- .../Mappings/HlslKnownTypes.cs | 16 ++--- .../HlslSourceRewriter.Diagnostics.cs | 2 +- .../SyntaxRewriters/HlslSourceRewriter.cs | 26 +++---- .../SyntaxRewriters/ShaderSourceRewriter.cs | 34 +++++----- .../SyntaxRewriters/StaticFieldRewriter.cs | 10 +-- ...ator.CreateBuildHlslSourceMethod.Syntax.cs | 2 +- ...erGenerator.CreateBuildHlslSourceMethod.cs | 68 +++++++++---------- ...rGenerator.CreateLoadDispatchDataMethod.cs | 4 +- .../Mappings/HlslKnownProperties.cs | 8 +-- .../ShaderMethodSourceGenerator.cs | 12 ++-- .../SyntaxRewriters/ExecuteMethodRewriter.cs | 8 +-- .../AnimatedComputeShaderPanel.Properties.cs | 16 ++--- .../Controls/ComputeShaderPanel.Properties.cs | 16 ++--- .../Helpers/SwapChainManager.Rendering.cs | 10 +-- .../GraphicsDeviceExtensions.Dispatching.cs | 2 +- .../Extensions/Texture1DExtensions.cs | 4 +- .../Extensions/Texture2DExtensions.cs | 8 +-- .../Extensions/Texture3DExtensions.cs | 12 ++-- .../Graphics/GraphicsDevice.DeviceLost.cs | 2 +- src/ComputeSharp/Graphics/GraphicsDevice.cs | 20 +++--- .../Helpers/DeviceHelper.ID3D12InfoQueue.cs | 3 +- .../__Internals/GraphicsResourceHelper.cs | 14 ++-- .../Graphics/Interop/InteropServices.cs | 32 ++++----- .../Graphics/Resources/Abstract/Buffer{T}.cs | 4 +- .../Resources/Abstract/StructuredBuffer{T}.cs | 26 +++---- .../Resources/Abstract/Texture1D{T}.cs | 32 ++++----- .../Resources/Abstract/Texture2D{T}.cs | 32 ++++----- .../Resources/Abstract/Texture3D{T}.cs | 32 ++++----- .../Resources/Abstract/TransferBuffer{T}.cs | 8 +-- .../Abstract/TransferTexture1D{T}.cs | 8 +-- .../Abstract/TransferTexture2D{T}.cs | 4 +- .../Abstract/TransferTexture3D{T}.cs | 4 +- .../Graphics/Resources/ConstantBuffer{T}.cs | 14 ++-- .../ReadWriteTexture1D{T,TPixel}.ReadOnly.cs | 10 +-- .../ReadWriteTexture1D{T}.ReadOnly.cs | 10 +-- .../ReadWriteTexture2D{T,TPixel}.ReadOnly.cs | 10 +-- .../ReadWriteTexture2D{T}.ReadOnly.cs | 10 +-- .../ReadWriteTexture3D{T,TPixel}.ReadOnly.cs | 10 +-- .../ReadWriteTexture3D{T}.ReadOnly.cs | 10 +-- .../Extensions/ComputeContextExtensions.cs | 62 ++++++++--------- .../Effects/BokehBlurEffect.cs | 16 ++--- tests/ComputeSharp.Pix.NuGet/Program.cs | 2 +- .../DeviceDisposalTests.cs | 22 +++--- .../DeviceLostTests.cs | 8 +-- .../NativeObjectTests.cs | 14 ++-- .../ComputeSharp.Tests/ComputeContextTests.cs | 52 +++++++------- .../Helpers/TolerantImageComparer.cs | 10 +-- .../ImageProcessingTests.cs | 12 ++-- .../ComputeSharp.Tests/ShaderCompilerTests.cs | 2 + .../ComputeSharp.Tests/ShaderRewriterTests.cs | 2 + tests/ComputeSharp.Tests/ShadersTests.cs | 4 +- .../Texture1DTests.Pixels.cs | 10 +-- .../Texture2DTests.Pixels.cs | 10 +-- .../Texture3DTests.Pixels.cs | 2 +- tests/ComputeSharp.Tests/Texture3DTests.cs | 3 +- 74 files changed, 455 insertions(+), 446 deletions(-) diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs index c514dc91..ce60fc75 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor.cs @@ -77,7 +77,7 @@ public sealed partial class HlslBokehBlurProcessor : IImageProcessor ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format."); } - var processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle); + Implementation processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle); return Unsafe.As>(processor); } diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs index ae9c1dc8..b438da57 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs @@ -76,8 +76,9 @@ public sealed partial class HlslBokehBlurProcessor componentsCount = definition.Components; // Reuse the initialized values from the cache, if possible - var parameters = (radius, componentsCount); - if (Cache.TryGetValue(parameters, out var info)) + (int radius, int componentsCount) parameters = (radius, componentsCount); + + if (Cache.TryGetValue(parameters, out (Vector4[] Parameters, float Scale, Complex64[][] Kernels) info)) { kernelParameters = info.Parameters; kernelsScale = info.Scale; @@ -171,7 +172,7 @@ public sealed partial class HlslBokehBlurProcessor /// private Complex64[][] CreateComplexKernels() { - var kernels = new Complex64[kernelParameters.Length][]; + Complex64[][] kernels = new Complex64[kernelParameters.Length][]; ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); for (int i = 0; i < kernelParameters.Length; i++) @@ -191,7 +192,7 @@ public sealed partial class HlslBokehBlurProcessor /// The angle component for each complex component. private Complex64[] CreateComplex1DKernel(float a, float b) { - var kernel = new Complex64[kernelSize]; + Complex64[] kernel = new Complex64[kernelSize]; ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan()); int r = radius; int n = -r; @@ -286,7 +287,7 @@ public sealed partial class HlslBokehBlurProcessor kernel.CopyFrom(kernels[j]); - using var context = graphicsDevice.CreateComputeContext(); + using ComputeContext context = graphicsDevice.CreateComputeContext(); context.For( source.Width, diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs index 0e54255a..980a4487 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor.cs @@ -82,7 +82,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor ThrowHelper.ThrowInvalidOperationException("This processor only supports the RGBA32 pixel format."); } - var processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle); + Implementation processor = new Implementation(this, configuration, Unsafe.As>(source), sourceRectangle); return Unsafe.As>(processor); } diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs index 3b2ce50e..dd029b2e 100644 --- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs +++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs @@ -104,7 +104,7 @@ public sealed partial class HlslGaussianBlurProcessor using ReadWriteTexture2D firstPassTexture = graphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height); using ReadOnlyBuffer kernelBuffer = graphicsDevice.AllocateReadOnlyBuffer(kernel); - using (var context = graphicsDevice.CreateComputeContext()) + using (ComputeContext context = graphicsDevice.CreateComputeContext()) { context.For(source.Width, source.Height, new(sourceTexture, firstPassTexture, kernelBuffer)); context.Barrier(firstPassTexture); diff --git a/samples/ComputeSharp.ImageProcessing/Program.cs b/samples/ComputeSharp.ImageProcessing/Program.cs index bc1113fb..7b764178 100644 --- a/samples/ComputeSharp.ImageProcessing/Program.cs +++ b/samples/ComputeSharp.ImageProcessing/Program.cs @@ -15,7 +15,7 @@ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly() using Image image = Image.Load(path); // Apply a series of processors and save the results -foreach (var effect in new (string Name, IImageProcessor Processor)[] +foreach ((string Name, IImageProcessor Processor) effect in new (string Name, IImageProcessor Processor)[] { ("bokeh", new HlslBokehBlurProcessor(80, 2)), ("gaussian", new HlslGaussianBlurProcessor(80)) diff --git a/samples/ComputeSharp.Sample/Helpers/Formatting.cs b/samples/ComputeSharp.Sample/Helpers/Formatting.cs index 6cb14ea9..54c23634 100644 --- a/samples/ComputeSharp.Sample/Helpers/Formatting.cs +++ b/samples/ComputeSharp.Sample/Helpers/Formatting.cs @@ -34,8 +34,8 @@ internal static class Formatting for (int i = 0; i < height; i++) { - var row = array.AsSpan(i * width, width).ToArray(); - var text = string.Join(",", row.Select(x => x.ToString(CultureInfo.InvariantCulture).PadLeft(numberWidth))); + float[] row = array.AsSpan(i * width, width).ToArray(); + string text = string.Join(",", row.Select(x => x.ToString(CultureInfo.InvariantCulture).PadLeft(numberWidth))); Console.WriteLine(text); } diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs index 97550c59..d022277a 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs @@ -20,7 +20,7 @@ public sealed class DebugAnalyticsService : IAnalyticsService if (data is not null) { - foreach (var info in data) + foreach ((string Property, object? Value) info in data) { _ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\""); } @@ -40,7 +40,7 @@ public sealed class DebugAnalyticsService : IAnalyticsService if (data is not null) { - foreach (var info in data) + foreach ((string Property, object? Value) info in data) { _ = builder.AppendLine($">> {info.Property}: \"{info.Value ?? ""}\""); } diff --git a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs index fa900fea..b8f42ccb 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs @@ -40,7 +40,7 @@ public sealed partial class MainWindow : Window { ShaderPanel.ShaderRunner = null; - foreach (var (panel, _) in this.shaderPanels) + foreach ((AnimatedComputeShaderPanel panel, object _) in this.shaderPanels) { panel.ShaderRunner = null; } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs index 5ccebec3..56410746 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -64,13 +64,13 @@ partial class ID2D1ShaderGenerator out ImmutableArray<(string Name, string HlslType, int Index)> resourceTextureFields); // Explore the syntax tree and extract the processed info - var semanticModelProvider = new SemanticModelProvider(compilation); - var (entryPoint, processedMethods) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, out bool methodsNeedD2D1RequiresScenePosition); - var staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions, out bool fieldsNeedD2D1RequiresScenePosition); + SemanticModelProvider semanticModelProvider = new SemanticModelProvider(compilation); + (string entryPoint, ImmutableArray<(string Signature, string Definition)> processedMethods) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, out bool methodsNeedD2D1RequiresScenePosition); + ImmutableArray<(string Name, string TypeDeclaration, string? Assignment)> staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions, out bool fieldsNeedD2D1RequiresScenePosition); // Process the discovered types and constants - var declaredTypes = GetDeclaredTypes(diagnostics, structDeclarationSymbol, discoveredTypes, instanceMethods); - var definedConstants = GetDefinedConstants(constantDefinitions); + ImmutableArray<(string Name, string Definition)> declaredTypes = GetDeclaredTypes(diagnostics, structDeclarationSymbol, discoveredTypes, instanceMethods); + ImmutableArray<(string Name, string Value)> definedConstants = GetDefinedConstants(constantDefinitions); // Check whether the scene position is required bool requiresScenePosition = GetD2DRequiresScenePositionInfo(structDeclarationSymbol); @@ -111,7 +111,7 @@ partial class ID2D1ShaderGenerator using ImmutableArrayBuilder<(string, string)> values = ImmutableArrayBuilder<(string, string)>.Rent(); using ImmutableArrayBuilder<(string, string, int)> resourceTextures = ImmutableArrayBuilder<(string, string, int)>.Rent(); - foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) + foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) { if (fieldSymbol.IsStatic) { @@ -205,9 +205,9 @@ partial class ID2D1ShaderGenerator needsD2D1RequiresScenePosition = false; - foreach (var fieldDeclaration in structDeclaration.Members.OfType()) + foreach (FieldDeclarationSyntax fieldDeclaration in structDeclaration.Members.OfType()) { - foreach (var variableDeclarator in fieldDeclaration.Declaration.Variables) + foreach (VariableDeclaratorSyntax variableDeclarator in fieldDeclaration.Declaration.Variables) { IFieldSymbol fieldSymbol = (IFieldSymbol)semanticModel.For(variableDeclarator).GetDeclaredSymbol(variableDeclarator)!; @@ -319,7 +319,7 @@ partial class ID2D1ShaderGenerator needsD2D1RequiresScenePosition |= shaderSourceRewriter.NeedsD2DRequiresScenePositionAttribute; // Emit the extracted local functions first - foreach (var localFunction in shaderSourceRewriter.LocalFunctions) + foreach (KeyValuePair localFunction in shaderSourceRewriter.LocalFunctions) { methods.Add(( localFunction.Value.AsDefinition().NormalizeWhitespace(eol: "\n").ToFullString(), @@ -362,10 +362,10 @@ partial class ID2D1ShaderGenerator { using ImmutableArrayBuilder<(string, string)> builder = ImmutableArrayBuilder<(string, string)>.Rent(); - foreach (var constant in constantDefinitions) + foreach (KeyValuePair constant in constantDefinitions) { - var ownerTypeName = ((INamedTypeSymbol)constant.Key.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); - var constantName = $"__{ownerTypeName}__{constant.Key.Name}"; + string ownerTypeName = ((INamedTypeSymbol)constant.Key.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); + string constantName = $"__{ownerTypeName}__{constant.Key.Name}"; builder.Add((constantName, constant.Value)); } @@ -392,13 +392,13 @@ partial class ID2D1ShaderGenerator IReadOnlyCollection invalidTypes; // Process the discovered types - foreach (var type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes)) + foreach (INamedTypeSymbol type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes)) { - var structType = type.GetFullMetadataName().ToHlslIdentifierName(); - var structDeclaration = StructDeclaration(structType); + string structType = type.GetFullMetadataName().ToHlslIdentifierName(); + StructDeclarationSyntax structDeclaration = StructDeclaration(structType); // Declare the fields of the current type - foreach (var field in type.GetMembers().OfType()) + foreach (IFieldSymbol field in type.GetMembers().OfType()) { if (field.IsStatic) continue; @@ -423,7 +423,7 @@ partial class ID2D1ShaderGenerator } // Declare the methods of the current type - foreach (var method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type))) + foreach (KeyValuePair method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type))) { structDeclaration = structDeclaration.AddMembers(method.Value); } @@ -453,7 +453,7 @@ partial class ID2D1ShaderGenerator /// The input instance to process. private static void DetectAndReportInvalidPropertyDeclarations(ImmutableArrayBuilder diagnostics, INamedTypeSymbol structDeclarationSymbol) { - foreach (var memberSymbol in structDeclarationSymbol.GetMembers()) + foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers()) { // Detect properties that are not explicit interface implementations if (memberSymbol is IPropertySymbol { ExplicitInterfaceImplementations.IsEmpty: true }) @@ -574,7 +574,7 @@ partial class ID2D1ShaderGenerator { AppendLF(); - foreach (var (name, value) in definedConstants) + foreach ((string name, string value) in definedConstants) { AppendLineAndLF($"#define {name} {value}"); } @@ -585,7 +585,7 @@ partial class ID2D1ShaderGenerator { AppendLF(); - foreach (var field in staticFields) + foreach ((string Name, string TypeDeclaration, string? Assignment) field in staticFields) { if (field.Assignment is string assignment) { @@ -599,7 +599,7 @@ partial class ID2D1ShaderGenerator } // Declared types - foreach (var (_, typeDefinition) in declaredTypes) + foreach ((string _, string typeDefinition) in declaredTypes) { AppendLF(); AppendLineAndLF(typeDefinition); @@ -610,14 +610,14 @@ partial class ID2D1ShaderGenerator { AppendLF(); - foreach (var (fieldName, fieldType) in valueFields) + foreach ((string fieldName, string fieldType) in valueFields) { AppendLineAndLF($"{fieldType} {fieldName};"); } } // Resource textures - foreach (var (fieldName, fieldType, index) in resourceTextureFields) + foreach ((string fieldName, string fieldType, int index) in resourceTextureFields) { AppendLF(); @@ -626,14 +626,14 @@ partial class ID2D1ShaderGenerator } // Forward declarations - foreach (var (forwardDeclaration, _) in processedMethods) + foreach ((string forwardDeclaration, string _) in processedMethods) { AppendLF(); AppendLineAndLF(forwardDeclaration); } // Captured methods - foreach (var (_, method) in processedMethods) + foreach ((string _, string method) in processedMethods) { AppendLF(); AppendLineAndLF(method); diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs index eefa62ba..987db1ce 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.cs @@ -72,7 +72,7 @@ partial class ID2D1ShaderGenerator else if (fieldSymbol.Type.IsUnmanagedType) { // Custom struct type defined by the user - foreach (var fieldInfo in GetCapturedFieldInfos(fieldSymbol.Type, fieldPath.Add(fieldName), rawDataOffset)) + foreach (FieldInfo fieldInfo in GetCapturedFieldInfos(fieldSymbol.Type, fieldPath.Add(fieldName), rawDataOffset)) { yield return fieldInfo; } @@ -117,7 +117,7 @@ partial class ID2D1ShaderGenerator { // For scalar, vector and linear matrix types, serialize the value normally. // Only the initial alignment needs to be considered, while data is packed. - var (fieldSize, fieldPack) = HlslKnownSizes.GetTypeInfo(typeName); + (int fieldSize, int fieldPack) = HlslKnownSizes.GetTypeInfo(typeName); // Check if the current type is a matrix type with more than one row. In this // case, each row is aligned as if it was a separate array, so the start of diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs index a2225374..4c6944b0 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadResourceTextureDescriptionsMethod.cs @@ -33,7 +33,7 @@ partial class ID2D1ShaderGenerator { using ImmutableArrayBuilder<(int? Index, int Rank)> resourceTextureInfos = ImmutableArrayBuilder<(int? Index, int Rank)>.Rent(); - foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) + foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) { // Only look for fields of a named type symbol (diagnostics is emitted by the HLSL rewriter if it's not the case). // We're only looking for instance fields of unmanaged types in this case (as resource textures are structs). diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs index 0da0cb58..00885bbe 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownKeywords.cs @@ -12,7 +12,7 @@ partial class HlslKnownKeywords static partial void AddKnownKeywords(ICollection knownKeywords) { // D2D1 intrinsics method names - foreach (var method in typeof(D2D).GetMethods(BindingFlags.Public | BindingFlags.Static)) + foreach (MethodInfo? method in typeof(D2D).GetMethods(BindingFlags.Public | BindingFlags.Static)) { string name = method.GetCustomAttribute()?.Name ?? method.Name; diff --git a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs index fb335ed0..24ae776a 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/Mappings/HlslKnownMethods.cs @@ -26,7 +26,7 @@ partial class HlslKnownMethods static partial void AddKnownMethods(IDictionary knownMethods) { // Programmatically load mappings from the D2D1 class as well - foreach (var method in + foreach (MethodInfo? method in from method in typeof(D2D).GetMethods(BindingFlags.Public | BindingFlags.Static) group method by method.Name into groups diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Factories/D2D1AffineTransformMapperFactory.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Factories/D2D1AffineTransformMapperFactory.cs index a38eb8c9..3e76e5b7 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Factories/D2D1AffineTransformMapperFactory.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Factories/D2D1AffineTransformMapperFactory.cs @@ -29,10 +29,10 @@ internal sealed class D2D1AffineTransformMapperFactory Point64 bottomRight = new(rectangle.Right, rectangle.Bottom); // Transform them with the current matrix - var transformedTopLeft = topLeft.Transform(in matrix); - var transformedTopRight = topRight.Transform(in matrix); - var transformedBottomLeft = bottomLeft.Transform(in matrix); - var transformedBottomRight = bottomRight.Transform(in matrix); + (double X, double Y) transformedTopLeft = topLeft.Transform(in matrix); + (double X, double Y) transformedTopRight = topRight.Transform(in matrix); + (double X, double Y) transformedBottomLeft = bottomLeft.Transform(in matrix); + (double X, double Y) transformedBottomRight = bottomRight.Transform(in matrix); // Calculate the bounding box of the transformed points double transformedLeft = Math.Min(Math.Min(transformedTopLeft.X, transformedTopRight.X), Math.Min(transformedBottomLeft.X, transformedBottomRight.X)); diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs index 1175f6ee..6d706a5a 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownKeywords.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -44,13 +45,13 @@ internal static partial class HlslKnownKeywords }); // HLSL primitive names - foreach (var type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes)) + foreach (Type? type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes)) { _ = knownKeywords.Add(type.Name.ToLowerInvariant()); } // HLSL intrinsics method names - foreach (var method in typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static)) + foreach (MethodInfo? method in typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static)) { string name = method.GetCustomAttribute()?.Name ?? method.Name; diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs index 78eacab8..8ea3c68d 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs @@ -128,7 +128,7 @@ internal static partial class HlslKnownMethods }; // Programmatically load mappings from the Hlsl class as well (the ones with no parameter matching) - foreach (var method in + foreach (MethodInfo? method in from method in typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static) group method by method.Name into groups @@ -171,7 +171,7 @@ internal static partial class HlslKnownMethods Dictionary knownMethods = new(); // Go through the previously discovered methods to find the ones requiring parameters mapping - foreach (var pair in KnownMethods) + foreach (KeyValuePair pair in KnownMethods) { // Only process methods marked as requiring parameters mapping if (pair.Value != nameof(HlslIntrinsicNameAttribute.RequiresParametersMatching)) diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs index 522c6dfd..885c06e9 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs @@ -24,7 +24,7 @@ internal static partial class HlslKnownOperators Dictionary knownOperators = new(); // Programmatically load mappings for the intrinsic operators on each HLSL primitive type - foreach (var item in + foreach ((Type Type, MethodInfo Operator, string IntrinsicName, bool RequiresParametersMatching) item in from type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes) from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public) where method.IsSpecialName && method.Name.StartsWith("op_") diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs index bb8f6c7e..2b5fd0d5 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownProperties.cs @@ -140,7 +140,7 @@ internal static partial class HlslKnownProperties }; // Programmatically load mappings for the instance members of the HLSL vector types - foreach (var item in + foreach ((Type Type, PropertyInfo Property) item in from type in HlslKnownTypes.KnownVectorTypes from property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public) select (Type: type, Property: property)) @@ -149,7 +149,7 @@ internal static partial class HlslKnownProperties } // Load mappings for the matrix properties as well - foreach (var item in + foreach ((Type Type, PropertyInfo Property) item in from type in HlslKnownTypes.KnownMatrixTypes from property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public) where Regex.IsMatch(property.Name, "^M[1-4]{2}$") @@ -282,7 +282,7 @@ internal static partial class HlslKnownProperties /// Whether or not a rank and axis could be resolved by the input indexer name. public static bool TryGetAccessorRankAndAxis(string name, out int rank, out int axis) { - if (KnownSizeAccessors.TryGetValue(name, out var info)) + if (KnownSizeAccessors.TryGetValue(name, out (int Rank, int Axis) info)) { (rank, axis) = info; diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs index 6bbc4f04..55df54a2 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownSizes.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Numerics; @@ -35,7 +36,7 @@ internal static class HlslKnownSizes }; foreach ( - var type in + Type? type in from type in Assembly.GetExecutingAssembly().ExportedTypes where Regex.IsMatch(type.FullName, @"^ComputeSharp\.(Bool|Double|Float|Int|UInt)") select type) diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs index 1120d5a5..18f10dfa 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownTypes.cs @@ -78,13 +78,13 @@ internal static partial class HlslKnownTypes }; // Add all the vector types - foreach (var type in KnownVectorTypes) + foreach (Type type in KnownVectorTypes) { knownTypes.Add(type.FullName, type.Name.ToLowerInvariant()); } // Add all the matrix types - foreach (var type in KnownMatrixTypes) + foreach (Type type in KnownMatrixTypes) { knownTypes.Add(type.FullName, type.Name.ToLowerInvariant()); } @@ -135,7 +135,7 @@ internal static partial class HlslKnownTypes { if (KnownMatrixTypes.Any(type => type.FullName == typeName)) { - var match = Regex.Match(typeName, @"^ComputeSharp\.(Bool|Int|UInt|Float|Double)([2-4])x([1-4])$"); + Match match = Regex.Match(typeName, @"^ComputeSharp\.(Bool|Int|UInt|Float|Double)([2-4])x([1-4])$"); if (match.Success) { @@ -243,7 +243,7 @@ internal static partial class HlslKnownTypes if (!customTypes.Add(type)) return; - foreach (var field in type.GetMembers().OfType()) + foreach (IFieldSymbol field in type.GetMembers().OfType()) { if (field.IsStatic) continue; @@ -291,12 +291,12 @@ internal static partial class HlslKnownTypes // types and their dependencies, and iteratively remove items from the map when they have no // dependencies left. When one type is processed and removed, it is also removed from the list // of dependencies of all other remaining types in the map, until there is none left. - foreach (var type in types) + foreach (INamedTypeSymbol type in types) { HashSet dependencies = new(SymbolEqualityComparer.Default); // Only add other custom types as dependencies, and ignore HLSL types - foreach (var field in type.GetMembers().OfType()) + foreach (IFieldSymbol field in type.GetMembers().OfType()) { if (field.IsStatic) continue; @@ -314,13 +314,13 @@ internal static partial class HlslKnownTypes while (queue.Count > 0) { - var entry = queue.Dequeue(); + (INamedTypeSymbol Type, HashSet Fields) entry = queue.Dequeue(); // No dependencies left, we can declare this type if (entry.Fields.Count == 0) { // Remove the current type from dependencies of others - foreach (var pair in queue) + foreach ((INamedTypeSymbol Type, HashSet Fields) pair in queue) { _ = pair.Fields.Remove(entry.Type); } diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs index 829186b1..c4e6beaa 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.Diagnostics.cs @@ -11,7 +11,7 @@ partial class HlslSourceRewriter /// public override SyntaxNode? VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node) { - var updatedNode = (AnonymousObjectCreationExpressionSyntax)base.VisitAnonymousObjectCreationExpression(node)!; + AnonymousObjectCreationExpressionSyntax updatedNode = (AnonymousObjectCreationExpressionSyntax)base.VisitAnonymousObjectCreationExpression(node)!; Diagnostics.Add(AnonymousObjectCreationExpression, node); diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs index b9b151e2..13ce4c18 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs @@ -68,7 +68,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode VisitCastExpression(CastExpressionSyntax node) { - var updatedNode = (CastExpressionSyntax)base.VisitCastExpression(node)!; + CastExpressionSyntax updatedNode = (CastExpressionSyntax)base.VisitCastExpression(node)!; return updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes); } @@ -76,7 +76,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitVariableDeclaration(VariableDeclarationSyntax node) { - var updatedNode = (VariableDeclarationSyntax)base.VisitVariableDeclaration(node)!; + VariableDeclarationSyntax updatedNode = (VariableDeclarationSyntax)base.VisitVariableDeclaration(node)!; if (SemanticModel.For(node).GetTypeInfo(node.Type).Type is ITypeSymbol { IsUnmanagedType: false } type) { @@ -95,7 +95,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode VisitObjectCreationExpression(ObjectCreationExpressionSyntax node) { - var updatedNode = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node)!; + ObjectCreationExpressionSyntax updatedNode = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node)!; if (SemanticModel.For(node).GetTypeInfo(node).Type is ITypeSymbol { IsUnmanagedType: false } type) { @@ -131,7 +131,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode VisitImplicitObjectCreationExpression(ImplicitObjectCreationExpressionSyntax node) { - var updatedNode = (ImplicitObjectCreationExpressionSyntax)base.VisitImplicitObjectCreationExpression(node)!; + ImplicitObjectCreationExpressionSyntax updatedNode = (ImplicitObjectCreationExpressionSyntax)base.VisitImplicitObjectCreationExpression(node)!; if (SemanticModel.For(node).GetTypeInfo(node).Type is ITypeSymbol { IsUnmanagedType: false } type) { @@ -167,7 +167,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode VisitDefaultExpression(DefaultExpressionSyntax node) { - var updatedNode = (DefaultExpressionSyntax)base.VisitDefaultExpression(node)!; + DefaultExpressionSyntax updatedNode = (DefaultExpressionSyntax)base.VisitDefaultExpression(node)!; updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes); @@ -178,7 +178,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitLiteralExpression(LiteralExpressionSyntax node) { - var updatedNode = (LiteralExpressionSyntax)base.VisitLiteralExpression(node)!; + LiteralExpressionSyntax updatedNode = (LiteralExpressionSyntax)base.VisitLiteralExpression(node)!; if (updatedNode.IsKind(SyntaxKind.DefaultLiteralExpression)) { @@ -236,7 +236,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitElementAccessExpression(ElementAccessExpressionSyntax node) { - var updatedNode = (ElementAccessExpressionSyntax)base.VisitElementAccessExpression(node)!; + ElementAccessExpressionSyntax updatedNode = (ElementAccessExpressionSyntax)base.VisitElementAccessExpression(node)!; if (SemanticModel.For(node).GetOperation(node) is IPropertyReferenceOperation operation) { @@ -246,7 +246,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter // For instance: texture[ThreadIds.X, ThreadIds.Y] will be rewritten as texture[int2(ThreadIds.X, ThreadIds.Y)]. if (HlslKnownProperties.TryGetMappedResourceIndexerTypeName(propertyName, out string? mapping)) { - var index = InvocationExpression(IdentifierName(mapping!), ArgumentList(updatedNode.ArgumentList.Arguments)); + InvocationExpressionSyntax index = InvocationExpression(IdentifierName(mapping!), ArgumentList(updatedNode.ArgumentList.Arguments)); return updatedNode.WithArgumentList(BracketedArgumentList(SingletonSeparatedList(Argument(index)))); } @@ -294,7 +294,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitAssignmentExpression(AssignmentExpressionSyntax node) { - var updatedNode = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(node)!; + AssignmentExpressionSyntax updatedNode = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(node)!; if (SemanticModel.For(node).GetOperation(node) is ICompoundAssignmentOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method }) { @@ -321,7 +321,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitBinaryExpression(BinaryExpressionSyntax node) { - var updatedNode = (BinaryExpressionSyntax)base.VisitBinaryExpression(node)!; + BinaryExpressionSyntax updatedNode = (BinaryExpressionSyntax)base.VisitBinaryExpression(node)!; // Process binary operations to see if the target operator method is an intrinsic if (SemanticModel.For(node).GetOperation(node) is IBinaryOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method }) @@ -346,7 +346,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitIdentifierName(IdentifierNameSyntax node) { - var updatedNode = (IdentifierNameSyntax)base.VisitIdentifierName(node)!; + IdentifierNameSyntax updatedNode = (IdentifierNameSyntax)base.VisitIdentifierName(node)!; if (SemanticModel.For(node).GetOperation(node) is IFieldReferenceOperation operation && operation.Field.IsConst && @@ -354,8 +354,8 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter { ConstantDefinitions[operation.Field] = ((IFormattable)operation.Field.ConstantValue!).ToString(null, CultureInfo.InvariantCulture); - var ownerTypeName = ((INamedTypeSymbol)operation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); - var constantName = $"__{ownerTypeName}__{operation.Field.Name}"; + string ownerTypeName = ((INamedTypeSymbol)operation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); + string constantName = $"__{ownerTypeName}__{operation.Field.Name}"; return IdentifierName(constantName); } diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index 75ed2076..266a41c2 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -129,7 +129,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter this.currentMethodIdentifier = node.Identifier; - var updatedNode = (MethodDeclarationSyntax?)base.Visit(node)!; + MethodDeclarationSyntax? updatedNode = (MethodDeclarationSyntax?)base.Visit(node)!; updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes); @@ -145,7 +145,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter if (updatedNode is not null) { - var implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray()); + BlockSyntax implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray()); // Add the tracked implicit declarations (at the start of the body) updatedNode = updatedNode.WithBody(implicitBlock).AddBodyStatements(updatedNode.Body!.Statements.ToArray()); @@ -164,7 +164,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter this.currentMethodIdentifier = node.Identifier; - var updatedNode = (LocalFunctionStatementSyntax?)base.Visit(node)!; + LocalFunctionStatementSyntax? updatedNode = (LocalFunctionStatementSyntax?)base.Visit(node)!; updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.ReturnType, node!.ReturnType, SemanticModel.For(node), DiscoveredTypes); @@ -180,7 +180,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter if (updatedNode is not null) { - var implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray()); + BlockSyntax implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray()); updatedNode = updatedNode.WithBody(implicitBlock).AddBodyStatements(updatedNode.Body!.Statements.ToArray()); } @@ -191,7 +191,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// public override SyntaxNode VisitParameter(ParameterSyntax node) { - var updatedNode = (ParameterSyntax)base.VisitParameter(node)!; + ParameterSyntax updatedNode = (ParameterSyntax)base.VisitParameter(node)!; // Convert the C# parameter modifiers to the HLSL equivalent SyntaxToken modifier = @@ -214,7 +214,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// public override SyntaxNode VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) { - var updatedNode = ((LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!); + LocalDeclarationStatementSyntax updatedNode = ((LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!); if (SemanticModel.For(node).GetOperation(node) is IOperation { Kind: OperationKind.UsingDeclaration }) { @@ -227,7 +227,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// public override SyntaxNode? VisitDeclarationExpression(DeclarationExpressionSyntax node) { - var updatedNode = (DeclarationExpressionSyntax)base.VisitDeclarationExpression(node)!; + DeclarationExpressionSyntax updatedNode = (DeclarationExpressionSyntax)base.VisitDeclarationExpression(node)!; updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node.Type, SemanticModel.For(node), DiscoveredTypes); @@ -255,7 +255,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter // being parsed. That is, this was a blobal method that was annotated in source. if (node.Identifier == this.currentMethodIdentifier) { - var updatedNode = + LocalFunctionStatementSyntax updatedNode = ((LocalFunctionStatementSyntax)base.VisitLocalFunctionStatement(node)!) .WithBlockBody() .WithAttributeLists(List()); @@ -278,7 +278,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter { this.localFunctionDepth++; - var updatedNode = + LocalFunctionStatementSyntax updatedNode = ((LocalFunctionStatementSyntax)base.VisitLocalFunctionStatement(node)!) .WithBlockBody() .WithAttributeLists(List()) @@ -311,7 +311,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node) { - var updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!; + MemberAccessExpressionSyntax updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!; if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression) && SemanticModel.For(node).GetOperation(node) is IMemberReferenceOperation operation) @@ -329,8 +329,8 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter ConstantDefinitions[fieldOperation.Field] = ((IFormattable)fieldOperation.Field.ConstantValue!).ToString(null, CultureInfo.InvariantCulture); - var ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); - var constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}"; + string ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); + string constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}"; return IdentifierName(constantName); } @@ -419,7 +419,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// public override SyntaxNode? VisitInvocationExpression(InvocationExpressionSyntax node) { - var updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!; + InvocationExpressionSyntax updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!; if (SemanticModel.For(node).GetOperation(node) is IInvocationOperation { TargetMethod: IMethodSymbol method } operation) { @@ -447,7 +447,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter // updated name is detailed in the override handling the local function statement. if (method.MethodKind == MethodKind.LocalFunction) { - var functionIdentifier = $"__{this.currentMethodIdentifier.Text}__{method.Name}"; + string functionIdentifier = $"__{this.currentMethodIdentifier.Text}__{method.Name}"; return updatedNode.WithExpression(IdentifierName(functionIdentifier)); } @@ -458,7 +458,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter // type as well, as they will be processed by the generator in a different path. if (!SymbolEqualityComparer.Default.Equals(this.shaderType, method.ContainingType)) { - var methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName(); + string methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName(); if (!this.staticMethods.ContainsKey(method)) { @@ -503,7 +503,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter { DiscoveredTypes.Add(structTypeSymbol); - var methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName(); + string methodIdentifier = method.GetFullMetadataName().ToHlslIdentifierName(); // Same as for static methods, ensure the method is available in source, and process it if so if (!this.instanceMethods.ContainsKey(method)) @@ -540,7 +540,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter /// public override SyntaxNode? VisitArgument(ArgumentSyntax node) { - var updatedNode = (ArgumentSyntax)base.VisitArgument(node)!; + ArgumentSyntax updatedNode = (ArgumentSyntax)base.VisitArgument(node)!; // Strip the ref keywords from arguments updatedNode = updatedNode.WithRefKindKeyword(Token(SyntaxKind.None)); diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs index 9df93f3e..17a9c8b2 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/StaticFieldRewriter.cs @@ -49,7 +49,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter /// public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyntax node) { - var updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!; + MemberAccessExpressionSyntax updatedNode = (MemberAccessExpressionSyntax)base.VisitMemberAccessExpression(node)!; if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression) && SemanticModel.For(node).GetOperation(node) is IMemberReferenceOperation operation) @@ -66,8 +66,8 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter ConstantDefinitions[fieldOperation.Field] = ((IFormattable)fieldOperation.Field.ConstantValue!).ToString(null, CultureInfo.InvariantCulture); - var ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); - var constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}"; + string ownerTypeName = ((INamedTypeSymbol)fieldOperation.Field.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); + string constantName = $"__{ownerTypeName}__{fieldOperation.Field.Name}"; return IdentifierName(constantName); } @@ -92,7 +92,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter /// public override SyntaxNode? VisitInvocationExpression(InvocationExpressionSyntax node) { - var updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!; + InvocationExpressionSyntax updatedNode = (InvocationExpressionSyntax)base.VisitInvocationExpression(node)!; if (SemanticModel.For(node).GetOperation(node) is IInvocationOperation operation && operation.TargetMethod is IMethodSymbol method && @@ -116,7 +116,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter /// public override SyntaxNode? VisitArgument(ArgumentSyntax node) { - var updatedNode = (ArgumentSyntax)base.VisitArgument(node)!; + ArgumentSyntax updatedNode = (ArgumentSyntax)base.VisitArgument(node)!; updatedNode = updatedNode.WithRefKindKeyword(Token(SyntaxKind.None)); diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs index c408de07..e83b3614 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.Syntax.cs @@ -154,7 +154,7 @@ partial class IShaderGenerator prologueStatements++; // .Add(""); - foreach (var item in items) + foreach (string item in items) { statements.Add( ExpressionStatement( diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs index 7bf082b7..06d66c8e 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateBuildHlslSourceMethod.cs @@ -58,20 +58,20 @@ partial class IShaderGenerator } // Explore the syntax tree and extract the processed info - var semanticModelProvider = new SemanticModelProvider(compilation); - var pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader) }); - var isComputeShader = pixelShaderSymbol is null; - var implicitTextureType = isComputeShader ? null : HlslKnownTypes.GetMappedNameForPixelShaderType(pixelShaderSymbol!); - var (resourceFields, valueFields) = GetInstanceFields(diagnostics, structDeclarationSymbol, discoveredTypes, isComputeShader); - var delegateInstanceFields = GetDispatchId.GetInfo(structDeclarationSymbol); - var sharedBuffers = GetSharedBuffers(diagnostics, structDeclarationSymbol, discoveredTypes); - var (entryPoint, processedMethods, isSamplerUsed) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, isComputeShader); - var implicitSamplerField = isSamplerUsed ? ("SamplerState", "__sampler") : default((string, string)?); - var staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions); + SemanticModelProvider semanticModelProvider = new SemanticModelProvider(compilation); + INamedTypeSymbol? pixelShaderSymbol = structDeclarationSymbol.AllInterfaces.FirstOrDefault(static interfaceSymbol => interfaceSymbol is { IsGenericType: true, Name: nameof(IPixelShader) }); + bool isComputeShader = pixelShaderSymbol is null; + string? implicitTextureType = isComputeShader ? null : HlslKnownTypes.GetMappedNameForPixelShaderType(pixelShaderSymbol!); + (ImmutableArray<(string MetadataName, string Name, string HlslType)> resourceFields, ImmutableArray<(string Name, string HlslType)> valueFields) = GetInstanceFields(diagnostics, structDeclarationSymbol, discoveredTypes, isComputeShader); + ImmutableArray delegateInstanceFields = GetDispatchId.GetInfo(structDeclarationSymbol); + ImmutableArray<(string Name, string Type, int? Count)> sharedBuffers = GetSharedBuffers(diagnostics, structDeclarationSymbol, discoveredTypes); + (string entryPoint, ImmutableArray<(string Signature, string Definition)> processedMethods, bool isSamplerUsed) = GetProcessedMethods(diagnostics, structDeclaration, structDeclarationSymbol, semanticModelProvider, discoveredTypes, staticMethods, instanceMethods, constantDefinitions, isComputeShader); + (string, string)? implicitSamplerField = isSamplerUsed ? ("SamplerState", "__sampler") : default((string, string)?); + ImmutableArray<(string Name, string TypeDeclaration, string? Assignment)> staticFields = GetStaticFields(diagnostics, semanticModelProvider, structDeclaration, structDeclarationSymbol, discoveredTypes, constantDefinitions); // Process the discovered types and constants - var declaredTypes = GetDeclaredTypes(diagnostics, structDeclarationSymbol, discoveredTypes, instanceMethods); - var definedConstants = GetDefinedConstants(constantDefinitions); + ImmutableArray<(string Name, string Definition)> declaredTypes = GetDeclaredTypes(diagnostics, structDeclarationSymbol, discoveredTypes, instanceMethods); + ImmutableArray<(string Name, string Value)> definedConstants = GetDefinedConstants(constantDefinitions); // Get the HLSL source data with the intermediate info return GetHlslSourceInfo( @@ -111,7 +111,7 @@ partial class IShaderGenerator bool hlslResourceFound = false; - foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) + foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) { if (fieldSymbol.IsStatic) { @@ -202,9 +202,9 @@ partial class IShaderGenerator { using ImmutableArrayBuilder<(string, string, string?)> builder = ImmutableArrayBuilder<(string, string, string?)>.Rent(); - foreach (var fieldDeclaration in structDeclaration.Members.OfType()) + foreach (FieldDeclarationSyntax fieldDeclaration in structDeclaration.Members.OfType()) { - foreach (var variableDeclarator in fieldDeclaration.Declaration.Variables) + foreach (VariableDeclaratorSyntax variableDeclarator in fieldDeclaration.Declaration.Variables) { IFieldSymbol fieldSymbol = (IFieldSymbol)semanticModel.For(variableDeclarator).GetDeclaredSymbol(variableDeclarator)!; @@ -266,7 +266,7 @@ partial class IShaderGenerator { using ImmutableArrayBuilder<(string, string, int?)> builder = ImmutableArrayBuilder<(string, string, int?)>.Rent(); - foreach (var fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) + foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType()) { if (!fieldSymbol.IsStatic) { @@ -382,7 +382,7 @@ partial class IShaderGenerator isSamplerUsed = isSamplerUsed || shaderSourceRewriter.IsSamplerUsed; // Emit the extracted local functions first - foreach (var localFunction in shaderSourceRewriter.LocalFunctions) + foreach (KeyValuePair localFunction in shaderSourceRewriter.LocalFunctions) { methods.Add(( localFunction.Value.AsDefinition().NormalizeWhitespace(eol: "\n").ToFullString(), @@ -428,10 +428,10 @@ partial class IShaderGenerator { using ImmutableArrayBuilder<(string, string)> builder = ImmutableArrayBuilder<(string, string)>.Rent(); - foreach (var constant in constantDefinitions) + foreach (KeyValuePair constant in constantDefinitions) { - var ownerTypeName = ((INamedTypeSymbol)constant.Key.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); - var constantName = $"__{ownerTypeName}__{constant.Key.Name}"; + string ownerTypeName = ((INamedTypeSymbol)constant.Key.ContainingSymbol).ToDisplayString().ToHlslIdentifierName(); + string constantName = $"__{ownerTypeName}__{constant.Key.Name}"; builder.Add((constantName, constant.Value)); } @@ -458,13 +458,13 @@ partial class IShaderGenerator IReadOnlyCollection invalidTypes; // Process the discovered types - foreach (var type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes)) + foreach (INamedTypeSymbol type in HlslKnownTypes.GetCustomTypes(types, out invalidTypes)) { - var structType = type.GetFullMetadataName().ToHlslIdentifierName(); - var structDeclaration = StructDeclaration(structType); + string structType = type.GetFullMetadataName().ToHlslIdentifierName(); + StructDeclarationSyntax structDeclaration = StructDeclaration(structType); // Declare the fields of the current type - foreach (var field in type.GetMembers().OfType()) + foreach (IFieldSymbol field in type.GetMembers().OfType()) { if (field.IsStatic) continue; @@ -489,7 +489,7 @@ partial class IShaderGenerator } // Declare the methods of the current type - foreach (var method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type))) + foreach (KeyValuePair method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type))) { structDeclaration = structDeclaration.AddMembers(method.Value); } @@ -519,7 +519,7 @@ partial class IShaderGenerator /// The input instance to process. private static void DetectAndReportInvalidPropertyDeclarations(ImmutableArrayBuilder diagnostics, INamedTypeSymbol structDeclarationSymbol) { - foreach (var memberSymbol in structDeclarationSymbol.GetMembers()) + foreach (ISymbol memberSymbol in structDeclarationSymbol.GetMembers()) { // Detect properties that are not explicit interface implementations if (memberSymbol is IPropertySymbol { ExplicitInterfaceImplementations.IsEmpty: true }) @@ -625,7 +625,7 @@ partial class IShaderGenerator AppendLF(); // Define declarations - foreach (var (name, value) in definedConstants) + foreach ((string name, string value) in definedConstants) { AppendLineAndLF($"#define {name} {value}"); } @@ -637,7 +637,7 @@ partial class IShaderGenerator { AppendLF(); - foreach (var field in staticFields) + foreach ((string Name, string TypeDeclaration, string? Assignment) field in staticFields) { if (field.Assignment is string assignment) { @@ -651,7 +651,7 @@ partial class IShaderGenerator } // Declared types - foreach (var (_, typeDefinition) in declaredTypes) + foreach ((string _, string typeDefinition) in declaredTypes) { AppendLF(); AppendLineAndLF(typeDefinition); @@ -672,7 +672,7 @@ partial class IShaderGenerator } // User-defined values - foreach (var (fieldName, fieldType) in valueFields) + foreach ((string fieldName, string fieldType) in valueFields) { AppendLineAndLF($" {fieldType} {fieldName};"); } @@ -698,7 +698,7 @@ partial class IShaderGenerator } // Resources - foreach (var (metadataName, fieldName, fieldType) in resourceFields) + foreach ((string metadataName, string fieldName, string fieldType) in resourceFields) { if (HlslKnownTypes.IsConstantBufferType(metadataName)) { @@ -721,7 +721,7 @@ partial class IShaderGenerator } // Shared buffers - foreach (var (bufferName, bufferType, bufferCount) in sharedBuffers) + foreach ((string bufferName, string bufferType, int? bufferCount) in sharedBuffers) { object count = (object?)bufferCount ?? "__GroupSize__get_X * __GroupSize__get_Y * __GroupSize__get_Z"; @@ -730,7 +730,7 @@ partial class IShaderGenerator } // Forward declarations - foreach (var (forwardDeclaration, _) in processedMethods) + foreach ((string forwardDeclaration, string _) in processedMethods) { AppendLF(); AppendLineAndLF(forwardDeclaration); @@ -739,7 +739,7 @@ partial class IShaderGenerator string capturedFieldsAndResourcesAndForwardDeclarations = FlushText(); // Captured methods - foreach (var (_, method) in processedMethods) + foreach ((string _, string method) in processedMethods) { AppendLF(); AppendLineAndLF(method); diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs index 07605072..f4a15b92 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadDispatchDataMethod.cs @@ -81,7 +81,7 @@ partial class IShaderGenerator else if (fieldSymbol.Type.IsUnmanagedType) { // Custom struct type defined by the user - foreach (var fieldInfo in GetCapturedFieldInfos(fieldSymbol.Type, fieldPath.Add(fieldName), resourceOffset, rawDataOffset)) + foreach (FieldInfo fieldInfo in GetCapturedFieldInfos(fieldSymbol.Type, fieldPath.Add(fieldName), resourceOffset, rawDataOffset)) { yield return fieldInfo; } @@ -142,7 +142,7 @@ partial class IShaderGenerator { // For scalar, vector and linear matrix types, serialize the value normally. // Only the initial alignment needs to be considered, while data is packed. - var (fieldSize, fieldPack) = HlslKnownSizes.GetTypeInfo(typeName); + (int fieldSize, int fieldPack) = HlslKnownSizes.GetTypeInfo(typeName); // Check if the current type is a matrix type with more than one row. In this // case, each row is aligned as if it was a separate array, so the start of diff --git a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs index 5f8d6636..59f3eb56 100644 --- a/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs +++ b/src/ComputeSharp.SourceGenerators/Mappings/HlslKnownProperties.cs @@ -72,7 +72,7 @@ partial class HlslKnownProperties PropertyInfo groupindexProperty = typeof(GroupIds).GetProperty(nameof(GroupIds.Index), BindingFlags.Static | BindingFlags.Public); // Programmatically load mappings for the dispatch types - foreach (var item in + foreach ((Type Type, PropertyInfo Property) item in from type in HlslKnownTypes.HlslDispatchTypes from property in type.GetProperties(BindingFlags.Static | BindingFlags.Public) select (Type: type, Property: property)) @@ -90,7 +90,7 @@ partial class HlslKnownProperties } // Programmatically load mappings for the normalized thread ids - foreach (var property in typeof(ThreadIds.Normalized).GetProperties(BindingFlags.Static | BindingFlags.Public)) + 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}"; @@ -127,7 +127,7 @@ partial class HlslKnownProperties } // Programmatically load mappings for the group size - foreach (var property in typeof(GroupSize).GetProperties(BindingFlags.Static | BindingFlags.Public)) + foreach (PropertyInfo? property in typeof(GroupSize).GetProperties(BindingFlags.Static | BindingFlags.Public)) { string key = $"{typeof(GroupSize).FullName}{Type.Delimiter}{property.Name}"; @@ -149,7 +149,7 @@ partial class HlslKnownProperties } // Programmatically load mappings for the dispatch size - foreach (var property in typeof(DispatchSize).GetProperties(BindingFlags.Static | BindingFlags.Public)) + foreach (PropertyInfo? property in typeof(DispatchSize).GetProperties(BindingFlags.Static | BindingFlags.Public)) { string key = $"{typeof(DispatchSize).FullName}{Type.Delimiter}{property.Name}"; diff --git a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs index 3cbea20c..db101d4f 100644 --- a/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/ShaderMethodSourceGenerator.cs @@ -87,10 +87,10 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator Dictionary instanceMethods = new(SymbolEqualityComparer.Default); // Unused in this generator // Explore the syntax tree and extract the processed info - var semanticModel = new SemanticModelProvider(compilation); - var (entryPoint, dependentMethods) = GetProcessedMethods(builder, methodDeclaration, semanticModel, discoveredTypes, constantDefinitions); - var definedTypes = IShaderGenerator.BuildHlslSource.GetDeclaredTypes(builder, methodSymbol, discoveredTypes, instanceMethods); - var definedConstants = IShaderGenerator.BuildHlslSource.GetDefinedConstants(constantDefinitions); + SemanticModelProvider semanticModel = new SemanticModelProvider(compilation); + (string entryPoint, ImmutableArray<(string Signature, string Definition)> dependentMethods) = GetProcessedMethods(builder, methodDeclaration, semanticModel, discoveredTypes, constantDefinitions); + ImmutableArray<(string Name, string Definition)> definedTypes = IShaderGenerator.BuildHlslSource.GetDeclaredTypes(builder, methodSymbol, discoveredTypes, instanceMethods); + ImmutableArray<(string Name, string Value)> definedConstants = IShaderGenerator.BuildHlslSource.GetDefinedConstants(constantDefinitions); diagnostics = builder.ToImmutable(); @@ -140,7 +140,7 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator using ImmutableArrayBuilder<(string, string)> methods = ImmutableArrayBuilder<(string, string)>.Rent(); // Emit the extracted local functions - foreach (var localFunction in shaderSourceRewriter.LocalFunctions) + foreach (KeyValuePair localFunction in shaderSourceRewriter.LocalFunctions) { methods.Add(( localFunction.Value.AsDefinition().NormalizeWhitespace(eol: "\n").ToFullString(), @@ -148,7 +148,7 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator } // Emit the discovered static methods - foreach (var staticMethod in staticMethods.Values) + foreach (MethodDeclarationSyntax staticMethod in staticMethods.Values) { methods.Add(( staticMethod.AsDefinition().NormalizeWhitespace(eol: "\n").ToFullString(), diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs index 9ca6de7f..597869e4 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ExecuteMethodRewriter.cs @@ -35,7 +35,7 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitParameterList(ParameterListSyntax node) { - var updatedNode = (ParameterListSyntax)base.VisitParameterList(node)!; + ParameterListSyntax updatedNode = (ParameterListSyntax)base.VisitParameterList(node)!; updatedNode = updatedNode.AddParameters(Parameter(Identifier($"uint3 {nameof(ThreadIds)} : SV_DispatchThreadID"))); @@ -74,7 +74,7 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitMethodDeclaration(MethodDeclarationSyntax node) { - var updatedNode = ((MethodDeclarationSyntax)base.VisitMethodDeclaration(node)!).WithModifiers(TokenList()); + MethodDeclarationSyntax updatedNode = ((MethodDeclarationSyntax)base.VisitMethodDeclaration(node)!).WithModifiers(TokenList()); // When we're rewriting the main compute shader method, we need to insert a range // check to ensure that invocation outside of the requested range are discarded. @@ -129,7 +129,7 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitReturnStatement(ReturnStatementSyntax node) { - var updatedNode = (ReturnStatementSyntax)base.VisitReturnStatement(node)!; + ReturnStatementSyntax updatedNode = (ReturnStatementSyntax)base.VisitReturnStatement(node)!; // { // __outputTexture[ThreadIds.xy] = ; @@ -154,7 +154,7 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter /// public override SyntaxNode? VisitMethodDeclaration(MethodDeclarationSyntax node) { - var updatedNode = ((MethodDeclarationSyntax)base.VisitMethodDeclaration(node)!).WithModifiers(TokenList()); + MethodDeclarationSyntax updatedNode = ((MethodDeclarationSyntax)base.VisitMethodDeclaration(node)!).WithModifiers(TokenList()); // Change the return type to void updatedNode = updatedNode.WithReturnType(PredefinedType(Token(SyntaxKind.VoidKeyword))); diff --git a/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.Properties.cs b/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.Properties.cs index b0d16c94..35a3d39d 100644 --- a/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.Properties.cs +++ b/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.Properties.cs @@ -72,7 +72,7 @@ partial class AnimatedComputeShaderPanel /// private static void OnShaderRunnerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (AnimatedComputeShaderPanel)d; + AnimatedComputeShaderPanel @this = (AnimatedComputeShaderPanel)d; if (@this.IsLoaded && !@this.IsPaused && @@ -109,8 +109,8 @@ partial class AnimatedComputeShaderPanel /// private static void OnResolutionScalePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (AnimatedComputeShaderPanel)d; - var resolutionScale = (double)e.NewValue; + AnimatedComputeShaderPanel @this = (AnimatedComputeShaderPanel)d; + double resolutionScale = (double)e.NewValue; @this.swapChainManager.QueueResolutionScaleChange(resolutionScale); } @@ -138,8 +138,8 @@ partial class AnimatedComputeShaderPanel /// private static void OnIsDynamicResolutionEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (AnimatedComputeShaderPanel)d; - var isDynamicResolutionEnabled = (bool)e.NewValue; + AnimatedComputeShaderPanel @this = (AnimatedComputeShaderPanel)d; + bool isDynamicResolutionEnabled = (bool)e.NewValue; @this.swapChainManager.QueueDynamicResolutionModeChange(isDynamicResolutionEnabled); } @@ -166,8 +166,8 @@ partial class AnimatedComputeShaderPanel /// private static void OnIsVerticalSyncEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (AnimatedComputeShaderPanel)d; - var isVerticalSyncEnabled = (bool)e.NewValue; + AnimatedComputeShaderPanel @this = (AnimatedComputeShaderPanel)d; + bool isVerticalSyncEnabled = (bool)e.NewValue; @this.swapChainManager.QueueVerticalSyncModeChange(isVerticalSyncEnabled); } @@ -193,7 +193,7 @@ partial class AnimatedComputeShaderPanel /// private static void OnIsPausedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (AnimatedComputeShaderPanel)d; + AnimatedComputeShaderPanel @this = (AnimatedComputeShaderPanel)d; if (@this.IsLoaded && (bool)e.NewValue is false && diff --git a/src/ComputeSharp.UI/Controls/ComputeShaderPanel.Properties.cs b/src/ComputeSharp.UI/Controls/ComputeShaderPanel.Properties.cs index 841fa959..2c5e37f5 100644 --- a/src/ComputeSharp.UI/Controls/ComputeShaderPanel.Properties.cs +++ b/src/ComputeSharp.UI/Controls/ComputeShaderPanel.Properties.cs @@ -72,7 +72,7 @@ partial class ComputeShaderPanel /// private static void OnFrameRequestQueueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (ComputeShaderPanel)d; + ComputeShaderPanel @this = (ComputeShaderPanel)d; if (@this.IsLoaded && e.NewValue is IFrameRequestQueue frameRequestQueue && @@ -107,7 +107,7 @@ partial class ComputeShaderPanel /// private static void OnShaderRunnerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (ComputeShaderPanel)d; + ComputeShaderPanel @this = (ComputeShaderPanel)d; if (@this.IsLoaded && @this.FrameRequestQueue is IFrameRequestQueue frameRequestQueue && @@ -144,8 +144,8 @@ partial class ComputeShaderPanel /// private static void OnResolutionScalePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (ComputeShaderPanel)d; - var resolutionScale = (double)e.NewValue; + ComputeShaderPanel @this = (ComputeShaderPanel)d; + double resolutionScale = (double)e.NewValue; @this.swapChainManager.QueueResolutionScaleChange(resolutionScale); } @@ -173,8 +173,8 @@ partial class ComputeShaderPanel /// private static void OnIsDynamicResolutionEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (ComputeShaderPanel)d; - var isDynamicResolutionEnabled = (bool)e.NewValue; + ComputeShaderPanel @this = (ComputeShaderPanel)d; + bool isDynamicResolutionEnabled = (bool)e.NewValue; @this.swapChainManager.QueueDynamicResolutionModeChange(isDynamicResolutionEnabled); } @@ -201,8 +201,8 @@ partial class ComputeShaderPanel /// private static void OnIsVerticalSyncEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var @this = (ComputeShaderPanel)d; - var isVerticalSyncEnabled = (bool)e.NewValue; + ComputeShaderPanel @this = (ComputeShaderPanel)d; + bool isVerticalSyncEnabled = (bool)e.NewValue; @this.swapChainManager.QueueVerticalSyncModeChange(isVerticalSyncEnabled); } diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs index de92d10d..a0a7eb9b 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.Rendering.cs @@ -34,7 +34,7 @@ partial class SwapChainManager // Here and in the calls below, only get a reference tracking lease when starting a render thread. // This avoids crashes when the panel has been disposed but some code (eg. event handlers) still // ends up calling into any of the APIs in this file, which is not intended but should not crash. - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); this.renderCancellationTokenSource?.Cancel(); @@ -79,7 +79,7 @@ partial class SwapChainManager // If there is a render thread currently running, stop it and restart it if (this.renderCancellationTokenSource?.IsCancellationRequested == false) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); this.renderCancellationTokenSource?.Cancel(); @@ -114,7 +114,7 @@ partial class SwapChainManager if (this.renderCancellationTokenSource?.IsCancellationRequested == false && this.isDynamicResolutionEnabled) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); this.renderCancellationTokenSource?.Cancel(); @@ -187,13 +187,13 @@ partial class SwapChainManager this.dynamicResolutionScale = this.resolutionScale; // These two leases are needed to ensure the manager isn't disposed while rendering is running - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); RenderLoopWithDynamicResolution(); } else { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); RenderLoop(); } diff --git a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs index 722c39c2..351e2244 100644 --- a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs +++ b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs @@ -150,7 +150,7 @@ public static partial class GraphicsDeviceExtensions { Guard.IsNotNull(device); - using var _0 = device.GetReferenceTrackingLease(); + using Interop.NativeObject.Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); diff --git a/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs index 6c01b6fc..40e37268 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs @@ -183,7 +183,7 @@ public static class Texture1DExtensions { Guard.IsNotNull(source); - var (offsetX, width) = x.GetOffsetAndLength(source.Width); + (int offsetX, int width) = x.GetOffsetAndLength(source.Width); source.CopyTo(destination, offsetX, width); } @@ -420,7 +420,7 @@ public static class Texture1DExtensions { Guard.IsNotNull(destination); - var (offsetX, width) = x.GetOffsetAndLength(destination.Width); + (int offsetX, int width) = x.GetOffsetAndLength(destination.Width); destination.CopyFrom(source, offsetX, width); } diff --git a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs index 3605e376..f3015fa5 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs @@ -213,8 +213,8 @@ public static class Texture2DExtensions { Guard.IsNotNull(source); - var (offsetX, width) = x.GetOffsetAndLength(source.Width); - var (offsetY, height) = y.GetOffsetAndLength(source.Height); + (int offsetX, int width) = x.GetOffsetAndLength(source.Width); + (int offsetY, int height) = y.GetOffsetAndLength(source.Height); source.CopyTo(destination, offsetX, offsetY, width, height); } @@ -487,8 +487,8 @@ public static class Texture2DExtensions { Guard.IsNotNull(destination); - var (offsetX, width) = x.GetOffsetAndLength(destination.Width); - var (offsetY, height) = y.GetOffsetAndLength(destination.Height); + (int offsetX, int width) = x.GetOffsetAndLength(destination.Width); + (int offsetY, int height) = y.GetOffsetAndLength(destination.Height); destination.CopyFrom(source, offsetX, offsetY, width, height); } diff --git a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs index e523b440..ade73640 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs @@ -173,9 +173,9 @@ public static class Texture3DExtensions { Guard.IsNotNull(source); - var (offsetX, width) = x.GetOffsetAndLength(source.Width); - var (offsetY, height) = y.GetOffsetAndLength(source.Height); - var (offsetZ, depth) = z.GetOffsetAndLength(source.Depth); + (int offsetX, int width) = x.GetOffsetAndLength(source.Width); + (int offsetY, int height) = y.GetOffsetAndLength(source.Height); + (int offsetZ, int depth) = z.GetOffsetAndLength(source.Depth); source.CopyTo(destination, offsetX, offsetY, offsetZ, width, height, depth); } @@ -472,9 +472,9 @@ public static class Texture3DExtensions { Guard.IsNotNull(destination); - var (offsetX, width) = x.GetOffsetAndLength(destination.Width); - var (offsetY, height) = y.GetOffsetAndLength(destination.Height); - var (offsetZ, depth) = z.GetOffsetAndLength(destination.Depth); + (int offsetX, int width) = x.GetOffsetAndLength(destination.Width); + (int offsetY, int height) = y.GetOffsetAndLength(destination.Height); + (int offsetZ, int depth) = z.GetOffsetAndLength(destination.Depth); destination.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth); } diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs index 4e296619..1251ab04 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs @@ -48,7 +48,7 @@ unsafe partial class GraphicsDevice /// private void QueueRaiseDeviceLostEventIfNeeded() { - using var _0 = TryGetReferenceTrackingLease(out bool leaseTaken); + using Lease _0 = TryGetReferenceTrackingLease(out bool leaseTaken); if (!leaseTaken) { diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.cs index 460e8325..1b33975a 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.cs @@ -164,12 +164,12 @@ public sealed unsafe partial class GraphicsDevice : NativeObject SharedMemorySize = dxgiDescription1->SharedSystemMemory; IsHardwareAccelerated = (dxgiDescription1->Flags & (uint)DXGI_ADAPTER_FLAG_SOFTWARE) == 0; - var d3D12Options1Data = d3D12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1); + D3D12_FEATURE_DATA_D3D12_OPTIONS1 d3D12Options1Data = d3D12Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1); ComputeUnits = d3D12Options1Data.TotalLaneCount; WavefrontSize = d3D12Options1Data.WaveLaneCountMin; - var d3D12Architecture1Data = d3D12Device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1); + D3D12_FEATURE_DATA_ARCHITECTURE1 d3D12Architecture1Data = d3D12Device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1); IsCacheCoherentUMA = d3D12Architecture1Data.CacheCoherentUMA != 0; @@ -252,11 +252,11 @@ public sealed unsafe partial class GraphicsDevice : NativeObject /// Whether the current device supports double precision floating point operations in shaders. public bool IsDoublePrecisionSupportAvailable() { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceLost(); - var d3D12OptionsData = this.d3D12Device.Get()->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS); + D3D12_FEATURE_DATA_D3D12_OPTIONS d3D12OptionsData = this.d3D12Device.Get()->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS); return d3D12OptionsData.DoublePrecisionFloatShaderOps; } @@ -270,7 +270,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject public bool IsReadOnlyTexture1DSupportedForType() where T : unmanaged { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceLost(); @@ -286,7 +286,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject public bool IsReadWriteTexture1DSupportedForType() where T : unmanaged { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceLost(); @@ -304,7 +304,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject public bool IsReadOnlyTexture2DSupportedForType() where T : unmanaged { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceLost(); @@ -320,7 +320,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject public bool IsReadWriteTexture2DSupportedForType() where T : unmanaged { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceLost(); @@ -338,7 +338,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject public bool IsReadOnlyTexture3DSupportedForType() where T : unmanaged { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceLost(); @@ -354,7 +354,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject public bool IsReadWriteTexture3DSupportedForType() where T : unmanaged { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceLost(); diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs index a10cb845..acbfb1a9 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.ID3D12InfoQueue.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; @@ -36,7 +37,7 @@ partial class DeviceHelper { StringBuilder builder = infoQueueMessageBuilder ??= new(1024); - foreach (var pair in D3D12InfoQueueMap) + foreach (KeyValuePair> pair in D3D12InfoQueueMap) { GraphicsDevice device = DevicesCache[pair.Key]; ID3D12InfoQueue* queue = pair.Value.Get(); diff --git a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs index a9afcefb..78800311 100644 --- a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs @@ -67,7 +67,7 @@ public static class GraphicsResourceHelper { Guard.IsNotNull(buffer); - using var _0 = buffer.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = buffer.GetReferenceTrackingLease(); buffer.ThrowIfDeviceMismatch(device); @@ -89,7 +89,7 @@ public static class GraphicsResourceHelper { Guard.IsNotNull(texture); - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.ThrowIfDeviceMismatch(device); @@ -111,7 +111,7 @@ public static class GraphicsResourceHelper { Guard.IsNotNull(texture); - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.ThrowIfDeviceMismatch(device); @@ -202,7 +202,7 @@ public static class GraphicsResourceHelper { Guard.IsNotNull(texture); - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.ThrowIfDeviceMismatch(device); @@ -224,7 +224,7 @@ public static class GraphicsResourceHelper { Guard.IsNotNull(texture); - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.ThrowIfDeviceMismatch(device); @@ -315,7 +315,7 @@ public static class GraphicsResourceHelper { Guard.IsNotNull(texture); - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.ThrowIfDeviceMismatch(device); @@ -337,7 +337,7 @@ public static class GraphicsResourceHelper { Guard.IsNotNull(texture); - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Interop/InteropServices.cs b/src/ComputeSharp/Graphics/Interop/InteropServices.cs index b1fe768c..ecf23531 100644 --- a/src/ComputeSharp/Graphics/Interop/InteropServices.cs +++ b/src/ComputeSharp/Graphics/Interop/InteropServices.cs @@ -34,7 +34,7 @@ public static unsafe class InteropServices /// Thrown if the IUnknown::QueryInterface call doesn't return S_OK. public static void GetID3D12Device(GraphicsDevice device, Guid* riid, void** ppvObject) { - using var _0 = device.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = device.GetReferenceTrackingLease(); device.D3D12Device->QueryInterface(riid, ppvObject).Assert(); } @@ -52,7 +52,7 @@ public static unsafe class InteropServices public static void GetID3D12Resource(Buffer buffer, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = buffer.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = buffer.GetReferenceTrackingLease(); buffer.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); } @@ -70,7 +70,7 @@ public static unsafe class InteropServices public static void GetID3D12Resource(Texture1D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); } @@ -88,7 +88,7 @@ public static unsafe class InteropServices public static void GetID3D12Resource(Texture2D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); } @@ -106,7 +106,7 @@ public static unsafe class InteropServices public static void GetID3D12Resource(Texture3D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); } @@ -124,7 +124,7 @@ public static unsafe class InteropServices public static void GetID3D12Resource(TransferBuffer buffer, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = buffer.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = buffer.GetReferenceTrackingLease(); buffer.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); } @@ -142,7 +142,7 @@ public static unsafe class InteropServices public static void GetID3D12Resource(TransferTexture2D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); } @@ -160,7 +160,7 @@ public static unsafe class InteropServices public static void GetID3D12Resource(TransferTexture3D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); texture.D3D12Resource->QueryInterface(riid, ppvObject).Assert(); } @@ -179,7 +179,7 @@ public static unsafe class InteropServices /// The instance has been disposed. public static int TryGetID3D12Device(GraphicsDevice device, Guid* riid, void** ppvObject) { - using var _0 = device.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = device.GetReferenceTrackingLease(); return device.D3D12Device->QueryInterface(riid, ppvObject); } @@ -200,7 +200,7 @@ public static unsafe class InteropServices public static int TryGetID3D12Resource(Buffer buffer, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = buffer.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = buffer.GetReferenceTrackingLease(); return buffer.D3D12Resource->QueryInterface(riid, ppvObject); } @@ -221,7 +221,7 @@ public static unsafe class InteropServices public static int TryGetID3D12Resource(Texture1D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); return texture.D3D12Resource->QueryInterface(riid, ppvObject); } @@ -242,7 +242,7 @@ public static unsafe class InteropServices public static int TryGetID3D12Resource(Texture2D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); return texture.D3D12Resource->QueryInterface(riid, ppvObject); } @@ -263,7 +263,7 @@ public static unsafe class InteropServices public static int TryGetID3D12Resource(Texture3D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); return texture.D3D12Resource->QueryInterface(riid, ppvObject); } @@ -284,7 +284,7 @@ public static unsafe class InteropServices public static int TryGetID3D12Resource(TransferBuffer buffer, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = buffer.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = buffer.GetReferenceTrackingLease(); return buffer.D3D12Resource->QueryInterface(riid, ppvObject); } @@ -305,7 +305,7 @@ public static unsafe class InteropServices public static int TryGetID3D12Resource(TransferTexture2D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); return texture.D3D12Resource->QueryInterface(riid, ppvObject); } @@ -326,7 +326,7 @@ public static unsafe class InteropServices public static int TryGetID3D12Resource(TransferTexture3D texture, Guid* riid, void** ppvObject) where T : unmanaged { - using var _0 = texture.GetReferenceTrackingLease(); + using NativeObject.Lease _0 = texture.GetReferenceTrackingLease(); return texture.D3D12Resource->QueryInterface(riid, ppvObject); } diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs index 136d7284..21ef2187 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs @@ -76,7 +76,7 @@ public unsafe abstract class Buffer : NativeObject, IGraphicsResource Guard.IsBetweenOrEqualTo(length, 1, (uint.MaxValue / elementSizeInBytes) & ~255); } - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -234,7 +234,7 @@ public unsafe abstract class Buffer : NativeObject, IGraphicsResource /// internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs index 13d07de9..195b607d 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs @@ -38,8 +38,8 @@ public abstract class StructuredBuffer : Buffer Guard.IsInRange(sourceOffset, 0, Length); Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -113,9 +113,9 @@ public abstract class StructuredBuffer : Buffer Guard.IsInRange(destinationOffset, 0, destination.Length); Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -158,9 +158,9 @@ public abstract class StructuredBuffer : Buffer Guard.IsInRange(destinationOffset, 0, destination.Length); Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -199,8 +199,8 @@ public abstract class StructuredBuffer : Buffer Guard.IsInRange(offset, 0, Length); Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -278,9 +278,9 @@ public abstract class StructuredBuffer : Buffer Guard.IsInRange(destinationOffset, 0, Length); Guard.IsLessThanOrEqualTo(destinationOffset + count, Length, nameof(destinationOffset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = source.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = source.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs index 5c902627..6b80e8bf 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs @@ -73,7 +73,7 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra { Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE1D_U_DIMENSION); - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -163,8 +163,8 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX)); Guard.IsGreaterThanOrEqualTo(size, width); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -247,9 +247,9 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX)); Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -307,9 +307,9 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra Guard.IsBetweenOrEqualTo(destinationOffsetX + width, 1, destination.Width, nameof(destinationOffsetX)); Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -361,8 +361,8 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX)); Guard.IsGreaterThanOrEqualTo(size, width); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -443,9 +443,9 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetX + width, source.Width, nameof(sourceOffsetX)); Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = source.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = source.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -532,7 +532,7 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra /// internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceMismatch(device); @@ -571,7 +571,7 @@ public unsafe abstract class Texture1D : NativeObject, IGraphicsResource, Gra /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs index d1b9e5fd..f35263e0 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs @@ -75,7 +75,7 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION); Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION); - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -178,8 +178,8 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY)); Guard.IsGreaterThanOrEqualTo(size, (nint)width * height); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -273,9 +273,9 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX)); Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -342,9 +342,9 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetX + width, Width, nameof(sourceOffsetX)); Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -401,8 +401,8 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY)); Guard.IsGreaterThanOrEqualTo(size, (nint)width * height); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -494,9 +494,9 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(destinationOffsetX + width, Width, nameof(destinationOffsetX)); Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = source.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = source.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -583,7 +583,7 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra /// internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceMismatch(device); @@ -622,7 +622,7 @@ public unsafe abstract class Texture2D : NativeObject, IGraphicsResource, Gra /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs index 65ff0dba..f1829d57 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs @@ -77,7 +77,7 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION); Guard.IsBetweenOrEqualTo(depth, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION); - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -193,8 +193,8 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ)); Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -300,9 +300,9 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY)); Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -378,9 +378,9 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(sourceOffsetY + height, Height, nameof(sourceOffsetY)); Guard.IsLessThanOrEqualTo(sourceOffsetZ + depth, Depth, nameof(sourceOffsetZ)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -442,8 +442,8 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ)); Guard.IsGreaterThanOrEqualTo(size, (nint)width * height * depth); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -547,9 +547,9 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra Guard.IsLessThanOrEqualTo(destinationOffsetY + height, Height, nameof(destinationOffsetY)); Guard.IsLessThanOrEqualTo(destinationOffsetZ + depth, Depth, nameof(destinationOffsetZ)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = source.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = source.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -636,7 +636,7 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra /// internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceMismatch(device); @@ -675,7 +675,7 @@ public unsafe abstract class Texture3D : NativeObject, IGraphicsResource, Gra /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs index 032ac0b3..fbec8370 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs @@ -51,7 +51,7 @@ public abstract unsafe class TransferBuffer : NativeObject, IGraphicsResource // The maximum length is set such that the aligned buffer size can't exceed uint.MaxValue Guard.IsBetweenOrEqualTo(length, 1, (uint.MaxValue / (uint)sizeof(T)) & ~255); - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -104,7 +104,7 @@ public abstract unsafe class TransferBuffer : NativeObject, IGraphicsResource [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); return new MemoryManager(this).Memory; } @@ -116,7 +116,7 @@ public abstract unsafe class TransferBuffer : NativeObject, IGraphicsResource [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); return new(this.mappedData, Length); } @@ -184,7 +184,7 @@ public abstract unsafe class TransferBuffer : NativeObject, IGraphicsResource { Guard.IsEqualTo(elementIndex, 0); - using var _0 = this.buffer.GetReferenceTrackingLease(); + using Lease _0 = this.buffer.GetReferenceTrackingLease(); return new(this.buffer.mappedData); } diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs index c9d8d5f9..b2741cc7 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs @@ -53,7 +53,7 @@ public unsafe abstract class TransferTexture1D : NativeObject, IGraphicsResou { Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE1D_U_DIMENSION); - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -109,7 +109,7 @@ public unsafe abstract class TransferTexture1D : NativeObject, IGraphicsResou [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); return new MemoryManager(this).Memory; } @@ -121,7 +121,7 @@ public unsafe abstract class TransferTexture1D : NativeObject, IGraphicsResou [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - using var _0 = GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); return new(this.mappedData, Width); } @@ -190,7 +190,7 @@ public unsafe abstract class TransferTexture1D : NativeObject, IGraphicsResou { Guard.IsEqualTo(elementIndex, 0); - using var _0 = this.buffer.GetReferenceTrackingLease(); + using Lease _0 = this.buffer.GetReferenceTrackingLease(); return new(this.buffer.mappedData); } diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs index 523e0fd1..121f3f24 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs @@ -53,7 +53,7 @@ public unsafe abstract class TransferTexture2D : NativeObject, IGraphicsResou Guard.IsBetweenOrEqualTo(width, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION); Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION); - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -115,7 +115,7 @@ public unsafe abstract class TransferTexture2D : NativeObject, IGraphicsResou [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - using var _0 = this.GetReferenceTrackingLease(); + using Lease _0 = this.GetReferenceTrackingLease(); return new(this.mappedData, Width, Height, (int)this.d3D12PlacedSubresourceFootprint.Footprint.RowPitch); } diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs index 65f202b4..c9ae6a1d 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs @@ -55,7 +55,7 @@ public unsafe abstract class TransferTexture3D : NativeObject, IGraphicsResou Guard.IsBetweenOrEqualTo(height, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION); Guard.IsBetweenOrEqualTo(depth, 1, D3D12.D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION); - using var _0 = device.GetReferenceTrackingLease(); + using Lease _0 = device.GetReferenceTrackingLease(); device.ThrowIfDeviceLost(); @@ -123,7 +123,7 @@ public unsafe abstract class TransferTexture3D : NativeObject, IGraphicsResou [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - using var _0 = this.GetReferenceTrackingLease(); + using Lease _0 = this.GetReferenceTrackingLease(); return new(this.mappedData, Width, Height, Depth, (int)this.d3D12PlacedSubresourceFootprint.Footprint.RowPitch); } diff --git a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs index 89964af3..ee6d2825 100644 --- a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs @@ -63,8 +63,8 @@ public sealed class ConstantBuffer : Buffer Guard.IsInRange(offset, 0, Length); Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -93,9 +93,9 @@ public sealed class ConstantBuffer : Buffer Guard.IsInRange(destinationOffset, 0, destination.Length); Guard.IsLessThanOrEqualTo(destinationOffset + length, destination.Length, nameof(destinationOffset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); - using var _2 = destination.GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); + using Lease _2 = destination.GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -125,8 +125,8 @@ public sealed class ConstantBuffer : Buffer Guard.IsInRange(offset, 0, Length); Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset)); - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs index 8b23e7b4..5222a611 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs @@ -24,8 +24,8 @@ partial class ReadWriteTexture1D /// internal IReadOnlyNormalizedTexture1D AsReadOnly() { - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -100,8 +100,8 @@ partial class ReadWriteTexture1D /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); @@ -119,7 +119,7 @@ partial class ReadWriteTexture1D { lease = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs index 82469421..5479eead 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs @@ -24,8 +24,8 @@ partial class ReadWriteTexture1D /// public IReadOnlyTexture1D AsReadOnly() { - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -100,8 +100,8 @@ partial class ReadWriteTexture1D /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); @@ -119,7 +119,7 @@ partial class ReadWriteTexture1D { lease = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs index f5ef03dc..d68a5644 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs @@ -24,8 +24,8 @@ partial class ReadWriteTexture2D /// internal IReadOnlyNormalizedTexture2D AsReadOnly() { - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -112,8 +112,8 @@ partial class ReadWriteTexture2D /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); @@ -131,7 +131,7 @@ partial class ReadWriteTexture2D { lease = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs index 485cdc6e..cd28466a 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs @@ -24,8 +24,8 @@ partial class ReadWriteTexture2D /// public IReadOnlyTexture2D AsReadOnly() { - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -112,8 +112,8 @@ partial class ReadWriteTexture2D /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); @@ -131,7 +131,7 @@ partial class ReadWriteTexture2D { lease = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs index 09ca8f60..ac5155e3 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs @@ -24,8 +24,8 @@ partial class ReadWriteTexture3D /// public IReadOnlyNormalizedTexture3D AsReadOnly() { - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -112,8 +112,8 @@ partial class ReadWriteTexture3D /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); @@ -131,7 +131,7 @@ partial class ReadWriteTexture3D { lease = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs index 212cbbd8..c8ad061f 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs @@ -24,8 +24,8 @@ partial class ReadWriteTexture3D /// public IReadOnlyTexture3D AsReadOnly() { - using var _0 = GraphicsDevice.GetReferenceTrackingLease(); - using var _1 = GetReferenceTrackingLease(); + using Lease _0 = GraphicsDevice.GetReferenceTrackingLease(); + using Lease _1 = GetReferenceTrackingLease(); GraphicsDevice.ThrowIfDeviceLost(); @@ -112,8 +112,8 @@ partial class ReadWriteTexture3D /// D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) { - using var _0 = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _0 = GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); @@ -131,7 +131,7 @@ partial class ReadWriteTexture3D { lease = GetReferenceTrackingLease(); - using var _1 = this.owner.GetReferenceTrackingLease(); + using Lease _1 = this.owner.GetReferenceTrackingLease(); this.owner.ThrowIfDeviceMismatch(device); diff --git a/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs b/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs index f1aa8f59..aee0c830 100644 --- a/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs +++ b/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs @@ -191,7 +191,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(buffer); - var handles = buffer.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = buffer.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice); context.Clear(buffer.D3D12Resource, handles.Gpu, handles.Cpu, isNormalized: false); } @@ -207,7 +207,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, isNormalized); } @@ -223,7 +223,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, isNormalized); } @@ -239,7 +239,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out bool isNormalized); context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, isNormalized); } @@ -257,7 +257,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, true); } @@ -275,7 +275,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, true); } @@ -293,7 +293,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); context.Clear(texture.D3D12Resource, handles.Gpu, handles.Cpu, true); } @@ -309,7 +309,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); using NativeObject.Lease lease = default; @@ -327,7 +327,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); using NativeObject.Lease lease = default; @@ -345,7 +345,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); using NativeObject.Lease lease = default; @@ -366,7 +366,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); context.Fill(texture.D3D12Resource, handles.Gpu, handles.Cpu, DXGIFormatHelper.ExtendToNormalizedValue(value.ToPixel())); } @@ -385,7 +385,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); context.Fill(texture.D3D12Resource, handles.Gpu, handles.Cpu, DXGIFormatHelper.ExtendToNormalizedValue(value.ToPixel())); } @@ -404,7 +404,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = texture.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); context.Fill(texture.D3D12Resource, handles.Gpu, handles.Cpu, DXGIFormatHelper.ExtendToNormalizedValue(value.ToPixel())); } @@ -421,7 +421,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); using NativeObject.Lease lease = default; @@ -444,7 +444,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); using NativeObject.Lease lease = default; @@ -467,7 +467,7 @@ public static class ComputeContextExtensions { Guard.IsNotNull(texture); - var handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); + (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _); using NativeObject.Lease lease = default; @@ -583,7 +583,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -600,7 +600,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -617,7 +617,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -634,7 +634,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -655,7 +655,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -672,7 +672,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -689,7 +689,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -706,7 +706,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -723,7 +723,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -744,7 +744,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -761,7 +761,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -778,7 +778,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -795,7 +795,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -812,7 +812,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } @@ -833,7 +833,7 @@ public static class ComputeContextExtensions using NativeObject.Lease lease = default; - var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); + (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource, out Unsafe.AsRef(in lease)); context.Transition(d3D12Resource, states.Before, states.After); } diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs index eae44adb..a2a7abbb 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/BokehBlurEffect.cs @@ -78,9 +78,9 @@ public sealed partial class BokehBlurEffect this.componentsCount = componentsCount; // Reuse the initialized values from the cache, if possible - var parameters = (this.radius, this.componentsCount); + (int radius, int componentsCount) parameters = (this.radius, this.componentsCount); - if (Cache.TryGetValue(parameters, out var info)) + if (Cache.TryGetValue(parameters, out (Vector4[] Parameters, float Scale, (float[] Real, float[] Imaginary)[] Kernels) info)) { this.kernelParameters = info.Parameters; this.kernelsScale = info.Scale; @@ -91,7 +91,7 @@ public sealed partial class BokehBlurEffect // Initialize the complex kernels and parameters with the current arguments (this.kernelParameters, this.kernelsScale) = GetParameters(); - var kernels = CreateComplexKernels(); + Complex64[][] kernels = CreateComplexKernels(); NormalizeKernels(kernels, this.kernelParameters); @@ -177,7 +177,7 @@ public sealed partial class BokehBlurEffect /// private Complex64[][] CreateComplexKernels() { - var kernels = new Complex64[kernelParameters.Length][]; + Complex64[][] kernels = new Complex64[kernelParameters.Length][]; ref Vector4 baseRef = ref MemoryMarshal.GetReference(kernelParameters.AsSpan()); for (int i = 0; i < kernelParameters.Length; i++) @@ -197,7 +197,7 @@ public sealed partial class BokehBlurEffect /// The angle component for each complex component. private Complex64[] CreateComplex1DKernel(float a, float b) { - var kernel = new Complex64[kernelSize]; + Complex64[] kernel = new Complex64[kernelSize]; ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel.AsSpan()); int r = radius; int n = -r; @@ -274,13 +274,13 @@ public sealed partial class BokehBlurEffect /// The input kernels to convert. private static (float[] Real, float[] Imaginary)[] ConvertKernelsToStructureOfArrays(Complex64[][] kernels) { - var structureOfArrayKernels = new (float[] Real, float[] Imaginary)[kernels.Length]; + (float[] Real, float[] Imaginary)[] structureOfArrayKernels = new (float[] Real, float[] Imaginary)[kernels.Length]; for (int i = 0; i < kernels.Length; i++) { Complex64[] kernel = kernels[i]; - var real = new float[kernel.Length]; - var imaginary = new float[kernel.Length]; + float[] real = new float[kernel.Length]; + float[] imaginary = new float[kernel.Length]; for (int j = 0; j < kernel.Length; j++) { diff --git a/tests/ComputeSharp.Pix.NuGet/Program.cs b/tests/ComputeSharp.Pix.NuGet/Program.cs index aa32da46..0d6e690b 100644 --- a/tests/ComputeSharp.Pix.NuGet/Program.cs +++ b/tests/ComputeSharp.Pix.NuGet/Program.cs @@ -15,7 +15,7 @@ float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray(); using ReadWriteBuffer gpuBuffer = GraphicsDevice.GetDefault().AllocateReadWriteBuffer(array); // Run the shader -using (var context = GraphicsDevice.GetDefault().CreateComputeContext()) +using (ComputeContext context = GraphicsDevice.GetDefault().CreateComputeContext()) { context.Log("Dispatching shader"); context.BeginEvent("Dispatching event"); diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs index 2caa1f97..d178b589 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs @@ -62,15 +62,15 @@ public partial class DeviceDisposalTests using (GraphicsDevice graphicsDevice = device.Get()) { - using var r1 = graphicsDevice.AllocateConstantBuffer(128); - using var r2 = graphicsDevice.AllocateReadOnlyBuffer(128); - using var r3 = graphicsDevice.AllocateReadWriteBuffer(128); - using var r4 = graphicsDevice.AllocateReadOnlyTexture2D(128, 128); - using var r5 = graphicsDevice.AllocateReadWriteTexture2D(128, 128); - using var r6 = graphicsDevice.AllocateUploadBuffer(128); - using var r7 = graphicsDevice.AllocateReadBackBuffer(128); - using var r8 = graphicsDevice.AllocateUploadTexture2D(128, 128); - using var r9 = graphicsDevice.AllocateReadBackTexture2D(128, 128); + using ConstantBuffer r1 = graphicsDevice.AllocateConstantBuffer(128); + using ReadOnlyBuffer r2 = graphicsDevice.AllocateReadOnlyBuffer(128); + using ReadWriteBuffer r3 = graphicsDevice.AllocateReadWriteBuffer(128); + using ReadOnlyTexture2D r4 = graphicsDevice.AllocateReadOnlyTexture2D(128, 128); + using ReadWriteTexture2D r5 = graphicsDevice.AllocateReadWriteTexture2D(128, 128); + using UploadBuffer r6 = graphicsDevice.AllocateUploadBuffer(128); + using ReadBackBuffer r7 = graphicsDevice.AllocateReadBackBuffer(128); + using UploadTexture2D r8 = graphicsDevice.AllocateUploadTexture2D(128, 128); + using ReadBackTexture2D r9 = graphicsDevice.AllocateReadBackTexture2D(128, 128); GraphicsDeviceHelper.GetD3D12Device(graphicsDevice, in d3D12Device); } @@ -118,7 +118,7 @@ public partial class DeviceDisposalTests using (GraphicsDevice graphicsDevice = device.Get()) { - using var buffer = graphicsDevice.AllocateReadWriteBuffer(128); + using ReadWriteBuffer buffer = graphicsDevice.AllocateReadWriteBuffer(128); using (ComputeContext context = graphicsDevice.CreateComputeContext()) { @@ -151,7 +151,7 @@ public partial class DeviceDisposalTests using (GraphicsDevice graphicsDevice = device.Get()) { - using var texture = graphicsDevice.AllocateReadWriteTexture2D(128, 128); + using ReadWriteTexture2D texture = graphicsDevice.AllocateReadWriteTexture2D(128, 128); using (ComputeContext context = graphicsDevice.CreateComputeContext()) { diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs index dbef514d..94fadf55 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs @@ -53,7 +53,7 @@ public class DeviceLostTests await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice); - using var _ = graphicsDevice.AllocateBuffer(bufferType, 128); + using Resources.Buffer _ = graphicsDevice.AllocateBuffer(bufferType, 128); } [CombinatorialTestMethod] @@ -67,7 +67,7 @@ public class DeviceLostTests await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice); - using var _ = graphicsDevice.AllocateTexture2D(textureType, 128, 128); + using Resources.Texture2D _ = graphicsDevice.AllocateTexture2D(textureType, 128, 128); } [CombinatorialTestMethod] @@ -81,7 +81,7 @@ public class DeviceLostTests await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice); - using var _ = graphicsDevice.AllocateTexture3D(textureType, 128, 128, 3); + using Resources.Texture3D _ = graphicsDevice.AllocateTexture3D(textureType, 128, 128, 3); } [CombinatorialTestMethod] @@ -153,6 +153,6 @@ public class DeviceLostTests await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice); - using var _ = graphicsDevice.CreateComputeContext(); + using ComputeContext _ = graphicsDevice.CreateComputeContext(); } } \ No newline at end of file diff --git a/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs b/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs index c43fc31a..4c939895 100644 --- a/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs +++ b/tests/ComputeSharp.Tests.Internals/NativeObjectTests.cs @@ -18,7 +18,7 @@ public class NativeObjectTests Assert.IsTrue(obj.IsDisposed); - using var lease0 = obj.TryGetReferenceTrackingLease(out bool leaseTaken); + using NativeObject.Lease lease0 = obj.TryGetReferenceTrackingLease(out bool leaseTaken); Assert.IsFalse(leaseTaken); @@ -30,7 +30,7 @@ public class NativeObjectTests { DisposableObject obj = new(); - var lease0 = obj.GetReferenceTrackingLease(); + NativeObject.Lease lease0 = obj.GetReferenceTrackingLease(); obj.Dispose(); @@ -49,7 +49,7 @@ public class NativeObjectTests { DisposableObject obj = new(); - var lease0 = obj.TryGetReferenceTrackingLease(out bool leaseTaken); + NativeObject.Lease lease0 = obj.TryGetReferenceTrackingLease(out bool leaseTaken); Assert.IsTrue(leaseTaken); @@ -89,7 +89,7 @@ public class NativeObjectTests { for (int j = 0; j < 4; j++) { - using var lease = obj.GetReferenceTrackingLease(); + using NativeObject.Lease lease = obj.GetReferenceTrackingLease(); } }); @@ -118,7 +118,7 @@ public class NativeObjectTests for (int j = 0; j < 4; j++) { - using var lease = obj.TryGetReferenceTrackingLease(out bool leaseTaken); + using NativeObject.Lease lease = obj.TryGetReferenceTrackingLease(out bool leaseTaken); if (isDisposed) { @@ -135,7 +135,7 @@ public class NativeObjectTests { DisposableObject obj = new(); - var outstandingLease = obj.GetReferenceTrackingLease(); + NativeObject.Lease outstandingLease = obj.GetReferenceTrackingLease(); _ = Parallel.For(0, 2048, i => { @@ -150,7 +150,7 @@ public class NativeObjectTests for (int j = 0; j < 4; j++) { - using var lease = obj.TryGetReferenceTrackingLease(out bool leaseTaken); + using NativeObject.Lease lease = obj.TryGetReferenceTrackingLease(out bool leaseTaken); if (isDisposed) { diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index 11e535fd..7410ca3a 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -896,13 +896,13 @@ public partial class ComputeContextTests string imagingPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets"); - using var sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); + using Image sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); using ReadOnlyTexture2D source = device.Get().LoadReadOnlyTexture2D(Path.Combine(imagingPath, "city.jpg")); using ReadWriteTexture2D sourceAsFloat4 = device.Get().AllocateReadWriteTexture2D(source.Width, source.Height); using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(sampled.Width, sampled.Height); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.For(source.Width, source.Height, new ConvertToNonNormalized2DShader(source, sourceAsFloat4)); context.Transition(sourceAsFloat4, ResourceState.ReadOnly); @@ -910,7 +910,7 @@ public partial class ComputeContextTests context.Transition(sourceAsFloat4, ResourceState.ReadWrite); } - using var processed = destination.ToImage(); + using Image processed = destination.ToImage(); TolerantImageComparer.AssertEqual(sampled, processed, 0.00000174f); } @@ -924,19 +924,19 @@ public partial class ComputeContextTests string imagingPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets"); - using var sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); + using Image sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); using ReadWriteTexture2D source = device.Get().LoadReadWriteTexture2D(Path.Combine(imagingPath, "city.jpg")); using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(sampled.Width, sampled.Height); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.Transition(source, ResourceState.ReadOnly); context.ForEach(destination, new LinearSamplingFromNormalized2DPixelShader(source.AsReadOnly())); context.Transition(source, ResourceState.ReadWrite); } - using var processed = destination.ToImage(); + using Image processed = destination.ToImage(); TolerantImageComparer.AssertEqual(sampled, processed, 0.0000017f); } @@ -950,15 +950,15 @@ public partial class ComputeContextTests string imagingPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets"); - using var sampled1 = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); - using var sampled2 = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024SamplingInverted.png")); + using Image sampled1 = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); + using Image sampled2 = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024SamplingInverted.png")); using ReadOnlyTexture2D image = device.Get().LoadReadOnlyTexture2D(Path.Combine(imagingPath, "city.jpg")); using ReadWriteTexture2D source = device.Get().AllocateReadWriteTexture2D(image.Width, image.Height); using ReadWriteTexture2D destination1 = device.Get().AllocateReadWriteTexture2D(sampled1.Width, sampled1.Height); using ReadWriteTexture2D destination2 = device.Get().AllocateReadWriteTexture2D(sampled1.Width, sampled1.Height); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { // Dispatch before any transitions, and UAV barrier test context.ForEach(source); @@ -980,8 +980,8 @@ public partial class ComputeContextTests context.ForEach(destination2, new LinearSamplingFromNormalized2DPixelShader(source.AsReadOnly())); } - using var processed1 = destination1.ToImage(); - using var processed2 = destination2.ToImage(); + using Image processed1 = destination1.ToImage(); + using Image processed2 = destination2.ToImage(); TolerantImageComparer.AssertEqual(sampled1, processed1, 0.0000017f); TolerantImageComparer.AssertEqual(sampled2, processed2, 0.0000028f); @@ -997,9 +997,9 @@ public partial class ComputeContextTests string originalPath = Path.Combine(assetsPath, "CityWith1920x1280Resizing.png"); string sampledPath = Path.Combine(assetsPath, "CityAfter1024x1024SamplingFrom1920x1080.png"); - var imageInfo = Image.Identify(originalPath); + IImageInfo imageInfo = Image.Identify(originalPath); - using var sampled = Image.Load(Path.Combine(assetsPath, sampledPath)); + using Image sampled = Image.Load(Path.Combine(assetsPath, sampledPath)); using ReadWriteTexture3D sourceAsFloat4 = device.Get().AllocateReadWriteTexture3D(imageInfo.Width, imageInfo.Height, 3); @@ -1024,7 +1024,7 @@ public partial class ComputeContextTests using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(sampled.Width, sampled.Height, 2); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.Transition(sourceAsFloat4, ResourceState.ReadOnly); context.For(destination.Width, destination.Height, destination.Depth, new LinearSampling3DComputeShader(sourceAsFloat4.AsReadOnly(), destination)); @@ -1033,7 +1033,7 @@ public partial class ComputeContextTests for (int z = 0; z < destination.Depth; z++) { - using var processed = destination.ToImage(depth: z); + using Image processed = destination.ToImage(depth: z); TolerantImageComparer.AssertEqual(sampled, processed, 0.000012f); } @@ -1049,9 +1049,9 @@ public partial class ComputeContextTests string originalPath = Path.Combine(assetsPath, "CityWith1920x1280Resizing.png"); string sampledPath = Path.Combine(assetsPath, "CityAfter1024x1024SamplingFrom1920x1080.png"); - var imageInfo = Image.Identify(originalPath); + IImageInfo imageInfo = Image.Identify(originalPath); - using var sampled = Image.Load(Path.Combine(assetsPath, sampledPath)); + using Image sampled = Image.Load(Path.Combine(assetsPath, sampledPath)); using ReadWriteTexture3D source = device.Get().AllocateReadWriteTexture3D(imageInfo.Width, imageInfo.Height, 3); @@ -1068,7 +1068,7 @@ public partial class ComputeContextTests using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(sampled.Width, sampled.Height, 2); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.Transition(source, ResourceState.ReadOnly); context.For(destination.Width, destination.Height, destination.Depth, new LinearSamplingFromNormalized3DComputeShader(source.AsReadOnly(), destination)); @@ -1077,7 +1077,7 @@ public partial class ComputeContextTests for (int z = 0; z < destination.Depth; z++) { - using var processed = destination.ToImage(depth: z); + using Image processed = destination.ToImage(depth: z); TolerantImageComparer.AssertEqual(sampled, processed, 0.000012f); } @@ -1092,12 +1092,12 @@ public partial class ComputeContextTests string imagingPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets"); - using var sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024SamplingAndDashing.png")); + using Image sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024SamplingAndDashing.png")); using ReadWriteTexture2D source = device.Get().LoadReadWriteTexture2D(Path.Combine(imagingPath, "city.jpg")); using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(sampled.Width, sampled.Height); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.For(source.Width, source.Height, new Dotted2DPixelShader(source)); context.Transition(source, ResourceState.ReadOnly); @@ -1106,7 +1106,7 @@ public partial class ComputeContextTests context.Fill(source, new Rgba32(0xFF, 0x6A, 0x00, 0x00)); } - using var processed = destination.ToImage(); + using Image processed = destination.ToImage(); TolerantImageComparer.AssertEqual(sampled, processed, 0.0000017f); @@ -1128,9 +1128,9 @@ public partial class ComputeContextTests string originalPath = Path.Combine(assetsPath, "CityWith1920x1280Resizing.png"); string sampledPath = Path.Combine(assetsPath, "CityAfter1024x1024SamplingFrom1920x1080AndDashing.png"); - var imageInfo = Image.Identify(originalPath); + IImageInfo imageInfo = Image.Identify(originalPath); - using var sampled = Image.Load(Path.Combine(assetsPath, sampledPath)); + using Image sampled = Image.Load(Path.Combine(assetsPath, sampledPath)); using ReadWriteTexture3D source = device.Get().AllocateReadWriteTexture3D(imageInfo.Width, imageInfo.Height, 3); @@ -1147,7 +1147,7 @@ public partial class ComputeContextTests using ReadWriteTexture3D destination = device.Get().AllocateReadWriteTexture3D(sampled.Width, sampled.Height, 2); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.For(source.Width, source.Height, source.Depth, new Dotted3DPixelShader(source)); context.Transition(source, ResourceState.ReadOnly); @@ -1158,7 +1158,7 @@ public partial class ComputeContextTests for (int z = 0; z < destination.Depth; z++) { - using var processed = destination.ToImage(depth: z); + using Image processed = destination.ToImage(depth: z); TolerantImageComparer.AssertEqual(sampled, processed, 0.000012f); } diff --git a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs index 21327df0..df76679c 100644 --- a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs +++ b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs @@ -23,8 +23,8 @@ internal static class TolerantImageComparer /// The allowed difference threshold for the normalized delta. public static void AssertEqual(string expectedPath, string actualPath, float threshold) { - using var expected = Image.Load(expectedPath); - using var actual = Image.Load(actualPath); + using Image expected = Image.Load(expectedPath); + using Image actual = Image.Load(actualPath); AssertEqual(expected, actual, threshold); } @@ -55,7 +55,7 @@ internal static class TolerantImageComparer float totalDifference = 0F; - var differences = new List(20); + List differences = new List(20); Span aBuffer = new ImageSharpRgba32[actual.Width]; Span bBuffer = new ImageSharpRgba32[actual.Width]; @@ -84,7 +84,7 @@ internal static class TolerantImageComparer { if (differences.Count < 20) { - var diff = new PixelDifference(new Point(x, y), aBuffer[x], bBuffer[x]); + PixelDifference diff = new PixelDifference(new Point(x, y), aBuffer[x], bBuffer[x]); differences.Add(diff); } @@ -102,7 +102,7 @@ internal static class TolerantImageComparer _ = builder.AppendLine($"The input images don't match. Normalized delta: {normalizedDifference}%"); _ = builder.AppendLine($"First {differences.Count} pixel deltas:"); - foreach (var delta in differences) + foreach (PixelDifference delta in differences) { _ = builder.AppendLine(delta.ToString()); } diff --git a/tests/ComputeSharp.Tests/ImageProcessingTests.cs b/tests/ComputeSharp.Tests/ImageProcessingTests.cs index 097f1218..66f1fcda 100644 --- a/tests/ComputeSharp.Tests/ImageProcessingTests.cs +++ b/tests/ComputeSharp.Tests/ImageProcessingTests.cs @@ -25,12 +25,12 @@ public class ImageProcessingTests string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); - using var original = Image.Load(Path.Combine(path, "city.jpg")); + using Image original = Image.Load(Path.Combine(path, "city.jpg")); original.Mutate(c => c.Resize(1920, 1080)); - using var cpu = original.Clone(c => c.BokehBlur(40, 2, 3)); - using var gpu = original.Clone(c => c.ApplyProcessor(new HlslBokehBlurProcessor(device.Get(), 40, 2))); + using Image cpu = original.Clone(c => c.BokehBlur(40, 2, 3)); + using Image gpu = original.Clone(c => c.ApplyProcessor(new HlslBokehBlurProcessor(device.Get(), 40, 2))); string expectedPath = Path.Combine(path, "city_bokeh_cpu.jpg"); string actualPath = Path.Combine(path, "city_bokeh_gpu.jpg"); @@ -49,12 +49,12 @@ public class ImageProcessingTests string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); - using var original = Image.Load(Path.Combine(path, "city.jpg")); + using Image original = Image.Load(Path.Combine(path, "city.jpg")); original.Mutate(c => c.Resize(1920, 1080)); - using var cpu = original.Clone(c => c.GaussianBlur(30f)); - using var gpu = original.Clone(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(device.Get(), 90))); + using Image cpu = original.Clone(c => c.GaussianBlur(30f)); + using Image gpu = original.Clone(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(device.Get(), 90))); string expectedPath = Path.Combine(path, "city_gaussian_cpu.jpg"); string actualPath = Path.Combine(path, "city_gaussian_gpu.jpg"); diff --git a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs index 81f83ae5..120c215e 100644 --- a/tests/ComputeSharp.Tests/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests/ShaderCompilerTests.cs @@ -3,6 +3,8 @@ using ComputeSharp.Interop; using ComputeSharp.Tests.Misc; using Microsoft.VisualStudio.TestTools.UnitTesting; +#pragma warning disable IDE0008 + namespace ComputeSharp.Tests { [TestClass] diff --git a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs index 82bd79b2..40af7999 100644 --- a/tests/ComputeSharp.Tests/ShaderRewriterTests.cs +++ b/tests/ComputeSharp.Tests/ShaderRewriterTests.cs @@ -4,6 +4,8 @@ using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; +#pragma warning disable IDE0008 + namespace ComputeSharp.Tests; [TestClass] diff --git a/tests/ComputeSharp.Tests/ShadersTests.cs b/tests/ComputeSharp.Tests/ShadersTests.cs index 2432060f..24720ae3 100644 --- a/tests/ComputeSharp.Tests/ShadersTests.cs +++ b/tests/ComputeSharp.Tests/ShadersTests.cs @@ -169,7 +169,7 @@ public class ShadersTests texture.GraphicsDevice.For(texture.Width, texture.Height, (T)Activator.CreateInstance(typeof(T), texture, 0f)!); } - var action = new Action>(RunComputeShader); + Action> action = new Action>(RunComputeShader); _ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture }); } @@ -181,7 +181,7 @@ public class ShadersTests texture.GraphicsDevice.ForEach(texture, (T)Activator.CreateInstance(typeof(T), 0f)!); } - var action = new Action>(RunPixelShader); + Action> action = new Action>(RunPixelShader); _ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture }); } diff --git a/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs index 4091e10f..41a1c2a2 100644 --- a/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture1DTests.Pixels.cs @@ -60,8 +60,8 @@ partial class Texture1DTests string imagingPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets"); - using var original = Image.Load(Path.Combine(imagingPath, "city.jpg")); - using var sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); + using Image original = Image.Load(Path.Combine(imagingPath, "city.jpg")); + using Image sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); if (!original.DangerousTryGetSinglePixelMemory(out Memory originalMemory)) { @@ -82,8 +82,8 @@ partial class Texture1DTests Assert.Inconclusive(); } - using var sampledRow = Image.WrapMemory(sampledMemory.Slice(0, sampled.Width), sampled.Width, 1); - using var processedRow = Image.WrapMemory(processed.AsMemory().Cast(), sampled.Width, 1); + using Image sampledRow = Image.WrapMemory(sampledMemory.Slice(0, sampled.Width), sampled.Width, 1); + using Image processedRow = Image.WrapMemory(processed.AsMemory().Cast(), sampled.Width, 1); TolerantImageComparer.AssertEqual(sampledRow, processedRow, 0.0000017f); } @@ -117,7 +117,7 @@ partial class Texture1DTests { using ReadWriteTexture1D texture = device.Get().AllocateReadWriteTexture1D(64); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.Transition(texture, ResourceState.ReadOnly); diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs index 89a85fde..2c32d10b 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs @@ -59,14 +59,14 @@ partial class Texture2DTests string imagingPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets"); - using var sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); + using Image sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); using ReadOnlyTexture2D source = device.Get().LoadReadOnlyTexture2D(Path.Combine(imagingPath, "city.jpg")); using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(sampled.Width, sampled.Height); device.Get().For(sampled.Width, sampled.Height, new SamplingComputeShader(source, destination)); - using var processed = destination.ToImage(); + using Image processed = destination.ToImage(); TolerantImageComparer.AssertEqual(sampled, processed, 0.0000017f); } @@ -92,14 +92,14 @@ partial class Texture2DTests string imagingPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging"); string assetsPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Assets"); - using var sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); + using Image sampled = Image.Load(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png")); using ReadOnlyTexture2D source = device.Get().LoadReadOnlyTexture2D(Path.Combine(imagingPath, "city.jpg")); using ReadWriteTexture2D destination = device.Get().AllocateReadWriteTexture2D(sampled.Width, sampled.Height); device.Get().ForEach(destination, new SamplingPixelShader(source)); - using var processed = destination.ToImage(); + using Image processed = destination.ToImage(); TolerantImageComparer.AssertEqual(sampled, processed, 0.0000017f); } @@ -132,7 +132,7 @@ partial class Texture2DTests { using ReadWriteTexture2D texture = device.Get().AllocateReadWriteTexture2D(64, 64); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.Transition(texture, ResourceState.ReadOnly); diff --git a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs index 50caca4d..42ff6ee9 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs @@ -64,7 +64,7 @@ partial class Texture3DTests { using ReadWriteTexture3D texture = device.Get().AllocateReadWriteTexture3D(32, 32, 2); - using (var context = device.Get().CreateComputeContext()) + using (ComputeContext context = device.Get().CreateComputeContext()) { context.Transition(texture, ResourceState.ReadOnly); diff --git a/tests/ComputeSharp.Tests/Texture3DTests.cs b/tests/ComputeSharp.Tests/Texture3DTests.cs index ea0f4ceb..2752d1cf 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.cs +++ b/tests/ComputeSharp.Tests/Texture3DTests.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using CommunityToolkit.HighPerformance; +using CommunityToolkit.HighPerformance.Enumerables; using ComputeSharp.Resources; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; @@ -183,7 +184,7 @@ public partial class Texture3DTests fixed (int* p = array) { - foreach (var item in new Span(p, array.Length).Enumerate()) + foreach (SpanEnumerable.Item item in new Span(p, array.Length).Enumerate()) { item.Value = item.Index; }