From e74ad2cd349164a7b7589e72afe54b417ab3c7af Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 17 Jan 2022 00:28:42 +0100 Subject: [PATCH] Improve XML docs for ReadWriteTexture[2D|3D].AsReadOnly() --- .../ReadWriteTexture2D{T,TPixel}.ReadOnly.cs | 15 ++++++++++++++- .../ReadWriteTexture3D{T,TPixel}.ReadOnly.cs | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs index da053be2..ec18c94f 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs @@ -25,7 +25,20 @@ partial class ReadWriteTexture2D /// Retrieves a wrapping instance for the current resource. /// /// An instance wrapping the current resource. - /// The returned instance can be used in a shader to enable texture sampling. + /// + /// The returned instance can be used in a shader to enable texture sampling. + /// + /// 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 , + /// and specify . After that, 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 , 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 . Failing to do so results in undefined behavior. + /// + /// + /// Thrown if the current instance or its associated device are disposed. + /// Thrown if the current instance is not in a readonly state. public IReadOnlyTexture2D AsReadOnly() { GraphicsDevice.ThrowIfDisposed(); diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs index 287efcb1..dff848da 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs @@ -25,7 +25,20 @@ partial class ReadWriteTexture3D /// Retrieves a wrapping instance for the current resource. /// /// An instance wrapping the current resource. - /// The returned instance can be used in a shader to enable texture sampling. + /// + /// The returned instance can be used in a shader to enable texture sampling. + /// + /// 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 , + /// and specify . After that, 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 , 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 . Failing to do so results in undefined behavior. + /// + /// + /// Thrown if the current instance or its associated device are disposed. + /// Thrown if the current instance is not in a readonly state. public IReadOnlyTexture3D AsReadOnly() { GraphicsDevice.ThrowIfDisposed();