OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_VULKAN_VULKAN_RENDER_PASS_H_ | 5 #ifndef GPU_VULKAN_VULKAN_RENDER_PASS_H_ |
6 #define GPU_VULKAN_VULKAN_RENDER_PASS_H_ | 6 #define GPU_VULKAN_VULKAN_RENDER_PASS_H_ |
7 | 7 |
8 #include <vulkan/vulkan.h> | 8 #include <vulkan/vulkan.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "gpu/vulkan/vulkan_export.h" | 12 #include "gpu/vulkan/vulkan_export.h" |
13 | 13 |
14 namespace gpu { | 14 namespace gpu { |
15 | 15 |
16 class CommandBufferRecorderBase; | 16 class CommandBufferRecorderBase; |
| 17 class VulkanDeviceQueue; |
17 class VulkanImageView; | 18 class VulkanImageView; |
18 class VulkanSwapChain; | 19 class VulkanSwapChain; |
19 | 20 |
20 class VULKAN_EXPORT VulkanRenderPass { | 21 class VULKAN_EXPORT VulkanRenderPass { |
21 public: | 22 public: |
22 enum class AttachmentType { | 23 enum class AttachmentType { |
23 // Use image view of the swap chain image. | 24 // Use image view of the swap chain image. |
24 ATTACHMENT_TYPE_SWAP_IMAGE, | 25 ATTACHMENT_TYPE_SWAP_IMAGE, |
25 | 26 |
26 // Use image view of the attachment data. | 27 // Use image view of the attachment data. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 struct RenderPassData { | 73 struct RenderPassData { |
73 RenderPassData(); | 74 RenderPassData(); |
74 ~RenderPassData(); | 75 ~RenderPassData(); |
75 | 76 |
76 std::vector<AttachmentData> attachments; | 77 std::vector<AttachmentData> attachments; |
77 std::vector<SubpassData> subpass_datas; | 78 std::vector<SubpassData> subpass_datas; |
78 | 79 |
79 bool ValidateData(const VulkanSwapChain* swap_chain) const; | 80 bool ValidateData(const VulkanSwapChain* swap_chain) const; |
80 }; | 81 }; |
81 | 82 |
82 VulkanRenderPass(); | 83 explicit VulkanRenderPass(VulkanDeviceQueue* device_queue); |
83 ~VulkanRenderPass(); | 84 ~VulkanRenderPass(); |
84 | 85 |
85 bool Initialize(const VulkanSwapChain* swap_chain, | 86 bool Initialize(const VulkanSwapChain* swap_chain, |
86 const RenderPassData& render_pass_data); | 87 const RenderPassData& render_pass_data); |
87 void Destroy(); | 88 void Destroy(); |
88 | 89 |
89 // Begins render pass to command_buffer. The variable exec_inline signifies | 90 // Begins render pass to command_buffer. The variable exec_inline signifies |
90 // whether or not the subpass commands will be executed inline (within a | 91 // whether or not the subpass commands will be executed inline (within a |
91 // primary command buffer) or whether it will be executed through a secondary | 92 // primary command buffer) or whether it will be executed through a secondary |
92 // command buffer. | 93 // command buffer. |
93 void BeginRenderPass(const CommandBufferRecorderBase& recorder, | 94 void BeginRenderPass(const CommandBufferRecorderBase& recorder, |
94 bool exec_inline); | 95 bool exec_inline); |
95 | 96 |
96 // Begins the next subpass after BeginRenderPass has been called. | 97 // Begins the next subpass after BeginRenderPass has been called. |
97 void NextSubPass(const CommandBufferRecorderBase& recorder); | 98 void NextSubPass(const CommandBufferRecorderBase& recorder); |
98 | 99 |
99 // Ends the render passes. | 100 // Ends the render passes. |
100 void EndRenderPass(const CommandBufferRecorderBase& recorder); | 101 void EndRenderPass(const CommandBufferRecorderBase& recorder); |
101 | 102 |
102 void SetClearValue(uint32_t attachment_index, VkClearValue clear_value); | 103 void SetClearValue(uint32_t attachment_index, VkClearValue clear_value); |
103 | 104 |
104 private: | 105 private: |
| 106 VulkanDeviceQueue* device_queue_ = nullptr; |
105 const VulkanSwapChain* swap_chain_ = nullptr; | 107 const VulkanSwapChain* swap_chain_ = nullptr; |
106 uint32_t num_sub_passes_ = 0; | 108 uint32_t num_sub_passes_ = 0; |
107 uint32_t current_sub_pass_ = 0; | 109 uint32_t current_sub_pass_ = 0; |
108 bool executing_ = false; | 110 bool executing_ = false; |
109 VkSubpassContents execution_type_ = VK_SUBPASS_CONTENTS_INLINE; | 111 VkSubpassContents execution_type_ = VK_SUBPASS_CONTENTS_INLINE; |
110 VkRenderPass render_pass_ = VK_NULL_HANDLE; | 112 VkRenderPass render_pass_ = VK_NULL_HANDLE; |
111 | 113 |
112 // There is 1 clear color for every attachment which needs a clear. | 114 // There is 1 clear color for every attachment which needs a clear. |
113 std::vector<VkClearValue> attachment_clear_values_; | 115 std::vector<VkClearValue> attachment_clear_values_; |
114 | 116 |
115 // There is 1 clear index for every attachment which needs a clear. This is | 117 // There is 1 clear index for every attachment which needs a clear. This is |
116 // kept in a separate array since it is only used setting clear values. | 118 // kept in a separate array since it is only used setting clear values. |
117 std::vector<uint32_t> attachment_clear_indexes_; | 119 std::vector<uint32_t> attachment_clear_indexes_; |
118 | 120 |
119 // There is 1 frame buffer for every swap chain image. | 121 // There is 1 frame buffer for every swap chain image. |
120 std::vector<VkFramebuffer> frame_buffers_; | 122 std::vector<VkFramebuffer> frame_buffers_; |
121 | 123 |
122 DISALLOW_COPY_AND_ASSIGN(VulkanRenderPass); | 124 DISALLOW_COPY_AND_ASSIGN(VulkanRenderPass); |
123 }; | 125 }; |
124 | 126 |
125 } // namespace gpu | 127 } // namespace gpu |
126 | 128 |
127 #endif // GPU_VULKAN_VULKAN_RENDER_PASS_H_ | 129 #endif // GPU_VULKAN_VULKAN_RENDER_PASS_H_ |
OLD | NEW |