Add new Transition and AsReadOnly extensions for writeable textures
このコミットが含まれているのは:
1 親
f01fc0ebfb
コミット
c81eecfd64
7ファイル変更
+375
-73
検索条件に一致するファイルはありません
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="ReadWriteTexture2D{T}"/> and <see cref="ReadWriteTexture2D{T, TPixel}"/> types.
|
||||
/// </summary>
|
||||
public static class ReadWriteTexture2DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture2D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture2D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture2D{float}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<float> AsReadOnly(this ReadWriteTexture2D<float> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture2D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture2D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture2D{Float2}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<Float2> AsReadOnly(this ReadWriteTexture2D<Float2> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture2D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture2D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture2D{Float3}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<Float3> AsReadOnly(this ReadWriteTexture2D<Float3> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture2D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture2D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture2D{Float4}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture2D<Float4> AsReadOnly(this ReadWriteTexture2D<Float4> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyNormalizedTexture2D{TPixel}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T, TPixel}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyNormalizedTexture2D{TPixel}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition{T, TPixel}(in ComputeContext, ReadWriteTexture2D{T, TPixel}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyNormalizedTexture2D<TPixel> AsReadOnly<T, TPixel>(this ReadWriteTexture2D<T, TPixel> texture)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> that contains extension methods for the <see cref="ReadWriteTexture3D{T}"/> and <see cref="ReadWriteTexture3D{T, TPixel}"/> types.
|
||||
/// </summary>
|
||||
public static class ReadWriteTexture3DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture3D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture3D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture3D{float}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<float> AsReadOnly(this ReadWriteTexture3D<float> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture3D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture3D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture3D{Float2}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<Float2> AsReadOnly(this ReadWriteTexture3D<Float2> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture3D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture3D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture3D{Float3}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<Float3> AsReadOnly(this ReadWriteTexture3D<Float3> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture3D{T}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyTexture3D{T}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition(in ComputeContext, ReadWriteTexture3D{Float4}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyTexture3D<Float4> AsReadOnly(this ReadWriteTexture3D<Float4> texture)
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyNormalizedTexture3D{TPixel}"/> instance for the input resource.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of items to store in the texture.</typeparam>
|
||||
/// <typeparam name="TPixel">The type of pixels used on the GPU side.</typeparam>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T, TPixel}"/> instance to create a wrapper for.</param>
|
||||
/// <returns>An <see cref="IReadOnlyNormalizedTexture3D{TPixel}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition{T, TPixel}(in ComputeContext, ReadWriteTexture3D{T, TPixel}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, this method can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public static IReadOnlyNormalizedTexture3D<TPixel> AsReadOnly<T, TPixel>(this ReadWriteTexture3D<T, TPixel> texture)
|
||||
where T : unmanaged, IPixel<T, TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
return texture.AsReadOnly();
|
||||
}
|
||||
}
|
||||
@@ -21,25 +21,8 @@ partial class ReadWriteTexture2D<T, TPixel>
|
||||
/// </summary>
|
||||
private ReadOnly? readOnlyWrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyNormalizedTexture2D{TPixel}"/> instance for the current resource.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IReadOnlyNormalizedTexture2D{TPixel}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition{T, TPixel}(in ComputeContext, ReadWriteTexture2D{T, TPixel}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, <see cref="AsReadOnly"/> can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
public IReadOnlyNormalizedTexture2D<TPixel> AsReadOnly()
|
||||
/// <inheritdoc cref="ReadWriteTexture2DExtensions.AsReadOnly{T, TPixel}(ReadWriteTexture2D{T, TPixel})"/>
|
||||
internal IReadOnlyNormalizedTexture2D<TPixel> AsReadOnly()
|
||||
{
|
||||
GraphicsDevice.ThrowIfDisposed();
|
||||
|
||||
|
||||
@@ -21,24 +21,7 @@ partial class ReadWriteTexture2D<T>
|
||||
/// </summary>
|
||||
private ReadOnly? readOnlyWrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture2D{TPixel}"/> instance for the current resource.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IReadOnlyTexture2D{TPixel}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition{T, TPixel}(in ComputeContext, ReadWriteTexture2D{T, TPixel}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, <see cref="AsReadOnly"/> can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
/// <inheritdoc cref="ReadWriteTexture2DExtensions.AsReadOnly(ReadWriteTexture2D{float})"/>
|
||||
public IReadOnlyTexture2D<T> AsReadOnly()
|
||||
{
|
||||
GraphicsDevice.ThrowIfDisposed();
|
||||
|
||||
@@ -21,24 +21,7 @@ partial class ReadWriteTexture3D<T, TPixel>
|
||||
/// </summary>
|
||||
private ReadOnly? readOnlyWrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyNormalizedTexture3D{TPixel}"/> instance for the current resource.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IReadOnlyNormalizedTexture3D{TPixel}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition{T, TPixel}(in ComputeContext, ReadWriteTexture3D{T, TPixel}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, <see cref="AsReadOnly"/> can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
/// <inheritdoc cref="ReadWriteTexture3DExtensions.AsReadOnly{T, TPixel}(ReadWriteTexture3D{T, TPixel})"/>
|
||||
public IReadOnlyNormalizedTexture3D<TPixel> AsReadOnly()
|
||||
{
|
||||
GraphicsDevice.ThrowIfDisposed();
|
||||
|
||||
@@ -21,24 +21,7 @@ partial class ReadWriteTexture3D<T>
|
||||
/// </summary>
|
||||
private ReadOnly? readOnlyWrapper;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a wrapping <see cref="IReadOnlyTexture3D{TPixel}"/> instance for the current resource.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IReadOnlyTexture3D{TPixel}"/> instance wrapping the current resource.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The returned instance can be used in a shader to enable texture sampling.</para>
|
||||
/// <para>
|
||||
/// This is an advanced API that can only be used after the current instance has been transitioned to be in a readonly state. To do so,
|
||||
/// use <see cref="ComputeContextExtensions.Transition{T, TPixel}(in ComputeContext, ReadWriteTexture3D{T, TPixel}, ResourceState)"/>,
|
||||
/// and specify <see cref="ResourceState.ReadOnly"/>. After that, <see cref="AsReadOnly"/> can be used to get a readonly wrapper for
|
||||
/// the current texture to use in a shader. This instance should not be cached or reused, but just passed directly to a shader
|
||||
/// being dispatched through that same <see cref="ComputeContext"/>, as it will not work if the texture changes state later on.
|
||||
/// Before the end of that list of operations, the texture also needs to be transitioned back to writeable state, using the same
|
||||
/// API as before but specifying <see cref="ResourceState.ReadWrite"/>. Failing to do so results in undefined behavior.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
/// <exception cref="ObjectDisposedException">Thrown if the current instance or its associated device are disposed.</exception>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the current instance is not in a readonly state.</exception>
|
||||
/// <inheritdoc cref="ReadWriteTexture3DExtensions.AsReadOnly(ReadWriteTexture3D{float})"/>
|
||||
public IReadOnlyTexture3D<T> AsReadOnly()
|
||||
{
|
||||
GraphicsDevice.ThrowIfDisposed();
|
||||
|
||||
@@ -363,6 +363,58 @@ public static class ComputeContextExtensions
|
||||
context.Run(texture, ref Unsafe.AsRef(in shader));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<float> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<Float2> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<Float3> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture2D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture2D<Float4> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
@@ -380,6 +432,58 @@ public static class ComputeContextExtensions
|
||||
context.Transition(d3D12Resource, states.Before, states.After);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Transitions the state of a specific resource.
|
||||
/// </summary>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<float> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<Float2> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<Float3> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
/// <param name="context">The <see cref="ComputeContext"/> to use to transition the resource.</param>
|
||||
/// <param name="texture">The input <see cref="ReadWriteTexture3D{T}"/> instance to transition.</param>
|
||||
/// <param name="resourceState">The state to transition the input resource to.</param>
|
||||
public static unsafe void Transition(this in ComputeContext context, ReadWriteTexture3D<Float4> texture, ResourceState resourceState)
|
||||
{
|
||||
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>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする