Refactor internal resource interfaces, remove GraphicsResourceHelper
このコミットが含まれているのは:
1 親
e2a8f1d1fe
コミット
39c72712ae
15ファイル変更
+179
-204
検索条件に一致するファイルはありません
@@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
namespace ComputeSharp.__Internals;
|
||||
|
||||
/// <summary>
|
||||
/// A helper class with some proxy methods to expose to generated code in external projects.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This type is not intended to be used directly by user code")]
|
||||
public static class GraphicsResourceHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for a readonly, non-generic readonly graphics resource types.
|
||||
/// </summary>
|
||||
internal unsafe interface IReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the resource.</returns>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ValidateAndGetGpuDescriptorHandle(GraphicsDevice device);
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves the underlying <see cref="ID3D12Resource"/> object.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <param name="lease">The <see cref="ReferenceTracker.Lease"/> value for the returned <see cref="ID3D12Resource"/> object.</param>
|
||||
/// <returns>The the underlying <see cref="ID3D12Resource"/> object.</returns>
|
||||
ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for a writeable, non-generic graphics resource types.
|
||||
/// </summary>
|
||||
internal unsafe interface IReadWriteResource : IReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves its GPU and CPU descriptor handles for a clear operation.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <param name="isNormalized">Indicates whether the current resource uses a normalized format.</param>
|
||||
/// <returns>The GPU and CPU descriptor handles for the resource.</returns>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized);
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves the underlying <see cref="ID3D12Resource"/> object, along with the transition states.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <param name="resourceState">The target state to transition the resource to.</param>
|
||||
/// <param name="d3D12Resource">The the underlying <see cref="ID3D12Resource"/> object.</param>
|
||||
/// <param name="lease">The <see cref="ReferenceTracker.Lease"/> value for the returned <see cref="ID3D12Resource"/> object.</param>
|
||||
/// <returns>The resource states for <paramref name="d3D12Resource"/>, before and after the transition.</returns>
|
||||
(D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <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 resource.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IGraphicsResource resource, GraphicsDevice device)
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(resource);
|
||||
|
||||
if (resource is IReadOnlyResource readOnlyResource)
|
||||
{
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = readOnlyResource.ValidateAndGetGpuDescriptorHandle(device);
|
||||
|
||||
return *(ulong*)&d3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
return default(ArgumentException).Throw<ulong>(nameof(resource));
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ 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 ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_FEATURE;
|
||||
@@ -20,7 +20,7 @@ using MemoryMarshal = System.Runtime.InteropServices.MemoryMarshal;
|
||||
using MemoryMarshal = ComputeSharp.NetStandard.MemoryMarshal;
|
||||
#endif
|
||||
|
||||
#pragma warning disable CS0618
|
||||
#pragma warning disable CA1063
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ComputeSharp.Resources;
|
||||
/// 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, GraphicsResourceHelper.IReadOnlyResource
|
||||
public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraphicsResource, ID3D12ReadOnlyResource
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
@@ -235,7 +235,7 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
/// <inheritdoc cref="ID3D12ReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
@@ -247,7 +247,7 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
this.d3D12ResourceDescriptorHandlesForTypedUnorderedAccessView.D3D12CpuDescriptorHandleNonShaderVisible);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
/// <inheritdoc cref="ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal unsafe ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
@@ -258,7 +258,7 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -268,7 +268,7 @@ public abstract unsafe partial class Buffer<T> : IReferenceTrackedObject, IGraph
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12Resource(device, out lease);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
@@ -9,6 +8,7 @@ using ComputeSharp.Graphics.Resources.Helpers;
|
||||
using ComputeSharp.Graphics.Resources.Interop;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Interop.Allocation;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_COMMAND_LIST_TYPE;
|
||||
@@ -17,7 +17,7 @@ using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
using static TerraFX.Interop.DirectX.D3D12_UAV_DIMENSION;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
|
||||
#pragma warning disable CS0618, CA1063
|
||||
#pragma warning disable CA1063
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ComputeSharp.Resources;
|
||||
/// A <see langword="class"/> representing a typed 1D texture stored on GPU memory.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGraphicsResource, GraphicsResourceHelper.IReadWriteResource
|
||||
public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGraphicsResource, ID3D12ReadWriteResource
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
@@ -511,7 +511,27 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12GpuDescriptorHandle;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID3D12ReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
@@ -523,17 +543,7 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
return (this.d3D12ResourceDescriptorHandles.D3D12GpuDescriptorHandle, this.d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandleNonShaderVisible);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice, ResourceState, out ID3D12Resource*, out ReferenceTracker.Lease)"/>
|
||||
/// <inheritdoc cref="ID3D12ReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice, ResourceState, out ID3D12Resource*, out ReferenceTracker.Lease)"/>
|
||||
internal (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
@@ -551,29 +561,19 @@ public abstract unsafe partial class Texture1D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
|
||||
/// <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)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.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)
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) ID3D12ReadWriteResource.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)
|
||||
(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) ID3D12ReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12ResourceAndTransitionStates(device, resourceState, out d3D12Resource, out lease);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
@@ -9,6 +8,7 @@ using ComputeSharp.Graphics.Resources.Helpers;
|
||||
using ComputeSharp.Graphics.Resources.Interop;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Interop.Allocation;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_COMMAND_LIST_TYPE;
|
||||
@@ -17,7 +17,7 @@ using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
using static TerraFX.Interop.DirectX.D3D12_UAV_DIMENSION;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
|
||||
#pragma warning disable CS0618, CA1063
|
||||
#pragma warning disable CA1063
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ComputeSharp.Resources;
|
||||
/// A <see langword="class"/> representing a typed 2D texture stored on GPU memory.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGraphicsResource, GraphicsResourceHelper.IReadWriteResource
|
||||
public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGraphicsResource, ID3D12ReadWriteResource
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
@@ -561,7 +561,17 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
/// <inheritdoc cref="ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID3D12ReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
@@ -573,17 +583,7 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
return (this.d3D12ResourceDescriptorHandles.D3D12GpuDescriptorHandle, this.d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandleNonShaderVisible);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice, ResourceState, out ID3D12Resource*, out ReferenceTracker.Lease)"/>
|
||||
/// <inheritdoc cref="ID3D12ReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice, ResourceState, out ID3D12Resource*, out ReferenceTracker.Lease)"/>
|
||||
internal (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
@@ -601,7 +601,7 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -611,19 +611,19 @@ public abstract unsafe partial class Texture2D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.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)
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) ID3D12ReadWriteResource.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)
|
||||
(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) ID3D12ReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12ResourceAndTransitionStates(device, resourceState, out d3D12Resource, out lease);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
@@ -9,6 +8,7 @@ using ComputeSharp.Graphics.Resources.Helpers;
|
||||
using ComputeSharp.Graphics.Resources.Interop;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Interop.Allocation;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D12_COMMAND_LIST_TYPE;
|
||||
@@ -17,7 +17,7 @@ using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
using static TerraFX.Interop.DirectX.D3D12_UAV_DIMENSION;
|
||||
using ResourceType = ComputeSharp.Graphics.Resources.Enums.ResourceType;
|
||||
|
||||
#pragma warning disable CS0618, CA1063
|
||||
#pragma warning disable CA1063
|
||||
|
||||
namespace ComputeSharp.Resources;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ComputeSharp.Resources;
|
||||
/// A <see langword="class"/> representing a typed 3D texture stored on GPU memory.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGraphicsResource, GraphicsResourceHelper.IReadWriteResource
|
||||
public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGraphicsResource, ID3D12ReadWriteResource
|
||||
where T : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
@@ -613,7 +613,17 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
/// <inheritdoc cref="ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ID3D12ReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice, out bool)"/>
|
||||
internal (D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
@@ -625,17 +635,7 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
return (this.d3D12ResourceDescriptorHandles.D3D12GpuDescriptorHandle, this.d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandleNonShaderVisible);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice, out ReferenceTracker.Lease)"/>
|
||||
internal ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
ThrowIfDeviceMismatch(device);
|
||||
|
||||
return D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice, ResourceState, out ID3D12Resource*, out ReferenceTracker.Lease)"/>
|
||||
/// <inheritdoc cref="ID3D12ReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice, ResourceState, out ID3D12Resource*, out ReferenceTracker.Lease)"/>
|
||||
internal (D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
@@ -653,7 +653,7 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -663,19 +663,19 @@ public abstract unsafe partial class Texture3D<T> : IReferenceTrackedObject, IGr
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.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)
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) ID3D12ReadWriteResource.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)
|
||||
(D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) ID3D12ReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
return ValidateAndGetID3D12ResourceAndTransitionStates(device, resourceState, out d3D12Resource, out lease);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using ComputeSharp.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
namespace ComputeSharp.Resources.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// An interface for a readonly, non-generic readonly graphics resource types.
|
||||
/// </summary>
|
||||
internal unsafe interface ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the resource.</returns>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ValidateAndGetGpuDescriptorHandle(GraphicsDevice device);
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves the underlying <see cref="ID3D12Resource"/> object.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <param name="lease">The <see cref="ReferenceTracker.Lease"/> value for the returned <see cref="ID3D12Resource"/> object.</param>
|
||||
/// <returns>The the underlying <see cref="ID3D12Resource"/> object.</returns>
|
||||
ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using ComputeSharp.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
namespace ComputeSharp.Resources.Interop;
|
||||
|
||||
/// <summary>
|
||||
/// An interface for a writeable, non-generic graphics resource types.
|
||||
/// </summary>
|
||||
internal unsafe interface ID3D12ReadWriteResource : ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves its GPU and CPU descriptor handles for a clear operation.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <param name="isNormalized">Indicates whether the current resource uses a normalized format.</param>
|
||||
/// <returns>The GPU and CPU descriptor handles for the resource.</returns>
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized);
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given resource for usage with a specified device, and retrieves the underlying <see cref="ID3D12Resource"/> object, along with the transition states.
|
||||
/// </summary>
|
||||
/// <param name="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <param name="resourceState">The target state to transition the resource to.</param>
|
||||
/// <param name="d3D12Resource">The the underlying <see cref="ID3D12Resource"/> object.</param>
|
||||
/// <param name="lease">The <see cref="ReferenceTracker.Lease"/> value for the returned <see cref="ID3D12Resource"/> object.</param>
|
||||
/// <returns>The resource states for <paramref name="d3D12Resource"/>, before and after the transition.</returns>
|
||||
(D3D12_RESOURCE_STATES Before, D3D12_RESOURCE_STATES After) ValidateAndGetID3D12ResourceAndTransitionStates(
|
||||
GraphicsDevice device,
|
||||
ResourceState resourceState,
|
||||
out ID3D12Resource* d3D12Resource,
|
||||
out ReferenceTracker.Lease lease);
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
|
||||
#pragma warning disable CS0618, IDE0022
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -56,7 +56,7 @@ partial class ReadWriteTexture1D<T, TPixel>
|
||||
/// <summary>
|
||||
/// A wrapper for a <see cref="ReadWriteTexture1D{T, TPixel}"/> resource that has been temporarily transitioned to readonly.
|
||||
/// </summary>
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyNormalizedTexture1D<TPixel>, GraphicsResourceHelper.IReadOnlyResource
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyNormalizedTexture1D<TPixel>, ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="ReadWriteTexture1D{T, TPixel}"/> instance being wrapped.
|
||||
@@ -98,7 +98,7 @@ partial class ReadWriteTexture1D<T, TPixel>
|
||||
public GraphicsDevice GraphicsDevice => this.owner.GraphicsDevice;
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = this.owner.GetReferenceTracker().GetLease();
|
||||
@@ -109,7 +109,7 @@ partial class ReadWriteTexture1D<T, TPixel>
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
@@ -119,6 +119,7 @@ partial class ReadWriteTexture1D<T, TPixel>
|
||||
|
||||
return this.owner.D3D12Resource;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override void DangerousOnDispose()
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
|
||||
#pragma warning disable CS0618, IDE0022
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -56,7 +56,7 @@ partial class ReadWriteTexture1D<T>
|
||||
/// <summary>
|
||||
/// A wrapper for a <see cref="ReadWriteTexture1D{T}"/> resource that has been temporarily transitioned to readonly.
|
||||
/// </summary>
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyTexture1D<T>, GraphicsResourceHelper.IReadOnlyResource
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyTexture1D<T>, ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="ReadWriteTexture1D{T}"/> instance being wrapped.
|
||||
@@ -98,7 +98,7 @@ partial class ReadWriteTexture1D<T>
|
||||
public GraphicsDevice GraphicsDevice => this.owner.GraphicsDevice;
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = this.owner.GetReferenceTracker().GetLease();
|
||||
@@ -109,7 +109,7 @@ partial class ReadWriteTexture1D<T>
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
|
||||
#pragma warning disable CS0618, IDE0022
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -56,7 +56,7 @@ partial class ReadWriteTexture2D<T, TPixel>
|
||||
/// <summary>
|
||||
/// A wrapper for a <see cref="ReadWriteTexture2D{T, TPixel}"/> resource that has been temporarily transitioned to readonly.
|
||||
/// </summary>
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyNormalizedTexture2D<TPixel>, GraphicsResourceHelper.IReadOnlyResource
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyNormalizedTexture2D<TPixel>, ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="ReadWriteTexture2D{T, TPixel}"/> instance being wrapped.
|
||||
@@ -110,7 +110,7 @@ partial class ReadWriteTexture2D<T, TPixel>
|
||||
public GraphicsDevice GraphicsDevice => this.owner.GraphicsDevice;
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = this.owner.GetReferenceTracker().GetLease();
|
||||
@@ -121,7 +121,7 @@ partial class ReadWriteTexture2D<T, TPixel>
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
|
||||
#pragma warning disable CS0618, IDE0022
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -59,7 +59,7 @@ partial class ReadWriteTexture2D<T>
|
||||
/// <summary>
|
||||
/// A wrapper for a <see cref="ReadWriteTexture2D{T}"/> resource that has been temporarily transitioned to readonly.
|
||||
/// </summary>
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyTexture2D<T>, GraphicsResourceHelper.IReadOnlyResource
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyTexture2D<T>, ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="ReadWriteTexture2D{T}"/> instance being wrapped.
|
||||
@@ -110,7 +110,7 @@ partial class ReadWriteTexture2D<T>
|
||||
public GraphicsDevice GraphicsDevice => this.owner.GraphicsDevice;
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = this.owner.GetReferenceTracker().GetLease();
|
||||
@@ -121,7 +121,7 @@ partial class ReadWriteTexture2D<T>
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
|
||||
#pragma warning disable CS0618, IDE0022
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -56,7 +56,7 @@ partial class ReadWriteTexture3D<T, TPixel>
|
||||
/// <summary>
|
||||
/// A wrapper for a <see cref="ReadWriteTexture3D{T, TPixel}"/> resource that has been temporarily transitioned to readonly.
|
||||
/// </summary>
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyNormalizedTexture3D<TPixel>, GraphicsResourceHelper.IReadOnlyResource
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyNormalizedTexture3D<TPixel>, ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="ReadWriteTexture3D{T, TPixel}"/> instance being wrapped.
|
||||
@@ -110,7 +110,7 @@ partial class ReadWriteTexture3D<T, TPixel>
|
||||
public GraphicsDevice GraphicsDevice => this.owner.GraphicsDevice;
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = this.owner.GetReferenceTracker().GetLease();
|
||||
@@ -121,7 +121,7 @@ partial class ReadWriteTexture3D<T, TPixel>
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands.Interop;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D12_SRV_DIMENSION;
|
||||
|
||||
#pragma warning disable CS0618, IDE0022
|
||||
#pragma warning disable IDE0022
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
@@ -56,7 +56,7 @@ partial class ReadWriteTexture3D<T>
|
||||
/// <summary>
|
||||
/// A wrapper for a <see cref="ReadWriteTexture3D{T}"/> resource that has been temporarily transitioned to readonly.
|
||||
/// </summary>
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyTexture3D<T>, GraphicsResourceHelper.IReadOnlyResource
|
||||
private sealed unsafe class ReadOnly : ReferenceTrackedObject, IReadOnlyTexture3D<T>, ID3D12ReadOnlyResource
|
||||
{
|
||||
/// <summary>
|
||||
/// The owning <see cref="ReadWriteTexture3D{T}"/> instance being wrapped.
|
||||
@@ -110,7 +110,7 @@ partial class ReadWriteTexture3D<T>
|
||||
public GraphicsDevice GraphicsDevice => this.owner.GraphicsDevice;
|
||||
|
||||
/// <inheritdoc/>
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE ID3D12ReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device)
|
||||
{
|
||||
using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease();
|
||||
using ReferenceTracker.Lease _1 = this.owner.GetReferenceTracker().GetLease();
|
||||
@@ -121,7 +121,7 @@ partial class ReadWriteTexture3D<T>
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
ID3D12Resource* ID3D12ReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease)
|
||||
{
|
||||
lease = GetReferenceTracker().GetLease();
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Commands;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using ComputeSharp.Shaders.Dispatching;
|
||||
using ComputeSharp.Shaders.Loading;
|
||||
using TerraFX.Interop.DirectX;
|
||||
@@ -213,7 +213,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
// Load the implicit output texture
|
||||
commandList.D3D12GraphicsCommandList->SetComputeRootDescriptorTable(
|
||||
1,
|
||||
((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetGpuDescriptorHandle(this.device));
|
||||
((ID3D12ReadOnlyResource)texture).ValidateAndGetGpuDescriptorHandle(this.device));
|
||||
|
||||
commandList.D3D12GraphicsCommandList->Dispatch((uint)groupsX, (uint)groupsY, 1);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Resources.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
@@ -145,7 +143,7 @@ public static class ComputeContextExtensions
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Barrier(((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
context.Barrier(((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -161,7 +159,7 @@ public static class ComputeContextExtensions
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Barrier(((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
context.Barrier(((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -177,7 +175,7 @@ public static class ComputeContextExtensions
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Barrier(((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
context.Barrier(((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -309,11 +307,11 @@ public static class ComputeContextExtensions
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((ID3D12ReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Clear(((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
context.Clear(((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -327,11 +325,11 @@ public static class ComputeContextExtensions
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((ID3D12ReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Clear(((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
context.Clear(((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -345,11 +343,11 @@ public static class ComputeContextExtensions
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((ID3D12ReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Clear(((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
context.Clear(((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)), handles.Gpu, handles.Cpu, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -421,12 +419,12 @@ public static class ComputeContextExtensions
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((ID3D12ReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Fill(
|
||||
((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)),
|
||||
((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)),
|
||||
handles.Gpu,
|
||||
handles.Cpu,
|
||||
DXGIFormatHelper.ExtendToNormalizedValue(value));
|
||||
@@ -444,12 +442,12 @@ public static class ComputeContextExtensions
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((ID3D12ReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Fill(
|
||||
((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)),
|
||||
((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)),
|
||||
handles.Gpu,
|
||||
handles.Cpu,
|
||||
DXGIFormatHelper.ExtendToNormalizedValue(value));
|
||||
@@ -467,12 +465,12 @@ public static class ComputeContextExtensions
|
||||
{
|
||||
default(ArgumentNullException).ThrowIfNull(texture);
|
||||
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((GraphicsResourceHelper.IReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
(D3D12_GPU_DESCRIPTOR_HANDLE Gpu, D3D12_CPU_DESCRIPTOR_HANDLE Cpu) handles = ((ID3D12ReadWriteResource)texture).ValidateAndGetGpuAndCpuDescriptorHandlesForClear(context.GraphicsDevice, out _);
|
||||
|
||||
using ReferenceTracker.Lease lease = default;
|
||||
|
||||
context.Fill(
|
||||
((GraphicsResourceHelper.IReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)),
|
||||
((ID3D12ReadOnlyResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice, out Unsafe.AsRef(in lease)),
|
||||
handles.Gpu,
|
||||
handles.Cpu,
|
||||
DXGIFormatHelper.ExtendToNormalizedValue(value));
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする