Add ComputeContext.Transition extensions
このコミットが含まれているのは:
1 親
189da1aa11
コミット
5d66b7fe05
2ファイル変更
+53
検索条件に一致するファイルはありません
@@ -253,6 +253,24 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
|
||||
commandList.D3D12GraphicsCommandList->Dispatch((uint)groupsX, (uint)groupsY, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a transition for a specific resource.
|
||||
/// </summary>
|
||||
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to change state for.</param>
|
||||
/// <param name="d3D12ResourceStatesBefore">The starting <see cref="D3D12_RESOURCE_STATES"/> value for the transition.</param>
|
||||
/// <param name="d3D12ResourceStatesAfter">The destnation <see cref="D3D12_RESOURCE_STATES"/> value for the transition.</param>
|
||||
internal readonly unsafe void Transition(
|
||||
ID3D12Resource* d3D12Resource,
|
||||
D3D12_RESOURCE_STATES d3D12ResourceStatesBefore,
|
||||
D3D12_RESOURCE_STATES d3D12ResourceStatesAfter)
|
||||
{
|
||||
ThrowInvalidOperationExceptionIfDeviceIsNull();
|
||||
|
||||
ref CommandList commandList = ref GetCommandList(in this, null);
|
||||
|
||||
commandList.D3D12GraphicsCommandList->TransitionBarrier(d3D12Resource, d3D12ResourceStatesBefore, d3D12ResourceStatesAfter);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Dispose()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using TerraFX.Interop.DirectX;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
@@ -361,4 +362,38 @@ public static class ComputeContextExtensions
|
||||
{
|
||||
context.Run(texture, ref Unsafe.AsRef(in shader));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T,TPixel}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition<T, TPixel>(this in ComputeContext context, ReadWriteTexture2D<T, TPixel> texture, ResourceState resourceState)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource);
|
||||
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T,TPixel}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition<T, TPixel>(this in ComputeContext context, ReadWriteTexture3D<T, TPixel> texture, ResourceState resourceState)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
var states = texture.ValidateAndGetID3D12ResourceAndTransitionStates(context.GraphicsDevice, resourceState, out ID3D12Resource* d3D12Resource);
|
||||
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする