<#@ 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 { ["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; public partial class Texture3DTests { [CombinatorialTestMethod] [AllDevices] <# foreach (var (t, tPixel) in EnumerateTypes()) { #> [Data(typeof(<#=t#>), typeof(<#=tPixel#>))] <# } #> public void Dispatch_NormalizedTexture3D(Device device, Type t, Type tPixel) { <# foreach (var (t, tPixel) in EnumerateTypes()) { #> if (t == typeof(<#=t#>) && tPixel == typeof(<#=tPixel#>)) { using ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source = device.Get().AllocateReadOnlyTexture3D<<#=t#>, <#=tPixel#>>(128, 128, 2); using ReadWriteTexture3D<<#=t#>, <#=tPixel#>> destination = device.Get().AllocateReadWriteTexture3D<<#=t#>, <#=tPixel#>>(128, 128, 2); device.Get().For(128, 128, 2, new Shader_Unorm_<#=t#>_<#=tPixel#>(source, destination)); } <# } #> } <# foreach (var (t, tPixel) in EnumerateTypes()) { #> [AutoConstructor] internal readonly partial struct Shader_Unorm_<#=t#>_<#=tPixel#> : IComputeShader { public readonly ReadOnlyTexture3D<<#=t#>, <#=tPixel#>> source; public readonly ReadWriteTexture3D<<#=t#>, <#=tPixel#>> destination; public void Execute() { destination[ThreadIds.XYZ] = (source[ThreadIds.XYZ] + destination[ThreadIds.XYZ]) / 2; } } <# } #> }