Renderer/Texture: Implement Update of a region + inherit AbstractImage

This commit is contained in:
Jérôme Leclercq
2021-09-07 18:42:53 +02:00
parent b6745b2906
commit 879b2f7aa6
11 changed files with 122 additions and 73 deletions

View File

@@ -249,16 +249,16 @@ namespace Nz
{
switch (pixelFormat)
{
case PixelFormat::BGRA8: return VK_FORMAT_B8G8R8A8_UNORM;
case PixelFormat::BGRA8_SRGB: return VK_FORMAT_B8G8R8A8_SRGB;
case PixelFormat::Depth16: return VK_FORMAT_D16_UNORM;
case PixelFormat::Depth16Stencil8: return VK_FORMAT_D16_UNORM_S8_UINT;
case PixelFormat::Depth24Stencil8: return VK_FORMAT_D24_UNORM_S8_UINT;
case PixelFormat::Depth32F: return VK_FORMAT_D32_SFLOAT;
case PixelFormat::BGRA8: return VK_FORMAT_B8G8R8A8_UNORM;
case PixelFormat::BGRA8_SRGB: return VK_FORMAT_B8G8R8A8_SRGB;
case PixelFormat::Depth16: return VK_FORMAT_D16_UNORM;
case PixelFormat::Depth16Stencil8: return VK_FORMAT_D16_UNORM_S8_UINT;
case PixelFormat::Depth24Stencil8: return VK_FORMAT_D24_UNORM_S8_UINT;
case PixelFormat::Depth32F: return VK_FORMAT_D32_SFLOAT;
case PixelFormat::Depth32FStencil8: return VK_FORMAT_D32_SFLOAT_S8_UINT;
case PixelFormat::RGBA8: return VK_FORMAT_R8G8B8A8_UNORM;
case PixelFormat::RGBA8_SRGB: return VK_FORMAT_R8G8B8A8_SRGB;
case PixelFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT;
case PixelFormat::RGBA8: return VK_FORMAT_R8G8B8A8_UNORM;
case PixelFormat::RGBA8_SRGB: return VK_FORMAT_R8G8B8A8_SRGB;
case PixelFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT;
default: break;
}

View File

@@ -30,7 +30,8 @@ namespace Nz
Vector3ui GetSize(UInt8 level = 0) const override;
ImageType GetType() const override;
bool Update(const void* ptr) override;
using Texture::Update;
bool Update(const void* ptr, const Boxui& box, unsigned int srcWidth, unsigned int srcHeight, UInt8 level) override;
VulkanTexture& operator=(const VulkanTexture&) = delete;
VulkanTexture& operator=(VulkanTexture&&) = delete;

View File

@@ -57,7 +57,10 @@ namespace Nz
inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height, UInt32 depth = 1);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, Int32 x, Int32 y, Int32 z, UInt32 width, UInt32 height, UInt32 depth);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 width, UInt32 height, UInt32 depth = 1);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, const VkBufferImageCopy& region);
inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 regionCount, const VkBufferImageCopy* regions);
inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0);
inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0);

View File

@@ -236,6 +236,24 @@ namespace Nz
return CopyBufferToImage(source, target, targetLayout, subresourceLayers, width, height, depth);
}
inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, Int32 x, Int32 y, Int32 z, UInt32 width, UInt32 height, UInt32 depth)
{
VkBufferImageCopy region = {
0,
0,
0,
subresourceLayers,
{ // imageOffset
x, y, z
},
{ // imageExtent
width, height, depth
}
};
return CopyBufferToImage(source, target, targetLayout, subresourceLayers, region);
}
inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 width, UInt32 height, UInt32 depth)
{
VkBufferImageCopy region = {
@@ -251,7 +269,17 @@ namespace Nz
}
};
return m_pool->GetDevice()->vkCmdCopyBufferToImage(m_handle, source, target, targetLayout, 1, &region);
return CopyBufferToImage(source, target, targetLayout, subresourceLayers, region);
}
inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, const VkBufferImageCopy& region)
{
return CopyBufferToImage(source, target, targetLayout, subresourceLayers, 1, &region);
}
inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 regionCount, const VkBufferImageCopy* regions)
{
return m_pool->GetDevice()->vkCmdCopyBufferToImage(m_handle, source, target, targetLayout, regionCount, regions);
}
inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance)