Create presentation command buffers for each surface instead of sharing globally
* Fixes multi-window vulkan validation errors because surfaces would just keep overwriting each other's command buffers.
This commit is contained in:
parent
2db8873f92
commit
e8bf0a8371
3 changed files with 7 additions and 7 deletions
|
@ -36,6 +36,7 @@ struct NativeSurface {
|
|||
VkRenderPass swapchainRenderPass = VK_NULL_HANDLE;
|
||||
|
||||
std::vector<VkFramebuffer> swapchainFramebuffers;
|
||||
std::vector<VkCommandBuffer> commandBuffers;
|
||||
};
|
||||
|
||||
class GFXVulkanPipeline;
|
||||
|
@ -128,8 +129,6 @@ private:
|
|||
|
||||
std::vector<NativeSurface*> native_surfaces;
|
||||
|
||||
std::vector<VkCommandBuffer> commandBuffers;
|
||||
|
||||
struct BoundShaderBuffer {
|
||||
GFXBuffer* buffer = nullptr;
|
||||
VkDeviceSize size = 0, offset = 0;
|
||||
|
|
|
@ -1213,7 +1213,7 @@ void GFXVulkan::submit(GFXCommandBuffer* command_buffer, const int identifier) {
|
|||
if(cmdbuf->handle != VK_NULL_HANDLE)
|
||||
cmd = cmdbuf->handle;
|
||||
else if(current_surface != nullptr)
|
||||
cmd = commandBuffers[current_surface-> currentFrame];
|
||||
cmd = current_surface->commandBuffers[current_surface-> currentFrame];
|
||||
|
||||
if(cmd == nullptr)
|
||||
return;
|
||||
|
@ -1999,17 +1999,17 @@ void GFXVulkan::createSwapchain(NativeSurface* native_surface, VkSwapchainKHR ol
|
|||
}
|
||||
|
||||
// allocate command buffers
|
||||
commandBuffers.resize(MAX_FRAMES_IN_FLIGHT);
|
||||
native_surface->commandBuffers.resize(MAX_FRAMES_IN_FLIGHT);
|
||||
|
||||
VkCommandBufferAllocateInfo allocInfo = {};
|
||||
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||
allocInfo.commandPool = commandPool;
|
||||
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
allocInfo.commandBufferCount = (uint32_t)commandBuffers.size();
|
||||
allocInfo.commandBufferCount = (uint32_t)native_surface->commandBuffers.size();
|
||||
|
||||
vkAllocateCommandBuffers(device, &allocInfo, commandBuffers.data());
|
||||
vkAllocateCommandBuffers(device, &allocInfo, native_surface->commandBuffers.data());
|
||||
|
||||
for (auto [i, cmdbuf] : utility::enumerate(commandBuffers))
|
||||
for (auto [i, cmdbuf] : utility::enumerate(native_surface->commandBuffers))
|
||||
name_object(device, VK_OBJECT_TYPE_COMMAND_BUFFER, (uint64_t)cmdbuf, ("main cmd buf " + std::to_string(i)).c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ void ImGuiPass::update_buffers(RenderTarget& target, const ImDrawData& draw_data
|
|||
target.current_index_size[target.current_frame] = new_index_size;
|
||||
}
|
||||
|
||||
// todo: dont map every frame
|
||||
auto vtx_map = engine->get_gfx()->get_buffer_contents(target.vertex_buffer[target.current_frame]);
|
||||
auto idx_map = engine->get_gfx()->get_buffer_contents(target.index_buffer[target.current_frame]);
|
||||
|
||||
|
|
Reference in a new issue