Use explicit types everywhere

このコミットが含まれているのは:
Sergio Pedri committed 2022-10-15 09:10:18 -07:00
1 親 27c629f3b4
コミット 16c0fc9aab
74ファイル変更
+455 -446

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -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<Image<ImageSharpRgba32>>(source), sourceRectangle);
Implementation processor = new Implementation(this, configuration, Unsafe.As<Image<ImageSharpRgba32>>(source), sourceRectangle);
return Unsafe.As<IImageProcessor<TPixel>>(processor);
}
+6 -5
ファイルの表示
@@ -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
/// </summary>
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
/// <param name="b">The angle component for each complex component.</param>
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<VerticalConvolutionProcessor>(
source.Width,
+1 -1
ファイルの表示
@@ -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<Image<ImageSharpRgba32>>(source), sourceRectangle);
Implementation processor = new Implementation(this, configuration, Unsafe.As<Image<ImageSharpRgba32>>(source), sourceRectangle);
return Unsafe.As<IImageProcessor<TPixel>>(processor);
}
+1 -1
ファイルの表示
@@ -104,7 +104,7 @@ public sealed partial class HlslGaussianBlurProcessor
using ReadWriteTexture2D<Rgba32, float4> firstPassTexture = graphicsDevice.AllocateReadWriteTexture2D<Rgba32, float4>(source.Width, source.Height);
using ReadOnlyBuffer<float> kernelBuffer = graphicsDevice.AllocateReadOnlyBuffer(kernel);
using (var context = graphicsDevice.CreateComputeContext())
using (ComputeContext context = graphicsDevice.CreateComputeContext())
{
context.For<VerticalConvolutionProcessor>(source.Width, source.Height, new(sourceTexture, firstPassTexture, kernelBuffer));
context.Barrier(firstPassTexture);
+1 -1
ファイルの表示
@@ -15,7 +15,7 @@ string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly()
using Image<ImageSharpRgba32> image = Image.Load<ImageSharpRgba32>(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))
+2 -2
ファイルの表示
@@ -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);
}
+2 -2
ファイルの表示
@@ -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 ?? "<NULL>"}\"");
}
@@ -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 ?? "<NULL>"}\"");
}
+1 -1
ファイルの表示
@@ -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;
}
@@ -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<IFieldSymbol>())
foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (fieldSymbol.IsStatic)
{
@@ -205,9 +205,9 @@ partial class ID2D1ShaderGenerator
needsD2D1RequiresScenePosition = false;
foreach (var fieldDeclaration in structDeclaration.Members.OfType<FieldDeclarationSyntax>())
foreach (FieldDeclarationSyntax fieldDeclaration in structDeclaration.Members.OfType<FieldDeclarationSyntax>())
{
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<string, LocalFunctionStatementSyntax> 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<IFieldSymbol, string> 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<INamedTypeSymbol> 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<IFieldSymbol>())
foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>())
{
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<IMethodSymbol, MethodDeclarationSyntax> method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type)))
{
structDeclaration = structDeclaration.AddMembers(method.Value);
}
@@ -453,7 +453,7 @@ partial class ID2D1ShaderGenerator
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
private static void DetectAndReportInvalidPropertyDeclarations(ImmutableArrayBuilder<DiagnosticInfo> 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);
@@ -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
@@ -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<IFieldSymbol>())
foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
// 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).
+1 -1
ファイルの表示
@@ -12,7 +12,7 @@ partial class HlslKnownKeywords
static partial void AddKnownKeywords(ICollection<string> 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<HlslIntrinsicNameAttribute>()?.Name ?? method.Name;
+1 -1
ファイルの表示
@@ -26,7 +26,7 @@ partial class HlslKnownMethods
static partial void AddKnownMethods(IDictionary<string, string> 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
+4 -4
ファイルの表示
@@ -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));
+3 -2
ファイルの表示
@@ -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<HlslIntrinsicNameAttribute>()?.Name ?? method.Name;
+2 -2
ファイルの表示
@@ -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<string, string> knownMethods = new();
// Go through the previously discovered methods to find the ones requiring parameters mapping
foreach (var pair in KnownMethods)
foreach (KeyValuePair<string, string> pair in KnownMethods)
{
// Only process methods marked as requiring parameters mapping
if (pair.Value != nameof(HlslIntrinsicNameAttribute.RequiresParametersMatching))
+1 -1
ファイルの表示
@@ -24,7 +24,7 @@ internal static partial class HlslKnownOperators
Dictionary<string, string> 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_")
+3 -3
ファイルの表示
@@ -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
/// <returns>Whether or not a rank and axis could be resolved by the input indexer name.</returns>
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;
+2 -1
ファイルの表示
@@ -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)
+8 -8
ファイルの表示
@@ -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<IFieldSymbol>())
foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>())
{
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<INamedTypeSymbol> dependencies = new(SymbolEqualityComparer.Default);
// Only add other custom types as dependencies, and ignore HLSL types
foreach (var field in type.GetMembers().OfType<IFieldSymbol>())
foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>())
{
if (field.IsStatic) continue;
@@ -314,13 +314,13 @@ internal static partial class HlslKnownTypes
while (queue.Count > 0)
{
var entry = queue.Dequeue();
(INamedTypeSymbol Type, HashSet<INamedTypeSymbol> 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<INamedTypeSymbol> Fields) pair in queue)
{
_ = pair.Fields.Remove(entry.Type);
}
@@ -11,7 +11,7 @@ partial class HlslSourceRewriter
/// <inheritdoc/>
public override SyntaxNode? VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node)
{
var updatedNode = (AnonymousObjectCreationExpressionSyntax)base.VisitAnonymousObjectCreationExpression(node)!;
AnonymousObjectCreationExpressionSyntax updatedNode = (AnonymousObjectCreationExpressionSyntax)base.VisitAnonymousObjectCreationExpression(node)!;
Diagnostics.Add(AnonymousObjectCreationExpression, node);
+13 -13
ファイルの表示
@@ -68,7 +68,7 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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);
}
+17 -17
ファイルの表示
@@ -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
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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<AttributeListSyntax>());
@@ -278,7 +278,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
{
this.localFunctionDepth++;
var updatedNode =
LocalFunctionStatementSyntax updatedNode =
((LocalFunctionStatementSyntax)base.VisitLocalFunctionStatement(node)!)
.WithBlockBody()
.WithAttributeLists(List<AttributeListSyntax>())
@@ -311,7 +311,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
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));
+5 -5
ファイルの表示
@@ -49,7 +49,7 @@ internal sealed partial class StaticFieldRewriter : HlslSourceRewriter
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public override SyntaxNode? VisitArgument(ArgumentSyntax node)
{
var updatedNode = (ArgumentSyntax)base.VisitArgument(node)!;
ArgumentSyntax updatedNode = (ArgumentSyntax)base.VisitArgument(node)!;
updatedNode = updatedNode.WithRefKindKeyword(Token(SyntaxKind.None));
@@ -154,7 +154,7 @@ partial class IShaderGenerator
prologueStatements++;
// <NAME>.Add("<ITEM>");
foreach (var item in items)
foreach (string item in items)
{
statements.Add(
ExpressionStatement(
+34 -34
ファイルの表示
@@ -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<byte>) });
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<byte>) });
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<string> 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<IFieldSymbol>())
foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
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<FieldDeclarationSyntax>())
foreach (FieldDeclarationSyntax fieldDeclaration in structDeclaration.Members.OfType<FieldDeclarationSyntax>())
{
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<IFieldSymbol>())
foreach (IFieldSymbol fieldSymbol in structDeclarationSymbol.GetMembers().OfType<IFieldSymbol>())
{
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<string, LocalFunctionStatementSyntax> 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<IFieldSymbol, string> 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<INamedTypeSymbol> 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<IFieldSymbol>())
foreach (IFieldSymbol field in type.GetMembers().OfType<IFieldSymbol>())
{
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<IMethodSymbol, MethodDeclarationSyntax> method in instanceMethods.Where(pair => SymbolEqualityComparer.Default.Equals(pair.Key.ContainingType, type)))
{
structDeclaration = structDeclaration.AddMembers(method.Value);
}
@@ -519,7 +519,7 @@ partial class IShaderGenerator
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
private static void DetectAndReportInvalidPropertyDeclarations(ImmutableArrayBuilder<DiagnosticInfo> 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);
+2 -2
ファイルの表示
@@ -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
+4 -4
ファイルの表示
@@ -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}";
+6 -6
ファイルの表示
@@ -87,10 +87,10 @@ public sealed partial class ShaderMethodSourceGenerator : IIncrementalGenerator
Dictionary<IMethodSymbol, MethodDeclarationSyntax> 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<string, LocalFunctionStatementSyntax> 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(),
+4 -4
ファイルの表示
@@ -35,7 +35,7 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter
/// <inheritdoc/>
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
/// <inheritdoc/>
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
/// <inheritdoc/>
public override SyntaxNode? VisitReturnStatement(ReturnStatementSyntax node)
{
var updatedNode = (ReturnStatementSyntax)base.VisitReturnStatement(node)!;
ReturnStatementSyntax updatedNode = (ReturnStatementSyntax)base.VisitReturnStatement(node)!;
// {
// __outputTexture[ThreadIds.xy] = <RETURN_EXPRESSION>;
@@ -154,7 +154,7 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter
/// <inheritdoc/>
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)));
+8 -8
ファイルの表示
@@ -72,7 +72,7 @@ partial class AnimatedComputeShaderPanel
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
private static void OnIsPausedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var @this = (AnimatedComputeShaderPanel)d;
AnimatedComputeShaderPanel @this = (AnimatedComputeShaderPanel)d;
if (@this.IsLoaded &&
(bool)e.NewValue is false &&
+8 -8
ファイルの表示
@@ -72,7 +72,7 @@ partial class ComputeShaderPanel
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
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);
}
+5 -5
ファイルの表示
@@ -34,7 +34,7 @@ partial class SwapChainManager<TOwner>
// 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<TOwner>
// 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<TOwner>
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<TOwner>
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();
}
+1 -1
ファイルの表示
@@ -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();
+2 -2
ファイルの表示
@@ -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);
}
+4 -4
ファイルの表示
@@ -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);
}
+6 -6
ファイルの表示
@@ -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);
}
+1 -1
ファイルの表示
@@ -48,7 +48,7 @@ unsafe partial class GraphicsDevice
/// </summary>
private void QueueRaiseDeviceLostEventIfNeeded()
{
using var _0 = TryGetReferenceTrackingLease(out bool leaseTaken);
using Lease _0 = TryGetReferenceTrackingLease(out bool leaseTaken);
if (!leaseTaken)
{
+10 -10
ファイルの表示
@@ -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_DATA_D3D12_OPTIONS1>(D3D12_FEATURE_D3D12_OPTIONS1);
D3D12_FEATURE_DATA_D3D12_OPTIONS1 d3D12Options1Data = d3D12Device->CheckFeatureSupport<D3D12_FEATURE_DATA_D3D12_OPTIONS1>(D3D12_FEATURE_D3D12_OPTIONS1);
ComputeUnits = d3D12Options1Data.TotalLaneCount;
WavefrontSize = d3D12Options1Data.WaveLaneCountMin;
var d3D12Architecture1Data = d3D12Device->CheckFeatureSupport<D3D12_FEATURE_DATA_ARCHITECTURE1>(D3D12_FEATURE_ARCHITECTURE1);
D3D12_FEATURE_DATA_ARCHITECTURE1 d3D12Architecture1Data = d3D12Device->CheckFeatureSupport<D3D12_FEATURE_DATA_ARCHITECTURE1>(D3D12_FEATURE_ARCHITECTURE1);
IsCacheCoherentUMA = d3D12Architecture1Data.CacheCoherentUMA != 0;
@@ -252,11 +252,11 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
/// <returns>Whether the current device supports double precision floating point operations in shaders.</returns>
public bool IsDoublePrecisionSupportAvailable()
{
using var _0 = GetReferenceTrackingLease();
using Lease _0 = GetReferenceTrackingLease();
ThrowIfDeviceLost();
var d3D12OptionsData = this.d3D12Device.Get()->CheckFeatureSupport<D3D12_FEATURE_DATA_D3D12_OPTIONS>(D3D12_FEATURE_D3D12_OPTIONS);
D3D12_FEATURE_DATA_D3D12_OPTIONS d3D12OptionsData = this.d3D12Device.Get()->CheckFeatureSupport<D3D12_FEATURE_DATA_D3D12_OPTIONS>(D3D12_FEATURE_D3D12_OPTIONS);
return d3D12OptionsData.DoublePrecisionFloatShaderOps;
}
@@ -270,7 +270,7 @@ public sealed unsafe partial class GraphicsDevice : NativeObject
public bool IsReadOnlyTexture1DSupportedForType<T>()
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<T>()
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<T>()
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<T>()
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<T>()
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<T>()
where T : unmanaged
{
using var _0 = GetReferenceTrackingLease();
using Lease _0 = GetReferenceTrackingLease();
ThrowIfDeviceLost();
+2 -1
ファイルの表示
@@ -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<Luid, ComPtr<ID3D12InfoQueue>> pair in D3D12InfoQueueMap)
{
GraphicsDevice device = DevicesCache[pair.Key];
ID3D12InfoQueue* queue = pair.Value.Get();
+7 -7
ファイルの表示
@@ -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);
+16 -16
ファイルの表示
@@ -34,7 +34,7 @@ public static unsafe class InteropServices
/// <exception cref="Win32Exception">Thrown if the <c>IUnknown::QueryInterface</c> call doesn't return <c>S_OK</c>.</exception>
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<T>(Buffer<T> 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<T>(Texture1D<T> 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<T>(Texture2D<T> 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<T>(Texture3D<T> 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<T>(TransferBuffer<T> 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<T>(TransferTexture2D<T> 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<T>(TransferTexture3D<T> 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
/// <exception cref="ObjectDisposedException">The <paramref name="device"/> instance has been disposed.</exception>
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<T>(Buffer<T> 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<T>(Texture1D<T> 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<T>(Texture2D<T> 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<T>(Texture3D<T> 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<T>(TransferBuffer<T> 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<T>(TransferTexture2D<T> 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<T>(TransferTexture3D<T> 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);
}
+2 -2
ファイルの表示
@@ -76,7 +76,7 @@ public unsafe abstract class Buffer<T> : 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<T> : NativeObject, IGraphicsResource
/// <inheritdoc cref="__Internals.GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device)
{
using var _0 = GetReferenceTrackingLease();
using Lease _0 = GetReferenceTrackingLease();
ThrowIfDeviceMismatch(device);
+13 -13
ファイルの表示
@@ -38,8 +38,8 @@ public abstract class StructuredBuffer<T> : Buffer<T>
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<T> : Buffer<T>
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<T> : Buffer<T>
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<T> : Buffer<T>
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<T> : Buffer<T>
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();
+16 -16
ファイルの表示
@@ -73,7 +73,7 @@ public unsafe abstract class Texture1D<T> : 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<T> : 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<T> : 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<T> : 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<T> : 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<T> : 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<T> : NativeObject, IGraphicsResource, Gra
/// <inheritdoc cref="GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
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<T> : NativeObject, IGraphicsResource, Gra
/// <inheritdoc/>
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
{
using var _0 = GetReferenceTrackingLease();
using Lease _0 = GetReferenceTrackingLease();
ThrowIfDeviceMismatch(device);
+16 -16
ファイルの表示
@@ -75,7 +75,7 @@ public unsafe abstract class Texture2D<T> : 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<T> : 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<T> : 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<T> : 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<T> : 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<T> : 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<T> : NativeObject, IGraphicsResource, Gra
/// <inheritdoc cref="GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
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<T> : NativeObject, IGraphicsResource, Gra
/// <inheritdoc/>
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
{
using var _0 = GetReferenceTrackingLease();
using Lease _0 = GetReferenceTrackingLease();
ThrowIfDeviceMismatch(device);
+16 -16
ファイルの表示
@@ -77,7 +77,7 @@ public unsafe abstract class Texture3D<T> : 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<T> : 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<T> : 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<T> : 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<T> : 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<T> : 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<T> : NativeObject, IGraphicsResource, Gra
/// <inheritdoc cref="GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
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<T> : NativeObject, IGraphicsResource, Gra
/// <inheritdoc/>
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IGraphicsResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
{
using var _0 = GetReferenceTrackingLease();
using Lease _0 = GetReferenceTrackingLease();
ThrowIfDeviceMismatch(device);
+4 -4
ファイルの表示
@@ -51,7 +51,7 @@ public abstract unsafe class TransferBuffer<T> : 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<T> : 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<T> : 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<T> : NativeObject, IGraphicsResource
{
Guard.IsEqualTo(elementIndex, 0);
using var _0 = this.buffer.GetReferenceTrackingLease();
using Lease _0 = this.buffer.GetReferenceTrackingLease();
return new(this.buffer.mappedData);
}
+4 -4
ファイルの表示
@@ -53,7 +53,7 @@ public unsafe abstract class TransferTexture1D<T> : 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<T> : 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<T> : 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<T> : NativeObject, IGraphicsResou
{
Guard.IsEqualTo(elementIndex, 0);
using var _0 = this.buffer.GetReferenceTrackingLease();
using Lease _0 = this.buffer.GetReferenceTrackingLease();
return new(this.buffer.mappedData);
}
+2 -2
ファイルの表示
@@ -53,7 +53,7 @@ public unsafe abstract class TransferTexture2D<T> : 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<T> : 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);
}
+2 -2
ファイルの表示
@@ -55,7 +55,7 @@ public unsafe abstract class TransferTexture3D<T> : 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<T> : 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);
}
+7 -7
ファイルの表示
@@ -63,8 +63,8 @@ public sealed class ConstantBuffer<T> : Buffer<T>
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<T> : Buffer<T>
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<T> : Buffer<T>
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();
+5 -5
ファイルの表示
@@ -24,8 +24,8 @@ partial class ReadWriteTexture1D<T, TPixel>
/// <inheritdoc cref="ReadWriteTexture1DExtensions.AsReadOnly{T, TPixel}(ReadWriteTexture1D{T, TPixel})"/>
internal IReadOnlyNormalizedTexture1D<TPixel> 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<T, TPixel>
/// <inheritdoc/>
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<T, TPixel>
{
lease = GetReferenceTrackingLease();
using var _1 = this.owner.GetReferenceTrackingLease();
using Lease _1 = this.owner.GetReferenceTrackingLease();
this.owner.ThrowIfDeviceMismatch(device);
+5 -5
ファイルの表示
@@ -24,8 +24,8 @@ partial class ReadWriteTexture1D<T>
/// <inheritdoc cref="ReadWriteTexture1DExtensions.AsReadOnly(ReadWriteTexture1D{float})"/>
public IReadOnlyTexture1D<T> 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<T>
/// <inheritdoc/>
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<T>
{
lease = GetReferenceTrackingLease();
using var _1 = this.owner.GetReferenceTrackingLease();
using Lease _1 = this.owner.GetReferenceTrackingLease();
this.owner.ThrowIfDeviceMismatch(device);
+5 -5
ファイルの表示
@@ -24,8 +24,8 @@ partial class ReadWriteTexture2D<T, TPixel>
/// <inheritdoc cref="ReadWriteTexture2DExtensions.AsReadOnly{T, TPixel}(ReadWriteTexture2D{T, TPixel})"/>
internal IReadOnlyNormalizedTexture2D<TPixel> 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<T, TPixel>
/// <inheritdoc/>
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<T, TPixel>
{
lease = GetReferenceTrackingLease();
using var _1 = this.owner.GetReferenceTrackingLease();
using Lease _1 = this.owner.GetReferenceTrackingLease();
this.owner.ThrowIfDeviceMismatch(device);
+5 -5
ファイルの表示
@@ -24,8 +24,8 @@ partial class ReadWriteTexture2D<T>
/// <inheritdoc cref="ReadWriteTexture2DExtensions.AsReadOnly(ReadWriteTexture2D{float})"/>
public IReadOnlyTexture2D<T> 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<T>
/// <inheritdoc/>
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<T>
{
lease = GetReferenceTrackingLease();
using var _1 = this.owner.GetReferenceTrackingLease();
using Lease _1 = this.owner.GetReferenceTrackingLease();
this.owner.ThrowIfDeviceMismatch(device);
+5 -5
ファイルの表示
@@ -24,8 +24,8 @@ partial class ReadWriteTexture3D<T, TPixel>
/// <inheritdoc cref="ReadWriteTexture3DExtensions.AsReadOnly{T, TPixel}(ReadWriteTexture3D{T, TPixel})"/>
public IReadOnlyNormalizedTexture3D<TPixel> 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<T, TPixel>
/// <inheritdoc/>
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<T, TPixel>
{
lease = GetReferenceTrackingLease();
using var _1 = this.owner.GetReferenceTrackingLease();
using Lease _1 = this.owner.GetReferenceTrackingLease();
this.owner.ThrowIfDeviceMismatch(device);
+5 -5
ファイルの表示
@@ -24,8 +24,8 @@ partial class ReadWriteTexture3D<T>
/// <inheritdoc cref="ReadWriteTexture3DExtensions.AsReadOnly(ReadWriteTexture3D{float})"/>
public IReadOnlyTexture3D<T> 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<T>
/// <inheritdoc/>
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<T>
{
lease = GetReferenceTrackingLease();
using var _1 = this.owner.GetReferenceTrackingLease();
using Lease _1 = this.owner.GetReferenceTrackingLease();
this.owner.ThrowIfDeviceMismatch(device);
+31 -31
ファイルの表示
@@ -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);
}
+8 -8
ファイルの表示
@@ -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
/// </summary>
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
/// <param name="b">The angle component for each complex component.</param>
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
/// <param name="kernels">The input kernels to convert.</param>
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++)
{
+1 -1
ファイルの表示
@@ -15,7 +15,7 @@ float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray();
using ReadWriteBuffer<float> 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");
+11 -11
ファイルの表示
@@ -62,15 +62,15 @@ public partial class DeviceDisposalTests
using (GraphicsDevice graphicsDevice = device.Get())
{
using var r1 = graphicsDevice.AllocateConstantBuffer<float>(128);
using var r2 = graphicsDevice.AllocateReadOnlyBuffer<float>(128);
using var r3 = graphicsDevice.AllocateReadWriteBuffer<float>(128);
using var r4 = graphicsDevice.AllocateReadOnlyTexture2D<float>(128, 128);
using var r5 = graphicsDevice.AllocateReadWriteTexture2D<float>(128, 128);
using var r6 = graphicsDevice.AllocateUploadBuffer<float>(128);
using var r7 = graphicsDevice.AllocateReadBackBuffer<float>(128);
using var r8 = graphicsDevice.AllocateUploadTexture2D<float>(128, 128);
using var r9 = graphicsDevice.AllocateReadBackTexture2D<float>(128, 128);
using ConstantBuffer<float> r1 = graphicsDevice.AllocateConstantBuffer<float>(128);
using ReadOnlyBuffer<float> r2 = graphicsDevice.AllocateReadOnlyBuffer<float>(128);
using ReadWriteBuffer<float> r3 = graphicsDevice.AllocateReadWriteBuffer<float>(128);
using ReadOnlyTexture2D<float> r4 = graphicsDevice.AllocateReadOnlyTexture2D<float>(128, 128);
using ReadWriteTexture2D<float> r5 = graphicsDevice.AllocateReadWriteTexture2D<float>(128, 128);
using UploadBuffer<float> r6 = graphicsDevice.AllocateUploadBuffer<float>(128);
using ReadBackBuffer<float> r7 = graphicsDevice.AllocateReadBackBuffer<float>(128);
using UploadTexture2D<float> r8 = graphicsDevice.AllocateUploadTexture2D<float>(128, 128);
using ReadBackTexture2D<float> r9 = graphicsDevice.AllocateReadBackTexture2D<float>(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<float>(128);
using ReadWriteBuffer<float> buffer = graphicsDevice.AllocateReadWriteBuffer<float>(128);
using (ComputeContext context = graphicsDevice.CreateComputeContext())
{
@@ -151,7 +151,7 @@ public partial class DeviceDisposalTests
using (GraphicsDevice graphicsDevice = device.Get())
{
using var texture = graphicsDevice.AllocateReadWriteTexture2D<Rgba32, float4>(128, 128);
using ReadWriteTexture2D<Rgba32, float4> texture = graphicsDevice.AllocateReadWriteTexture2D<Rgba32, float4>(128, 128);
using (ComputeContext context = graphicsDevice.CreateComputeContext())
{
+4 -4
ファイルの表示
@@ -53,7 +53,7 @@ public class DeviceLostTests
await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice);
using var _ = graphicsDevice.AllocateBuffer<float>(bufferType, 128);
using Resources.Buffer<float> _ = graphicsDevice.AllocateBuffer<float>(bufferType, 128);
}
[CombinatorialTestMethod]
@@ -67,7 +67,7 @@ public class DeviceLostTests
await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice);
using var _ = graphicsDevice.AllocateTexture2D<float>(textureType, 128, 128);
using Resources.Texture2D<float> _ = graphicsDevice.AllocateTexture2D<float>(textureType, 128, 128);
}
[CombinatorialTestMethod]
@@ -81,7 +81,7 @@ public class DeviceLostTests
await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice);
using var _ = graphicsDevice.AllocateTexture3D<float>(textureType, 128, 128, 3);
using Resources.Texture3D<float> _ = graphicsDevice.AllocateTexture3D<float>(textureType, 128, 128, 3);
}
[CombinatorialTestMethod]
@@ -153,6 +153,6 @@ public class DeviceLostTests
await GraphicsDeviceHelper.RemoveDeviceAsync(graphicsDevice);
using var _ = graphicsDevice.CreateComputeContext();
using ComputeContext _ = graphicsDevice.CreateComputeContext();
}
}
+7 -7
ファイルの表示
@@ -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)
{
+26 -26
ファイルの表示
@@ -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<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using ReadOnlyTexture2D<Rgba32, float4> source = device.Get().LoadReadOnlyTexture2D<Rgba32, float4>(Path.Combine(imagingPath, "city.jpg"));
using ReadWriteTexture2D<float4> sourceAsFloat4 = device.Get().AllocateReadWriteTexture2D<float4>(source.Width, source.Height);
using ReadWriteTexture2D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(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<Rgba32, ImageSharpRgba32>();
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>();
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<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using ReadWriteTexture2D<Rgba32, float4> source = device.Get().LoadReadWriteTexture2D<Rgba32, float4>(Path.Combine(imagingPath, "city.jpg"));
using ReadWriteTexture2D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(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<Rgba32, ImageSharpRgba32>();
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>();
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<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using var sampled2 = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024SamplingInverted.png"));
using Image<ImageSharpRgba32> sampled1 = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using Image<ImageSharpRgba32> sampled2 = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024SamplingInverted.png"));
using ReadOnlyTexture2D<Rgba32, float4> image = device.Get().LoadReadOnlyTexture2D<Rgba32, float4>(Path.Combine(imagingPath, "city.jpg"));
using ReadWriteTexture2D<Rgba32, float4> source = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(image.Width, image.Height);
using ReadWriteTexture2D<Rgba32, float4> destination1 = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(sampled1.Width, sampled1.Height);
using ReadWriteTexture2D<Rgba32, float4> destination2 = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(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<ClearPixelShader, float4>(source);
@@ -980,8 +980,8 @@ public partial class ComputeContextTests
context.ForEach(destination2, new LinearSamplingFromNormalized2DPixelShader(source.AsReadOnly()));
}
using var processed1 = destination1.ToImage<Rgba32, ImageSharpRgba32>();
using var processed2 = destination2.ToImage<Rgba32, ImageSharpRgba32>();
using Image<ImageSharpRgba32> processed1 = destination1.ToImage<Rgba32, ImageSharpRgba32>();
using Image<ImageSharpRgba32> processed2 = destination2.ToImage<Rgba32, ImageSharpRgba32>();
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<ImageSharpRgba32>(Path.Combine(assetsPath, sampledPath));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, sampledPath));
using ReadWriteTexture3D<float4> sourceAsFloat4 = device.Get().AllocateReadWriteTexture3D<float4>(imageInfo.Width, imageInfo.Height, 3);
@@ -1024,7 +1024,7 @@ public partial class ComputeContextTests
using ReadWriteTexture3D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture3D<Rgba32, float4>(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<Rgba32, ImageSharpRgba32>(depth: z);
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>(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<ImageSharpRgba32>(Path.Combine(assetsPath, sampledPath));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, sampledPath));
using ReadWriteTexture3D<Rgba32, float4> source = device.Get().AllocateReadWriteTexture3D<Rgba32, float4>(imageInfo.Width, imageInfo.Height, 3);
@@ -1068,7 +1068,7 @@ public partial class ComputeContextTests
using ReadWriteTexture3D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture3D<Rgba32, float4>(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<Rgba32, ImageSharpRgba32>(depth: z);
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>(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<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024SamplingAndDashing.png"));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024SamplingAndDashing.png"));
using ReadWriteTexture2D<Rgba32, float4> source = device.Get().LoadReadWriteTexture2D<Rgba32, float4>(Path.Combine(imagingPath, "city.jpg"));
using ReadWriteTexture2D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(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<Rgba32, ImageSharpRgba32>();
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>();
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<ImageSharpRgba32>(Path.Combine(assetsPath, sampledPath));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, sampledPath));
using ReadWriteTexture3D<Rgba32, float4> source = device.Get().AllocateReadWriteTexture3D<Rgba32, float4>(imageInfo.Width, imageInfo.Height, 3);
@@ -1147,7 +1147,7 @@ public partial class ComputeContextTests
using ReadWriteTexture3D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture3D<Rgba32, float4>(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<Rgba32, ImageSharpRgba32>(depth: z);
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>(depth: z);
TolerantImageComparer.AssertEqual(sampled, processed, 0.000012f);
}
+5 -5
ファイルの表示
@@ -23,8 +23,8 @@ internal static class TolerantImageComparer
/// <param name="threshold">The allowed difference threshold for the normalized delta.</param>
public static void AssertEqual(string expectedPath, string actualPath, float threshold)
{
using var expected = Image.Load<ImageSharpRgba32>(expectedPath);
using var actual = Image.Load<ImageSharpRgba32>(actualPath);
using Image<ImageSharpRgba32> expected = Image.Load<ImageSharpRgba32>(expectedPath);
using Image<ImageSharpRgba32> actual = Image.Load<ImageSharpRgba32>(actualPath);
AssertEqual(expected, actual, threshold);
}
@@ -55,7 +55,7 @@ internal static class TolerantImageComparer
float totalDifference = 0F;
var differences = new List<PixelDifference>(20);
List<PixelDifference> differences = new List<PixelDifference>(20);
Span<ImageSharpRgba32> aBuffer = new ImageSharpRgba32[actual.Width];
Span<ImageSharpRgba32> 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());
}
+6 -6
ファイルの表示
@@ -25,12 +25,12 @@ public class ImageProcessingTests
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging");
using var original = Image.Load<ImageSharpRgba32>(Path.Combine(path, "city.jpg"));
using Image<ImageSharpRgba32> original = Image.Load<ImageSharpRgba32>(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<ImageSharpRgba32> cpu = original.Clone(c => c.BokehBlur(40, 2, 3));
using Image<ImageSharpRgba32> 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<ImageSharpRgba32>(Path.Combine(path, "city.jpg"));
using Image<ImageSharpRgba32> original = Image.Load<ImageSharpRgba32>(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<ImageSharpRgba32> cpu = original.Clone(c => c.GaussianBlur(30f));
using Image<ImageSharpRgba32> 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");
+2
ファイルの表示
@@ -3,6 +3,8 @@ using ComputeSharp.Interop;
using ComputeSharp.Tests.Misc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#pragma warning disable IDE0008
namespace ComputeSharp.Tests
{
[TestClass]
+2
ファイルの表示
@@ -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]
+2 -2
ファイルの表示
@@ -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<ReadWriteTexture2D<Rgba32, float4>>(RunComputeShader<SwapChain.Shaders.Compute.ColorfulInfinity>);
Action<ReadWriteTexture2D<Rgba32, float4>> action = new Action<ReadWriteTexture2D<Rgba32, float4>>(RunComputeShader<SwapChain.Shaders.Compute.ColorfulInfinity>);
_ = 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<ReadWriteTexture2D<Rgba32, float4>>(RunPixelShader<ColorfulInfinity>);
Action<ReadWriteTexture2D<Rgba32, float4>> action = new Action<ReadWriteTexture2D<Rgba32, float4>>(RunPixelShader<ColorfulInfinity>);
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
}
+5 -5
ファイルの表示
@@ -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<ImageSharpRgba32>(Path.Combine(imagingPath, "city.jpg"));
using var sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using Image<ImageSharpRgba32> original = Image.Load<ImageSharpRgba32>(Path.Combine(imagingPath, "city.jpg"));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
if (!original.DangerousTryGetSinglePixelMemory(out Memory<ImageSharpRgba32> 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<Rgba32, ImageSharpRgba32>(), sampled.Width, 1);
using Image<ImageSharpRgba32> sampledRow = Image.WrapMemory(sampledMemory.Slice(0, sampled.Width), sampled.Width, 1);
using Image<ImageSharpRgba32> processedRow = Image.WrapMemory(processed.AsMemory().Cast<Rgba32, ImageSharpRgba32>(), sampled.Width, 1);
TolerantImageComparer.AssertEqual(sampledRow, processedRow, 0.0000017f);
}
@@ -117,7 +117,7 @@ partial class Texture1DTests
{
using ReadWriteTexture1D<T, TPixel> texture = device.Get().AllocateReadWriteTexture1D<T, TPixel>(64);
using (var context = device.Get().CreateComputeContext())
using (ComputeContext context = device.Get().CreateComputeContext())
{
context.Transition(texture, ResourceState.ReadOnly);
+5 -5
ファイルの表示
@@ -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<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using ReadOnlyTexture2D<Rgba32, float4> source = device.Get().LoadReadOnlyTexture2D<Rgba32, float4>(Path.Combine(imagingPath, "city.jpg"));
using ReadWriteTexture2D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(sampled.Width, sampled.Height);
device.Get().For(sampled.Width, sampled.Height, new SamplingComputeShader(source, destination));
using var processed = destination.ToImage<Rgba32, ImageSharpRgba32>();
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>();
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<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using Image<ImageSharpRgba32> sampled = Image.Load<ImageSharpRgba32>(Path.Combine(assetsPath, "CityAfter1024x1024Sampling.png"));
using ReadOnlyTexture2D<Rgba32, float4> source = device.Get().LoadReadOnlyTexture2D<Rgba32, float4>(Path.Combine(imagingPath, "city.jpg"));
using ReadWriteTexture2D<Rgba32, float4> destination = device.Get().AllocateReadWriteTexture2D<Rgba32, float4>(sampled.Width, sampled.Height);
device.Get().ForEach(destination, new SamplingPixelShader(source));
using var processed = destination.ToImage<Rgba32, ImageSharpRgba32>();
using Image<ImageSharpRgba32> processed = destination.ToImage<Rgba32, ImageSharpRgba32>();
TolerantImageComparer.AssertEqual(sampled, processed, 0.0000017f);
}
@@ -132,7 +132,7 @@ partial class Texture2DTests
{
using ReadWriteTexture2D<T, TPixel> texture = device.Get().AllocateReadWriteTexture2D<T, TPixel>(64, 64);
using (var context = device.Get().CreateComputeContext())
using (ComputeContext context = device.Get().CreateComputeContext())
{
context.Transition(texture, ResourceState.ReadOnly);
+1 -1
ファイルの表示
@@ -64,7 +64,7 @@ partial class Texture3DTests
{
using ReadWriteTexture3D<T, TPixel> texture = device.Get().AllocateReadWriteTexture3D<T, TPixel>(32, 32, 2);
using (var context = device.Get().CreateComputeContext())
using (ComputeContext context = device.Get().CreateComputeContext())
{
context.Transition(texture, ResourceState.ReadOnly);
+2 -1
ファイルの表示
@@ -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<int>(p, array.Length).Enumerate())
foreach (SpanEnumerable<int>.Item item in new Span<int>(p, array.Length).Enumerate())
{
item.Value = item.Index;
}