84 行
2.2 KiB
Plaintext
84 行
2.2 KiB
Plaintext
<#@ template debug="false" hostspecific="false" language="C#" #>
|
|
<#@ assembly name="System.Core" #>
|
|
<#@ import namespace="System.Linq" #>
|
|
<#@ import namespace="System.Text" #>
|
|
<#@ import namespace="System.Collections.Generic" #>
|
|
<#@ output extension=".g.cs"#>
|
|
<#
|
|
var typesMap = new Dictionary<string, string[]>
|
|
{
|
|
["Bgra32"] = new[] { "Float4" },
|
|
["R16"] = new[] { "float" },
|
|
["R8"] = new[] { "float" },
|
|
["Rg16"] = new[] { "Float2" },
|
|
["Rg32"] = new[] { "Float2" },
|
|
["Rgba32"] = new[] { "Float4" },
|
|
["Rgba64"] = new[] { "Float4" }
|
|
};
|
|
|
|
IEnumerable<(string T, string TPixel)> EnumerateTypes()
|
|
{
|
|
foreach (var pair in typesMap)
|
|
foreach (var tPixel in pair.Value)
|
|
yield return (pair.Key, tPixel);
|
|
}
|
|
#>
|
|
using System;
|
|
using ComputeSharp.Tests.Attributes;
|
|
using ComputeSharp.Tests.Extensions;
|
|
|
|
namespace ComputeSharp.Tests;
|
|
|
|
partial class Texture1DTests
|
|
{
|
|
[CombinatorialTestMethod]
|
|
[AllDevices]
|
|
<#
|
|
foreach (var (t, tPixel) in EnumerateTypes())
|
|
{
|
|
#>
|
|
[Data(typeof(<#=t#>), typeof(<#=tPixel#>))]
|
|
<#
|
|
}
|
|
#>
|
|
public void Dispatch_NormalizedTexture1D(Device device, Type t, Type tPixel)
|
|
{
|
|
<#
|
|
foreach (var (t, tPixel) in EnumerateTypes())
|
|
{
|
|
#>
|
|
if (t == typeof(<#=t#>) && tPixel == typeof(<#=tPixel#>))
|
|
{
|
|
using ReadOnlyTexture1D<<#=t#>, <#=tPixel#>> source = device.Get().AllocateReadOnlyTexture1D<<#=t#>, <#=tPixel#>>(128);
|
|
using ReadWriteTexture1D<<#=t#>, <#=tPixel#>> destination = device.Get().AllocateReadWriteTexture1D<<#=t#>, <#=tPixel#>>(128);
|
|
|
|
device.Get().For(128, new Shader_Unorm_<#=t#>_<#=tPixel#>(source, destination));
|
|
}
|
|
<#
|
|
}
|
|
#>
|
|
}
|
|
<#
|
|
|
|
foreach (var (t, tPixel) in EnumerateTypes())
|
|
{
|
|
#>
|
|
|
|
[AutoConstructor]
|
|
[ThreadGroupSize(DefaultThreadGroupSizes.X)]
|
|
[GeneratedComputeShaderDescriptor]
|
|
internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader
|
|
{
|
|
public readonly ReadOnlyTexture1D<<#=t#>, <#=tPixel#>> source;
|
|
public readonly ReadWriteTexture1D<<#=t#>, <#=tPixel#>> destination;
|
|
|
|
public void Execute()
|
|
{
|
|
destination[ThreadIds.X] = (source[ThreadIds.X] + destination[ThreadIds.X]) / 2;
|
|
}
|
|
}
|
|
<#
|
|
}
|
|
#>
|
|
}
|