Use primary constructors in published projects
このコミットが含まれているのは:
1 親
531e3c3b35
コミット
46a6b25756
54ファイル変更
+210
-564
検索条件に一致するファイルはありません
@@ -46,7 +46,7 @@
|
||||
This is used eg. to replace Unsafe.SizeOf<T>() calls with just sizeof(T). The warning is not necessary
|
||||
since in order to use these APIs the caller already has to be in an unsafe context.
|
||||
-->
|
||||
<NoWarn>$(NoWarn);CS8500;IDE0290;IDE0305;IDE0028;IDE0300;IDE0301;IDE0302</NoWarn>
|
||||
<NoWarn>$(NoWarn);CS8500;IDE0305;IDE0028;IDE0300;IDE0301;IDE0302</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Centralized location for all generated artifacts -->
|
||||
|
||||
@@ -184,22 +184,9 @@ public abstract class MissingAttributeCodeFixer : CodeFixProvider
|
||||
/// <summary>
|
||||
/// A custom <see cref="FixAllProvider"/> with the logic from <see cref="MissingAttributeCodeFixer"/>.
|
||||
/// </summary>
|
||||
private sealed class FixAllProvider : DocumentBasedFixAllProvider
|
||||
/// <param name="codeFixer">The owning <see cref="MissingAttributeCodeFixer"/> instance.</param>
|
||||
private sealed class FixAllProvider(MissingAttributeCodeFixer codeFixer) : DocumentBasedFixAllProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="MissingAttributeCodeFixer"/> instance.
|
||||
/// </summary>
|
||||
private readonly MissingAttributeCodeFixer codeFixer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FixAllProvider"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="codeFixer">The owning <see cref="MissingAttributeCodeFixer"/> instance.</param>
|
||||
public FixAllProvider(MissingAttributeCodeFixer codeFixer)
|
||||
{
|
||||
this.codeFixer = codeFixer;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override async Task<Document?> FixAllAsync(FixAllContext fixAllContext, Document document, ImmutableArray<Diagnostic> diagnostics)
|
||||
{
|
||||
@@ -220,7 +207,7 @@ public abstract class MissingAttributeCodeFixer : CodeFixProvider
|
||||
}
|
||||
|
||||
// Get the syntax node with the updated declaration
|
||||
SyntaxNode updatedStructDeclaration = await this.codeFixer.AddMissingAttribute(
|
||||
SyntaxNode updatedStructDeclaration = await codeFixer.AddMissingAttribute(
|
||||
document,
|
||||
structDeclaration,
|
||||
fixAllContext.CancellationToken);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,23 +6,15 @@ namespace ComputeSharp.Core.Intrinsics.Attributes;
|
||||
/// <summary>
|
||||
/// An attribute indicating the native member name of a given HLSL intrinsic.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the HLSL intrinsic.</param>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
[Conditional("SOURCE_GENERATOR")]
|
||||
internal sealed class HlslIntrinsicNameAttribute : Attribute
|
||||
internal sealed class HlslIntrinsicNameAttribute(string name) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="HlslIntrinsicNameAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the HLSL intrinsic.</param>
|
||||
public HlslIntrinsicNameAttribute(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the HLSL intrinsic.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
public string Name => name;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not matching parameters is also required to extract the name of this intrinsic.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma warning disable CS0660, CS0661
|
||||
#pragma warning disable CS0660, CS0661, IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma warning disable CS0660, CS0661
|
||||
#pragma warning disable CS0660, CS0661, IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Numerics;
|
||||
|
||||
#pragma warning disable CS0660, CS0661
|
||||
#pragma warning disable CS0660, CS0661, IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma warning disable CS0660, CS0661
|
||||
#pragma warning disable CS0660, CS0661, IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma warning disable CS0660, CS0661
|
||||
#pragma warning disable CS0660, CS0661, IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
|
||||
@@ -24,20 +24,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// This attribute can also be added to a whole assembly, and will be used by default if not overridden by a shader type.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="options">The compiler options to use to compile the shader.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class D2DCompileOptionsAttribute : Attribute
|
||||
public sealed class D2DCompileOptionsAttribute(D2D1CompileOptions options) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="D2DCompileOptionsAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="options">The compiler options to use to compile the shader.</param>
|
||||
public D2DCompileOptionsAttribute(D2D1CompileOptions options)
|
||||
{
|
||||
Options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of threads in each thread group for the X axis
|
||||
/// </summary>
|
||||
public D2D1CompileOptions Options { get; }
|
||||
public D2D1CompileOptions Options => options;
|
||||
}
|
||||
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
/// <param name="value">The value for the author.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = false)]
|
||||
public sealed class D2DEffectAuthorAttribute : Attribute
|
||||
public sealed class D2DEffectAuthorAttribute(string value) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DEffectAuthorAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="value">The value for the author.</param>
|
||||
public D2DEffectAuthorAttribute(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the author value.
|
||||
/// </summary>
|
||||
public string Value { get; }
|
||||
public string Value => value;
|
||||
}
|
||||
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
/// <param name="value">The value for the category.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = false)]
|
||||
public sealed class D2DEffectCategoryAttribute : Attribute
|
||||
public sealed class D2DEffectCategoryAttribute(string value) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DEffectCategoryAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="value">The value for the category.</param>
|
||||
public D2DEffectCategoryAttribute(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the category value.
|
||||
/// </summary>
|
||||
public string Value { get; }
|
||||
public string Value => value;
|
||||
}
|
||||
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
/// <param name="value">The value for the description.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class D2DEffectDescriptionAttribute : Attribute
|
||||
public sealed class D2DEffectDescriptionAttribute(string value) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DEffectDescriptionAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="value">The value for the description.</param>
|
||||
public D2DEffectDescriptionAttribute(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description value.
|
||||
/// </summary>
|
||||
public string Value { get; }
|
||||
public string Value => value;
|
||||
}
|
||||
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
/// <param name="value">The value for the display name.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class D2DEffectDisplayNameAttribute : Attribute
|
||||
public sealed class D2DEffectDisplayNameAttribute(string value) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DEffectDisplayNameAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="value">The value for the display name.</param>
|
||||
public D2DEffectDisplayNameAttribute(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name value.
|
||||
/// </summary>
|
||||
public string Value { get; }
|
||||
public string Value => value;
|
||||
}
|
||||
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <remarks>
|
||||
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
|
||||
/// </remarks>
|
||||
/// <param name="value">The value for the effect id.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class D2DEffectIdAttribute : Attribute
|
||||
public sealed class D2DEffectIdAttribute(string value) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DEffectIdAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="value">The value for the effect id.</param>
|
||||
public D2DEffectIdAttribute(string value)
|
||||
{
|
||||
Value = Guid.Parse(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the effect id value.
|
||||
/// </summary>
|
||||
public Guid Value { get; }
|
||||
public Guid Value { get; } = Guid.Parse(value);
|
||||
}
|
||||
@@ -10,20 +10,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <para>This attribute directly maps to <c>#define D2D_INPUT<N>_COMPLEX</c>.</para>
|
||||
/// <para>For more info, see <see href="https://docs.microsoft.com/en-us/windows/win32/direct2d/hlsl-helpers"/>.</para>
|
||||
/// </remarks>
|
||||
/// <param name="index">The index of the resource to declare as using complex sampling.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)]
|
||||
public sealed class D2DInputComplexAttribute : Attribute
|
||||
public sealed class D2DInputComplexAttribute(int index) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DInputComplexAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the resource to declare as using complex sampling.</param>
|
||||
public D2DInputComplexAttribute(int index)
|
||||
{
|
||||
Index = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the resource declared as using complex sampling.
|
||||
/// </summary>
|
||||
public int Index { get; }
|
||||
public int Index => index;
|
||||
}
|
||||
@@ -10,20 +10,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <para>This attribute directly maps to <c>#define D2D_INPUT_COUNT <N></c>.</para>
|
||||
/// <para>For more info, see <see href="https://docs.microsoft.com/en-us/windows/win32/direct2d/hlsl-helpers"/>.</para>
|
||||
/// </remarks>
|
||||
/// <param name="count">The number of texture inputs for the shader.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class D2DInputCountAttribute : Attribute
|
||||
public sealed class D2DInputCountAttribute(int count) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DInputCountAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of texture inputs for the shader.</param>
|
||||
public D2DInputCountAttribute(int count)
|
||||
{
|
||||
Count = count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of texture inputs for the shader.
|
||||
/// </summary>
|
||||
public int Count { get; }
|
||||
public int Count => count;
|
||||
}
|
||||
@@ -10,29 +10,20 @@ namespace ComputeSharp.D2D1;
|
||||
/// <para>This attribute exposes the options that can be set via <c>D2D1_INPUT_DESCRIPTION</c>.</para>
|
||||
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/ns-d2d1effectauthor-d2d1_input_description"/>.</para>
|
||||
/// </remarks>
|
||||
/// <param name="index">The index of the resource to declare the description for.</param>
|
||||
/// <param name="filter">The type of filter to apply to the input texture.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)]
|
||||
public sealed class D2DInputDescriptionAttribute : Attribute
|
||||
public sealed class D2DInputDescriptionAttribute(int index, D2D1Filter filter) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DInputDescriptionAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the resource to declare the description for.</param>
|
||||
/// <param name="filter">The type of filter to apply to the input texture.</param>
|
||||
public D2DInputDescriptionAttribute(int index, D2D1Filter filter)
|
||||
{
|
||||
Index = index;
|
||||
Filter = filter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the resource to declare the description for.
|
||||
/// </summary>
|
||||
public int Index { get; }
|
||||
public int Index => index;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of filter to apply to the input texture.
|
||||
/// </summary>
|
||||
public D2D1Filter Filter { get; }
|
||||
public D2D1Filter Filter => filter;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mip level to retrieve from the upstream transform, if specified.
|
||||
|
||||
@@ -10,20 +10,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <para>This attribute directly maps to <c>#define D2D_INPUT<N>_SIMPLE</c>.</para>
|
||||
/// <para>For more info, see <see href="https://docs.microsoft.com/en-us/windows/win32/direct2d/hlsl-helpers"/>.</para>
|
||||
/// </remarks>
|
||||
/// <param name="index">The index of the resource to declare as using simple sampling.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)]
|
||||
public sealed class D2DInputSimpleAttribute : Attribute
|
||||
public sealed class D2DInputSimpleAttribute(int index) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DInputSimpleAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the resource to declare as using simple sampling.</param>
|
||||
public D2DInputSimpleAttribute(int index)
|
||||
{
|
||||
Index = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the resource declared as using simple sampling.
|
||||
/// </summary>
|
||||
public int Index { get; }
|
||||
public int Index => index;
|
||||
}
|
||||
@@ -9,20 +9,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <remarks>
|
||||
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/ne-d2d1effectauthor-d2d1_pixel_options"/>.
|
||||
/// </remarks>
|
||||
/// <param name="options">The options to specify for the shader.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
|
||||
public sealed class D2DPixelOptionsAttribute : Attribute
|
||||
public sealed class D2DPixelOptionsAttribute(D2D1PixelOptions options) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DPixelOptionsAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="options">The options to specify for the shader.</param>
|
||||
public D2DPixelOptionsAttribute(D2D1PixelOptions options)
|
||||
{
|
||||
Options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the options to specify for the shader.
|
||||
/// </summary>
|
||||
public D2D1PixelOptions Options { get; }
|
||||
public D2D1PixelOptions Options => options;
|
||||
}
|
||||
@@ -32,20 +32,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// to further customize the shader profile to use when compiling the HLSL source, and the compile options to use.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="hlslSource">The number of texture inputs for the shader.</param>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class D2DPixelShaderSourceAttribute : Attribute
|
||||
public sealed class D2DPixelShaderSourceAttribute([StringSyntax("Hlsl")] string hlslSource) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DPixelShaderSourceAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="hlslSource">The number of texture inputs for the shader.</param>
|
||||
public D2DPixelShaderSourceAttribute([StringSyntax("Hlsl")] string hlslSource)
|
||||
{
|
||||
HlslSource = hlslSource;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of texture inputs for the shader.
|
||||
/// </summary>
|
||||
public string HlslSource { get; }
|
||||
public string HlslSource => hlslSource;
|
||||
}
|
||||
@@ -9,20 +9,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// <remarks>
|
||||
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/nf-d2d1effectauthor-id2d1drawinfo-setresourcetexture"/>.</para>
|
||||
/// </remarks>
|
||||
/// <param name="index">The index of the annotated resource field.</param>
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
|
||||
public sealed class D2DResourceTextureIndexAttribute : Attribute
|
||||
public sealed class D2DResourceTextureIndexAttribute(int index) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="D2DResourceTextureIndexAttribute"/> type with the specified arguments.
|
||||
/// </summary>
|
||||
/// <param name="index">The index of the annotated resource field.</param>
|
||||
public D2DResourceTextureIndexAttribute(int index)
|
||||
{
|
||||
Index = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the annotated resource field.
|
||||
/// </summary>
|
||||
public int Index { get; }
|
||||
public int Index => index;
|
||||
}
|
||||
@@ -24,20 +24,12 @@ namespace ComputeSharp.D2D1;
|
||||
/// This attribute can also be added to a whole assembly, and will be used by default if not overridden by a shader type.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="shaderProfile">The target shader profile to use to compile the shader.</param>
|
||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class D2DShaderProfileAttribute : Attribute
|
||||
public sealed class D2DShaderProfileAttribute(D2D1ShaderProfile shaderProfile) : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="D2DShaderProfileAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="shaderProfile">The target shader profile to use to compile the shader.</param>
|
||||
public D2DShaderProfileAttribute(D2D1ShaderProfile shaderProfile)
|
||||
{
|
||||
ShaderProfile = shaderProfile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shader profile used to compile the annotated D2D1 pixel shader.
|
||||
/// </summary>
|
||||
public D2D1ShaderProfile ShaderProfile { get; }
|
||||
public D2D1ShaderProfile ShaderProfile => shaderProfile;
|
||||
}
|
||||
@@ -10,7 +10,8 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Buffers;
|
||||
/// <summary>
|
||||
/// Represents a heap-based, array-backed output sink into which binary data can be written.
|
||||
/// </summary>
|
||||
internal ref struct ArrayPoolBinaryWriter
|
||||
/// <param name="capacity">The initial capacity of the writer object.</param>
|
||||
internal ref struct ArrayPoolBinaryWriter(int capacity)
|
||||
{
|
||||
/// <summary>
|
||||
/// The default buffer size to use to expand empty arrays.
|
||||
@@ -20,21 +21,12 @@ internal ref struct ArrayPoolBinaryWriter
|
||||
/// <summary>
|
||||
/// The underlying <see cref="byte"/> array.
|
||||
/// </summary>
|
||||
private byte[]? array;
|
||||
private byte[]? array = ArrayPool<byte>.Shared.Rent(capacity);
|
||||
|
||||
/// <summary>
|
||||
/// The starting offset within <see cref="array"/>.
|
||||
/// </summary>
|
||||
private int index;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ArrayPoolBinaryWriter"/> type.
|
||||
/// </summary>
|
||||
public ArrayPoolBinaryWriter(int capacity)
|
||||
{
|
||||
this.array = ArrayPool<byte>.Shared.Rent(capacity);
|
||||
this.index = 0;
|
||||
}
|
||||
private int index = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data written to the underlying buffer so far, as a <see cref="ReadOnlySpan{T}"/>.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp.D2D1.Interop;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp.D2D1.Interop;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,36 +8,17 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
/// <summary>
|
||||
/// A 64-bit version of the <see cref="Point"/> type.
|
||||
/// </summary>
|
||||
internal readonly struct Point64
|
||||
/// <param name="x">The horizontal coordinate of the point.</param>
|
||||
/// <param name="y">The vertical coordinate of the point.</param>
|
||||
internal readonly struct Point64(long x, long y)
|
||||
{
|
||||
/// <summary>
|
||||
/// The left coordinate of the current point.
|
||||
/// </summary>
|
||||
private readonly long x;
|
||||
|
||||
/// <summary>
|
||||
/// The top coordinate of the current point.
|
||||
/// </summary>
|
||||
private readonly long y;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Point64"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The horizontal coordinate of the point.</param>
|
||||
/// <param name="y">The vertical coordinate of the point.</param>
|
||||
public Point64(long x, long y)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the horizontal coordinate of the current point.
|
||||
/// </summary>
|
||||
public readonly long X
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.x;
|
||||
get => x;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,7 +27,7 @@ internal readonly struct Point64
|
||||
public readonly long Y
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.y;
|
||||
get => y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,7 +58,7 @@ internal readonly struct Point64
|
||||
// [ M21, M22 ]
|
||||
// [ x, y] [ M31, M32 ] = [ x * M11 + y * M21 + M31, x * M12 + y * M22 + m32]
|
||||
return (
|
||||
Math.Round(((double)this.x * matrix.M11) + ((double)this.y * matrix.M21) + matrix.M31),
|
||||
Math.Round(((double)this.x * matrix.M12) + ((double)this.y * matrix.M22) + matrix.M32));
|
||||
Math.Round(((double)x * matrix.M11) + ((double)y * matrix.M21) + matrix.M31),
|
||||
Math.Round(((double)x * matrix.M12) + ((double)y * matrix.M22) + matrix.M32));
|
||||
}
|
||||
}
|
||||
@@ -7,42 +7,21 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Helpers;
|
||||
/// <summary>
|
||||
/// A 64-bit version of the <see cref="Rectangle"/> type.
|
||||
/// </summary>
|
||||
internal struct Rectangle64
|
||||
/// <param name="x">The left coordinate of the rectangle.</param>
|
||||
/// <param name="y">The top coordinate of the rectangle.</param>
|
||||
/// <param name="width">The width of the rectangle.</param>
|
||||
/// <param name="height">The height of the rectangle.</param>
|
||||
internal struct Rectangle64(long x, long y, long width, long height)
|
||||
{
|
||||
/// <summary>
|
||||
/// The left coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
private long x;
|
||||
private long x = x;
|
||||
|
||||
/// <summary>
|
||||
/// The top coordinate of the current rectangle.
|
||||
/// </summary>
|
||||
private long y;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the current rectangle.
|
||||
/// </summary>
|
||||
private long width;
|
||||
|
||||
/// <summary>
|
||||
/// The height of the current rectangle.
|
||||
/// </summary>
|
||||
private long height;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Rectangle64"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="x">The left coordinate of the rectangle.</param>
|
||||
/// <param name="y">The top coordinate of the rectangle.</param>
|
||||
/// <param name="width">The width of the rectangle.</param>
|
||||
/// <param name="height">The height of the rectangle.</param>
|
||||
public Rectangle64(long x, long y, long width, long height)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
private long y = y;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the left coordinate of the current rectangle.
|
||||
@@ -68,7 +47,7 @@ internal struct Rectangle64
|
||||
public readonly long Right
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.x + this.width;
|
||||
get => this.x + width;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,7 +56,7 @@ internal struct Rectangle64
|
||||
public readonly long Bottom
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this.y + this.height;
|
||||
get => this.y + height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,8 +81,9 @@ internal struct Rectangle64
|
||||
|
||||
this.x = left;
|
||||
this.y = top;
|
||||
this.width = right - left;
|
||||
this.height = bottom - top;
|
||||
|
||||
width = right - left;
|
||||
height = bottom - top;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -119,8 +99,9 @@ internal struct Rectangle64
|
||||
|
||||
this.x = left;
|
||||
this.y = top;
|
||||
this.width = Math.Max(right - left, 0);
|
||||
this.height = Math.Max(bottom - top, 0);
|
||||
|
||||
width = Math.Max(right - left, 0);
|
||||
height = Math.Max(bottom - top, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,8 +115,9 @@ internal struct Rectangle64
|
||||
{
|
||||
this.x -= left;
|
||||
this.y -= top;
|
||||
this.width += left + right;
|
||||
this.height += top + bottom;
|
||||
|
||||
width += left + right;
|
||||
height += top + bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -146,7 +128,7 @@ internal struct Rectangle64
|
||||
{
|
||||
Intersect(new Rectangle64(int.MinValue / 2, int.MinValue / 2, int.MaxValue, int.MaxValue));
|
||||
|
||||
return new((int)this.x, (int)this.y, (int)this.width, (int)this.height);
|
||||
return new((int)this.x, (int)this.y, (int)width, (int)height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,27 +6,13 @@ namespace ComputeSharp.SourceGeneration.Helpers;
|
||||
/// <summary>
|
||||
/// A type providing <see cref="SemanticModel"/> instances for nodes.
|
||||
/// </summary>
|
||||
internal sealed class SemanticModelProvider
|
||||
/// <param name="compilation">The source <see cref="Compilation"/> instance.</param>
|
||||
internal sealed class SemanticModelProvider(Compilation compilation)
|
||||
{
|
||||
/// <summary>
|
||||
/// The source <see cref="Compilation"/> instance.
|
||||
/// </summary>
|
||||
private readonly Compilation compilation;
|
||||
|
||||
/// <summary>
|
||||
/// The map of loaded <see cref="SemanticModel"/> instances.
|
||||
/// </summary>
|
||||
private readonly Dictionary<SyntaxTree, SemanticModel> semanticModelsMap;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SemanticModelProvider"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="compilation">The source <see cref="Compilation"/> instance.</param>
|
||||
public SemanticModelProvider(Compilation compilation)
|
||||
{
|
||||
this.compilation = compilation;
|
||||
this.semanticModelsMap = new Dictionary<SyntaxTree, SemanticModel>();
|
||||
}
|
||||
private readonly Dictionary<SyntaxTree, SemanticModel> semanticModelsMap = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="SemanticModel"/> instance with info on a given <see cref="SyntaxNode"/>.
|
||||
@@ -37,7 +23,7 @@ internal sealed class SemanticModelProvider
|
||||
{
|
||||
if (!this.semanticModelsMap.TryGetValue(syntaxNode.SyntaxTree, out SemanticModel semanticModel))
|
||||
{
|
||||
semanticModel = this.compilation.GetSemanticModel(syntaxNode.SyntaxTree);
|
||||
semanticModel = compilation.GetSemanticModel(syntaxNode.SyntaxTree);
|
||||
|
||||
this.semanticModelsMap.Add(syntaxNode.SyntaxTree, semanticModel);
|
||||
}
|
||||
|
||||
@@ -19,24 +19,16 @@ namespace ComputeSharp.SourceGeneration.SyntaxRewriters;
|
||||
/// <summary>
|
||||
/// A custom <see cref="CSharpSyntaxRewriter"/> type that processes C# static field to convert to HLSL static fields (possibly constant).
|
||||
/// </summary>
|
||||
internal sealed partial class StaticFieldRewriter : HlslSourceRewriter
|
||||
/// <param name="semanticModel">The <see cref="SemanticModelProvider"/> instance for the target syntax tree.</param>
|
||||
/// <param name="discoveredTypes">The set of discovered custom types.</param>
|
||||
/// <param name="constantDefinitions">The collection of discovered constant definitions.</param>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
|
||||
internal sealed partial class StaticFieldRewriter(
|
||||
SemanticModelProvider semanticModel,
|
||||
ICollection<INamedTypeSymbol> discoveredTypes,
|
||||
IDictionary<IFieldSymbol, string> constantDefinitions,
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics) : HlslSourceRewriter(semanticModel, discoveredTypes, constantDefinitions, diagnostics)
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="StaticFieldRewriter"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="semanticModel">The <see cref="SemanticModelProvider"/> instance for the target syntax tree.</param>
|
||||
/// <param name="discoveredTypes">The set of discovered custom types.</param>
|
||||
/// <param name="constantDefinitions">The collection of discovered constant definitions.</param>
|
||||
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
|
||||
public StaticFieldRewriter(
|
||||
SemanticModelProvider semanticModel,
|
||||
ICollection<INamedTypeSymbol> discoveredTypes,
|
||||
IDictionary<IFieldSymbol, string> constantDefinitions,
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics)
|
||||
: base(semanticModel, discoveredTypes, constantDefinitions, diagnostics)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="CSharpSyntaxRewriter.Visit(SyntaxNode?)"/>
|
||||
public ExpressionSyntax? Visit(VariableDeclaratorSyntax? node)
|
||||
{
|
||||
|
||||
@@ -148,17 +148,18 @@ internal sealed class DynamicCache<TKey, TValue>
|
||||
/// <summary>
|
||||
/// An entry to use in <see cref="DynamicCache{TKey, TValue}"/>.
|
||||
/// </summary>
|
||||
private sealed class Entry
|
||||
/// <param name="key">The key to use for the entry.</param>
|
||||
private sealed class Entry(TKey key)
|
||||
{
|
||||
/// <summary>
|
||||
/// A weak reference to the actual entry instance.
|
||||
/// </summary>
|
||||
private readonly WeakReference<TKey> reference;
|
||||
private readonly WeakReference<TKey> reference = new(key);
|
||||
|
||||
/// <summary>
|
||||
/// The hashcode of the target key (so it's available even after the key is gone).
|
||||
/// </summary>
|
||||
private readonly int hashCode;
|
||||
private readonly int hashCode = EqualityComparer<TKey>.Default.GetHashCode(key);
|
||||
|
||||
/// <summary>
|
||||
/// The last key matched from <see cref="Equals(object?)"/>, if available.
|
||||
@@ -170,16 +171,6 @@ internal sealed class DynamicCache<TKey, TValue>
|
||||
/// </summary>
|
||||
private bool isPerformingLookup;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Entry"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="key">The key to use for the entry.</param>
|
||||
public Entry(TKey key)
|
||||
{
|
||||
this.reference = new WeakReference<TKey>(key);
|
||||
this.hashCode = EqualityComparer<TKey>.Default.GetHashCode(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the current entry is alive.
|
||||
/// </summary>
|
||||
@@ -265,33 +256,19 @@ internal sealed class DynamicCache<TKey, TValue>
|
||||
/// <summary>
|
||||
/// An object reponsible for removing dead <see cref="Entry"/> instance from the table.
|
||||
/// </summary>
|
||||
private sealed class EntryRemover
|
||||
/// <remarks>
|
||||
/// Creates a new <see cref="EntryRemover"/> instance with the specified parameters.
|
||||
/// </remarks>
|
||||
/// <param name="map"><inheritdoc cref="DynamicCache{TKey, TValue}.map" path="/node()"/></param>
|
||||
/// <param name="entry">The target <see cref="Entry"/> instance to remove from <see cref="map"/>.</param>
|
||||
private sealed class EntryRemover(ConcurrentDictionary<Entry, TValue> map, Entry entry)
|
||||
{
|
||||
/// <inheritdoc cref="DynamicCache{TKey, TValue}.map"/>
|
||||
private readonly ConcurrentDictionary<Entry, TValue> map;
|
||||
|
||||
/// <summary>
|
||||
/// The target <see cref="Entry"/> instance to remove from <see cref="map"/>.
|
||||
/// </summary>
|
||||
private readonly Entry entry;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="EntryRemover"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="map"><inheritdoc cref="DynamicCache{TKey, TValue}.map" path="/node()"/></param>
|
||||
/// <param name="entry"><inheritdoc cref="entry" path="/node()"/></param>
|
||||
public EntryRemover(ConcurrentDictionary<Entry, TValue> map, Entry entry)
|
||||
{
|
||||
this.map = map;
|
||||
this.entry = entry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes <see cref="entry"/> from <see cref="map"/> when the current instance is finalized.
|
||||
/// Removes the target entry from the map when the current instance is finalized.
|
||||
/// </summary>
|
||||
~EntryRemover()
|
||||
{
|
||||
_ = this.map.TryRemove(this.entry, out _);
|
||||
_ = map.TryRemove(entry, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,22 +34,14 @@ internal static class EquatableArray
|
||||
/// An imutable, equatable array. This is equivalent to <see cref="ImmutableArray{T}"/> but with value equality support.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values in the array.</typeparam>
|
||||
internal readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnumerable<T>
|
||||
/// <param name="array">The input <see cref="ImmutableArray{T}"/> to wrap.</param>
|
||||
internal readonly struct EquatableArray<T>(ImmutableArray<T> array) : IEquatable<EquatableArray<T>>, IEnumerable<T>
|
||||
where T : IEquatable<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The underlying <typeparamref name="T"/> array.
|
||||
/// </summary>
|
||||
private readonly T[]? array;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="EquatableArray{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="array">The input <see cref="ImmutableArray{T}"/> to wrap.</param>
|
||||
public EquatableArray(ImmutableArray<T> array)
|
||||
{
|
||||
this.array = Unsafe.As<ImmutableArray<T>, T[]?>(ref array);
|
||||
}
|
||||
private readonly T[]? array = Unsafe.As<ImmutableArray<T>, T[]?>(ref array);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to an item at a specified position within the array.
|
||||
|
||||
@@ -8,6 +8,8 @@ using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
/// <summary>
|
||||
@@ -351,21 +353,13 @@ internal sealed class IndentedTextWriter : IDisposable
|
||||
/// <summary>
|
||||
/// Represents an indented block that needs to be closed.
|
||||
/// </summary>
|
||||
public struct Block : IDisposable
|
||||
/// <param name="writer">The input <see cref="IndentedTextWriter"/> instance to wrap.</param>
|
||||
public struct Block(IndentedTextWriter writer) : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="IndentedTextWriter"/> instance to write to.
|
||||
/// </summary>
|
||||
private IndentedTextWriter? writer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Block"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="writer">The input <see cref="IndentedTextWriter"/> instance to wrap.</param>
|
||||
public Block(IndentedTextWriter writer)
|
||||
{
|
||||
this.writer = writer;
|
||||
}
|
||||
private IndentedTextWriter? writer = writer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
|
||||
@@ -37,19 +37,19 @@ namespace ComputeSharp.SourceGeneration.Helpers;
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of objects to pool.</typeparam>
|
||||
internal sealed class ObjectPool<T>
|
||||
/// <param name="factory">The input factory to produce <typeparamref name="T"/> items.</param>
|
||||
/// <remarks>
|
||||
/// The factory is stored for the lifetime of the pool. We will call this only when pool needs to
|
||||
/// expand. compared to "new T()", Func gives more flexibility to implementers and faster than "new T()".
|
||||
/// </remarks>
|
||||
/// <param name="size">The pool size to use.</param>
|
||||
internal sealed class ObjectPool<T>(Func<T> factory, int size)
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// The factory is stored for the lifetime of the pool. We will call this only when pool needs to
|
||||
/// expand. compared to "new T()", Func gives more flexibility to implementers and faster than "new T()".
|
||||
/// </summary>
|
||||
private readonly Func<T> factory;
|
||||
|
||||
/// <summary>
|
||||
/// The array of cached items.
|
||||
/// </summary>
|
||||
private readonly Element[] items;
|
||||
private readonly Element[] items = new Element[size - 1];
|
||||
|
||||
/// <summary>
|
||||
/// Storage for the pool objects. The first item is stored in a dedicated field
|
||||
@@ -66,17 +66,6 @@ internal sealed class ObjectPool<T>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ObjectPool{T}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="factory">The input factory to produce <typeparamref name="T"/> items.</param>
|
||||
/// <param name="size">The pool size to use.</param>
|
||||
public ObjectPool(Func<T> factory, int size)
|
||||
{
|
||||
this.factory = factory;
|
||||
this.items = new Element[size - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Produces a <typeparamref name="T"/> instance.
|
||||
/// </summary>
|
||||
@@ -131,7 +120,7 @@ internal sealed class ObjectPool<T>
|
||||
}
|
||||
}
|
||||
|
||||
return this.factory();
|
||||
return factory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Dxc;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,21 +9,13 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters;
|
||||
/// <summary>
|
||||
/// A custom <see cref="CSharpSyntaxRewriter"/> type that does postprocessing fixups on the shader main method.
|
||||
/// </summary>
|
||||
internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter
|
||||
/// <param name="shaderSourceRewriter">The <see cref="SourceGeneration.SyntaxRewriters.ShaderSourceRewriter"/> instance used to process the input tree.</param>
|
||||
internal abstract class ExecuteMethodRewriter(ShaderSourceRewriter shaderSourceRewriter) : CSharpSyntaxRewriter
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Compute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="shaderSourceRewriter">The <see cref="ShaderSourceRewriter"/> instance used to process the input tree.</param>
|
||||
public ExecuteMethodRewriter(ShaderSourceRewriter shaderSourceRewriter)
|
||||
{
|
||||
ShaderSourceRewriter = shaderSourceRewriter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="ShaderSourceRewriter"/> instance used to process the input tree.
|
||||
/// </summary>
|
||||
protected ShaderSourceRewriter ShaderSourceRewriter { get; }
|
||||
protected ShaderSourceRewriter ShaderSourceRewriter => shaderSourceRewriter;
|
||||
|
||||
/// <inheritdoc cref="CSharpSyntaxRewriter.Visit(SyntaxNode?)"/>
|
||||
public TNode? Visit<TNode>(TNode? node)
|
||||
@@ -60,17 +52,12 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter
|
||||
/// <summary>
|
||||
/// A custom <see cref="ExecuteMethodRewriter"/> type specialized for compute shaders.
|
||||
/// </summary>
|
||||
public sealed class Compute : ExecuteMethodRewriter
|
||||
/// <remarks>
|
||||
/// Creates a new <see cref="Compute"/> instance with the specified parameters.
|
||||
/// </remarks>
|
||||
/// <param name="shaderSourceRewriter">The <see cref="SourceGeneration.SyntaxRewriters.ShaderSourceRewriter"/> instance used to process the input tree.</param>
|
||||
public sealed class Compute(ShaderSourceRewriter shaderSourceRewriter) : ExecuteMethodRewriter(shaderSourceRewriter)
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Compute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="shaderSourceRewriter">The <see cref="ShaderSourceRewriter"/> instance used to process the input tree.</param>
|
||||
public Compute(ShaderSourceRewriter shaderSourceRewriter)
|
||||
: base(shaderSourceRewriter)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitMethodDeclaration(MethodDeclarationSyntax node)
|
||||
{
|
||||
@@ -115,17 +102,9 @@ internal abstract class ExecuteMethodRewriter : CSharpSyntaxRewriter
|
||||
/// <summary>
|
||||
/// A custom <see cref="ExecuteMethodRewriter"/> type specialized for compute shaders.
|
||||
/// </summary>
|
||||
public sealed class Pixel : ExecuteMethodRewriter
|
||||
/// <param name="shaderSourceRewriter">The <see cref="SourceGeneration.SyntaxRewriters.ShaderSourceRewriter"/> instance used to process the input tree.</param>
|
||||
public sealed class Pixel(ShaderSourceRewriter shaderSourceRewriter) : ExecuteMethodRewriter(shaderSourceRewriter)
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Pixel"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="shaderSourceRewriter">The <see cref="ShaderSourceRewriter"/> instance used to process the input tree.</param>
|
||||
public Pixel(ShaderSourceRewriter shaderSourceRewriter)
|
||||
: base(shaderSourceRewriter)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override SyntaxNode? VisitReturnStatement(ReturnStatementSyntax node)
|
||||
{
|
||||
|
||||
@@ -38,4 +38,5 @@ dotnet_diagnostic.IDE0060.severity = none
|
||||
dotnet_diagnostic.IDE0090.severity = none
|
||||
dotnet_diagnostic.IDE0160.severity = none
|
||||
dotnet_diagnostic.IDE0180.severity = none
|
||||
dotnet_diagnostic.IDE0290.severity = none
|
||||
dotnet_diagnostic.IDE1006.severity = none
|
||||
@@ -38,4 +38,5 @@ dotnet_diagnostic.IDE0060.severity = none
|
||||
dotnet_diagnostic.IDE0090.severity = none
|
||||
dotnet_diagnostic.IDE0160.severity = none
|
||||
dotnet_diagnostic.IDE0180.severity = none
|
||||
dotnet_diagnostic.IDE0290.severity = none
|
||||
dotnet_diagnostic.IDE1006.severity = none
|
||||
@@ -3,7 +3,7 @@ using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
#pragma warning disable CS0618, IDE0290
|
||||
|
||||
namespace ComputeSharp.WinUI.Extensions;
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,8 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,8 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,8 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,27 +10,13 @@ namespace ComputeSharp.Graphics.Commands.Interop;
|
||||
/// <summary>
|
||||
/// A type that acts as a pool to get new <see cref="ID3D12CommandList"/> instances wheen needed.
|
||||
/// </summary>
|
||||
internal readonly unsafe struct ID3D12CommandListPool : IDisposable
|
||||
/// <param name="d3D12CommandListType">The command list type to use.</param>
|
||||
internal readonly unsafe struct ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE d3D12CommandListType) : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The command list type being used by the current instance.
|
||||
/// </summary>
|
||||
private readonly D3D12_COMMAND_LIST_TYPE d3D12CommandListType;
|
||||
|
||||
/// <summary>
|
||||
/// The queue of <see cref="D3D12CommandListBundle"/> items with the available command lists.
|
||||
/// </summary>
|
||||
private readonly Queue<D3D12CommandListBundle> d3D12CommandListBundleQueue;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ID3D12CommandListPool"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="d3D12CommandListType">The command list type to use.</param>
|
||||
public ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE d3D12CommandListType)
|
||||
{
|
||||
this.d3D12CommandListType = d3D12CommandListType;
|
||||
this.d3D12CommandListBundleQueue = new Queue<D3D12CommandListBundle>();
|
||||
}
|
||||
private readonly Queue<D3D12CommandListBundle> d3D12CommandListBundleQueue = new();
|
||||
|
||||
/// <summary>
|
||||
/// Rents a <see cref="ID3D12GraphicsCommandList"/> and <see cref="ID3D12CommandAllocator"/> pair.
|
||||
@@ -107,8 +93,8 @@ internal readonly unsafe struct ID3D12CommandListPool : IDisposable
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void CreateCommandListAndAllocator(ID3D12Device* d3D12Device, ID3D12PipelineState* d3D12PipelineState, out ID3D12GraphicsCommandList* d3D12CommandList, out ID3D12CommandAllocator* d3D12CommandAllocator)
|
||||
{
|
||||
using ComPtr<ID3D12CommandAllocator> d3D12CommandAllocatorComPtr = d3D12Device->CreateCommandAllocator(this.d3D12CommandListType);
|
||||
using ComPtr<ID3D12GraphicsCommandList> d3D12CommandListComPtr = d3D12Device->CreateCommandList(this.d3D12CommandListType, d3D12CommandAllocatorComPtr.Get(), d3D12PipelineState);
|
||||
using ComPtr<ID3D12CommandAllocator> d3D12CommandAllocatorComPtr = d3D12Device->CreateCommandAllocator(d3D12CommandListType);
|
||||
using ComPtr<ID3D12GraphicsCommandList> d3D12CommandListComPtr = d3D12Device->CreateCommandList(d3D12CommandListType, d3D12CommandAllocatorComPtr.Get(), d3D12PipelineState);
|
||||
|
||||
fixed (ID3D12GraphicsCommandList** d3D12CommandListPtr = &d3D12CommandList)
|
||||
fixed (ID3D12CommandAllocator** d3D12CommandAllocatorPtr = &d3D12CommandAllocator)
|
||||
@@ -121,27 +107,18 @@ internal readonly unsafe struct ID3D12CommandListPool : IDisposable
|
||||
/// <summary>
|
||||
/// A type representing a bundle of a cached command list and related allocator.
|
||||
/// </summary>
|
||||
private readonly struct D3D12CommandListBundle
|
||||
/// <param name="d3D12CommandList">The <see cref="ID3D12GraphicsCommandList"/> value to wrap.</param>
|
||||
/// <param name="d3D12CommandAllocator">The <see cref="ID3D12CommandAllocator"/> value to wrap.</param>
|
||||
private readonly struct D3D12CommandListBundle(ID3D12GraphicsCommandList* d3D12CommandList, ID3D12CommandAllocator* d3D12CommandAllocator)
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12GraphicsCommandList"/> value for the current entry.
|
||||
/// </summary>
|
||||
public readonly ID3D12GraphicsCommandList* D3D12CommandList;
|
||||
public readonly ID3D12GraphicsCommandList* D3D12CommandList = d3D12CommandList;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12CommandAllocator"/> value for the current entry.
|
||||
/// </summary>
|
||||
public readonly ID3D12CommandAllocator* D3D12CommandAllocator;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="D3D12CommandListBundle"/> instance with the given parameters.
|
||||
/// </summary>
|
||||
/// <param name="d3D12CommandList">The <see cref="ID3D12GraphicsCommandList"/> value to wrap.</param>
|
||||
/// <param name="d3D12CommandAllocator">The <see cref="ID3D12CommandAllocator"/> value to wrap.</param>
|
||||
public D3D12CommandListBundle(ID3D12GraphicsCommandList* d3D12CommandList, ID3D12CommandAllocator* d3D12CommandAllocator)
|
||||
{
|
||||
this.D3D12CommandList = d3D12CommandList;
|
||||
this.D3D12CommandAllocator = d3D12CommandAllocator;
|
||||
}
|
||||
public readonly ID3D12CommandAllocator* D3D12CommandAllocator = d3D12CommandAllocator;
|
||||
}
|
||||
}
|
||||
@@ -5,36 +5,26 @@ namespace ComputeSharp.Graphics.Commands.Interop;
|
||||
/// <summary>
|
||||
/// A type representing a bundle of reusable resource descriptor handles.
|
||||
/// </summary>
|
||||
internal readonly struct ID3D12ResourceDescriptorHandles
|
||||
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
/// <param name="d3D12GpuDescriptorHandle">The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
/// <param name="d3D12CpuDescriptorHandleNonShaderVisible">The non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
internal readonly struct ID3D12ResourceDescriptorHandles(
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible)
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value for the current entry.
|
||||
/// </summary>
|
||||
public readonly D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandle;
|
||||
public readonly D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandle = d3D12CpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value for the current entry.
|
||||
/// </summary>
|
||||
public readonly D3D12_GPU_DESCRIPTOR_HANDLE D3D12GpuDescriptorHandle;
|
||||
public readonly D3D12_GPU_DESCRIPTOR_HANDLE D3D12GpuDescriptorHandle = d3D12GpuDescriptorHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value for the current entry, non shader visible.
|
||||
/// </summary>
|
||||
public readonly D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandleNonShaderVisible;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ID3D12ResourceDescriptorHandles"/> instance with the given parameters.
|
||||
/// </summary>
|
||||
/// <param name="d3D12CpuDescriptorHandle">The <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
/// <param name="d3D12GpuDescriptorHandle">The <see cref="D3D12_GPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
/// <param name="d3D12CpuDescriptorHandleNonShaderVisible">The non shader visible <see cref="D3D12_CPU_DESCRIPTOR_HANDLE"/> value to wrap.</param>
|
||||
public ID3D12ResourceDescriptorHandles(
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandle,
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle,
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE d3D12CpuDescriptorHandleNonShaderVisible)
|
||||
{
|
||||
this.D3D12CpuDescriptorHandle = d3D12CpuDescriptorHandle;
|
||||
this.D3D12GpuDescriptorHandle = d3D12GpuDescriptorHandle;
|
||||
this.D3D12CpuDescriptorHandleNonShaderVisible = d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
}
|
||||
public readonly D3D12_CPU_DESCRIPTOR_HANDLE D3D12CpuDescriptorHandleNonShaderVisible = d3D12CpuDescriptorHandleNonShaderVisible;
|
||||
}
|
||||
@@ -19,21 +19,13 @@ partial class DeviceHelper
|
||||
/// <summary>
|
||||
/// A custom query type that iterates through devices matching a given predicate.
|
||||
/// </summary>
|
||||
public sealed unsafe class DeviceQuery : IEnumerable<GraphicsDevice>
|
||||
/// <param name="predicate">The input predicate to select devices to create.</param>
|
||||
public sealed unsafe class DeviceQuery(Predicate<GraphicsDeviceInfo>? predicate) : IEnumerable<GraphicsDevice>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Predicate{T}"/> instance to use to select devices to create.
|
||||
/// </summary>
|
||||
private readonly Predicate<GraphicsDeviceInfo>? predicate;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Enumerator"/> instance for the given predicate.
|
||||
/// </summary>
|
||||
/// <param name="predicate">The input predicate to select devices to create.</param>
|
||||
public DeviceQuery(Predicate<GraphicsDeviceInfo>? predicate)
|
||||
{
|
||||
this.predicate = predicate;
|
||||
}
|
||||
private readonly Predicate<GraphicsDeviceInfo>? predicate = predicate;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerator<GraphicsDevice> GetEnumerator()
|
||||
@@ -50,12 +42,13 @@ partial class DeviceHelper
|
||||
/// <summary>
|
||||
/// The enumerator type for a <see cref="DeviceQuery"/> instance.
|
||||
/// </summary>
|
||||
private sealed unsafe class Enumerator : ReferenceTrackedObject, IEnumerator<GraphicsDevice>
|
||||
/// <param name="predicate">The input predicate to select devices to create.</param>
|
||||
private sealed unsafe class Enumerator(Predicate<GraphicsDeviceInfo>? predicate) : ReferenceTrackedObject, IEnumerator<GraphicsDevice>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Predicate{T}"/> instance to use to select devices to create, if present.
|
||||
/// </summary>
|
||||
private readonly Predicate<GraphicsDeviceInfo>? predicate;
|
||||
private readonly Predicate<GraphicsDeviceInfo>? predicate = predicate;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IDXGIFactory6"/> instance used to enumerate devices.
|
||||
@@ -82,15 +75,6 @@ partial class DeviceHelper
|
||||
/// </summary>
|
||||
private GraphicsDevice? graphicsDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="Enumerator"/> instance for the given predicate.
|
||||
/// </summary>
|
||||
/// <param name="predicate">The input predicate to select devices to create.</param>
|
||||
public Enumerator(Predicate<GraphicsDeviceInfo>? predicate)
|
||||
{
|
||||
this.predicate = predicate;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public GraphicsDevice Current => this.graphicsDevice!;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace ComputeSharp.Interop;
|
||||
#pragma warning disable CS0618, IDE0290
|
||||
|
||||
#pragma warning disable CS0618
|
||||
namespace ComputeSharp.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// An object acting as reference tracked for a given managed object.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable IDE0290
|
||||
|
||||
namespace ComputeSharp.Interop;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,7 +10,7 @@ using ComputeSharp.Win32;
|
||||
using static ComputeSharp.Win32.D3D12_FEATURE;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
|
||||
#pragma warning disable CA1063
|
||||
#pragma warning disable CA1063, CA2213
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
@@ -147,21 +147,13 @@ public abstract unsafe partial class TransferBuffer<T> : IReferenceTrackedObject
|
||||
/// <summary>
|
||||
/// A <see cref="MemoryManager{T}"/> implementation wrapping a <see cref="TransferBuffer{T}"/> instance.
|
||||
/// </summary>
|
||||
private sealed class MemoryManager : MemoryManager<T>
|
||||
/// <param name="buffer">The <see cref="TransferBuffer{T}"/> in use.</param>
|
||||
private sealed class MemoryManager(TransferBuffer<T> buffer) : MemoryManager<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="TransferBuffer{T}"/> in use.
|
||||
/// </summary>
|
||||
private readonly TransferBuffer<T> buffer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MemoryManager"/> instance for a given buffer.
|
||||
/// </summary>
|
||||
/// <param name="buffer">The <see cref="TransferBuffer{T}"/> in use.</param>
|
||||
public MemoryManager(TransferBuffer<T> buffer)
|
||||
{
|
||||
this.buffer = buffer;
|
||||
}
|
||||
private readonly TransferBuffer<T> buffer = buffer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Memory<T> Memory
|
||||
|
||||
@@ -9,7 +9,7 @@ using ComputeSharp.Win32;
|
||||
using static ComputeSharp.Win32.D3D12_FORMAT_SUPPORT1;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
|
||||
#pragma warning disable CA1063
|
||||
#pragma warning disable CA1063, CA2213
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
@@ -152,21 +152,13 @@ public abstract unsafe partial class TransferTexture1D<T> : IReferenceTrackedObj
|
||||
/// <summary>
|
||||
/// A <see cref="MemoryManager{T}"/> implementation wrapping a <see cref="TransferTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
private sealed class MemoryManager : MemoryManager<T>
|
||||
/// <param name="buffer">The <see cref="TransferTexture1D{T}"/> in use.</param>
|
||||
private sealed class MemoryManager(TransferTexture1D<T> buffer) : MemoryManager<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="TransferTexture1D{T}"/> in use.
|
||||
/// </summary>
|
||||
private readonly TransferTexture1D<T> buffer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MemoryManager"/> instance for a given buffer.
|
||||
/// </summary>
|
||||
/// <param name="buffer">The <see cref="TransferTexture1D{T}"/> in use.</param>
|
||||
public MemoryManager(TransferTexture1D<T> buffer)
|
||||
{
|
||||
this.buffer = buffer;
|
||||
}
|
||||
private readonly TransferTexture1D<T> buffer = buffer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Memory<T> Memory
|
||||
|
||||
@@ -6,21 +6,13 @@ namespace ComputeSharp.Resources.Debug;
|
||||
/// A debug proxy used to display items in a <see cref="TransferTexture1D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to display.</typeparam>
|
||||
internal sealed class TransferTexture1DDebugView<T>
|
||||
/// <param name="texture">The input <see cref="TransferTexture1D{T}"/> instance with the items to display.</param>
|
||||
internal sealed class TransferTexture1DDebugView<T>(TransferTexture1D<T>? texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TransferTexture1DDebugView{T}"/> class with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="TransferTexture1D{T}"/> instance with the items to display.</param>
|
||||
public TransferTexture1DDebugView(TransferTexture1D<T>? texture)
|
||||
{
|
||||
Items = texture?.Span.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items to display for the current instance.
|
||||
/// </summary>
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
|
||||
public T[]? Items { get; }
|
||||
public T[]? Items { get; } = texture?.Span.ToArray();
|
||||
}
|
||||
@@ -6,21 +6,13 @@ namespace ComputeSharp.Resources.Debug;
|
||||
/// A debug proxy used to display items in a <see cref="TransferTexture2D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to display.</typeparam>
|
||||
internal sealed class TransferTexture2DDebugView<T>
|
||||
/// <param name="texture">The input <see cref="TransferTexture2D{T}"/> instance with the items to display.</param>
|
||||
internal sealed class TransferTexture2DDebugView<T>(TransferTexture2D<T>? texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TransferTexture2DDebugView{T}"/> class with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="TransferTexture2D{T}"/> instance with the items to display.</param>
|
||||
public TransferTexture2DDebugView(TransferTexture2D<T>? texture)
|
||||
{
|
||||
Items = texture?.View.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items to display for the current instance.
|
||||
/// </summary>
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
|
||||
public T[,]? Items { get; }
|
||||
public T[,]? Items { get; } = texture?.View.ToArray();
|
||||
}
|
||||
@@ -6,21 +6,13 @@ namespace ComputeSharp.Resources.Debug;
|
||||
/// A debug proxy used to display items in a <see cref="TransferTexture3D{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to display.</typeparam>
|
||||
internal sealed class TransferTexture3DDebugView<T>
|
||||
/// <param name="texture">The input <see cref="TransferTexture3D{T}"/> instance with the items to display.</param>
|
||||
internal sealed class TransferTexture3DDebugView<T>(TransferTexture3D<T>? texture)
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TransferTexture3DDebugView{T}"/> class with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="TransferTexture3D{T}"/> instance with the items to display.</param>
|
||||
public TransferTexture3DDebugView(TransferTexture3D<T>? texture)
|
||||
{
|
||||
Items = texture?.View.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items to display for the current instance.
|
||||
/// </summary>
|
||||
[DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
|
||||
public T[,,]? Items { get; }
|
||||
public T[,,]? Items { get; } = texture?.View.ToArray();
|
||||
}
|
||||
@@ -8,35 +8,20 @@ namespace ComputeSharp.Graphics.Resources.Interop;
|
||||
/// <summary>
|
||||
/// A type representing a mapped memory resource.
|
||||
/// </summary>
|
||||
internal readonly unsafe ref struct ID3D12ResourceMap
|
||||
/// <param name="d3D12Resource">The input <see cref="ID3D12Resource"/> instance to map.</param>
|
||||
/// <param name="pointer">The pointer to the mapped resource.</param>
|
||||
[method: MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal readonly unsafe ref struct ID3D12ResourceMap(ID3D12Resource* d3D12Resource, void* pointer)
|
||||
{
|
||||
/// <summary>
|
||||
/// The target <see cref="ID3D12Resource"/> to map.
|
||||
/// </summary>
|
||||
private readonly ID3D12Resource* d3D12Resource;
|
||||
|
||||
/// <summary>
|
||||
/// The pointer to the mapped resource.
|
||||
/// </summary>
|
||||
public readonly void* Pointer;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ID3D12ResourceMap"/> instance for a given <see cref="ID3D12Resource"/> value.
|
||||
/// </summary>
|
||||
/// <param name="d3D12Resource">The input <see cref="ID3D12Resource"/> instance to map.</param>
|
||||
/// <param name="pointer">The pointer to the mapped resource.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ID3D12ResourceMap(ID3D12Resource* d3D12Resource, void* pointer)
|
||||
{
|
||||
this.d3D12Resource = d3D12Resource;
|
||||
|
||||
this.Pointer = pointer;
|
||||
}
|
||||
public readonly void* Pointer = pointer;
|
||||
|
||||
/// <inheritdoc cref="IDisposable.Dispose"/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
{
|
||||
this.d3D12Resource->Unmap();
|
||||
d3D12Resource->Unmap();
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする