diff --git a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs index c385655d..f7b27044 100644 --- a/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/__Internals/GraphicsResourceHelper.cs @@ -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 } /// - /// 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. /// - /// The type of values stored in the input buffer. - /// The input instance to check. + /// The input instance to check. /// The target instance in use. - /// The GPU descriptor handle for the buffer. + /// The GPU descriptor handle for the resource. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(Buffer 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; - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadOnlyTexture1D 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; - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadWriteTexture1D 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; - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyTexture1D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of normalized values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyNormalizedTexture1D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of normalized values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadWriteNormalizedTexture1D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadOnlyTexture2D 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; - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadWriteTexture2D 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; - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyTexture2D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of normalized values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyNormalizedTexture2D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of normalized values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadWriteNormalizedTexture2D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadOnlyTexture3D 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; - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(ReadWriteTexture3D 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; - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyTexture3D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of normalized values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadOnlyNormalizedTexture3D 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(nameof(texture)); - } - - /// - /// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle. - /// - /// The type of normalized values stored in the input texture. - /// The input instance to check. - /// The target instance in use. - /// The GPU descriptor handle for the texture. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ulong ValidateAndGetGpuDescriptorHandle(IReadWriteNormalizedTexture3D 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(nameof(texture)); + return default(ArgumentException).Throw(nameof(resource)); } } \ No newline at end of file diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs index 1086eb75..39b7017a 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs @@ -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; /// /// A representing a typed buffer stored on GPU memory. /// /// The type of items stored on the buffer. -public abstract unsafe partial class Buffer : IReferenceTrackedObject, IGraphicsResource +public abstract unsafe partial class Buffer : IReferenceTrackedObject, IGraphicsResource, GraphicsResourceHelper.IReadOnlyResource where T : unmanaged { /// @@ -232,7 +235,7 @@ public abstract unsafe partial class Buffer : IReferenceTrackedObject, IGraph } } - /// + /// 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 : IReferenceTrackedObject, IGraph this.d3D12ResourceDescriptorHandlesForTypedUnorderedAccessView.D3D12CpuDescriptorHandleNonShaderVisible); } - /// + /// internal unsafe ID3D12Resource* ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease) { lease = GetReferenceTracker().GetLease(); @@ -253,4 +256,20 @@ public abstract unsafe partial class Buffer : IReferenceTrackedObject, IGraph return D3D12Resource; } + + /// + D3D12_GPU_DESCRIPTOR_HANDLE GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetGpuDescriptorHandle(GraphicsDevice device) + { + using ReferenceTracker.Lease _0 = GetReferenceTracker().GetLease(); + + ThrowIfDeviceMismatch(device); + + return D3D12GpuDescriptorHandle; + } + + /// + ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease) + { + return ValidateAndGetID3D12Resource(device, out lease); + } } \ No newline at end of file diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs index d1b26f54..0d31dbff 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs @@ -560,18 +560,18 @@ public abstract unsafe partial class Texture1D : IReferenceTrackedObject, IGr return D3D12GpuDescriptorHandle; } - /// - (D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) - { - return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized); - } - /// ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease) { return ValidateAndGetID3D12Resource(device, out lease); } + /// + (D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) + { + return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized); + } + /// (D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease) { diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs index 1b169d23..ce0cb9ea 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs @@ -610,18 +610,18 @@ public abstract unsafe partial class Texture2D : IReferenceTrackedObject, IGr return D3D12GpuDescriptorHandle; } - /// - (D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) - { - return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized); - } - /// ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease) { return ValidateAndGetID3D12Resource(device, out lease); } + /// + (D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) + { + return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized); + } + /// (D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease) { diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs index a524344e..9983a98d 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs @@ -662,18 +662,18 @@ public abstract unsafe partial class Texture3D : IReferenceTrackedObject, IGr return D3D12GpuDescriptorHandle; } - /// - (D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) - { - return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized); - } - /// ID3D12Resource* GraphicsResourceHelper.IReadOnlyResource.ValidateAndGetID3D12Resource(GraphicsDevice device, out ReferenceTracker.Lease lease) { return ValidateAndGetID3D12Resource(device, out lease); } + /// + (D3D12_GPU_DESCRIPTOR_HANDLE, D3D12_CPU_DESCRIPTOR_HANDLE) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetGpuAndCpuDescriptorHandlesForClear(GraphicsDevice device, out bool isNormalized) + { + return ValidateAndGetGpuAndCpuDescriptorHandlesForClear(device, out isNormalized); + } + /// (D3D12_RESOURCE_STATES, D3D12_RESOURCE_STATES) GraphicsResourceHelper.IReadWriteResource.ValidateAndGetID3D12ResourceAndTransitionStates(GraphicsDevice device, ResourceState resourceState, out ID3D12Resource* d3D12Resource, out ReferenceTracker.Lease lease) {