diff --git a/src/Graphics/ResourceUploader.cs b/src/Graphics/ResourceUploader.cs
index c4f426c..938872e 100644
--- a/src/Graphics/ResourceUploader.cs
+++ b/src/Graphics/ResourceUploader.cs
@@ -47,9 +47,11 @@ namespace MoonWorks.Graphics
///
/// Prepares upload of data into a GpuBuffer.
///
- public void SetBufferData(GpuBuffer buffer, uint bufferOffset, Span data) where T : unmanaged
+ public void SetBufferData(GpuBuffer buffer, uint bufferOffsetInElements, Span data) where T : unmanaged
{
- var lengthInBytes = (uint) (Marshal.SizeOf() * data.Length);
+ uint elementSize = (uint) Marshal.SizeOf();
+ uint offsetInBytes = elementSize * bufferOffsetInElements;
+ uint lengthInBytes = (uint) (elementSize * data.Length);
uint resourceOffset;
fixed (void* spanPtr = data)
@@ -57,12 +59,19 @@ namespace MoonWorks.Graphics
resourceOffset = CopyData(spanPtr, lengthInBytes);
}
- var bufferCopyParams = new BufferCopy(resourceOffset, bufferOffset, lengthInBytes);
+ var bufferCopyParams = new BufferCopy(resourceOffset, offsetInBytes, lengthInBytes);
BufferUploads.Add((buffer, bufferCopyParams));
}
// Textures
+ public Texture CreateTexture2D(Span pixelData, uint width, uint height)
+ {
+ var texture = Texture.CreateTexture2D(Device, width, height, TextureFormat.R8G8B8A8, TextureUsageFlags.Sampler);
+ SetTextureData(texture, pixelData);
+ return texture;
+ }
+
///
/// Creates a 2D Texture from compressed image data to be uploaded.
///