-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrp.hpp
115 lines (91 loc) · 4 KB
/
rp.hpp
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
#pragma once
#include <fwd.hpp>
#include <handle.hpp>
#include <util/intrusive.hpp>
#include <vk/vulkan.h>
#include <vector>
#include <memory>
#include <atomic>
namespace vil {
struct RenderPassDesc {
std::vector<std::unique_ptr<std::byte[]>> exts; // pNext chains
std::vector<std::vector<VkAttachmentReference2>> attachmentRefs;
std::vector<std::vector<u32>> attachmentIDs; // preserve attachment arrays
std::vector<VkAttachmentDescription2> attachments;
std::vector<VkSubpassDescription2> subpasses;
std::vector<VkSubpassDependency2> dependencies;
// main pNext chain
const void* pNext {};
VkRenderPassCreateFlags flags {};
};
struct RenderPass : SharedDeviceHandle {
static constexpr auto objectType = VK_OBJECT_TYPE_RENDER_PASS;
VkRenderPass handle {};
RenderPassDesc desc;
};
struct Framebuffer : SharedDeviceHandle {
static constexpr auto objectType = VK_OBJECT_TYPE_FRAMEBUFFER;
VkFramebuffer handle {};
// NOTE: keep in mind that this might be empty for an imageless fb
// TODO: makes probably more sense to use IntrusivePtr here and
// remove ImageView::fbs (since we don't need to unregister
// on destruction anymore).
std::vector<ImageView*> attachments;
IntrusivePtr<RenderPass> rp {};
u32 width {};
u32 height {};
u32 layers {};
bool imageless {};
~Framebuffer();
};
// Creates 3 RenderPassDescriptions compatible to the given one where
// the only differences are:
// - the first and second renderpasses stores all attachments in the end
// - the second and third renderpasses loads all attachments in the beginning
// This way, one renderpass can be split into three, e.g. to insert
// non-renderpass commands in between (at two points).
// - addSync: whether to add external subpass dependencies making sure that
// the renderpasses are synchronized as one (i.e. strict ordering of
// drawing commands).
// NOTE: the pNext chains are currently lost (needs fix for each extension we want to support)
// we could probably just forward pNext chains. Evaluate!
// We already warn about it though.
struct RenderPassSplitDesc {
RenderPassDesc desc0;
RenderPassDesc desc1;
RenderPassDesc desc2;
};
RenderPassSplitDesc splitInterruptable(const RenderPassDesc&,
bool addSync = true, bool addInternalDep = false);
// Returns whether the given renderpass can be split in the given subpass.
// While this is usually possible, there are some combinations of resolve
// attachment placements (when using attachment after resolving) that make
// this impossible.
bool splittable(const RenderPassDesc&, unsigned splitSubpass);
// Creates a new renderpass for the given device with the given description.
VkRenderPass create(Device&, const RenderPassDesc&);
VKAPI_ATTR VkResult VKAPI_CALL CreateFramebuffer(
VkDevice device,
const VkFramebufferCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkFramebuffer* pFramebuffer);
VKAPI_ATTR void VKAPI_CALL DestroyFramebuffer(
VkDevice device,
VkFramebuffer framebuffer,
const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass(
VkDevice device,
const VkRenderPassCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkRenderPass* pRenderPass);
VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass2(
VkDevice device,
const VkRenderPassCreateInfo2* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkRenderPass* pRenderPass);
VKAPI_ATTR void VKAPI_CALL DestroyRenderPass(
VkDevice device,
VkRenderPass renderPass,
const VkAllocationCallbacks* pAllocator);
// No need to hook GetRenderAreaGranularity
} // namespace vil