Chromium Code Reviews| Index: gpu/vulkan/vulkan_render_pass.h |
| diff --git a/gpu/vulkan/vulkan_render_pass.h b/gpu/vulkan/vulkan_render_pass.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..39294ac5294d0c8f05791aa159ad60e4ec7dc157 |
| --- /dev/null |
| +++ b/gpu/vulkan/vulkan_render_pass.h |
| @@ -0,0 +1,128 @@ |
| +// 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_RENDER_PASS_H_ |
| +#define GPU_VULKAN_VULKAN_RENDER_PASS_H_ |
| + |
| +#include <vulkan/vulkan.h> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "gpu/vulkan/vulkan_export.h" |
| + |
| +namespace gpu { |
| + |
| +class CommandBufferRecorderBase; |
| +class VulkanImageView; |
| +class VulkanSwapChain; |
| + |
| +class VULKAN_EXPORT VulkanRenderPass { |
| + public: |
| + enum class AttachmentType { |
| + // Use image view of the swap chain image. |
| + ATTACHMENT_TYPE_SWAP_IMAGE, |
| + |
| + // Use image view of the attachment data. |
| + ATTACHMENT_TYPE_ATTACHMENT_VIEW, |
| + }; |
| + |
| + enum class ImageLayoutType { |
| + // Undefined image layout. |
| + IMAGE_LAYOUT_UNDEFINED, |
| + |
| + // Image layout whiches matches the image view. |
| + IMAGE_LAYOUT_TYPE_IMAGE_VIEW, |
| + |
| + // Image layout for presenting. |
| + IMAGE_LAYOUT_TYPE_PRESENT, |
| + }; |
| + |
| + struct AttachmentData { |
| + AttachmentType attachment_type; |
| + VkSampleCountFlagBits sample_count; |
| + VkAttachmentLoadOp load_op; |
| + VkAttachmentStoreOp store_op; |
| + // 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.
|
| + // IMAGE_TYPE_DEPTH_STENCIL image views. |
| + VkAttachmentLoadOp stencil_load_op; |
| + VkAttachmentStoreOp stencil_store_op; |
| + ImageLayoutType start_layout; |
| + ImageLayoutType end_layout; |
| + 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.
|
| + VulkanImageView* image_views; // used for ATTACHMENT_TYPE_ATTACHMENT_VIEW. |
|
piman
2016/03/25 02:01:26
Why plural?
|
| + VkClearValue clear_value; // used for VK_ATTACHMENT_LOAD_OP_CLEAR. |
| + |
| + bool ValidateData(const VulkanSwapChain* swap_chain) const; |
| + }; |
| + |
| + struct SubpassAttachment { |
| + uint32_t attachment_index; |
| + ImageLayoutType subpass_layout; |
| + }; |
| + |
| + struct SubpassData { |
| + SubpassData(); |
| + ~SubpassData(); |
| + |
| + std::vector<SubpassAttachment> subpass_attachments; |
| + |
| + bool ValidateData(uint32_t num_attachments) const; |
| + }; |
| + |
| + struct RenderPassData { |
| + RenderPassData(); |
| + ~RenderPassData(); |
| + |
| + std::vector<AttachmentData> attachments; |
| + std::vector<SubpassData> subpass_datas; |
| + |
| + bool ValidateData(const VulkanSwapChain* swap_chain) const; |
| + }; |
| + |
| + VulkanRenderPass(); |
| + ~VulkanRenderPass(); |
| + |
| + 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.
|
| + const RenderPassData& render_pass_data); |
| + void Destroy(); |
| + |
| + // Begins render pass to command_buffer. The variable exec_inline signifies |
| + // whether or not the subpass commands will be executed inline (within a |
| + // primary command buffer) or whether it will be executed through a secondary |
| + // command buffer. |
| + void BeginRenderPass(const CommandBufferRecorderBase& recorder, |
| + 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.
|
| + |
| + // Begins the next subpass after BeginRenderPass has been called. |
| + void NextSubPass(const CommandBufferRecorderBase& recorder); |
| + |
| + // Ends the render passes. |
| + void EndRenderPass(const CommandBufferRecorderBase& recorder); |
| + |
| + void SetClearValue(uint32_t attachment_index, VkClearValue clear_value); |
| + |
| + private: |
| + const VulkanSwapChain* swap_chain_ = nullptr; |
| + uint32_t num_sub_passes_ = 0; |
| + uint32_t current_sub_pass_ = 0; |
| + bool executing_ = false; |
| + VkSubpassContents execution_type_ = VK_SUBPASS_CONTENTS_INLINE; |
| + VkRenderPass render_pass_ = VK_NULL_HANDLE; |
| + |
| + // There is 1 clear color for every attachment which needs a clear. |
| + std::vector<VkClearValue> attachment_clear_values_; |
| + |
| + // There is 1 clear index for every attachment which needs a clear. This is |
| + // kept in a separate array since it is only used setting clear values. |
| + std::vector<uint32_t> attachment_clear_indexes_; |
| + |
| + // There is 1 frame buffer for every swap chain image. |
| + std::vector<VkFramebuffer> frame_buffers_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(VulkanRenderPass); |
| +}; |
| + |
| +} // namespace gpu |
| + |
| +#endif // GPU_VULKAN_VULKAN_RENDER_PASS_H_ |