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

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: Put back in present semaphore 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 unified diff | Download patch
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/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/vulkan/vulkan_export.h"
13
14 namespace gpu {
15
16 class VulkanCommandPool;
17
18 class VULKAN_EXPORT VulkanCommandBuffer {
19 public:
20 VulkanCommandBuffer(VulkanCommandPool* command_pool, bool primary);
21 ~VulkanCommandBuffer();
22
23 bool Initialize();
24 void Destroy();
25
26 // Submit primary command buffer to the queue.
27 bool Submit(VkQueue queue,
28 uint32_t num_wait_semaphores,
29 VkSemaphore* wait_semaphores,
30 uint32_t num_signal_semaphores,
31 VkSemaphore* signal_semaphores,
32 VkFence fence);
33
34 // Enqueue secondary command buffer within a primary command buffer.
35 void Enqueue(VkCommandBuffer primary_command_buffer);
36
37 void Clear();
38
39 private:
40 friend class CommandBufferRecorderBase;
41
42 enum RecordType {
43 // Nothing has been recorded yet.
44 RECORD_TYPE_EMPTY,
45
46 // Recorded for single use, will be reset upon submission.
47 RECORD_TYPE_SINGLE_USE,
48
49 // Recording for multi use, once submitted it can't be modified until reset.
50 RECORD_TYPE_MULTI_USE,
51
52 // Recorded for multi-use, can no longer be modified unless reset.
53 RECORD_TYPE_RECORDED,
54
55 // Dirty, should be cleared before use. This assumes its externally
56 // synchronized and the command buffer is no longer in use.
57 RECORD_TYPE_DIRTY,
58 };
59
60 void PostExecution();
61 void ResetIfDirty();
62
63 const bool primary_;
64 bool recording_ = false;
65 RecordType record_type_ = RECORD_TYPE_EMPTY;
66 VulkanCommandPool* command_pool_;
67 VkCommandBuffer command_buffer_ = VK_NULL_HANDLE;
68
69 DISALLOW_COPY_AND_ASSIGN(VulkanCommandBuffer);
70 };
71
72 class VULKAN_EXPORT CommandBufferRecorderBase {
73 public:
74 VkCommandBuffer handle() const { return handle_; }
75
76 protected:
77 CommandBufferRecorderBase(VulkanCommandBuffer& command_buffer)
78 : handle_(command_buffer.command_buffer_) {
79 command_buffer.ResetIfDirty();
80 }
81
82 virtual ~CommandBufferRecorderBase();
83
84 void ValidateSingleUse(VulkanCommandBuffer& command_buffer) {
85 DCHECK((VulkanCommandBuffer::RECORD_TYPE_SINGLE_USE ==
86 command_buffer.record_type_) ||
87 (VulkanCommandBuffer::RECORD_TYPE_EMPTY ==
88 command_buffer.record_type_));
89 command_buffer.record_type_ = VulkanCommandBuffer::RECORD_TYPE_SINGLE_USE;
90 }
91
92 void ValidateMultiUse(VulkanCommandBuffer& command_buffer) {
93 DCHECK((VulkanCommandBuffer::RECORD_TYPE_MULTI_USE ==
94 command_buffer.record_type_) ||
95 (VulkanCommandBuffer::RECORD_TYPE_EMPTY ==
96 command_buffer.record_type_));
97 command_buffer.record_type_ = VulkanCommandBuffer::RECORD_TYPE_MULTI_USE;
98 }
99
100 VkCommandBuffer handle_;
101 };
102
103 class VULKAN_EXPORT ScopedMultiUseCommandBufferRecorder
104 : public CommandBufferRecorderBase {
105 public:
106 ScopedMultiUseCommandBufferRecorder(VulkanCommandBuffer& command_buffer);
107 ~ScopedMultiUseCommandBufferRecorder() override {}
108
109 private:
110 DISALLOW_COPY_AND_ASSIGN(ScopedMultiUseCommandBufferRecorder);
111 };
112
113 class VULKAN_EXPORT ScopedSingleUseCommandBufferRecorder
114 : public CommandBufferRecorderBase {
115 public:
116 ScopedSingleUseCommandBufferRecorder(VulkanCommandBuffer& command_buffer);
117 ~ScopedSingleUseCommandBufferRecorder() override {}
118
119 private:
120 DISALLOW_COPY_AND_ASSIGN(ScopedSingleUseCommandBufferRecorder);
121 };
122
123 } // namespace gpu
124
125 #endif // GPU_VULKAN_VULKAN_COMMAND_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698