RavEngine
Loading...
Searching...
No Matches
VkTexture.hpp
1#pragma once
2#include <RGL/Types.hpp>
3#include <RGL/Texture.hpp>
4#include <RGL/Span.hpp>
5#include <volk.h>
6#include <memory>
7#include <vector>
8#include <string>
9
10struct VmaAllocation_T;
11
12namespace RGL {
13 struct DeviceVk;
14 struct TextureVk : public ITexture, public std::enable_shared_from_this<TextureVk> {
15 VkImageView vkImageView = VK_NULL_HANDLE;
16 VkImage vkImage = VK_NULL_HANDLE;
17 struct SwapchainVK* owningSwapchain = nullptr; // will remain null if the texture is not created by a swapchain
18 const std::shared_ptr<DeviceVk> owningDevice;
19 bool owning = false;
20 TextureVk(decltype(owningDevice), decltype(vkImageView) imageView, decltype(vkImage) image, const Dimension& size);
21 TextureVk(decltype(owningDevice), const TextureConfig&, const TextureUploadData& bytes);
22 TextureVk(decltype(owningDevice), const TextureConfig&);
23 Dimension GetSize() const final;
24 virtual ~TextureVk();
25
26 const TextureConfig createdConfig;
27 VkImageAspectFlags createdAspectVk = VK_IMAGE_ASPECT_COLOR_BIT;
28 VkFormat format;
29
30 VkImageLayout nativeFormat = VK_IMAGE_LAYOUT_UNDEFINED;
31
32 VmaAllocation_T* alloc = VK_NULL_HANDLE;
33
34 TextureView GetDefaultView() const final;
35 TextureView GetViewForMip(uint32_t mip) const final;
36
37 RGLCustomTextureViewPtr MakeCustomTextureView(const CustomTextureViewConfig& config) const;
38
39 std::vector<TextureView> mipViews;
40
41 std::string debugName;
42
43 uint32_t globalDescriptorIndex = 0;
44
45 uint8_t GetNumMips() const final {
46 return createdConfig.mipLevels;
47 }
48 };
49
51 const std::shared_ptr<const TextureVk> owningTexture = nullptr;
52 const CustomTextureViewConfig config;
53 CustomTextureViewVk(decltype(owningTexture) owning, const CustomTextureViewConfig& config);
54
55 VkImageView imageView = VK_NULL_HANDLE;
56
58
59 TextureView GetView() const;
60 };
61}
Definition Texture.hpp:152
Definition Texture.hpp:168
Definition format.h:4067
Definition Texture.hpp:157
Definition VkTexture.hpp:50
Definition Texture.hpp:25
Definition VkSwapchain.hpp:10
Definition Texture.hpp:138
Definition Texture.hpp:162
Definition Texture.hpp:43
Definition VkTexture.hpp:14