CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
VKImage.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "VKCommon.hpp"
11
12#include "VKMemoryAllocator.hpp"
13
16
18
20
21namespace CeresEngine {
22 class GPUBuffer;
23}
24
25namespace CeresEngine {
26
27 class VKCommandBuffer;
28
31
32 class VKImage final : public GPUImage, public VKDeviceObject<VKImage, GPUImage> {
33 using super = GPUImage;
34 friend class VKImageView;
35
36 private:
39
42
45
48
51
56 bool mOwns = true;
57
60
62
65
66 public:
70
74
77
80
82 static void operator delete(void* p, std::size_t size) noexcept;
83
86
87 public:
90
91 private:
93
94 public:
96
97 void transitionImageLayout(const VkCommandBuffer commandBuffer, const VkImageLayout newLayout, const GPUImageLocation& location) {
98 transitionImageLayout(commandBuffer, newLayout,
100 .baseArrayLayer = location.arrayLayer,
101 .numArrayLayers = 1,
102 .baseMipLevel = location.mipLevel,
103 .numMipLevels = 1,
104 });
105 }
106
108 transitionImageLayout(commandBuffer, newLayout,
110 .baseArrayLayer = 0,
111 .numArrayLayers = descriptor.arrayLayers,
112 .baseMipLevel = 0,
113 .numMipLevels = descriptor.mipLevels,
114 });
115 }
116
118
121
124 void generateMips(VkCommandBuffer commandBuffer);
125
126 public:
128
131 };
132
167
168} // namespace CeresEngine
#define CE_EXPLICIT_FALSE
Definition Macros.hpp:416
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
GPUDevice & device
The owning device this object was created from.
Definition Common.hpp:55
Definition GPUImage.hpp:331
static UInt32 size(const GPUImageDescriptor &imageDesc) noexcept
Definition GPUImage.hpp:527
GPUImage & image
The image that this view belongs to.
Definition GPUImage.hpp:531
const Descriptor & descriptor
A structure that describes the object and it's properties.
Definition Common.hpp:69
Definition VKDevice.hpp:79
Definition VKCommon.hpp:143
Definition VKImage.hpp:32
VkImage mImage
The Vulkan image object.
Definition VKImage.hpp:41
SmallVector< VkImageLayout, 10 > mLayouts
Definition VKImage.hpp:61
void transitionImageLayout(VkCommandBuffer commandBuffer, VkImageLayout oldLayout, VkImageLayout newLayout, UInt32 mipLevel, UInt32 layer)
void setLayout(VkImageLayout newLayout, UInt32 mipLevel, UInt32 layer=0)
void generateMips(VkCommandBuffer commandBuffer)
Generates the whole mipmap chain.
VKSwapchain * mSwapchain
If the image belongs to a swapchain, points to the owning swapchain.
Definition VKImage.hpp:64
VKImageViewCache mImageViews
A cache of all active image views.
Definition VKImage.hpp:59
const GPUImageDescriptor mDescriptor
A structure that describes the and it's properties.
Definition VKImage.hpp:38
void setLayout(VkImageLayout newLayout, const GPUImageSubresource &subresource)
static Allocator & getAllocator() noexcept
Returns the allocator for VKImage.
VKImage(VKDevice &device, const GPUImageDescriptor &descriptor)
VkFormat mFormat
The Vulkan image format.
Definition VKImage.hpp:50
void transitionImageLayout(VkCommandBuffer commandBuffer, VkImageLayout newLayout, const GPUImageSubresource &subresource)
VKObjectAllocator Allocator
An allocator type used to allocate new VKImage instances from a memory pool.
Definition VKImage.hpp:73
VKMemoryAllocation mImageMemory
The allocated memory.
Definition VKImage.hpp:44
GPUImageViewPtr createView(const GPUImageViewDescriptor &descriptor) final
VkImageLayout getLayout(UInt32 mipLevel, UInt32 layer=0) const
VKImage(VKDevice &device, const GPUImageDescriptor &descriptor, VkImage existingImage, VKSwapchain *swapchain)
VkDeviceSize mSize
The image size.
Definition VKImage.hpp:47
bool mOwns
A flag indicating if the VKImage objects owns the mImage instance.
Definition VKImage.hpp:56
void transitionImageLayout(const VkCommandBuffer commandBuffer, const VkImageLayout newLayout, const GPUImageLocation &location)
Definition VKImage.hpp:97
VKSwapchain * getSwapchain() const noexcept
If the image belongs to a swapchain, points to the owning swapchain.
Definition VKImage.hpp:130
void transitionImageLayout(const VkCommandBuffer commandBuffer, const VkImageLayout newLayout)
Definition VKImage.hpp:107
UInt32 getMipLevels() const
Definition VKImage.hpp:133
const GPUImageViewDescriptor mDescriptor
A structure that describes the and it's properties.
Definition VKImage.hpp:136
VKImageView(VKImage &image, const GPUImageViewDescriptor &descriptor)
static Allocator & getAllocator() noexcept
Returns the allocator for VKImageView.
VKObjectAllocator Allocator
An allocator type used to allocate new VKImageView instances from a memory pool.
Definition VKImage.hpp:153
VkImageView mImageView
The Vulkan image view.
Definition VKImage.hpp:139
VKImagePtr mImage
The parent image.
Definition VKImage.hpp:142
void destroy() noexcept final
Definition VKMemoryAllocator.hpp:21
Definition VKSwapchain.hpp:23
Definition Application.hpp:19
sfl::small_vector< T, N, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > SmallVector
SmallVector is a sequence container similar to Vector.
Definition SmallVector.hpp:31
ThreadSafeAllocator< MemoryPool< NodePool, AllocatorReference< VKAllocator > > > VKObjectAllocator
A pool allocator to be used for individual object pools.
Definition VKCommon.hpp:59
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668
Definition GPUImage.hpp:247
UInt32 mipLevels
Number of MIP-map levels.
Definition GPUImage.hpp:296
UInt32 arrayLayers
Number of array layers.
Definition GPUImage.hpp:287
Image location structure: MIP-map level and offset.
Definition GPUImage.hpp:120
UInt32 arrayLayer
Zero-based array layer index.
Definition GPUImage.hpp:132
UInt32 mipLevel
MIP-map level for the sub-image, where 0 is the base image, and N > 0 is the N-th MIP-map level.
Definition GPUImage.hpp:137
Image subresource descriptor which specifies the array layer and MIP-map level range of a image resou...
Definition GPUImage.hpp:77
UInt32 baseArrayLayer
Zero-based index of the first array layer.
Definition GPUImage.hpp:84
Image view descriptor structure.
Definition GPUImage.hpp:482