Add missing GraphicsResourceHelper APIs to support new interfaces

このコミットが含まれているのは:
Sergio Pedri committed 2022-01-22 16:47:56 +01:00
1 親 c81eecfd64
コミット 9cb5c35287
1ファイル変更
+42
+42
ファイルの表示
@@ -108,6 +108,27 @@ public static class GraphicsResourceHelper
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
{
if (texture is IGraphicsResource resource)
{
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
return *(ulong*)&d3D12GpuDescriptorHandle;
}
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance");
}
/// <summary>
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
/// </summary>
@@ -188,6 +209,27 @@ public static class GraphicsResourceHelper
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
{
if (texture is IGraphicsResource resource)
{
D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);
return *(ulong*)&d3D12GpuDescriptorHandle;
}
return ThrowHelper.ThrowArgumentException<ulong>("The input texture is not a valid instance");
}
/// <summary>
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
/// </summary>