21 enum class ImageSizeInfo : uint32_t {
26 ViewportRelative = 1u << 30u,
29 SwapchainRelative = 1u << 31u,
31 MetaBits = Multiply | ViewportRelative | SwapchainRelative,
32 SizeBits = ~static_cast<uint32_t>(MetaBits)
35 bool operator==(
const MetaSize& other)
const {
36 return value == other.value;
39 explicit operator uint32_t()
const {
43 static const MetaSize Pixels(uint32_t x) {
return { .value = x }; };
44 static const MetaSize Viewport() {
return {
static_cast<uint32_t
>(ImageSizeInfo::ViewportRelative) }; };
45 static const MetaSize Swapchain() {
return {
static_cast<uint32_t
>(ImageSizeInfo::SwapchainRelative) }; };
46 static MetaSize MultiplyViewport(uint32_t x) {
return {
static_cast<uint32_t
>(ImageSizeInfo::ViewportRelative) |
static_cast<uint32_t
>(ImageSizeInfo::Multiply) | x }; }
47 static MetaSize MultiplySwapchain(uint32_t x) {
return {
static_cast<uint32_t
>(ImageSizeInfo::SwapchainRelative) |
static_cast<uint32_t
>(ImageSizeInfo::Multiply) | x }; }
49 static MetaSize DivideViewport(uint32_t x) {
return {
static_cast<uint32_t
>(ImageSizeInfo::ViewportRelative) | x }; }
50 static MetaSize DivideSwapchain(uint32_t x) {
return {
static_cast<uint32_t
>(ImageSizeInfo::SwapchainRelative) | x }; }
52 inline bool IsSwapchainRelative()
const {
53 return value &
static_cast<uint32_t
>(ImageSizeInfo::SwapchainRelative);
56 inline bool IsViewportRelative()
const {
57 return value &
static_cast<uint32_t
>(ImageSizeInfo::ViewportRelative);
60 inline bool IsMultiply()
const {
61 return value &
static_cast<uint32_t
>(ImageSizeInfo::Multiply);
64 inline bool IsDivide()
const {
65 return (value &
static_cast<uint32_t
>(ImageSizeInfo::Multiply)) == 0;
68 uint32_t Resolve(uint32_t viewportResolution, uint32_t swapchainResolution)
const {
69 uint32_t size = value &
static_cast<uint32_t
>(ImageSizeInfo::SizeBits);
70 bool isAbsoluteSize = (size == 0);
72 if (IsViewportRelative()) {
76 : viewportResolution * size;
81 : viewportResolution / size;
84 else if (IsSwapchainRelative()) {
88 : swapchainResolution * size;
93 : swapchainResolution / size;
106 static const MetaSize2D Zero() {
return { 0, 0 }; };
108 static const MetaSize2D Pixels(uint32_t x, uint32_t y) {
return { MetaSize::Pixels(x), MetaSize::Pixels(y) }; };
109 static const MetaSize2D Viewport() {
return { MetaSize::Viewport(), MetaSize::Viewport() }; };
110 static const MetaSize2D Swapchain() {
return { MetaSize::Swapchain(), MetaSize::Swapchain() }; };
112 static MetaSize2D MultiplyViewport(uint32_t x) {
return { MetaSize::MultiplyViewport(x), MetaSize::MultiplyViewport(x) }; }
113 static MetaSize2D MultiplySwapchain(uint32_t x) {
return { MetaSize::MultiplySwapchain(x), MetaSize::MultiplySwapchain(x) }; }
115 static MetaSize2D DivideViewport(uint32_t x) {
return { MetaSize::DivideViewport(x), MetaSize::DivideViewport(x) }; }
116 static MetaSize2D DivideSwapchain(uint32_t x) {
return { MetaSize::DivideSwapchain(x), MetaSize::DivideSwapchain(x) }; }
118 bool operator==(
const MetaSize2D& other)
const {
119 return x == other.x && y == other.y;
122 Grindstone::Math::Uint2 Resolve(Grindstone::Math::Uint2 viewportResolution, Grindstone::Math::Uint2 swapchainResolution)
const {
123 return { x.Resolve(viewportResolution.x, swapchainResolution.x), y.Resolve(viewportResolution.y, swapchainResolution.y) };
126 Grindstone::Math::Uint2 Resolve(Grindstone::Math::Uint2 swapchainResolution)
const {
127 GS_ASSERT(!x.IsViewportRelative());
128 GS_ASSERT(!y.IsViewportRelative());
129 return { x.Resolve(0, swapchainResolution.x), y.Resolve(0, swapchainResolution.y) };
137 static const MetaRect Pixels(uint32_t width, uint32_t height) {
138 return { MetaSize2D::Zero(), MetaSize2D::Pixels(width, height) };
140 static const MetaRect Pixels(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
141 return { MetaSize2D::Pixels(x, y), MetaSize2D::Pixels(width, height) };
143 static const MetaRect Viewport() {
return { MetaSize2D::Zero(), MetaSize2D::Viewport() }; }
144 static const MetaRect Swapchain() {
return { MetaSize2D::Zero(), MetaSize2D::Swapchain() }; }
146 bool operator==(
const MetaRect& other)
const {
147 return offset == other.offset && extent == other.extent;
150 Grindstone::Math::IntRect2D Resolve(Grindstone::Math::Uint2 viewportResolution, Grindstone::Math::Uint2 swapchainResolution)
const {
151 return { offset.Resolve(viewportResolution, swapchainResolution), extent.Resolve(viewportResolution, swapchainResolution) };
155 return { offset.Resolve(swapchainResolution), extent.Resolve(swapchainResolution) };
159 enum class RenderGraphImageUsage : uint16_t {
165 ColorAttachment = 1 << 4,
166 DepthAttachment = 1 << 5,
167 StencilAttachment = 1 << 6,
168 SubpassInputAttachment = 1 << 7,
171 SampledRead =
static_cast<uint16_t
>(RenderGraphImageUsage::Sampled) |
static_cast<uint16_t
>(RenderGraphImageUsage::Read),
172 StorageRead =
static_cast<uint16_t
>(RenderGraphImageUsage::Storage) |
static_cast<uint16_t
>(RenderGraphImageUsage::Read),
173 StorageWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::Storage) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
174 StorageReadWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::StorageRead) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
175 ColorAttachmentRead =
static_cast<uint16_t
>(RenderGraphImageUsage::ColorAttachment) |
static_cast<uint16_t
>(RenderGraphImageUsage::Read),
176 ColorAttachmentWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::ColorAttachment) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
177 ColorAttachmentReadWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::ColorAttachmentRead) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
178 DepthAttachmentRead =
static_cast<uint16_t
>(RenderGraphImageUsage::DepthAttachment) |
static_cast<uint16_t
>(RenderGraphImageUsage::Read),
179 DepthAttachmentWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::DepthAttachment) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
180 DepthAttachmentReadWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::DepthAttachmentRead) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
181 StencilAttachmentRead =
static_cast<uint16_t
>(RenderGraphImageUsage::StencilAttachment) |
static_cast<uint16_t
>(RenderGraphImageUsage::Read),
182 StencilAttachmentWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::StencilAttachment) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
183 StencilAttachmentReadWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::StencilAttachmentRead) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write),
184 DepthStencilAttachmentRead =
static_cast<uint16_t
>(RenderGraphImageUsage::DepthAttachmentRead) |
static_cast<uint16_t
>(RenderGraphImageUsage::StencilAttachment),
185 DepthStencilAttachmentWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::DepthAttachmentWrite) |
static_cast<uint16_t
>(RenderGraphImageUsage::StencilAttachment),
186 DepthStencilAttachmentReadWrite =
static_cast<uint16_t
>(RenderGraphImageUsage::DepthAttachmentReadWrite) |
static_cast<uint16_t
>(RenderGraphImageUsage::StencilAttachment),
187 SubpassInputAttachmentRead =
static_cast<uint16_t
>(RenderGraphImageUsage::SubpassInputAttachment) |
static_cast<uint16_t
>(RenderGraphImageUsage::Read),
188 TransferSrc =
static_cast<uint16_t
>(RenderGraphImageUsage::Transfer) |
static_cast<uint16_t
>(RenderGraphImageUsage::Read),
189 TransferDst =
static_cast<uint16_t
>(RenderGraphImageUsage::Transfer) |
static_cast<uint16_t
>(RenderGraphImageUsage::Write)
229 Grindstone::String name;
231 uint32_t samples = 1;
232 uint32_t mipLevels = 1;
234 uint32_t arrayLayers = 1;
235 Grindstone::GraphicsAPI::Format format;
237 GraphicsAPI::ImageDimension imageDimensions = GraphicsAPI::ImageDimension::Dimension2D;
238 GraphicsAPI::MemoryUsage memoryUsage = GraphicsAPI::MemoryUsage::GPUOnly;
241 Grindstone::GraphicsAPI::ImageLayout externalInitialLayout;
242 Grindstone::GraphicsAPI::AccessFlags externalInitialAccessFlags;
243 Grindstone::GraphicsAPI::PipelineStageBit externalInitialPipelineStage;
244 Grindstone::GraphicsAPI::ImageLayout externalFinalLayout;
245 Grindstone::GraphicsAPI::AccessFlags externalFinalAccessFlags;
246 Grindstone::GraphicsAPI::PipelineStageBit externalFinalPipelineStage;
251 size == other.size &&
252 samples == other.samples &&
253 mipLevels == other.mipLevels &&
254 arrayLayers == other.arrayLayers &&
255 depth == other.depth &&
256 format == other.format;