Add unit tests for 1D texture dimension accessors
このコミットが含まれているのは:
1 親
8c7c659aa3
コミット
d3476684fc
2ファイル変更
+236
検索条件に一致するファイルはありません
@@ -72,6 +72,234 @@ public partial class ResourceDimensionsTests
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8)]
|
||||
[Data(64)]
|
||||
[Data(128)]
|
||||
[Data(376)]
|
||||
public void ReadOnlyTexture1D_T1_AsReadOnlyTexture1D(Device device, int axis0)
|
||||
{
|
||||
using ReadOnlyTexture1D<float> resource = device.Get().AllocateReadOnlyTexture1D<float>(axis0);
|
||||
using ReadWriteBuffer<int> result = device.Get().AllocateReadWriteBuffer<int>(1);
|
||||
|
||||
device.Get().For(1, new ReadOnlyTexture1D_T1_AsReadOnlyTexture1DShader(resource, result));
|
||||
|
||||
int[] dimensions = result.ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
expected: new[] { axis0 },
|
||||
actual: dimensions);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct ReadOnlyTexture1D_T1_AsReadOnlyTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<float> source;
|
||||
public readonly ReadWriteBuffer<int> result;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
result[0] = source.Width;
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8)]
|
||||
[Data(64)]
|
||||
[Data(128)]
|
||||
[Data(376)]
|
||||
public void ReadWriteTexture1D_T1_AsReadWriteTexture1D(Device device, int axis0)
|
||||
{
|
||||
using ReadWriteTexture1D<float> resource = device.Get().AllocateReadWriteTexture1D<float>(axis0);
|
||||
using ReadWriteBuffer<int> result = device.Get().AllocateReadWriteBuffer<int>(1);
|
||||
|
||||
device.Get().For(1, new ReadWriteTexture1D_T1_AsReadWriteTexture1DShader(resource, result));
|
||||
|
||||
int[] dimensions = result.ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
expected: new[] { axis0 },
|
||||
actual: dimensions);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T1_AsReadWriteTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture1D<float> source;
|
||||
public readonly ReadWriteBuffer<int> result;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
result[0] = source.Width;
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8)]
|
||||
[Data(64)]
|
||||
[Data(128)]
|
||||
[Data(376)]
|
||||
public void ReadWriteTexture1D_T1_AsIReadOnlyTexture1D(Device device, int axis0)
|
||||
{
|
||||
using ReadWriteTexture1D<float> resource = device.Get().AllocateReadWriteTexture1D<float>(axis0);
|
||||
using ReadWriteBuffer<int> result = device.Get().AllocateReadWriteBuffer<int>(1);
|
||||
|
||||
using (var context = device.Get().CreateComputeContext())
|
||||
{
|
||||
context.Transition(resource, ResourceState.ReadOnly);
|
||||
context.For(1, new ReadWriteTexture1D_T1_AsIReadOnlyTexture1DShader(resource.AsReadOnly(), result));
|
||||
}
|
||||
|
||||
int[] dimensions = result.ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
expected: new[] { axis0 },
|
||||
actual: dimensions);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T1_AsIReadOnlyTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyTexture1D<float> source;
|
||||
public readonly ReadWriteBuffer<int> result;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
result[0] = source.Width;
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8)]
|
||||
[Data(64)]
|
||||
[Data(128)]
|
||||
[Data(376)]
|
||||
public void ReadOnlyTexture1D_T2_AsReadOnlyTexture1D(Device device, int axis0)
|
||||
{
|
||||
using ReadOnlyTexture1D<Rgba32, float4> resource = device.Get().AllocateReadOnlyTexture1D<Rgba32, float4>(axis0);
|
||||
using ReadWriteBuffer<int> result = device.Get().AllocateReadWriteBuffer<int>(1);
|
||||
|
||||
device.Get().For(1, new ReadOnlyTexture1D_T2_AsReadOnlyTexture1DShader(resource, result));
|
||||
|
||||
int[] dimensions = result.ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
expected: new[] { axis0 },
|
||||
actual: dimensions);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct ReadOnlyTexture1D_T2_AsReadOnlyTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadOnlyTexture1D<Rgba32, float4> source;
|
||||
public readonly ReadWriteBuffer<int> result;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
result[0] = source.Width;
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8)]
|
||||
[Data(64)]
|
||||
[Data(128)]
|
||||
[Data(376)]
|
||||
public void ReadOnlyTexture1D_T2_AsIReadOnlyNormalizedTexture1D(Device device, int axis0)
|
||||
{
|
||||
using ReadOnlyTexture1D<Rgba32, float4> resource = device.Get().AllocateReadOnlyTexture1D<Rgba32, float4>(axis0);
|
||||
using ReadWriteBuffer<int> result = device.Get().AllocateReadWriteBuffer<int>(1);
|
||||
|
||||
device.Get().For(1, new ReadOnlyTexture1D_T2_AsIReadOnlyNormalizedTexture1DShader(resource, result));
|
||||
|
||||
int[] dimensions = result.ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
expected: new[] { axis0 },
|
||||
actual: dimensions);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct ReadOnlyTexture1D_T2_AsIReadOnlyNormalizedTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadOnlyNormalizedTexture1D<float4> source;
|
||||
public readonly ReadWriteBuffer<int> result;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
result[0] = source.Width;
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8)]
|
||||
[Data(64)]
|
||||
[Data(128)]
|
||||
[Data(376)]
|
||||
public void ReadWriteTexture1D_T2_AsReadWriteTexture1D(Device device, int axis0)
|
||||
{
|
||||
using ReadWriteTexture1D<Rgba32, float4> resource = device.Get().AllocateReadWriteTexture1D<Rgba32, float4>(axis0);
|
||||
using ReadWriteBuffer<int> result = device.Get().AllocateReadWriteBuffer<int>(1);
|
||||
|
||||
device.Get().For(1, new ReadWriteTexture1D_T2_AsReadWriteTexture1DShader(resource, result));
|
||||
|
||||
int[] dimensions = result.ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
expected: new[] { axis0 },
|
||||
actual: dimensions);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T2_AsReadWriteTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteTexture1D<Rgba32, float4> source;
|
||||
public readonly ReadWriteBuffer<int> result;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
result[0] = source.Width;
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8)]
|
||||
[Data(64)]
|
||||
[Data(128)]
|
||||
[Data(376)]
|
||||
public void ReadWriteTexture1D_T2_AsIReadWriteNormalizedTexture1D(Device device, int axis0)
|
||||
{
|
||||
using ReadWriteTexture1D<Rgba32, float4> resource = device.Get().AllocateReadWriteTexture1D<Rgba32, float4>(axis0);
|
||||
using ReadWriteBuffer<int> result = device.Get().AllocateReadWriteBuffer<int>(1);
|
||||
|
||||
device.Get().For(1, new ReadWriteTexture1D_T2_AsIReadWriteNormalizedTexture1DShader(resource, result));
|
||||
|
||||
int[] dimensions = result.ToArray();
|
||||
|
||||
CollectionAssert.AreEqual(
|
||||
expected: new[] { axis0 },
|
||||
actual: dimensions);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
internal readonly partial struct ReadWriteTexture1D_T2_AsIReadWriteNormalizedTexture1DShader : IComputeShader
|
||||
{
|
||||
public readonly IReadWriteNormalizedTexture1D<float4> source;
|
||||
public readonly ReadWriteBuffer<int> result;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
result[0] = source.Width;
|
||||
}
|
||||
}
|
||||
|
||||
[CombinatorialTestMethod]
|
||||
[AllDevices]
|
||||
[Data(8, 12)]
|
||||
|
||||
@@ -20,6 +20,10 @@ var typesMap = new Dictionary<string, string[]>
|
||||
{
|
||||
["ReadOnlyBuffer<float>"] = new[] { "Length" },
|
||||
["ReadWriteBuffer<float>"] = new[] { "Length" },
|
||||
["ReadOnlyTexture1D<float>"] = new[] { "Width" },
|
||||
["ReadWriteTexture1D<float>"] = new[] { "Width" },
|
||||
["ReadOnlyTexture1D<Rgba32, float4>"] = new[] { "Width" },
|
||||
["ReadWriteTexture1D<Rgba32, float4>"] = new[] { "Width" },
|
||||
["ReadOnlyTexture2D<float>"] = new[] { "Width", "Height" },
|
||||
["ReadWriteTexture2D<float>"] = new[] { "Width", "Height" },
|
||||
["ReadOnlyTexture2D<Rgba32, float4>"] = new[] { "Width", "Height" },
|
||||
@@ -33,6 +37,9 @@ var typesMap = new Dictionary<string, string[]>
|
||||
// Map of all resource types that also have a supported interface
|
||||
var interfacesMap = new Dictionary<string, string>
|
||||
{
|
||||
["ReadWriteTexture1D<float>"] = "IReadOnlyTexture1D<float>",
|
||||
["ReadOnlyTexture1D<Rgba32, float4>"] = "IReadOnlyNormalizedTexture1D<float4>",
|
||||
["ReadWriteTexture1D<Rgba32, float4>"] = "IReadWriteNormalizedTexture1D<float4>",
|
||||
["ReadWriteTexture2D<float>"] = "IReadOnlyTexture2D<float>",
|
||||
["ReadOnlyTexture2D<Rgba32, float4>"] = "IReadOnlyNormalizedTexture2D<float4>",
|
||||
["ReadWriteTexture2D<Rgba32, float4>"] = "IReadWriteNormalizedTexture2D<float4>",
|
||||
@@ -44,6 +51,7 @@ var interfacesMap = new Dictionary<string, string>
|
||||
// Map of all resource that need a readonly wrapper
|
||||
var readonlyWrappersMap = new HashSet<string>
|
||||
{
|
||||
"IReadOnlyTexture1D<float>",
|
||||
"IReadOnlyTexture2D<float>",
|
||||
"IReadOnlyTexture3D<float>"
|
||||
};
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする