Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_RENDER_PASS_H_ | |
| 6 #define GPU_VULKAN_VULKAN_RENDER_PASS_H_ | |
| 7 | |
| 8 #include <vulkan/vulkan.h> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "gpu/vulkan/vulkan_export.h" | |
| 13 | |
| 14 namespace gpu { | |
| 15 | |
| 16 class CommandBufferRecorderBase; | |
| 17 class VulkanImageView; | |
| 18 class VulkanSwapChain; | |
| 19 | |
| 20 class VULKAN_EXPORT VulkanRenderPass { | |
| 21 public: | |
| 22 enum class AttachmentType { | |
| 23 // Use image view of the swap chain image. | |
| 24 ATTACHMENT_TYPE_SWAP_IMAGE, | |
| 25 | |
| 26 // Use image view of the attachment data. | |
| 27 ATTACHMENT_TYPE_ATTACHMENT_VIEW, | |
| 28 }; | |
| 29 | |
| 30 enum class ImageLayoutType { | |
| 31 // Undefined image layout. | |
| 32 IMAGE_LAYOUT_UNDEFINED, | |
| 33 | |
| 34 // Image layout whiches matches the image view. | |
| 35 IMAGE_LAYOUT_TYPE_IMAGE_VIEW, | |
| 36 | |
| 37 // Image layout for presenting. | |
| 38 IMAGE_LAYOUT_TYPE_PRESENT, | |
| 39 }; | |
| 40 | |
| 41 struct AttachmentData { | |
| 42 AttachmentType attachment_type; | |
| 43 VkSampleCountFlagBits sample_count; | |
| 44 VkAttachmentLoadOp load_op; | |
| 45 VkAttachmentStoreOp store_op; | |
| 46 // The stencil ops are only sued for IMAGE_TYPE_STENCIL and | |
|
piman
2016/03/25 02:01:26
nit: sued->used
David Yen
2016/03/25 17:36:14
Done.
| |
| 47 // IMAGE_TYPE_DEPTH_STENCIL image views. | |
| 48 VkAttachmentLoadOp stencil_load_op; | |
| 49 VkAttachmentStoreOp stencil_store_op; | |
| 50 ImageLayoutType start_layout; | |
| 51 ImageLayoutType end_layout; | |
| 52 uint32_t num_image_views; // If more than 1, must match swap chain count. | |
|
piman
2016/03/25 02:01:26
I'm not exactly sure why you need this, or what it
David Yen
2016/03/25 17:36:14
So this attachment data is meant to used to create
piman
2016/03/25 21:13:22
I think I understand. It's hard to imagine a use c
David Yen
2016/03/26 00:33:30
Ok, removed.
| |
| 53 VulkanImageView* image_views; // used for ATTACHMENT_TYPE_ATTACHMENT_VIEW. | |
|
piman
2016/03/25 02:01:26
Why plural?
| |
| 54 VkClearValue clear_value; // used for VK_ATTACHMENT_LOAD_OP_CLEAR. | |
| 55 | |
| 56 bool ValidateData(const VulkanSwapChain* swap_chain) const; | |
| 57 }; | |
| 58 | |
| 59 struct SubpassAttachment { | |
| 60 uint32_t attachment_index; | |
| 61 ImageLayoutType subpass_layout; | |
| 62 }; | |
| 63 | |
| 64 struct SubpassData { | |
| 65 SubpassData(); | |
| 66 ~SubpassData(); | |
| 67 | |
| 68 std::vector<SubpassAttachment> subpass_attachments; | |
| 69 | |
| 70 bool ValidateData(uint32_t num_attachments) const; | |
| 71 }; | |
| 72 | |
| 73 struct RenderPassData { | |
| 74 RenderPassData(); | |
| 75 ~RenderPassData(); | |
| 76 | |
| 77 std::vector<AttachmentData> attachments; | |
| 78 std::vector<SubpassData> subpass_datas; | |
| 79 | |
| 80 bool ValidateData(const VulkanSwapChain* swap_chain) const; | |
| 81 }; | |
| 82 | |
| 83 VulkanRenderPass(); | |
| 84 ~VulkanRenderPass(); | |
| 85 | |
| 86 bool Initialize(const VulkanSwapChain* swap_chain, | |
|
piman
2016/03/25 02:01:26
Do you have to pass a SwapChain here?
What if I wa
David Yen
2016/03/25 17:36:14
We will probably have to create another Initialize
piman
2016/03/25 21:13:22
I don't see a use case to do more than one.
Well,
David Yen
2016/03/26 00:33:30
Acknowledged.
| |
| 87 const RenderPassData& render_pass_data); | |
| 88 void Destroy(); | |
| 89 | |
| 90 // Begins render pass to command_buffer. The variable exec_inline signifies | |
| 91 // whether or not the subpass commands will be executed inline (within a | |
| 92 // primary command buffer) or whether it will be executed through a secondary | |
| 93 // command buffer. | |
| 94 void BeginRenderPass(const CommandBufferRecorderBase& recorder, | |
| 95 bool exec_inline); | |
|
piman
2016/03/25 02:01:26
This is ok as a first step, but I think eventually
David Yen
2016/03/25 17:36:14
Hmm that is interesting. Acknowledged.
| |
| 96 | |
| 97 // Begins the next subpass after BeginRenderPass has been called. | |
| 98 void NextSubPass(const CommandBufferRecorderBase& recorder); | |
| 99 | |
| 100 // Ends the render passes. | |
| 101 void EndRenderPass(const CommandBufferRecorderBase& recorder); | |
| 102 | |
| 103 void SetClearValue(uint32_t attachment_index, VkClearValue clear_value); | |
| 104 | |
| 105 private: | |
| 106 const VulkanSwapChain* swap_chain_ = nullptr; | |
| 107 uint32_t num_sub_passes_ = 0; | |
| 108 uint32_t current_sub_pass_ = 0; | |
| 109 bool executing_ = false; | |
| 110 VkSubpassContents execution_type_ = VK_SUBPASS_CONTENTS_INLINE; | |
| 111 VkRenderPass render_pass_ = VK_NULL_HANDLE; | |
| 112 | |
| 113 // There is 1 clear color for every attachment which needs a clear. | |
| 114 std::vector<VkClearValue> attachment_clear_values_; | |
| 115 | |
| 116 // There is 1 clear index for every attachment which needs a clear. This is | |
| 117 // kept in a separate array since it is only used setting clear values. | |
| 118 std::vector<uint32_t> attachment_clear_indexes_; | |
| 119 | |
| 120 // There is 1 frame buffer for every swap chain image. | |
| 121 std::vector<VkFramebuffer> frame_buffers_; | |
| 122 | |
| 123 DISALLOW_COPY_AND_ASSIGN(VulkanRenderPass); | |
| 124 }; | |
| 125 | |
| 126 } // namespace gpu | |
| 127 | |
| 128 #endif // GPU_VULKAN_VULKAN_RENDER_PASS_H_ | |
| OLD | NEW |