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

Side by Side 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, 8 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_VULKAN_VULKAN_COMMAND_BUFFER_H_
6 #define GPU_VULKAN_VULKAN_COMMAND_BUFFER_H_
7
8 #include <vulkan/vulkan.h>
9
10 #include "base/logging.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "gpu/vulkan/vulkan_export.h"
14
15 namespace gpu {
16
17 class VulkanCommandPool;
18
19 class VULKAN_EXPORT VulkanCommandBuffer {
20 public:
21 VulkanCommandBuffer(VulkanCommandPool* command_pool, bool primary);
22 ~VulkanCommandBuffer();
23
24 bool Initialize();
25 void Destroy();
26
27 // Submit primary command buffer to the queue.
28 bool Submit(VkQueue queue,
29 uint32_t num_wait_semaphores,
30 VkSemaphore* wait_semaphores,
31 uint32_t num_signal_semaphores,
32 VkSemaphore* signal_semaphores);
33
34 // Enqueue secondary command buffer within a primary command buffer.
35 void Enqueue(VkCommandBuffer primary_command_buffer);
36
37 void Clear();
38
39 // This blocks until the commands from the previous submit are done.
40 void Wait(uint64_t timeout);
41
42 // This simply tests asynchronously if the commands from the previous submit
43 // is finished.
44 bool SubmissionFinished();
45
46 private:
47 friend class CommandBufferRecorderBase;
48
49 enum RecordType {
50 // Nothing has been recorded yet.
51 RECORD_TYPE_EMPTY,
52
53 // Recorded for single use, will be reset upon submission.
54 RECORD_TYPE_SINGLE_USE,
55
56 // Recording for multi use, once submitted it can't be modified until reset.
57 RECORD_TYPE_MULTI_USE,
58
59 // Recorded for multi-use, can no longer be modified unless reset.
60 RECORD_TYPE_RECORDED,
61
62 // Dirty, should be cleared before use. This assumes its externally
63 // synchronized and the command buffer is no longer in use.
64 RECORD_TYPE_DIRTY,
65 };
66
67 void PostExecution();
68 void ResetIfDirty();
69
70 const bool primary_;
71 bool recording_ = false;
72 RecordType record_type_ = RECORD_TYPE_EMPTY;
73 VulkanCommandPool* command_pool_;
74 VkCommandBuffer command_buffer_ = VK_NULL_HANDLE;
75 VkFence submission_fence_ = VK_NULL_HANDLE;
76
77 DISALLOW_COPY_AND_ASSIGN(VulkanCommandBuffer);
78 };
79
80 class VULKAN_EXPORT CommandBufferRecorderBase {
81 public:
82 VkCommandBuffer handle() const { return handle_; }
83
84 protected:
85 CommandBufferRecorderBase(VulkanCommandBuffer& command_buffer)
86 : handle_(command_buffer.command_buffer_) {
87 command_buffer.ResetIfDirty();
88 }
89
90 virtual ~CommandBufferRecorderBase();
91
92 void ValidateSingleUse(VulkanCommandBuffer& command_buffer) {
93 DCHECK((VulkanCommandBuffer::RECORD_TYPE_SINGLE_USE ==
94 command_buffer.record_type_) ||
95 (VulkanCommandBuffer::RECORD_TYPE_EMPTY ==
96 command_buffer.record_type_));
97 command_buffer.record_type_ = VulkanCommandBuffer::RECORD_TYPE_SINGLE_USE;
98 }
99
100 void ValidateMultiUse(VulkanCommandBuffer& command_buffer) {
101 DCHECK((VulkanCommandBuffer::RECORD_TYPE_MULTI_USE ==
102 command_buffer.record_type_) ||
103 (VulkanCommandBuffer::RECORD_TYPE_EMPTY ==
104 command_buffer.record_type_));
105 command_buffer.record_type_ = VulkanCommandBuffer::RECORD_TYPE_MULTI_USE;
106 }
107
108 VkCommandBuffer handle_;
109 };
110
111 class VULKAN_EXPORT ScopedMultiUseCommandBufferRecorder
112 : public CommandBufferRecorderBase {
113 public:
114 ScopedMultiUseCommandBufferRecorder(VulkanCommandBuffer& command_buffer);
115 ~ScopedMultiUseCommandBufferRecorder() override {}
116
117 private:
118 DISALLOW_COPY_AND_ASSIGN(ScopedMultiUseCommandBufferRecorder);
119 };
120
121 class VULKAN_EXPORT ScopedSingleUseCommandBufferRecorder
122 : public CommandBufferRecorderBase {
123 public:
124 ScopedSingleUseCommandBufferRecorder(VulkanCommandBuffer& command_buffer);
125 ~ScopedSingleUseCommandBufferRecorder() override {}
126
127 private:
128 DISALLOW_COPY_AND_ASSIGN(ScopedSingleUseCommandBufferRecorder);
129 };
130
131 } // namespace gpu
132
133 #endif // GPU_VULKAN_VULKAN_COMMAND_BUFFER_H_
OLDNEW
« 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