-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathimage.hpp
148 lines (115 loc) · 5.35 KB
/
image.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#pragma once
#include <fwd.hpp>
#include <memory.hpp>
#include <imageLayout.hpp>
namespace vil {
struct Image : MemoryResource {
static constexpr auto objectType = VK_OBJECT_TYPE_IMAGE;
VkImage handle {};
VkImageCreateInfo ci;
// resource references
std::vector<ImageView*> views; // TODO: unordered set?
// when images belongs to a swapchain
Swapchain* swapchain {};
u32 swapchainImageID {};
bool externalMemory {}; // whether it supports importing/exporting
// Properties related to our changes
bool allowsNearestSampling {};
bool allowsLinearSampling {};
bool concurrentHooked {}; // whether we moved it into concurrent sharing mode
bool hasTransferSrc {}; // whether we were able to set transferSrc usage
// Device mutex must be locked and returned span only accessed
// while it's locked.
span<const ImageSubresourceLayout> pendingLayoutLocked() const;
void initLayout();
void applyLocked(span<const ImageSubresourceLayout>);
void onApiDestroy();
~Image();
private:
// The image layout this image will have when *all* activated and pending
// submissions are completed. When there are no pending submissions using
// this image, it's the current layout.
// Synced using device mutex.
std::vector<ImageSubresourceLayout> pendingLayout_;
};
struct ImageView : SharedDeviceHandle {
static constexpr auto objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
Image* img {}; // TODO: IntrusivePtr?
VkImageView handle {};
VkImageViewCreateInfo ci;
std::vector<Framebuffer*> fbs; // TODO: unordered set?
~ImageView();
};
struct Sampler : SharedDeviceHandle {
static constexpr auto objectType = VK_OBJECT_TYPE_SAMPLER;
VkSampler handle {};
VkSamplerCreateInfo ci;
};
std::string defaultName(const Image&);
std::string defaultName(const ImageView&);
VKAPI_ATTR VkResult VKAPI_CALL CreateImage(
VkDevice device,
const VkImageCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkImage* pImage);
VKAPI_ATTR void VKAPI_CALL DestroyImage(
VkDevice device,
VkImage image,
const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL BindImageMemory(
VkDevice device,
VkImage image,
VkDeviceMemory memory,
VkDeviceSize memoryOffset);
VKAPI_ATTR VkResult VKAPI_CALL BindImageMemory2(
VkDevice device,
uint32_t bindInfoCount,
const VkBindImageMemoryInfo* pBindInfos);
VKAPI_ATTR void VKAPI_CALL GetImageMemoryRequirements(
VkDevice device,
VkImage image,
VkMemoryRequirements* pMemoryRequirements);
VKAPI_ATTR void VKAPI_CALL GetImageSparseMemoryRequirements(
VkDevice device,
VkImage image,
uint32_t* pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements* pSparseMemoryRequirements);
VKAPI_ATTR void VKAPI_CALL GetImageSubresourceLayout(
VkDevice device,
VkImage image,
const VkImageSubresource* pSubresource,
VkSubresourceLayout* pLayout);
VKAPI_ATTR void VKAPI_CALL GetImageMemoryRequirements2(
VkDevice device,
const VkImageMemoryRequirementsInfo2* pInfo,
VkMemoryRequirements2* pMemoryRequirements);
VKAPI_ATTR void VKAPI_CALL GetImageSparseMemoryRequirements2(
VkDevice device,
const VkImageSparseMemoryRequirementsInfo2* pInfo,
uint32_t* pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements2* pSparseMemoryRequirements);
VKAPI_ATTR VkResult VKAPI_CALL GetImageDrmFormatModifierPropertiesEXT(
VkDevice device,
VkImage image,
VkImageDrmFormatModifierPropertiesEXT* pProperties);
// imageView
VKAPI_ATTR VkResult VKAPI_CALL CreateImageView(
VkDevice device,
const VkImageViewCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkImageView* pView);
VKAPI_ATTR void VKAPI_CALL DestroyImageView(
VkDevice device,
VkImageView imageView,
const VkAllocationCallbacks* pAllocator);
// sampler
VKAPI_ATTR VkResult VKAPI_CALL CreateSampler(
VkDevice device,
const VkSamplerCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSampler* pSampler);
VKAPI_ATTR void VKAPI_CALL DestroySampler(
VkDevice device,
VkSampler sampler,
const VkAllocationCallbacks* pAllocator);
} // namespace vil