diff --git a/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs b/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs
index 2e8cd78c..d40c81b0 100644
--- a/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs
+++ b/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs
@@ -30,6 +30,48 @@ public static class GraphicsDeviceExtensions
};
}
+ ///
+ /// Allocates a new instance of the specified type.
+ ///
+ /// The type of items in the texture.
+ /// The target instance to allocate the texture for.
+ /// The type of texture to allocate.
+ /// The width of the texture to create.
+ /// The allocation mode to use for the new resource.
+ /// A instance of the requested size.
+ public static Texture1D AllocateTexture1D(this GraphicsDevice device, Type type, int width, AllocationMode allocationMode = AllocationMode.Default)
+ where T : unmanaged
+ {
+ return type switch
+ {
+ _ when type == typeof(ReadOnlyTexture1D<>) => device.AllocateReadOnlyTexture1D(width, allocationMode),
+ _ when type == typeof(ReadWriteTexture1D<>) => device.AllocateReadWriteTexture1D(width, allocationMode),
+ _ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
+ };
+ }
+
+ ///
+ /// Allocates a new instance of the specified type.
+ ///
+ /// The type of items in the texture.
+ /// The type of pixels used on the GPU side.
+ /// The target instance to allocate the texture for.
+ /// The type of texture to allocate.
+ /// The width of the texture to create.
+ /// The allocation mode to use for the new resource.
+ /// A instance of the requested size.
+ public static Texture1D AllocateTexture1D(this GraphicsDevice device, Type type, int width, AllocationMode allocationMode = AllocationMode.Default)
+ where T : unmanaged, IPixel
+ where TPixel : unmanaged
+ {
+ return type switch
+ {
+ _ when type == typeof(ReadOnlyTexture1D<,>) => device.AllocateReadOnlyTexture1D(width, allocationMode),
+ _ when type == typeof(ReadWriteTexture1D<,>) => device.AllocateReadWriteTexture1D(width, allocationMode),
+ _ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
+ };
+ }
+
///
/// Allocates a new instance of the specified type.
///
@@ -223,6 +265,25 @@ public static class GraphicsDeviceExtensions
};
}
+ ///
+ /// Allocates a new instance of the specified type.
+ ///
+ /// The type of items in the texture.
+ /// The target instance to allocate the texture for.
+ /// The type of texture to allocate.
+ /// The data to load on the texture.
+ /// A instance of the requested type.
+ public static Texture1D AllocateTexture1D(this GraphicsDevice device, Type type, T[] data)
+ where T : unmanaged
+ {
+ return type switch
+ {
+ _ when type == typeof(ReadOnlyTexture1D<>) => device.AllocateReadOnlyTexture1D(data),
+ _ when type == typeof(ReadWriteTexture1D<>) => device.AllocateReadWriteTexture1D(data),
+ _ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
+ };
+ }
+
///
/// Allocates a new instance of the specified type.
///