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

Side by Side Diff: gpu/vulkan/vulkan_render_pass.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/vulkan_platform.h ('k') | gpu/vulkan/vulkan_render_pass.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_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 used for IMAGE_TYPE_STENCIL and
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 VulkanImageView* image_view; // used for ATTACHMENT_TYPE_ATTACHMENT_VIEW.
53 VkClearValue clear_value; // used for VK_ATTACHMENT_LOAD_OP_CLEAR.
54
55 bool ValidateData(const VulkanSwapChain* swap_chain) const;
56 };
57
58 struct SubpassAttachment {
59 uint32_t attachment_index;
60 ImageLayoutType subpass_layout;
61 };
62
63 struct SubpassData {
64 SubpassData();
65 ~SubpassData();
66
67 std::vector<SubpassAttachment> subpass_attachments;
68
69 bool ValidateData(uint32_t num_attachments) const;
70 };
71
72 struct RenderPassData {
73 RenderPassData();
74 ~RenderPassData();
75
76 std::vector<AttachmentData> attachments;
77 std::vector<SubpassData> subpass_datas;
78
79 bool ValidateData(const VulkanSwapChain* swap_chain) const;
80 };
81
82 VulkanRenderPass();
83 ~VulkanRenderPass();
84
85 bool Initialize(const VulkanSwapChain* swap_chain,
86 const RenderPassData& render_pass_data);
87 void Destroy();
88
89 // 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 // primary command buffer) or whether it will be executed through a secondary
92 // command buffer.
93 void BeginRenderPass(const CommandBufferRecorderBase& recorder,
94 bool exec_inline);
95
96 // Begins the next subpass after BeginRenderPass has been called.
97 void NextSubPass(const CommandBufferRecorderBase& recorder);
98
99 // Ends the render passes.
100 void EndRenderPass(const CommandBufferRecorderBase& recorder);
101
102 void SetClearValue(uint32_t attachment_index, VkClearValue clear_value);
103
104 private:
105 const VulkanSwapChain* swap_chain_ = nullptr;
106 uint32_t num_sub_passes_ = 0;
107 uint32_t current_sub_pass_ = 0;
108 bool executing_ = false;
109 VkSubpassContents execution_type_ = VK_SUBPASS_CONTENTS_INLINE;
110 VkRenderPass render_pass_ = VK_NULL_HANDLE;
111
112 // There is 1 clear color for every attachment which needs a clear.
113 std::vector<VkClearValue> attachment_clear_values_;
114
115 // 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.
117 std::vector<uint32_t> attachment_clear_indexes_;
118
119 // There is 1 frame buffer for every swap chain image.
120 std::vector<VkFramebuffer> frame_buffers_;
121
122 DISALLOW_COPY_AND_ASSIGN(VulkanRenderPass);
123 };
124
125 } // namespace gpu
126
127 #endif // GPU_VULKAN_VULKAN_RENDER_PASS_H_
OLDNEW
« no previous file with comments | « gpu/vulkan/vulkan_platform.h ('k') | gpu/vulkan/vulkan_render_pass.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698