Rename Vk::Queue to Vk::QueueHandle
This commit is contained in:
parent
0ace9a5e8d
commit
cee47f366f
|
|
@ -22,7 +22,7 @@
|
|||
#include <Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Image.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Queue.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Surface.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Swapchain.hpp>
|
||||
#include <vector>
|
||||
|
|
@ -70,7 +70,7 @@ namespace Nz
|
|||
Vk::DeviceMemory m_depthBufferMemory;
|
||||
Vk::Image m_depthBuffer;
|
||||
Vk::ImageView m_depthBufferView;
|
||||
Vk::Queue m_presentQueue;
|
||||
Vk::QueueHandle m_presentQueue;
|
||||
Vk::Swapchain m_swapchain;
|
||||
UInt32 m_presentableFamilyQueue;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <Nazara/VulkanRenderer/Wrapper/Pipeline.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Queue.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/RenderPass.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Semaphore.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Nz
|
|||
{
|
||||
class CommandBuffer;
|
||||
class Instance;
|
||||
class Queue;
|
||||
class QueueHandle;
|
||||
|
||||
class NAZARA_VULKANRENDERER_API Device : public std::enable_shared_from_this<Device>
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ namespace Nz
|
|||
inline const std::vector<QueueFamilyInfo>& GetEnabledQueues() const;
|
||||
inline const QueueList& GetEnabledQueues(UInt32 familyQueue) const;
|
||||
|
||||
Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex);
|
||||
QueueHandle GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex);
|
||||
inline Instance& GetInstance();
|
||||
inline const Instance& GetInstance() const;
|
||||
inline VkResult GetLastErrorCode() const;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_VULKANRENDERER_VKQUEUE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Device.hpp>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
|
|
@ -15,14 +16,14 @@ namespace Nz
|
|||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Queue
|
||||
class QueueHandle
|
||||
{
|
||||
public:
|
||||
inline Queue();
|
||||
inline Queue(Device& device, VkQueue queue);
|
||||
inline Queue(const Queue& queue);
|
||||
inline Queue(Queue&& queue);
|
||||
inline ~Queue() = default;
|
||||
inline QueueHandle();
|
||||
inline QueueHandle(Device& device, VkQueue queue);
|
||||
QueueHandle(const QueueHandle& queue) = delete;
|
||||
QueueHandle(QueueHandle&& queue) noexcept = default;
|
||||
~QueueHandle() = default;
|
||||
|
||||
inline Device& GetDevice() const;
|
||||
inline VkResult GetLastErrorCode() const;
|
||||
|
|
@ -32,24 +33,25 @@ namespace Nz
|
|||
|
||||
inline bool Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const;
|
||||
inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const;
|
||||
inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const;
|
||||
inline bool Submit(const VkSubmitInfo& submit, VkFence signalFence = VK_NULL_HANDLE) const;
|
||||
inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence = VK_NULL_HANDLE) const;
|
||||
|
||||
inline bool WaitIdle() const;
|
||||
|
||||
Queue& operator=(const Queue& queue) = delete;
|
||||
inline Queue& operator=(Queue&&);
|
||||
QueueHandle& operator=(const QueueHandle& queue) = delete;
|
||||
QueueHandle& operator=(QueueHandle&&) noexcept = default;
|
||||
|
||||
inline operator VkQueue();
|
||||
|
||||
protected:
|
||||
Device* m_device;
|
||||
MovablePtr<Device> m_device;
|
||||
VkQueue m_handle;
|
||||
mutable VkResult m_lastErrorCode;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Queue.inl>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.inl>
|
||||
|
||||
#endif // NAZARA_VULKANRENDERER_VKQUEUE_HPP
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// This file is part of the "Nazara Engine - Vulkan Renderer"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Queue.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/VulkanRenderer/Utils.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
|
@ -11,30 +11,30 @@ namespace Nz
|
|||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline Queue::Queue() :
|
||||
inline QueueHandle::QueueHandle() :
|
||||
m_handle(VK_NULL_HANDLE),
|
||||
m_lastErrorCode(VkResult::VK_SUCCESS)
|
||||
{
|
||||
}
|
||||
|
||||
inline Queue::Queue(Device& device, VkQueue queue) :
|
||||
inline QueueHandle::QueueHandle(Device& device, VkQueue queue) :
|
||||
m_device(&device),
|
||||
m_handle(queue),
|
||||
m_lastErrorCode(VkResult::VK_SUCCESS)
|
||||
{
|
||||
}
|
||||
|
||||
inline Device& Queue::GetDevice() const
|
||||
inline Device& QueueHandle::GetDevice() const
|
||||
{
|
||||
return *m_device;
|
||||
}
|
||||
|
||||
inline VkResult Queue::GetLastErrorCode() const
|
||||
inline VkResult QueueHandle::GetLastErrorCode() const
|
||||
{
|
||||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) const
|
||||
inline bool QueueHandle::Present(const VkPresentInfoKHR& presentInfo) const
|
||||
{
|
||||
m_lastErrorCode = m_device->vkQueuePresentKHR(m_handle, &presentInfo);
|
||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
|
|
@ -46,7 +46,7 @@ namespace Nz
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) const
|
||||
inline bool QueueHandle::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) const
|
||||
{
|
||||
VkPresentInfoKHR presentInfo =
|
||||
{
|
||||
|
|
@ -63,34 +63,34 @@ namespace Nz
|
|||
return Present(presentInfo);
|
||||
}
|
||||
|
||||
inline bool Queue::Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const
|
||||
inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const
|
||||
{
|
||||
return Submit(1U, &commandBuffer, waitSemaphore, waitStage, signalSemaphore, signalFence);
|
||||
}
|
||||
|
||||
inline bool Queue::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const
|
||||
inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence) const
|
||||
{
|
||||
VkSubmitInfo submitInfo = {
|
||||
VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||
nullptr,
|
||||
(waitSemaphore) ? 1U : 0U,
|
||||
&waitSemaphore,
|
||||
waitSemaphoreCount,
|
||||
waitSemaphores,
|
||||
&waitStage,
|
||||
commandBufferCount,
|
||||
commandBuffers,
|
||||
(signalSemaphore) ? 1U : 0U,
|
||||
&signalSemaphore
|
||||
signalSemaphoreCount,
|
||||
signalSemaphores
|
||||
};
|
||||
|
||||
return Submit(submitInfo, signalFence);
|
||||
}
|
||||
|
||||
inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence signalFence) const
|
||||
inline bool QueueHandle::Submit(const VkSubmitInfo& submit, VkFence signalFence) const
|
||||
{
|
||||
return Submit(1, &submit, signalFence);
|
||||
}
|
||||
|
||||
inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence) const
|
||||
inline bool QueueHandle::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence) const
|
||||
{
|
||||
m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, signalFence);
|
||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
|
|
@ -102,7 +102,7 @@ namespace Nz
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool Queue::WaitIdle() const
|
||||
inline bool QueueHandle::WaitIdle() const
|
||||
{
|
||||
m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle);
|
||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
|
|
@ -114,16 +114,7 @@ namespace Nz
|
|||
return true;
|
||||
}
|
||||
|
||||
inline Queue& Queue::operator=(Queue&& queue)
|
||||
{
|
||||
m_device = std::move(queue.m_device);
|
||||
m_handle = queue.m_handle;
|
||||
m_lastErrorCode = queue.m_lastErrorCode;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline Queue::operator VkQueue()
|
||||
inline QueueHandle::operator VkQueue()
|
||||
{
|
||||
return m_handle;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Queue.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -131,7 +131,7 @@ namespace Nz
|
|||
copyCommandBuffer.CopyBuffer(m_stagingBuffer, m_buffer, m_size);
|
||||
copyCommandBuffer.End();
|
||||
|
||||
Vk::Queue transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0);
|
||||
Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0);
|
||||
if (!transferQueue.Submit(copyCommandBuffer, VK_NULL_HANDLE, 0, VK_NULL_HANDLE, m_stagingFence))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/CommandPool.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Queue.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
|
|
@ -150,25 +150,24 @@ namespace Nz
|
|||
return true;
|
||||
}
|
||||
|
||||
Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex)
|
||||
{
|
||||
VkQueue queue;
|
||||
vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue);
|
||||
|
||||
return Queue(*this, queue);
|
||||
}
|
||||
|
||||
void Device::WaitAndDestroyDevice()
|
||||
QueueHandle Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex)
|
||||
{
|
||||
assert(m_device != VK_NULL_HANDLE);
|
||||
|
||||
if (vkDeviceWaitIdle)
|
||||
vkDeviceWaitIdle(m_device);
|
||||
const auto& queues = GetEnabledQueues(queueFamilyIndex);
|
||||
NazaraAssert(queueIndex < queues.size(), "Invalid queue index");
|
||||
|
||||
m_internalData.reset();
|
||||
|
||||
if (vkDestroyDevice)
|
||||
vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr);
|
||||
return QueueHandle(*this, queues[queueIndex].queue);
|
||||
}
|
||||
|
||||
void Device::ResetPointers()
|
||||
|
|
@ -187,5 +186,18 @@ namespace Nz
|
|||
#undef NAZARA_VULKANRENDERER_DEVICE_EXT_END
|
||||
#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION
|
||||
}
|
||||
|
||||
void Device::WaitAndDestroyDevice()
|
||||
{
|
||||
assert(m_device != VK_NULL_HANDLE);
|
||||
|
||||
if (vkDeviceWaitIdle)
|
||||
vkDeviceWaitIdle(m_device);
|
||||
|
||||
m_internalData.reset();
|
||||
|
||||
if (vkDestroyDevice)
|
||||
vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue