From a4cb35cdbc6c8ed9b2568ff51b471323282b4863 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 18 Jun 2018 15:45:06 -0400 Subject: [PATCH] Vulkan: Split off QueueVk --- src/backend/CMakeLists.txt | 2 ++ src/backend/vulkan/BufferVk.h | 2 ++ src/backend/vulkan/GeneratedCodeIncludes.h | 1 + src/backend/vulkan/QueueVk.cpp | 39 ++++++++++++++++++++++ src/backend/vulkan/QueueVk.h | 36 ++++++++++++++++++++ src/backend/vulkan/VulkanBackend.cpp | 20 +---------- src/backend/vulkan/VulkanBackend.h | 14 +++----- 7 files changed, 85 insertions(+), 29 deletions(-) create mode 100644 src/backend/vulkan/QueueVk.cpp create mode 100644 src/backend/vulkan/QueueVk.h diff --git a/src/backend/CMakeLists.txt b/src/backend/CMakeLists.txt index cb2bb1ad22..08633c1a40 100644 --- a/src/backend/CMakeLists.txt +++ b/src/backend/CMakeLists.txt @@ -293,6 +293,8 @@ if (NXT_ENABLE_VULKAN) ${VULKAN_DIR}/NativeSwapChainImplVk.h ${VULKAN_DIR}/PipelineLayoutVk.cpp ${VULKAN_DIR}/PipelineLayoutVk.h + ${VULKAN_DIR}/QueueVk.cpp + ${VULKAN_DIR}/QueueVk.h ${VULKAN_DIR}/RenderPassCache.cpp ${VULKAN_DIR}/RenderPassCache.h ${VULKAN_DIR}/RenderPassDescriptorVk.cpp diff --git a/src/backend/vulkan/BufferVk.h b/src/backend/vulkan/BufferVk.h index 9db4fdfbb7..c00015df42 100644 --- a/src/backend/vulkan/BufferVk.h +++ b/src/backend/vulkan/BufferVk.h @@ -51,6 +51,8 @@ namespace backend { namespace vulkan { DeviceMemoryAllocation mMemoryAllocation; }; + using BufferView = BufferViewBase; + class MapRequestTracker { public: MapRequestTracker(Device* device); diff --git a/src/backend/vulkan/GeneratedCodeIncludes.h b/src/backend/vulkan/GeneratedCodeIncludes.h index 7af9d703fb..90243f67a9 100644 --- a/src/backend/vulkan/GeneratedCodeIncludes.h +++ b/src/backend/vulkan/GeneratedCodeIncludes.h @@ -21,6 +21,7 @@ #include "backend/vulkan/DepthStencilStateVk.h" #include "backend/vulkan/InputStateVk.h" #include "backend/vulkan/PipelineLayoutVk.h" +#include "backend/vulkan/QueueVk.h" #include "backend/vulkan/RenderPassDescriptorVk.h" #include "backend/vulkan/RenderPipelineVk.h" #include "backend/vulkan/SamplerVk.h" diff --git a/src/backend/vulkan/QueueVk.cpp b/src/backend/vulkan/QueueVk.cpp new file mode 100644 index 0000000000..b0004a08c3 --- /dev/null +++ b/src/backend/vulkan/QueueVk.cpp @@ -0,0 +1,39 @@ +// Copyright 2018 The NXT Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "backend/vulkan/QueueVk.h" + +#include "backend/vulkan/CommandBufferVk.h" +#include "backend/vulkan/VulkanBackend.h" + +namespace backend { namespace vulkan { + + Queue::Queue(Device* device) : QueueBase(device) { + } + + Queue::~Queue() { + } + + void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { + Device* device = ToBackend(GetDevice()); + + VkCommandBuffer commandBuffer = device->GetPendingCommandBuffer(); + for (uint32_t i = 0; i < numCommands; ++i) { + commands[i]->RecordCommands(commandBuffer); + } + + device->SubmitPendingCommands(); + } + +}} // namespace backend::vulkan diff --git a/src/backend/vulkan/QueueVk.h b/src/backend/vulkan/QueueVk.h new file mode 100644 index 0000000000..caf72450ac --- /dev/null +++ b/src/backend/vulkan/QueueVk.h @@ -0,0 +1,36 @@ +// Copyright 2018 The NXT Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef BACKEND_VULKAN_QUEUEVK_H_ +#define BACKEND_VULKAN_QUEUEVK_H_ + +#include "backend/Queue.h" + +namespace backend { namespace vulkan { + + class CommandBuffer; + class Device; + + class Queue : public QueueBase { + public: + Queue(Device* device); + ~Queue(); + + // NXT API + void Submit(uint32_t numCommands, CommandBuffer* const* commands); + }; + +}} // namespace backend::vulkan + +#endif // BACKEND_VULKAN_QUEUEVK_H_ diff --git a/src/backend/vulkan/VulkanBackend.cpp b/src/backend/vulkan/VulkanBackend.cpp index 326c95c342..03a738f340 100644 --- a/src/backend/vulkan/VulkanBackend.cpp +++ b/src/backend/vulkan/VulkanBackend.cpp @@ -27,6 +27,7 @@ #include "backend/vulkan/InputStateVk.h" #include "backend/vulkan/NativeSwapChainImplVk.h" #include "backend/vulkan/PipelineLayoutVk.h" +#include "backend/vulkan/QueueVk.h" #include "backend/vulkan/RenderPassCache.h" #include "backend/vulkan/RenderPassDescriptorVk.h" #include "backend/vulkan/RenderPipelineVk.h" @@ -675,23 +676,4 @@ namespace backend { namespace vulkan { commands->commandBuffer = VK_NULL_HANDLE; } - // Queue - - Queue::Queue(Device* device) : QueueBase(device) { - } - - Queue::~Queue() { - } - - void Queue::Submit(uint32_t numCommands, CommandBuffer* const* commands) { - Device* device = ToBackend(GetDevice()); - - VkCommandBuffer commandBuffer = device->GetPendingCommandBuffer(); - for (uint32_t i = 0; i < numCommands; ++i) { - commands[i]->RecordCommands(commandBuffer); - } - - device->SubmitPendingCommands(); - } - }} // namespace backend::vulkan diff --git a/src/backend/vulkan/VulkanBackend.h b/src/backend/vulkan/VulkanBackend.h index c2f45591a3..2458c2c36b 100644 --- a/src/backend/vulkan/VulkanBackend.h +++ b/src/backend/vulkan/VulkanBackend.h @@ -18,7 +18,6 @@ #include "nxt/nxtcpp.h" #include "backend/Device.h" -#include "backend/Queue.h" #include "backend/ToBackend.h" #include "backend/vulkan/VulkanFunctions.h" #include "backend/vulkan/VulkanInfo.h" @@ -28,6 +27,10 @@ #include +namespace backend { + class BufferViewBase; +} + namespace backend { namespace vulkan { class BindGroup; @@ -201,15 +204,6 @@ namespace backend { namespace vulkan { std::vector mWaitSemaphores; }; - class Queue : public QueueBase { - public: - Queue(Device* device); - ~Queue(); - - // NXT API - void Submit(uint32_t numCommands, CommandBuffer* const* commands); - }; - }} // namespace backend::vulkan #endif // BACKEND_VULKAN_VULKANBACKEND_H_