diff --git a/src/Veldrid/Vk/VkGraphicsDevice.cs b/src/Veldrid/Vk/VkGraphicsDevice.cs index ad8e5f56d..913ff8777 100644 --- a/src/Veldrid/Vk/VkGraphicsDevice.cs +++ b/src/Veldrid/Vk/VkGraphicsDevice.cs @@ -1068,7 +1068,7 @@ private VkTexture GetFreeStagingTexture(uint width, uint height, uint depth, Pix if (tex.Memory.Size >= totalSize) { _availableStagingTextures.RemoveAt(i); - tex.SetStagingDimensions(width, height, depth); + tex.SetStagingDimensions(width, height, depth, format); return tex; } } @@ -1078,7 +1078,7 @@ private VkTexture GetFreeStagingTexture(uint width, uint height, uint depth, Pix uint texHeight = Math.Max(256, height); VkTexture newTex = (VkTexture)ResourceFactory.CreateTexture(TextureDescription.Texture3D( texWidth, texHeight, depth, 1, format, TextureUsage.Staging)); - newTex.SetStagingDimensions(width, height, depth); + newTex.SetStagingDimensions(width, height, depth, format); return newTex; } diff --git a/src/Veldrid/Vk/VkTexture.cs b/src/Veldrid/Vk/VkTexture.cs index 29a7f622b..1454b68ee 100644 --- a/src/Veldrid/Vk/VkTexture.cs +++ b/src/Veldrid/Vk/VkTexture.cs @@ -12,6 +12,7 @@ internal unsafe class VkTexture : Texture private readonly VkImage _optimalImage; private readonly VkMemoryBlock _memoryBlock; private readonly Vulkan.VkBuffer _stagingBuffer; + private PixelFormat _format; // Static for regular images -- may change for shared staging images private readonly uint _actualImageArrayLayers; private bool _destroyed; @@ -26,7 +27,7 @@ internal unsafe class VkTexture : Texture public override uint Depth => _depth; - public override PixelFormat Format { get; } + public override PixelFormat Format => _format; public override uint MipLevels { get; } @@ -60,7 +61,7 @@ internal VkTexture(VkGraphicsDevice gd, ref TextureDescription description) _actualImageArrayLayers = isCubemap ? 6 * ArrayLayers : ArrayLayers; - Format = description.Format; + _format = description.Format; Usage = description.Usage; Type = description.Type; SampleCount = description.SampleCount; @@ -172,7 +173,7 @@ internal VkTexture(VkGraphicsDevice gd, ref TextureDescription description) _height = height; _depth = 1; VkFormat = vkFormat; - Format = VkFormats.VkToVdPixelFormat(VkFormat); + _format = VkFormats.VkToVdPixelFormat(VkFormat); ArrayLayers = arrayLayers; Usage = usage; SampleCount = sampleCount; @@ -310,13 +311,14 @@ public override string Name } } - internal void SetStagingDimensions(uint width, uint height, uint depth) + internal void SetStagingDimensions(uint width, uint height, uint depth, PixelFormat format) { Debug.Assert(_stagingBuffer != Vulkan.VkBuffer.Null); Debug.Assert(Usage == TextureUsage.Staging); _width = width; _height = height; _depth = depth; + _format = format; } public override void Dispose()