SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
VulkanCubemapTexture.hpp
Go to the documentation of this file.
1#ifndef VULKANCUBEMAPTEXTURE_HPP_
2#define VULKANCUBEMAPTEXTURE_HPP_
3
4#include <Core/OSDef.hpp>
5#include <Runtime/Texture.hpp>
6#include <vulkan/vulkan.h>
7#include <array>
8#include <string>
9
10namespace Sleak {
11namespace RenderEngine {
12
13/// Vulkan cubemap texture, loadable from six face images or a single equirectangular panorama.
14class ENGINE_API VulkanCubemapTexture : public ::Sleak::Texture {
15public:
16 VulkanCubemapTexture(VkDevice device, VkPhysicalDevice physicalDevice,
17 VkCommandPool commandPool, VkQueue graphicsQueue);
18 ~VulkanCubemapTexture() override;
19
20 /// Loads and uploads 6 face images: +X, -X, +Y, -Y, +Z, -Z.
21 bool LoadCubemap(const std::array<std::string, 6>& facePaths);
22
23 /// Load from a single equirectangular panorama and convert to cubemap
24 bool LoadEquirectangular(const std::string& path, uint32_t faceSize = 512);
25
26 // Texture interface
27 /// Unused for cubemaps; load via LoadCubemap/LoadEquirectangular instead.
28 bool LoadFromMemory(const void* data, uint32_t width, uint32_t height,
29 TextureFormat format) override;
30 /// Unused for cubemaps; load via LoadCubemap/LoadEquirectangular instead.
31 bool LoadFromFile(const std::string& filePath) override;
32
33 void Bind(uint32_t slot = 0) const override;
34 void Unbind() const override;
35
36 void SetFilter(TextureFilter filter) override;
37 void SetWrapMode(TextureWrapMode wrapMode) override;
38
39 uint32_t GetWidth() const override { return m_width; }
40 uint32_t GetHeight() const override { return m_height; }
41 TextureFormat GetFormat() const override { return m_format; }
42 TextureType GetType() const override { return TextureType::TextureCube; }
43
44 VkImageView GetImageView() const { return m_imageView; }
45 VkSampler GetSampler() const { return m_sampler; }
46
47private:
48 void Cleanup();
49 /// Finds a physical device memory type matching the filter and required properties.
50 uint32_t FindMemoryType(uint32_t typeFilter,
51 VkMemoryPropertyFlags properties);
52 /// Records a pipeline barrier moving all 6 cube faces between image layouts.
53 void TransitionImageLayout(VkImage image, VkImageLayout oldLayout,
54 VkImageLayout newLayout,
55 uint32_t layerCount);
56
57 VkDevice m_device = VK_NULL_HANDLE;
58 VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE;
59 VkCommandPool m_commandPool = VK_NULL_HANDLE;
60 VkQueue m_graphicsQueue = VK_NULL_HANDLE;
61
62 VkImage m_image = VK_NULL_HANDLE;
63 VkDeviceMemory m_imageMemory = VK_NULL_HANDLE;
64 VkImageView m_imageView = VK_NULL_HANDLE;
65 VkSampler m_sampler = VK_NULL_HANDLE;
66
67 uint32_t m_width = 0;
68 uint32_t m_height = 0;
70};
71
72} // namespace RenderEngine
73} // namespace Sleak
74
75#endif // VULKANCUBEMAPTEXTURE_HPP_
int width
int height
bool LoadCubemap(const std::array< std::string, 6 > &facePaths)
Loads and uploads 6 face images: +X, -X, +Y, -Y, +Z, -Z.
bool LoadFromMemory(const void *data, uint32_t width, uint32_t height, TextureFormat format) override
Unused for cubemaps; load via LoadCubemap/LoadEquirectangular instead.
void SetFilter(TextureFilter filter) override
VulkanCubemapTexture(VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue graphicsQueue)
bool LoadEquirectangular(const std::string &path, uint32_t faceSize=512)
Load from a single equirectangular panorama and convert to cubemap.
void SetWrapMode(TextureWrapMode wrapMode) override
bool LoadFromFile(const std::string &filePath) override
Unused for cubemaps; load via LoadCubemap/LoadEquirectangular instead.
void Bind(uint32_t slot=0) const override
TextureFormat
Definition Texture.hpp:10
TextureFilter
Definition Texture.hpp:28
TextureType
Definition Texture.hpp:20
TextureWrapMode
Definition Texture.hpp:43
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.
Definition Camera.hpp:10