forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render_pass_state.h
131 lines (114 loc) · 5.21 KB
/
render_pass_state.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* Copyright (c) 2015-2021 The Khronos Group Inc.
* Copyright (c) 2015-2021 Valve Corporation
* Copyright (c) 2015-2021 LunarG, Inc.
* Copyright (C) 2015-2021 Google Inc.
* Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Courtney Goeltzenleuchter <[email protected]>
* Author: Tobin Ehlis <[email protected]>
* Author: Chris Forbes <[email protected]>
* Author: Mark Lobodzinski <[email protected]>
* Author: Dave Houlton <[email protected]>
* Author: John Zulauf <[email protected]>
* Author: Tobias Hector <[email protected]>
* Author: Jeremy Gebben <[email protected]>
*/
#pragma once
#include "base_node.h"
class IMAGE_VIEW_STATE;
static inline uint32_t GetSubpassDepthStencilAttachmentIndex(const safe_VkPipelineDepthStencilStateCreateInfo *pipe_ds_ci,
const safe_VkAttachmentReference2 *depth_stencil_ref) {
uint32_t depth_stencil_attachment = VK_ATTACHMENT_UNUSED;
if (pipe_ds_ci && depth_stencil_ref) {
depth_stencil_attachment = depth_stencil_ref->attachment;
}
return depth_stencil_attachment;
}
struct SUBPASS_INFO {
bool used;
VkImageUsageFlagBits usage;
VkImageLayout layout;
SUBPASS_INFO() : used(false), usage(VkImageUsageFlagBits(0)), layout(VK_IMAGE_LAYOUT_UNDEFINED) {}
};
// Store the DAG.
struct DAGNode {
uint32_t pass;
std::vector<uint32_t> prev;
std::vector<uint32_t> next;
};
struct SubpassDependencyGraphNode {
uint32_t pass;
struct Dependency {
const VkSubpassDependency2 *dependency;
const SubpassDependencyGraphNode *node;
Dependency() = default;
Dependency(const VkSubpassDependency2 *dependency_, const SubpassDependencyGraphNode *node_)
: dependency(dependency_), node(node_) {}
};
std::map<const SubpassDependencyGraphNode *, std::vector<const VkSubpassDependency2 *>> prev;
std::map<const SubpassDependencyGraphNode *, std::vector<const VkSubpassDependency2 *>> next;
std::vector<uint32_t> async; // asynchronous subpasses with a lower subpass index
std::vector<const VkSubpassDependency2 *> barrier_from_external;
std::vector<const VkSubpassDependency2 *> barrier_to_external;
std::unique_ptr<VkSubpassDependency2> implicit_barrier_from_external;
std::unique_ptr<VkSubpassDependency2> implicit_barrier_to_external;
};
struct SubpassLayout {
uint32_t index;
VkImageLayout layout;
};
class RENDER_PASS_STATE : public BASE_NODE {
public:
struct AttachmentTransition {
uint32_t prev_pass;
uint32_t attachment;
VkImageLayout old_layout;
VkImageLayout new_layout;
AttachmentTransition(uint32_t prev_pass_, uint32_t attachment_, VkImageLayout old_layout_, VkImageLayout new_layout_)
: prev_pass(prev_pass_), attachment(attachment_), old_layout(old_layout_), new_layout(new_layout_) {}
};
const safe_VkRenderPassCreateInfo2 createInfo;
using SubpassVec = std::vector<uint32_t>;
using SelfDepVec = std::vector<SubpassVec>;
const std::vector<SubpassVec> self_dependencies;
using DAGNodeVec = std::vector<DAGNode>;
const DAGNodeVec subpass_to_node;
using FirstReadMap = layer_data::unordered_map<uint32_t, bool>;
const FirstReadMap attachment_first_read;
const SubpassVec attachment_first_subpass;
const SubpassVec attachment_last_subpass;
using FirstIsTransitionVec = std::vector<bool>;
const FirstIsTransitionVec attachment_first_is_transition;
using SubpassGraphVec = std::vector<SubpassDependencyGraphNode>;
const SubpassGraphVec subpass_dependencies;
using TransitionVec = std::vector<std::vector<AttachmentTransition>>;
const TransitionVec subpass_transitions;
RENDER_PASS_STATE(VkRenderPass rp, VkRenderPassCreateInfo2 const *pCreateInfo);
RENDER_PASS_STATE(VkRenderPass rp, VkRenderPassCreateInfo const *pCreateInfo);
VkRenderPass renderPass() const { return handle_.Cast<VkRenderPass>(); }
bool UsesColorAttachment(uint32_t subpass) const;
bool UsesDepthStencilAttachment(uint32_t subpass) const;
};
class FRAMEBUFFER_STATE : public BASE_NODE {
public:
const safe_VkFramebufferCreateInfo createInfo;
std::shared_ptr<const RENDER_PASS_STATE> rp_state;
std::vector<std::shared_ptr<IMAGE_VIEW_STATE>> attachments_view_state;
FRAMEBUFFER_STATE(VkFramebuffer fb, const VkFramebufferCreateInfo *pCreateInfo, std::shared_ptr<RENDER_PASS_STATE> &&rpstate,
std::vector<std::shared_ptr<IMAGE_VIEW_STATE>> &&attachments);
VkFramebuffer framebuffer() const { return handle_.Cast<VkFramebuffer>(); }
virtual ~FRAMEBUFFER_STATE() { Destroy(); }
void Destroy() override;
};