From 9b7a007c31072bc9aebd1134aa4f1bfd28a4c541 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 24 Feb 2021 15:43:43 -0800 Subject: Explicit swapchain interface in `gfx`. (#1726) * Explicit swapchain interface in `gfx`. * Correctly return nullptr when `IRenderer` creation failed. * Fix crashes on CUDA tests. * Cleanups. --- tools/gfx/vulkan/vk-device-queue.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tools/gfx/vulkan/vk-device-queue.h') diff --git a/tools/gfx/vulkan/vk-device-queue.h b/tools/gfx/vulkan/vk-device-queue.h index cd53b6b9d..9869a3caf 100644 --- a/tools/gfx/vulkan/vk-device-queue.h +++ b/tools/gfx/vulkan/vk-device-queue.h @@ -2,6 +2,7 @@ #pragma once #include "vk-api.h" +#include "vk-descriptor-allocator.h" namespace gfx { @@ -35,6 +36,7 @@ struct VulkanDeviceQueue /// Make the specified event 'current' - meaning it's semaphore must be waited on VkSemaphore makeCurrent(EventType eventType); + VkSemaphore getSemaphore(EventType eventType); /// Makes the event no longer required to be waited on void makeCompleted(EventType eventType); /// Returns true if the event is already current @@ -43,6 +45,11 @@ struct VulkanDeviceQueue /// Get the command buffer VkCommandBuffer getCommandBuffer() const { return m_commandBuffer; } + VulkanDescriptorSet allocTransientDescriptorSet(VkDescriptorSetLayout layout) + { + return m_descSetAllocator[m_commandBufferIndex].allocate(layout); + } + /// Get the queue VkQueue getQueue() const { return m_queue; } @@ -76,19 +83,21 @@ struct VulkanDeviceQueue VkQueue m_queue = VK_NULL_HANDLE; - VkCommandPool m_commandPool = VK_NULL_HANDLE; int m_numCommandBuffers = 0; int m_commandBufferIndex = 0; // There are the same amount of command buffers as fences + VkCommandPool m_commandPools[kMaxCommandBuffers] = {VK_NULL_HANDLE}; VkCommandBuffer m_commandBuffers[kMaxCommandBuffers] = { VK_NULL_HANDLE }; Fence m_fences[kMaxCommandBuffers] = { {VK_NULL_HANDLE, 0, 0u} }; VkCommandBuffer m_commandBuffer = VK_NULL_HANDLE; - + VkCommandPool m_commandPool = VK_NULL_HANDLE; VkSemaphore m_semaphores[int(EventType::CountOf)]; VkSemaphore m_currentSemaphores[int(EventType::CountOf)]; + DescriptorSetAllocator m_descSetAllocator[kMaxCommandBuffers]; + uint64_t m_lastFenceCompleted = 1; uint64_t m_nextFenceValue = 2; -- cgit v1.2.3