using System; using System.Numerics; using System.Reflection; using ComputeSharp.__Internals; using ComputeSharp.Resources; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; #pragma warning disable CS0618 namespace ComputeSharp.Tests { public partial class Texture3DTests { [CombinatorialTestMethod] [AllDevices] [Resource(typeof(ReadOnlyTexture3D<,>))] [Resource(typeof(ReadWriteTexture3D<,>))] [Data(typeof(Bgra32), typeof(Vector4))] [Data(typeof(Bgra32), typeof(Float4))] [Data(typeof(R16), typeof(float))] [Data(typeof(R8), typeof(float))] [Data(typeof(Rg16), typeof(Vector2))] [Data(typeof(Rg16), typeof(Float2))] [Data(typeof(Rg32), typeof(Vector2))] [Data(typeof(Rg32), typeof(Float2))] [Data(typeof(Rgba32), typeof(Vector4))] [Data(typeof(Rgba32), typeof(Float4))] [Data(typeof(Rgba64), typeof(Vector4))] [Data(typeof(Rgba64), typeof(Float4))] public void Allocate_Uninitialized_Pixel_Ok(Device device, Type textureType, Type t, Type tPixel) { static void Test(Device device, Type textureType) where T : unmanaged, IUnorm where TPixel : unmanaged { using Texture3D texture = device.Get().AllocateTexture3D(textureType, 128, 128, 2); Assert.IsNotNull(texture); Assert.AreEqual(texture.Width, 128); Assert.AreEqual(texture.Height, 128); Assert.AreEqual(texture.Depth, 2); Assert.AreSame(texture.GraphicsDevice, device.Get()); if (textureType == typeof(ReadOnlyTexture3D<,>)) { Assert.IsTrue(texture is ReadOnlyTexture3D); } else { Assert.IsTrue(texture is ReadWriteTexture3D); } } try { new Action(Test).Method.GetGenericMethodDefinition().MakeGenericMethod(t, tPixel).Invoke(null, new object[] { device, textureType }); } catch (TargetInvocationException e) when (e.InnerException is not null) { throw e.InnerException; } } } }