Added dispatch helpers for normalized texture interfaces
このコミットが含まれているのは:
1 親
226481aff6
コミット
958fa15a11
5ファイル変更
+152
-16
検索条件に一致するファイルはありません
@@ -2,6 +2,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.Resources;
|
||||
using Microsoft.Toolkit.Diagnostics;
|
||||
using TerraFX.Interop;
|
||||
|
||||
namespace ComputeSharp.__Internals
|
||||
@@ -13,11 +14,26 @@ namespace ComputeSharp.__Internals
|
||||
[Obsolete("This type is not intended to be used directly by user code")]
|
||||
public static class GraphicsResourceHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface for non-generic graphics resource types.
|
||||
/// </summary>
|
||||
internal interface IGraphicsResource
|
||||
{
|
||||
/// <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 buffer 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="device">The target <see cref="GraphicsDevice"/> instance in use.</param>
|
||||
/// <returns>The GPU descriptor handle for the buffer.</returns>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -31,37 +47,133 @@ namespace ComputeSharp.__Internals
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given buffer for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <param name="buffer">The input <see cref="Texture2D{T}"/> instance to check.</param>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="Texture2D{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>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong ValidateAndGetGpuDescriptorHandle<T>(Texture2D<T> buffer, GraphicsDevice device)
|
||||
public static ulong ValidateAndGetGpuDescriptorHandle<T>(Texture2D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
buffer.ThrowIfDisposed();
|
||||
buffer.ThrowIfDeviceMismatch(device);
|
||||
texture.ThrowIfDisposed();
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
return Unsafe.As<D3D12_GPU_DESCRIPTOR_HANDLE, ulong>(ref Unsafe.AsRef(in buffer.D3D12GpuDescriptorHandle));
|
||||
return Unsafe.As<D3D12_GPU_DESCRIPTOR_HANDLE, ulong>(ref Unsafe.AsRef(in texture.D3D12GpuDescriptorHandle));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the given buffer for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// Validates the given texture for usage with a specified device, and retrieves its GPU descriptor handle.
|
||||
/// </summary>
|
||||
/// <param name="buffer">The input <see cref="Texture3D{T}"/> instance to check.</param>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadOnlyTexture2D{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>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong ValidateAndGetGpuDescriptorHandle<T>(Texture3D<T> buffer, GraphicsDevice device)
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyTexture2D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : 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>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadWriteTexture2D{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>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteTexture2D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : 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>
|
||||
/// <typeparam name="T">The type of values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="Texture3D{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>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong ValidateAndGetGpuDescriptorHandle<T>(Texture3D<T> texture, GraphicsDevice device)
|
||||
where T : unmanaged
|
||||
{
|
||||
buffer.ThrowIfDisposed();
|
||||
buffer.ThrowIfDeviceMismatch(device);
|
||||
texture.ThrowIfDisposed();
|
||||
texture.ThrowIfDeviceMismatch(device);
|
||||
|
||||
return Unsafe.As<D3D12_GPU_DESCRIPTOR_HANDLE, ulong>(ref Unsafe.AsRef(in buffer.D3D12GpuDescriptorHandle));
|
||||
return Unsafe.As<D3D12_GPU_DESCRIPTOR_HANDLE, ulong>(ref Unsafe.AsRef(in texture.D3D12GpuDescriptorHandle));
|
||||
}
|
||||
|
||||
/// <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="IReadOnlyTexture3D{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>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadOnlyTexture3D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : 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>
|
||||
/// <typeparam name="TPixel">The type of normalized values stored in the input texture.</typeparam>
|
||||
/// <param name="texture">The input <see cref="IReadWriteTexture3D{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>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[Obsolete("This method is not intended to be called directly by user code")]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ulong ValidateAndGetGpuDescriptorHandle<TPixel>(IReadWriteTexture3D<TPixel> texture, GraphicsDevice device)
|
||||
where TPixel : 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする