Added missing normalized texture types
このコミットが含まれているのは:
1 親
aaf8b5cac4
コミット
b54fb3c7df
6ファイル変更
+187
-4
検索条件に一致するファイルはありません
@@ -0,0 +1,56 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics;
|
||||
using ComputeSharp.Graphics.Buffers.Abstract;
|
||||
using ComputeSharp.Graphics.Buffers.Enums;
|
||||
using ComputeSharp.Graphics.Buffers.Views;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a typed readonly 2D texture stored on GPU memory.
|
||||
/// </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>
|
||||
[DebuggerTypeProxy(typeof(Texture2DDebugView<>))]
|
||||
[DebuggerDisplay("{ToString(),raw}")]
|
||||
public sealed class ReadOnlyTexture2D<T, TPixel> : Texture2D<T>
|
||||
where T : unmanaged, IUnorm<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadOnlyTexture2D{T,TPixel}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
internal ReadOnlyTexture2D(GraphicsDevice device, int width, int height)
|
||||
: base(device, width, height, ResourceType.ReadOnly)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
|
||||
/// </summary>
|
||||
/// <param name="x">The horizontal offset of the value to get.</param>
|
||||
/// <param name="y">The vertical offset of the value to get.</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
|
||||
public T this[int x, int y] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T, TPixel>)}<T>[int,int]");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
|
||||
/// </summary>
|
||||
/// <param name="xy">The coordinates of the value to get.</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
|
||||
public T this[Int2 xy] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture2D<T,TPixel>)}<T>[Int2]");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"ComputeSharp.ReadOnlyTexture2D<{typeof(T)},{typeof(TPixel)}>[{Width}, {Height}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics;
|
||||
using ComputeSharp.Graphics.Buffers.Abstract;
|
||||
using ComputeSharp.Graphics.Buffers.Enums;
|
||||
using ComputeSharp.Graphics.Buffers.Views;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a typed readonly 3D texture stored on GPU memory.
|
||||
/// </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>
|
||||
[DebuggerTypeProxy(typeof(Texture3DDebugView<>))]
|
||||
[DebuggerDisplay("{ToString(),raw}")]
|
||||
public sealed class ReadOnlyTexture3D<T, TPixel> : Texture3D<T>
|
||||
where T : unmanaged, IUnorm<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadOnlyTexture3D{T,TPixel}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
internal ReadOnlyTexture3D(GraphicsDevice device, int width, int height, int depth)
|
||||
: base(device, width, height, depth, ResourceType.ReadOnly)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
|
||||
/// </summary>
|
||||
/// <param name="x">The horizontal offset of the value to get.</param>
|
||||
/// <param name="y">The vertical offset of the value to get.</param>
|
||||
/// <param name="y">The depthwise offset of the value to get.</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
|
||||
public T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture3D<T, TPixel>)}<T>[int,int,int]");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current readonly texture.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The coordinates of the value to get.</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
|
||||
public T this[Int3 xyz] => throw new InvalidExecutionContextException($"{nameof(ReadOnlyTexture3D<T, TPixel>)}<T>[Int3]");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"ComputeSharp.ReadOnlyTexture3D<{typeof(T)},{nameof(TPixel)}>[{Width}, {Height}, {Depth}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Diagnostics;
|
||||
using ComputeSharp.__Internals;
|
||||
using ComputeSharp.Exceptions;
|
||||
using ComputeSharp.Graphics;
|
||||
using ComputeSharp.Graphics.Buffers.Abstract;
|
||||
using ComputeSharp.Graphics.Buffers.Enums;
|
||||
using ComputeSharp.Graphics.Buffers.Views;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> representing a typed readonly 3D texture stored on GPU memory.
|
||||
/// </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>
|
||||
[DebuggerTypeProxy(typeof(Texture3DDebugView<>))]
|
||||
[DebuggerDisplay("{ToString(),raw}")]
|
||||
public sealed class ReadWriteTexture3D<T, TPixel> : Texture3D<T>
|
||||
where T : unmanaged, IUnorm<TPixel>
|
||||
where TPixel : unmanaged
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ReadOnlyTexture2D{T,TPixel}"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="depth">The depth of the texture.</param>
|
||||
internal ReadWriteTexture3D(GraphicsDevice device, int width, int height, int depth)
|
||||
: base(device, width, height, depth, ResourceType.ReadWrite)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current writeable texture.
|
||||
/// </summary>
|
||||
/// <param name="x">The horizontal offset of the value to get.</param>
|
||||
/// <param name="y">The vertical offset of the value to get.</param>
|
||||
/// <param name="z">The depthwise offset of the value to get.</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
|
||||
public ref T this[int x, int y, int z] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture3D<T, TPixel>)}<T>[int,int,int]");
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single <typeparamref name="T"/> value from the current writeable texture.
|
||||
/// </summary>
|
||||
/// <param name="xyz">The coordinates of the value to get.</param>
|
||||
/// <remarks>This API can only be used from a compute shader, and will always throw if used anywhere else.</remarks>
|
||||
public ref T this[Int3 xyz] => throw new InvalidExecutionContextException($"{nameof(ReadWriteTexture3D<T, TPixel>)}<T>[Int3]");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"ComputeSharp.ReadWriteTexture3D<{typeof(T)},{nameof(TPixel)}>[{Width}, {Height}, {Depth}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,9 @@ namespace ComputeSharp.Shaders.Mappings
|
||||
return
|
||||
genericType == typeof(ReadOnlyBuffer<>) ||
|
||||
genericType == typeof(ReadOnlyTexture2D<>) ||
|
||||
genericType == typeof(ReadOnlyTexture3D<>);
|
||||
genericType == typeof(ReadOnlyTexture2D<,>) ||
|
||||
genericType == typeof(ReadOnlyTexture3D<>) ||
|
||||
genericType == typeof(ReadOnlyTexture3D<,>);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,7 +98,8 @@ namespace ComputeSharp.Shaders.Mappings
|
||||
genericType == typeof(ReadWriteBuffer<>) ||
|
||||
genericType == typeof(ReadWriteTexture2D<>) ||
|
||||
genericType == typeof(ReadWriteTexture2D<,>) ||
|
||||
genericType == typeof(ReadWriteTexture3D<>);
|
||||
genericType == typeof(ReadWriteTexture3D<>) ||
|
||||
genericType == typeof(ReadWriteTexture3D<,>);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,13 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
private static readonly IReadOnlyDictionary<string, string> KnownIndexers = new Dictionary<string, string>
|
||||
{
|
||||
[$"ComputeSharp.ReadOnlyTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2",
|
||||
[$"ComputeSharp.ReadOnlyTexture2D`2.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2",
|
||||
[$"ComputeSharp.ReadWriteTexture2D`1.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2",
|
||||
[$"ComputeSharp.ReadWriteTexture2D`2.this[{typeof(int).FullName}, {typeof(int).FullName}]"] = "int2",
|
||||
[$"ComputeSharp.ReadOnlyTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3",
|
||||
[$"ComputeSharp.ReadWriteTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3"
|
||||
[$"ComputeSharp.ReadOnlyTexture3D`2.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3",
|
||||
[$"ComputeSharp.ReadWriteTexture3D`1.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3",
|
||||
[$"ComputeSharp.ReadWriteTexture3D`2.this[{typeof(int).FullName}, {typeof(int).FullName}, {typeof(int).FullName}]"] = "int3"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
@@ -72,10 +71,13 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
case "ComputeSharp.ReadOnlyBuffer`1":
|
||||
case "ComputeSharp.ReadWriteBuffer`1":
|
||||
case "ComputeSharp.ReadOnlyTexture2D`1":
|
||||
case "ComputeSharp.ReadOnlyTexture2D`2":
|
||||
case "ComputeSharp.ReadWriteTexture2D`1":
|
||||
case "ComputeSharp.ReadWriteTexture2D`2":
|
||||
case "ComputeSharp.ReadOnlyTexture3D`1":
|
||||
case "ComputeSharp.ReadOnlyTexture3D`2":
|
||||
case "ComputeSharp.ReadWriteTexture3D`1":
|
||||
case "ComputeSharp.ReadWriteTexture3D`2":
|
||||
return true;
|
||||
default: return false;
|
||||
};
|
||||
@@ -125,10 +127,13 @@ namespace ComputeSharp.SourceGenerators.Mappings
|
||||
"ComputeSharp.ReadOnlyBuffer`1" => $"StructuredBuffer<{mapped}>",
|
||||
"ComputeSharp.ReadWriteBuffer`1" => $"RWStructuredBuffer<{mapped}>",
|
||||
"ComputeSharp.ReadOnlyTexture2D`1" => $"Texture2D<{mapped}>",
|
||||
"ComputeSharp.ReadOnlyTexture2D`2" => $"Texture2D<unorm {mapped}>",
|
||||
"ComputeSharp.ReadWriteTexture2D`1" => $"RWTexture2D<{mapped}>",
|
||||
"ComputeSharp.ReadWriteTexture2D`2" => $"RWTexture2D<unorm {mapped}>",
|
||||
"ComputeSharp.ReadOnlyTexture3D`1" => $"Texture3D<{mapped}>",
|
||||
"ComputeSharp.ReadOnlyTexture3D`2" => $"Texture3D<unorm {mapped}>",
|
||||
"ComputeSharp.ReadWriteTexture3D`1" => $"RWTexture3D<{mapped}>",
|
||||
"ComputeSharp.ReadWriteTexture3D`2" => $"RWTexture3D<unorm {mapped}>",
|
||||
_ => throw new ArgumentException()
|
||||
};
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする