Skip to content

Commit

Permalink
let vkmap/unmap allocate and delete host_buf
Browse files Browse the repository at this point in the history
  • Loading branch information
masahi committed Apr 8, 2021
1 parent d84ab98 commit 62d19eb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/runtime/vulkan/vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,11 @@ class VulkanModuleNode final : public runtime::ModuleNode {
vkDestroyDescriptorSetLayout(vctx.device, pe->descriptor_set_layout, nullptr);
vkDestroyShaderModule(vctx.device, pe->shader, nullptr);
// UBO
if (pe->ubo.host_buf) {
if (pe->ubo.vk_buf) {
vkUnmapMemory(vctx.device, pe->ubo.vk_buf->memory);
vkDestroyBuffer(vctx.device, pe->ubo.vk_buf->buffer, nullptr);
vkFreeMemory(vctx.device, pe->ubo.vk_buf->memory, nullptr);
delete pe->ubo.vk_buf;
// TOOD(masahi): Fix segfault here
// delete[] (ArgUnion64*)pe->ubo.host_buf;
}
}
}
Expand Down Expand Up @@ -986,7 +985,6 @@ class VulkanModuleNode final : public runtime::ModuleNode {
if (nbytes_scalars > max_push_constants_) {
// Allocate, bind and map UBO
UniformBuffer& ubo = pe->ubo;
ubo.host_buf = new ArgUnion64[num_pod];
ubo.vk_buf = CreateBuffer(vctx, nbytes_scalars, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
vkMapMemory(vctx.device, ubo.vk_buf->memory, 0, nbytes_scalars, 0, &(ubo.host_buf));
}
Expand Down

0 comments on commit 62d19eb

Please sign in to comment.