VideoBackends:Vulkan: Use VMA for stream buffer

This commit is contained in:
Robin Kertels
2022-10-07 23:48:11 +02:00
parent 0e1b7a7b35
commit 1ba58e83ca
6 changed files with 86 additions and 164 deletions

View File

@ -30,7 +30,7 @@ public:
};
VKTexture() = delete;
VKTexture(const TextureConfig& tex_config, VkDeviceMemory device_memory, VkImage image,
VKTexture(const TextureConfig& tex_config, VmaAllocation alloc, VkImage image,
std::string_view name, VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED,
ComputeImageLayout compute_layout = ComputeImageLayout::Undefined);
~VKTexture();
@ -51,11 +51,10 @@ public:
void FinishedRendering() override;
VkImage GetImage() const { return m_image; }
VkDeviceMemory GetDeviceMemory() const { return m_device_memory; }
VkImageView GetView() const { return m_view; }
VkImageLayout GetLayout() const { return m_layout; }
VkFormat GetVkFormat() const { return GetVkFormatForHostTextureFormat(m_config.format); }
bool IsAdopted() const { return m_device_memory != VkDeviceMemory(VK_NULL_HANDLE); }
bool IsAdopted() const { return m_alloc != VmaAllocation(VK_NULL_HANDLE); }
static std::unique_ptr<VKTexture> Create(const TextureConfig& tex_config, std::string_view name);
static std::unique_ptr<VKTexture>
@ -74,7 +73,7 @@ public:
private:
bool CreateView(VkImageViewType type);
VkDeviceMemory m_device_memory;
VmaAllocation m_alloc;
VkImage m_image;
VkImageView m_view = VK_NULL_HANDLE;
mutable VkImageLayout m_layout = VK_IMAGE_LAYOUT_UNDEFINED;
@ -92,7 +91,7 @@ public:
VKStagingTexture() = delete;
VKStagingTexture(PrivateTag, StagingTextureType type, const TextureConfig& config,
std::unique_ptr<StagingBuffer> buffer, VkImage linear_image,
VkDeviceMemory linear_image_memory);
VmaAllocation linear_image_alloc);
~VKStagingTexture();
@ -110,8 +109,8 @@ public:
static std::unique_ptr<VKStagingTexture> Create(StagingTextureType type,
const TextureConfig& config);
static std::pair<VkImage, VkDeviceMemory> CreateLinearImage(StagingTextureType type,
const TextureConfig& config);
static std::pair<VkImage, VmaAllocation> CreateLinearImage(StagingTextureType type,
const TextureConfig& config);
private:
void CopyFromTextureToLinearImage(const VKTexture* src_tex,
@ -120,7 +119,7 @@ private:
std::unique_ptr<StagingBuffer> m_staging_buffer;
VkImage m_linear_image = VK_NULL_HANDLE;
VkDeviceMemory m_linear_image_memory = VK_NULL_HANDLE;
VmaAllocation m_linear_image_alloc = VK_NULL_HANDLE;
u64 m_flush_fence_counter = 0;
};