Improve vulkan resource freeing
and some minor improvements to the Renderer, now taking in an AssetRef<Pipeline> as parameter.
This commit is contained in:
@@ -30,8 +30,12 @@ namespace Copium
|
||||
|
||||
Buffer::~Buffer()
|
||||
{
|
||||
vkFreeMemory(Vulkan::GetDevice(), memory, nullptr);
|
||||
vkDestroyBuffer(Vulkan::GetDevice(), handle, nullptr);
|
||||
VkDeviceMemory memoryCpy = memory;
|
||||
VkBuffer handleCpy = handle;
|
||||
Vulkan::GetDevice().QueueIdleCommand([memoryCpy, handleCpy]() {
|
||||
vkFreeMemory(Vulkan::GetDevice(), memoryCpy, nullptr);
|
||||
vkDestroyBuffer(Vulkan::GetDevice(), handleCpy, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
void Buffer::Update(void* indexData, int index)
|
||||
|
||||
@@ -29,7 +29,10 @@ namespace Copium
|
||||
|
||||
CommandBuffer::~CommandBuffer()
|
||||
{
|
||||
vkFreeCommandBuffers(Vulkan::GetDevice(), Vulkan::GetDevice().GetCommandPool(), commandBuffers.size(), commandBuffers.data());
|
||||
std::vector<VkCommandBuffer> commandBuffersCpy = commandBuffers;
|
||||
Vulkan::GetDevice().QueueIdleCommand([commandBuffersCpy]() {
|
||||
vkFreeCommandBuffers(Vulkan::GetDevice(), Vulkan::GetDevice().GetCommandPool(), commandBuffersCpy.size(), commandBuffersCpy.data());
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Test as constexpr function to see if it avoids the switch case
|
||||
|
||||
@@ -30,14 +30,18 @@ namespace Copium
|
||||
|
||||
Framebuffer::~Framebuffer()
|
||||
{
|
||||
for (auto& framebuffer : framebuffers)
|
||||
vkDestroyFramebuffer(Vulkan::GetDevice(), framebuffer, nullptr);
|
||||
vkDestroyRenderPass(Vulkan::GetDevice(), renderPass, nullptr);
|
||||
std::vector<VkFramebuffer> framebuffersCpy = framebuffers;
|
||||
VkRenderPass renderPassCpy = renderPass;
|
||||
Vulkan::GetDevice().QueueIdleCommand([framebuffersCpy, renderPassCpy]() {
|
||||
for (auto& framebuffer : framebuffersCpy)
|
||||
vkDestroyFramebuffer(Vulkan::GetDevice(), framebuffer, nullptr);
|
||||
vkDestroyRenderPass(Vulkan::GetDevice(), renderPassCpy, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
void Framebuffer::Resize(uint32_t width, uint32_t height)
|
||||
{
|
||||
vkDeviceWaitIdle(Vulkan::GetDevice());
|
||||
Vulkan::GetDevice().WaitIdle();
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
for (auto&& framebuffer : framebuffers)
|
||||
|
||||
@@ -23,7 +23,11 @@ namespace Copium
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Mat3, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(glm::mat3));
|
||||
// memcpy(buffer.data() + offset, &data[0], sizeof(glm::vec3));
|
||||
// memcpy(buffer.data() + offset + 16, &data[1], sizeof(glm::vec3));
|
||||
// memcpy(buffer.data() + offset + 32, &data[2], sizeof(glm::vec3));
|
||||
glm::mat4x3 mat43{data};
|
||||
memcpy(buffer.data() + offset, &mat43, sizeof(glm::mat4x3));
|
||||
}
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, const glm::mat4& data)
|
||||
|
||||
Reference in New Issue
Block a user