Remove split UAV barriers (unsupported), add more unit tests

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-28 16:58:17 +01:00
1 親 37670e8f4c
コミット ec70bcf61b
9ファイル変更
+85 -287

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -74,7 +74,7 @@ public partial class DispatchingBenchmark : IDisposable
using var context = GraphicsDevice.Default.CreateComputeContext();
context.For(64, new TestShader(Buffer!));
context.FullBarrier(Buffer!);
context.Barrier(Buffer!);
context.For(64, new TestShader(Buffer!));
}
+2 -2
ファイルの表示
@@ -293,8 +293,8 @@ public sealed partial class HlslBokehBlurProcessor
source.Height,
new(texture, reals, imaginaries, kernel));
context.FullBarrier(reals);
context.FullBarrier(imaginaries);
context.Barrier(reals);
context.Barrier(imaginaries);
context.For<HorizontalConvolutionAndAccumulatePartialsProcessor>(
source.Width,
+1 -1
ファイルの表示
@@ -108,7 +108,7 @@ public sealed partial class HlslGaussianBlurProcessor
using (var context = GraphicsDevice.CreateComputeContext())
{
context.For<VerticalConvolutionProcessor>(source.Width, source.Height, new(sourceTexture, firstPassTexture, kernelBuffer));
context.FullBarrier(firstPassTexture);
context.Barrier(firstPassTexture);
context.For<HorizontalConvolutionProcessor>(source.Width, source.Height, new(firstPassTexture, sourceTexture, kernelBuffer));
}
+1 -31
ファイルの表示
@@ -197,7 +197,7 @@ internal static unsafe class ID3D12GraphicsCommandListExtensions
/// <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>
public static void TransitioneBarrier(
public static void TransitionBarrier(
this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList,
ID3D12Resource* d3D12Resource,
D3D12_RESOURCE_STATES d3D12ResourceStatesBefore,
@@ -220,36 +220,6 @@ internal static unsafe class ID3D12GraphicsCommandListExtensions
d3D12GraphicsCommandList.ResourceBarrier(1, &d3D12ResourceBarrier);
}
/// <summary>
/// Starts a UAV resource barrier for a specific resource.
/// </summary>
/// <param name="d3D12GraphicsCommandList">The <see cref="ID3D12GraphicsCommandList"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to start the barrier for.</param>
public static void StartUAVBarrier(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, ID3D12Resource* d3D12Resource)
{
D3D12_RESOURCE_BARRIER d3D12ResourceBarrier = default;
d3D12ResourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
d3D12ResourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY;
d3D12ResourceBarrier.Anonymous.UAV.pResource = d3D12Resource;
d3D12GraphicsCommandList.ResourceBarrier(1, &d3D12ResourceBarrier);
}
/// <summary>
/// Ends a UAV resource barrier for a specific resource.
/// </summary>
/// <param name="d3D12GraphicsCommandList">The <see cref="ID3D12GraphicsCommandList"/> instance in use.</param>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to end the barrier for.</param>
public static void EndUAVBarrier(this ref ID3D12GraphicsCommandList d3D12GraphicsCommandList, ID3D12Resource* d3D12Resource)
{
D3D12_RESOURCE_BARRIER d3D12ResourceBarrier = default;
d3D12ResourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
d3D12ResourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_END_ONLY;
d3D12ResourceBarrier.Anonymous.UAV.pResource = d3D12Resource;
d3D12GraphicsCommandList.ResourceBarrier(1, &d3D12ResourceBarrier);
}
/// <summary>
/// Binds an input constant buffer to the first root parameter.
/// </summary>
+12 -12
ファイルの表示
@@ -207,7 +207,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
{
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
}
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
@@ -226,7 +226,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -287,8 +287,8 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(destination.D3D12Resource, destination.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(destination.D3D12Resource, destination.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
@@ -306,8 +306,8 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(destination.D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, destination.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(destination.D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, destination.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -349,7 +349,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
}
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintDestination = &destination.D3D12PlacedSubresourceFootprint)
@@ -371,7 +371,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -439,7 +439,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
@@ -458,7 +458,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -500,7 +500,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintSource = &source.D3D12PlacedSubresourceFootprint)
@@ -522,7 +522,7 @@ public unsafe abstract class Texture2D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
+12 -12
ファイルの表示
@@ -223,7 +223,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
{
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
}
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
@@ -242,7 +242,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -314,8 +314,8 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(destination.D3D12Resource, destination.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(destination.D3D12Resource, destination.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
@@ -333,8 +333,8 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(destination.D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, destination.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(destination.D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, destination.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -385,7 +385,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_SOURCE);
}
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintDestination = &destination.D3D12PlacedSubresourceFootprint)
@@ -407,7 +407,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_SOURCE, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -483,7 +483,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
copyCommandList.D3D12GraphicsCommandList->CopyTextureRegion(
@@ -502,7 +502,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
@@ -553,7 +553,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, this.d3D12ResourceState, D3D12_RESOURCE_STATE_COPY_DEST);
}
fixed (D3D12_PLACED_SUBRESOURCE_FOOTPRINT* d3D12PlacedSubresourceFootprintSource = &source.D3D12PlacedSubresourceFootprint)
@@ -575,7 +575,7 @@ public unsafe abstract class Texture3D<T> : NativeObject, GraphicsResourceHelper
if (copyCommandList.D3D12CommandListType == D3D12_COMMAND_LIST_TYPE_COMPUTE)
{
copyCommandList.D3D12GraphicsCommandList->TransitioneBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
copyCommandList.D3D12GraphicsCommandList->TransitionBarrier(D3D12Resource, D3D12_RESOURCE_STATE_COPY_DEST, this.d3D12ResourceState);
}
copyCommandList.ExecuteAndWaitForCompletion();
+4 -28
ファイルの表示
@@ -43,36 +43,10 @@ public ref struct ComputeContext
public GraphicsDevice GraphicsDevice => this.device;
/// <summary>
/// Starts a resource barrier for a specific resource.
/// </summary>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to start the barrier for.</param>
internal readonly unsafe void StartBarrier(ID3D12Resource* d3D12Resource)
{
ThrowInvalidOperationExceptionIfDeviceIsNull();
ref CommandList commandList = ref GetCommandList(in this);
commandList.D3D12GraphicsCommandList->StartUAVBarrier(d3D12Resource);
}
/// <summary>
/// Ends a resource barrier for a specific resource.
/// </summary>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to end the barrier for.</param>
internal readonly unsafe void EndBarrier(ID3D12Resource* d3D12Resource)
{
ThrowInvalidOperationExceptionIfDeviceIsNull();
ref CommandList commandList = ref GetCommandList(in this);
commandList.D3D12GraphicsCommandList->EndUAVBarrier(d3D12Resource);
}
/// <summary>
/// Inserts a full a resource barrier for a specific resource.
/// Inserts a resource barrier for a specific resource.
/// </summary>
/// <param name="d3D12Resource">The <see cref="ID3D12Resource"/> to insert the barrier for.</param>
internal readonly unsafe void FullBarrier(ID3D12Resource* d3D12Resource)
internal readonly unsafe void Barrier(ID3D12Resource* d3D12Resource)
{
ThrowInvalidOperationExceptionIfDeviceIsNull();
@@ -91,6 +65,8 @@ public ref struct ComputeContext
internal readonly unsafe void Run<T>(int x, int y, int z, ref T shader)
where T : struct, IComputeShader
{
ThrowInvalidOperationExceptionIfDeviceIsNull();
bool xIs1 = x == 1;
bool yIs1 = y == 1;
bool zIs1 = z == 1;
+21 -197
ファイルの表示
@@ -11,267 +11,91 @@ namespace ComputeSharp;
public static partial class ComputeContextExtensions
{
/// <summary>
/// Starts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="buffer">The input <see cref="ReadWriteBuffer{T}"/> instance to start the barrier for.</param>
public static unsafe void StartBarrier<T>(this in ComputeContext context, ReadWriteBuffer<T> buffer)
where T : unmanaged
{
context.StartBarrier(buffer.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Starts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to start the barrier for.</param>
public static unsafe void StartBarrier<T>(this in ComputeContext context, ReadWriteTexture2D<T> texture)
where T : unmanaged
{
context.StartBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Starts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteBuffer{T}"/> instance to start the barrier for.</param>
public static unsafe void StartBarrier<T>(this in ComputeContext context, ReadWriteTexture3D<T> texture)
where T : unmanaged
{
context.StartBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Starts a resource barrier for 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 insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T,TPixel}"/> instance to start the barrier for.</param>
public static unsafe void StartBarrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture2D<T, TPixel> texture)
where T : unmanaged, IUnorm<TPixel>
where TPixel : unmanaged
{
context.StartBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Starts a resource barrier for 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 insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T,TPixel}"/> instance to start the barrier for.</param>
public static unsafe void StartBarrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture3D<T, TPixel> texture)
where T : unmanaged, IUnorm<TPixel>
where TPixel : unmanaged
{
context.StartBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Starts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="IReadWriteTexture2D{TPixel}"/> instance to start the barrier for.</param>
public static unsafe void StartBarrier<TPixel>(this in ComputeContext context, IReadWriteTexture2D<TPixel> texture)
where TPixel : unmanaged
{
context.StartBarrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Starts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="IReadWriteTexture3D{TPixel}"/> instance to start the barrier for.</param>
public static unsafe void StartBarrier<TPixel>(this in ComputeContext context, IReadWriteTexture3D<TPixel> texture)
where TPixel : unmanaged
{
context.StartBarrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Ends a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="buffer">The input <see cref="ReadWriteBuffer{T}"/> instance to end the barrier for.</param>
public static unsafe void EndBarrier<T>(this in ComputeContext context, ReadWriteBuffer<T> buffer)
where T : unmanaged
{
context.EndBarrier(buffer.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Ends a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to end the barrier for.</param>
public static unsafe void EndBarrier<T>(this in ComputeContext context, ReadWriteTexture2D<T> texture)
where T : unmanaged
{
context.EndBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Ends a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteBuffer{T}"/> instance to end the barrier for.</param>
public static unsafe void EndBarrier<T>(this in ComputeContext context, ReadWriteTexture3D<T> texture)
where T : unmanaged
{
context.EndBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Ends a resource barrier for 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 insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T,TPixel}"/> instance to end the barrier for.</param>
public static unsafe void EndBarrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture2D<T, TPixel> texture)
where T : unmanaged, IUnorm<TPixel>
where TPixel : unmanaged
{
context.EndBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Ends a resource barrier for 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 insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T,TPixel}"/> instance to end the barrier for.</param>
public static unsafe void EndBarrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture3D<T, TPixel> texture)
where T : unmanaged, IUnorm<TPixel>
where TPixel : unmanaged
{
context.EndBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Ends a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="IReadWriteTexture2D{TPixel}"/> instance to end the barrier for.</param>
public static unsafe void EndBarrier<TPixel>(this in ComputeContext context, IReadWriteTexture2D<TPixel> texture)
where TPixel : unmanaged
{
context.EndBarrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Ends a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="IReadWriteTexture3D{TPixel}"/> instance to end the barrier for.</param>
public static unsafe void EndBarrier<TPixel>(this in ComputeContext context, IReadWriteTexture3D<TPixel> texture)
where TPixel : unmanaged
{
context.EndBarrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Inserts a full resource barrier for a specific resource.
/// Inserts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the buffer.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="buffer">The input <see cref="ReadWriteBuffer{T}"/> instance to insert the barrier for.</param>
public static unsafe void FullBarrier<T>(this in ComputeContext context, ReadWriteBuffer<T> buffer)
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteBuffer<T> buffer)
where T : unmanaged
{
context.FullBarrier(buffer.ValidateAndGetID3D12Resource(context.GraphicsDevice));
context.Barrier(buffer.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Inserts a full resource barrier for a specific resource.
/// Inserts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to insert the barrier for.</param>
public static unsafe void FullBarrier<T>(this in ComputeContext context, ReadWriteTexture2D<T> texture)
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteTexture2D<T> texture)
where T : unmanaged
{
context.FullBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Inserts a full resource barrier for a specific resource.
/// Inserts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="T">The type of items stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteBuffer{T}"/> instance to insert the barrier for.</param>
public static unsafe void FullBarrier<T>(this in ComputeContext context, ReadWriteTexture3D<T> texture)
public static unsafe void Barrier<T>(this in ComputeContext context, ReadWriteTexture3D<T> texture)
where T : unmanaged
{
context.FullBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Inserts a full resource barrier for a specific resource.
/// Inserts a resource barrier for 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 insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T,TPixel}"/> instance to insert the barrier for.</param>
public static unsafe void FullBarrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture2D<T, TPixel> texture)
public static unsafe void Barrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture2D<T, TPixel> texture)
where T : unmanaged, IUnorm<TPixel>
where TPixel : unmanaged
{
context.FullBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Inserts a full resource barrier for a specific resource.
/// Inserts a resource barrier for 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 insert the resource barrier.</param>
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T,TPixel}"/> instance to insert the barrier for.</param>
public static unsafe void FullBarrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture3D<T, TPixel> texture)
public static unsafe void Barrier<T, TPixel>(this in ComputeContext context, ReadWriteTexture3D<T, TPixel> texture)
where T : unmanaged, IUnorm<TPixel>
where TPixel : unmanaged
{
context.FullBarrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
context.Barrier(texture.ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Inserts a full resource barrier for a specific resource.
/// Inserts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="IReadWriteTexture2D{TPixel}"/> instance to insert the barrier for.</param>
public static unsafe void FullBarrier<TPixel>(this in ComputeContext context, IReadWriteTexture2D<TPixel> texture)
public static unsafe void Barrier<TPixel>(this in ComputeContext context, IReadWriteTexture2D<TPixel> texture)
where TPixel : unmanaged
{
context.FullBarrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
context.Barrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
/// Inserts a full resource barrier for a specific resource.
/// Inserts a resource barrier for a specific resource.
/// </summary>
/// <typeparam name="TPixel">The type of pixels stored on the texture.</typeparam>
/// <param name="context">The <see cref="ComputeContext"/> to use to insert the resource barrier.</param>
/// <param name="texture">The input <see cref="IReadWriteTexture3D{TPixel}"/> instance to insert the barrier for.</param>
public static unsafe void FullBarrier<TPixel>(this in ComputeContext context, IReadWriteTexture3D<TPixel> texture)
public static unsafe void Barrier<TPixel>(this in ComputeContext context, IReadWriteTexture3D<TPixel> texture)
where TPixel : unmanaged
{
context.FullBarrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
context.Barrier(((GraphicsResourceHelper.IGraphicsResource)texture).ValidateAndGetID3D12Resource(context.GraphicsDevice));
}
/// <summary>
+31 -3
ファイルの表示
@@ -45,7 +45,7 @@ public partial class ComputeContextTests
using (ComputeContext context = device.Get().CreateComputeContext())
{
context.ForEach(texture, default(ClearPixelShader));
context.FullBarrier(texture);
context.Barrier(texture);
context.ForEach(texture, new ColorPixelShader(new float4(0.22f, 0.44f, 0.66f, 0.88f)));
}
@@ -74,9 +74,8 @@ public partial class ComputeContextTests
context.For(512, new OffsetComputeShader(buffer, 0));
context.For(64, new OffsetComputeShader(buffer, 512));
context.ForEach(texture, default(ClearPixelShader));
context.StartBarrier(texture);
context.For(299, new OffsetComputeShader(buffer, 576));
context.EndBarrier(texture);
context.Barrier(texture);
context.ForEach(texture, new ColorPixelShader(new float4(0.22f, 0.44f, 0.66f, 0.88f)));
context.For(149, new OffsetComputeShader(buffer, 875));
}
@@ -107,6 +106,35 @@ public partial class ComputeContextTests
}
}
[CombinatorialTestMethod]
[AllDevices]
[ExpectedException(typeof(InvalidOperationException))]
public void Barrier_WithoutPreviousDispatches_ThrowsException(Device device)
{
using ReadWriteBuffer<int> buffer = device.Get().AllocateReadWriteBuffer<int>(64);
using (ComputeContext context = device.Get().CreateComputeContext())
{
context.Barrier(buffer);
}
Assert.Fail();
}
[CombinatorialTestMethod]
[AllDevices]
[ExpectedException(typeof(InvalidOperationException))]
public void DefaultContext_Barrier_ThrowsException(Device device)
{
using ReadWriteBuffer<int> buffer = device.Get().AllocateReadWriteBuffer<int>(64);
using ComputeContext context = default;
context.Barrier(buffer);
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void DefaultContext_For_ThrowsException()