Remove all specialized overloads in GraphicsResourceHelper
このコミットが含まれているのは:
1 親
0c970156f0
コミット
e2a8f1d1fe
5ファイル変更
+49
-371
検索条件に一致するファイルはありません
@@ -2,7 +2,6 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
namespace ComputeSharp.__Internals;
|
||||
@@ -60,363 +59,23 @@ public static class GraphicsResourceHelper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given buffer for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// Validates the given resource for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input buffer.</typeparam>
|
||||
/// <param name="buffer">The input <see cref="Buffer{T}"/> instance to check.</param>
|
||||
/// <param name="resource">The input <see cref="IGraphicsResource"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the buffer.</returns>
|
||||
/// <returns>The GPU descriptor handle for the resource.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(Buffer<T> buffer, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IGraphicsResource resource, GraphicsDevice device)
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(buffer);
|
||||
default(ArgumentNullException).ThrowIfNull(resource);
|
||||
|
||||
using ReferenceTracker.Lease _0 = buffer.GetReferenceTracker().GetLease();
|
||||
|
||||
buffer.ThrowIfDeviceMismatch(device);
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = buffer.D3D12GpuDescriptorHandle;
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadOnlyTexture1D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadOnlyTexture1D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = texture.D3D12GpuDescriptorHandle;
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture1D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadWriteTexture1D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = texture.D3D12GpuDescriptorHandle;
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadOnlyTexture1D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(IReadOnlyTexture1D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
if (resource is IReadOnlyResource readOnlyResource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = readOnlyResource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadOnlyNormalizedTexture1D{TPixel}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyNormalizedTexture1D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadWriteNormalizedTexture1D{TPixel}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteNormalizedTexture1D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadOnlyTexture2D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadOnlyTexture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = texture.D3D12GpuDescriptorHandle;
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadWriteTexture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = texture.D3D12GpuDescriptorHandle;
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadOnlyTexture2D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(IReadOnlyTexture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadOnlyNormalizedTexture2D{TPixel}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyNormalizedTexture2D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadWriteNormalizedTexture2D{TPixel}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteNormalizedTexture2D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadOnlyTexture3D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadOnlyTexture3D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = texture.D3D12GpuDescriptorHandle;
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(ReadWriteTexture3D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
using ReferenceTracker.Lease _0 = texture.GetReferenceTracker().GetLease();
|
||||
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = texture.D3D12GpuDescriptorHandle;
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadOnlyTexture3D{T}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<T>(IReadOnlyTexture3D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadOnlyNormalizedTexture3D{TPixel}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyNormalizedTexture3D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadWriteNormalizedTexture3D{TPixel}"/> instance to check.</param>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the texture.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteNormalizedTexture3D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
if (texture is IReadOnlyResource resource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(texture));
|
||||
return default(ArgumentException).Throw<ulong>(nameof(resource));
|
||||
}
|
||||
}
|
||||
@@ -2,30 +2,33 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Core.Helpers;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Interop.Allocation;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_FEATURE;
|
||||
using static TerraFX.Interop.DirectX.DXGI_FORMAT;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
using ComputeSharp.Interop.Allocation;
|
||||
#if NET6_0_OR_GREATER
|
||||
using MemoryMarshal = System.Runtime.InteropServices.MemoryMarshal;
|
||||
#else
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a typed buffer stored on GPU memory.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
|
||||
public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraphicsResource
|
||||
public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraphicsResource, GraphicsResourceHelper.IReadOnlyResource
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
@@ -232,7 +235,7 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="__Internals.GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
@@ -244,7 +247,7 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
this.d3D12ResourceDescriptorHandlesForTypedUnorderedAccessView.D3D12CpuDescriptorHandleNonShaderVisible);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="__Internals.GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal unsafe ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
@@ -253,4 +256,20 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
|
||||
return D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12Resource(device, out lease);
|
||||
}
|
||||
}
|
||||
@@ -560,18 +560,18 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
return D3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12Resource(device, out lease);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
|
||||
@@ -610,18 +610,18 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
return D3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12Resource(device, out lease);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
|
||||
@@ -662,18 +662,18 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
return D3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12Resource(device, out lease);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする