Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Unified Diff: gpu/vulkan/vulkan_command_buffer.h

Issue 1776453003: Added initial implementation of Vulkan Render Passes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn_vulkan
Patch Set: Adding logging/macros headers Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/vulkan/tests/vulkan_tests_main.cc ('k') | gpu/vulkan/vulkan_command_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/vulkan/vulkan_command_buffer.h
diff --git a/gpu/vulkan/vulkan_command_buffer.h b/gpu/vulkan/vulkan_command_buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..31f37a64d1f2731ec8dfbdaa4d218b1f2925d2b0
--- /dev/null
+++ b/gpu/vulkan/vulkan_command_buffer.h
@@ -0,0 +1,133 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_VULKAN_VULKAN_COMMAND_BUFFER_H_
+#define GPU_VULKAN_VULKAN_COMMAND_BUFFER_H_
+
+#include <vulkan/vulkan.h>
+
+#include "base/logging.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "gpu/vulkan/vulkan_export.h"
+
+namespace gpu {
+
+class VulkanCommandPool;
+
+class VULKAN_EXPORT VulkanCommandBuffer {
+ public:
+ VulkanCommandBuffer(VulkanCommandPool* command_pool, bool primary);
+ ~VulkanCommandBuffer();
+
+ bool Initialize();
+ void Destroy();
+
+ // Submit primary command buffer to the queue.
+ bool Submit(VkQueue queue,
+ uint32_t num_wait_semaphores,
+ VkSemaphore* wait_semaphores,
+ uint32_t num_signal_semaphores,
+ VkSemaphore* signal_semaphores);
+
+ // Enqueue secondary command buffer within a primary command buffer.
+ void Enqueue(VkCommandBuffer primary_command_buffer);
+
+ void Clear();
+
+ // This blocks until the commands from the previous submit are done.
+ void Wait(uint64_t timeout);
+
+ // This simply tests asynchronously if the commands from the previous submit
+ // is finished.
+ bool SubmissionFinished();
+
+ private:
+ friend class CommandBufferRecorderBase;
+
+ enum RecordType {
+ // Nothing has been recorded yet.
+ RECORD_TYPE_EMPTY,
+
+ // Recorded for single use, will be reset upon submission.
+ RECORD_TYPE_SINGLE_USE,
+
+ // Recording for multi use, once submitted it can't be modified until reset.
+ RECORD_TYPE_MULTI_USE,
+
+ // Recorded for multi-use, can no longer be modified unless reset.
+ RECORD_TYPE_RECORDED,
+
+ // Dirty, should be cleared before use. This assumes its externally
+ // synchronized and the command buffer is no longer in use.
+ RECORD_TYPE_DIRTY,
+ };
+
+ void PostExecution();
+ void ResetIfDirty();
+
+ const bool primary_;
+ bool recording_ = false;
+ RecordType record_type_ = RECORD_TYPE_EMPTY;
+ VulkanCommandPool* command_pool_;
+ VkCommandBuffer command_buffer_ = VK_NULL_HANDLE;
+ VkFence submission_fence_ = VK_NULL_HANDLE;
+
+ DISALLOW_COPY_AND_ASSIGN(VulkanCommandBuffer);
+};
+
+class VULKAN_EXPORT CommandBufferRecorderBase {
+ public:
+ VkCommandBuffer handle() const { return handle_; }
+
+ protected:
+ CommandBufferRecorderBase(VulkanCommandBuffer& command_buffer)
+ : handle_(command_buffer.command_buffer_) {
+ command_buffer.ResetIfDirty();
+ }
+
+ virtual ~CommandBufferRecorderBase();
+
+ void ValidateSingleUse(VulkanCommandBuffer& command_buffer) {
+ DCHECK((VulkanCommandBuffer::RECORD_TYPE_SINGLE_USE ==
+ command_buffer.record_type_) ||
+ (VulkanCommandBuffer::RECORD_TYPE_EMPTY ==
+ command_buffer.record_type_));
+ command_buffer.record_type_ = VulkanCommandBuffer::RECORD_TYPE_SINGLE_USE;
+ }
+
+ void ValidateMultiUse(VulkanCommandBuffer& command_buffer) {
+ DCHECK((VulkanCommandBuffer::RECORD_TYPE_MULTI_USE ==
+ command_buffer.record_type_) ||
+ (VulkanCommandBuffer::RECORD_TYPE_EMPTY ==
+ command_buffer.record_type_));
+ command_buffer.record_type_ = VulkanCommandBuffer::RECORD_TYPE_MULTI_USE;
+ }
+
+ VkCommandBuffer handle_;
+};
+
+class VULKAN_EXPORT ScopedMultiUseCommandBufferRecorder
+ : public CommandBufferRecorderBase {
+ public:
+ ScopedMultiUseCommandBufferRecorder(VulkanCommandBuffer& command_buffer);
+ ~ScopedMultiUseCommandBufferRecorder() override {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedMultiUseCommandBufferRecorder);
+};
+
+class VULKAN_EXPORT ScopedSingleUseCommandBufferRecorder
+ : public CommandBufferRecorderBase {
+ public:
+ ScopedSingleUseCommandBufferRecorder(VulkanCommandBuffer& command_buffer);
+ ~ScopedSingleUseCommandBufferRecorder() override {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedSingleUseCommandBufferRecorder);
+};
+
+} // namespace gpu
+
+#endif // GPU_VULKAN_VULKAN_COMMAND_BUFFER_H_
« no previous file with comments | « gpu/vulkan/tests/vulkan_tests_main.cc ('k') | gpu/vulkan/vulkan_command_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698