diff --git a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs index ec23a17f..4536d996 100644 --- a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs @@ -43,7 +43,7 @@ public sealed class ConstantBuffer : Buffer /// /// The index of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - public T this[int i] => throw new InvalidExecutionContextException($"{typeof(ConstantBuffer)}[{typeof(int)}]"); + public ref readonly T this[int i] => throw new InvalidExecutionContextException($"{typeof(ConstantBuffer)}[{typeof(int)}]"); /// /// Gets the right padded size for elements to store in the current instance. diff --git a/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture2D{TPixel}.cs b/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture2D{TPixel}.cs index 367d8dd1..39fa80da 100644 --- a/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture2D{TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture2D{TPixel}.cs @@ -24,14 +24,14 @@ public interface IReadOnlyTexture2D : IGraphicsResource /// The horizontal offset of the value to get. /// The vertical offset of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[int x, int y] { get; } + ref readonly TPixel this[int x, int y] { get; } /// /// Gets a single value from the current readonly texture. /// /// The coordinates of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[Int2 xy] { get; } + ref readonly TPixel this[Int2 xy] { get; } /// /// Gets a single value from the current readonly texture with linear sampling. @@ -39,12 +39,12 @@ public interface IReadOnlyTexture2D : IGraphicsResource /// The horizontal normalized offset of the value to get. /// The vertical normalized offset of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[float u, float v] { get; } + ref readonly TPixel this[float u, float v] { get; } /// /// Gets a single value from the current readonly texture with linear sampling. /// /// The normalized coordinates of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[Float2 uv] { get; } + ref readonly TPixel this[Float2 uv] { get; } } diff --git a/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture3D{TPixel}.cs b/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture3D{TPixel}.cs index 7a92ae62..625cd1f8 100644 --- a/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture3D{TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/Interfaces/IReadOnlyTexture3D{TPixel}.cs @@ -30,14 +30,14 @@ public interface IReadOnlyTexture3D : IGraphicsResource /// The vertical offset of the value to get. /// The depthwise offset of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[int x, int y, int z] { get; } + ref readonly TPixel this[int x, int y, int z] { get; } /// /// Gets a single value from the current readonly texture. /// /// The coordinates of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[Int3 xyz] { get; } + ref readonly TPixel this[Int3 xyz] { get; } /// /// Gets a single value from the current readonly texture with linear sampling. @@ -46,12 +46,12 @@ public interface IReadOnlyTexture3D : IGraphicsResource /// The vertical normalized offset of the value to get. /// The depthwise normalized offset of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[float u, float v, float w] { get; } + ref readonly TPixel this[float u, float v, float w] { get; } /// /// Gets a single value from the current readonly texture with linear sampling. /// /// The normalized coordinates of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - TPixel this[Float3 uvw] { get; } + ref readonly TPixel this[Float3 uvw] { get; } } diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs index 7f5c2cb0..46613dae 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs @@ -31,7 +31,7 @@ public sealed class ReadOnlyBuffer : StructuredBuffer /// /// The index of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - public T this[int i] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyBuffer)}[{typeof(int)}]"); + public ref readonly T this[int i] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyBuffer)}[{typeof(int)}]"); /// public override string ToString() diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs index ec1c9cfc..8ad822a1 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs @@ -31,16 +31,16 @@ public sealed class ReadOnlyTexture2D : Texture2D, IReadOnlyTextur } /// - public TPixel this[int x, int y] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(int)}, {typeof(int)}]"); + public ref readonly TPixel this[int x, int y] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(int)}, {typeof(int)}]"); /// - public TPixel this[Int2 xy] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(Int2)}]"); + public ref readonly TPixel this[Int2 xy] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(Int2)}]"); /// - public TPixel this[float u, float v] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(float)}, {typeof(float)}]"); + public ref readonly TPixel this[float u, float v] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(float)}, {typeof(float)}]"); /// - public TPixel this[Float2 uv] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(Float2)}]"); + public ref readonly TPixel this[Float2 uv] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(Float2)}]"); /// public override string ToString() diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs index a59b1919..5b6e7271 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs @@ -34,14 +34,14 @@ public sealed class ReadOnlyTexture2D : Texture2D /// The horizontal offset of the value to get. /// The vertical offset of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - public T this[int x, int y] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(int)}, {typeof(int)}]"); + public ref readonly T this[int x, int y] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(int)}, {typeof(int)}]"); /// /// Gets a single value from the current readonly texture. /// /// The coordinates of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - public T this[Int2 xy] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(Int2)}]"); + public ref readonly T this[Int2 xy] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture2D)}[{typeof(Int2)}]"); /// public override string ToString() diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs index e67020da..7f0ca4bd 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs @@ -32,16 +32,16 @@ public sealed class ReadOnlyTexture3D : Texture3D, IReadOnlyTextur } /// - public TPixel this[int x, int y, int z] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(int)}, {typeof(int)}, {typeof(int)}]"); + public ref readonly TPixel this[int x, int y, int z] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(int)}, {typeof(int)}, {typeof(int)}]"); /// - public TPixel this[Int3 xyz] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(Int3)}]"); + public ref readonly TPixel this[Int3 xyz] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(Int3)}]"); /// - public TPixel this[float u, float v, float w] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(float)}, {typeof(float)}, {typeof(float)}]"); + public ref readonly TPixel this[float u, float v, float w] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(float)}, {typeof(float)}, {typeof(float)}]"); /// - public TPixel this[Float3 uvw] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(Float3)}]"); + public ref readonly TPixel this[Float3 uvw] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(Float3)}]"); /// public override string ToString() diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs index 9d7082b7..dd4baaa0 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs @@ -36,14 +36,14 @@ public sealed class ReadOnlyTexture3D : Texture3D /// The vertical offset of the value to get. /// The depthwise offset of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - public T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(int)}, {typeof(int)}, {typeof(int)}]"); + public ref readonly T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(int)}, {typeof(int)}, {typeof(int)}]"); /// /// Gets a single value from the current readonly texture. /// /// The coordinates of the value to get. /// This API can only be used from a compute shader, and will always throw if used anywhere else. - public T this[Int3 xyz] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(Int3)}]"); + public ref readonly T this[Int3 xyz] => throw new InvalidExecutionContextException($"{typeof(ReadOnlyTexture3D)}[{typeof(Int3)}]"); /// public override string ToString()