Program Listing for File gpu_texture.hpp¶
↰ Return to documentation for file (inexor/vulkan-renderer/wrapper/gpu_texture.hpp
)
#pragma once
#include "inexor/vulkan-renderer/wrapper/cpu_texture.hpp"
#include "inexor/vulkan-renderer/wrapper/device.hpp"
#include "inexor/vulkan-renderer/wrapper/gpu_memory_buffer.hpp"
#include "inexor/vulkan-renderer/wrapper/image.hpp"
#include <memory>
namespace inexor::vulkan_renderer::wrapper {
// Forward declarations
class Device;
class GPUMemoryBuffer;
class GpuTexture {
std::unique_ptr<Image> m_texture_image;
VkSampler m_sampler{VK_NULL_HANDLE};
int m_texture_width{0};
int m_texture_height{0};
int m_texture_channels{0};
int m_mip_levels{0};
std::string m_name;
const Device &m_device;
const VkFormat m_texture_image_format{VK_FORMAT_R8G8B8A8_UNORM};
void create_texture(void *texture_data, std::size_t texture_size);
void transition_image_layout(VkImage image, VkImageLayout old_layout, VkImageLayout new_layout);
void create_texture_sampler();
public:
GpuTexture(const Device &device, const CpuTexture &cpu_texture);
GpuTexture(const Device &device, void *data, std::size_t data_size, int texture_width, int texture_height,
int texture_channels, int mip_levels, std::string name);
GpuTexture(const GpuTexture &) = delete;
GpuTexture(GpuTexture &&) noexcept;
~GpuTexture();
GpuTexture &operator=(const GpuTexture &) = delete;
GpuTexture &operator=(GpuTexture &&) = delete;
[[nodiscard]] const std::string &name() const {
return m_name;
}
[[nodiscard]] VkImage image() const {
return m_texture_image->get();
}
[[nodiscard]] VkImageView image_view() const {
return m_texture_image->image_view();
}
[[nodiscard]] VkSampler sampler() const {
return m_sampler;
}
};
} // namespace inexor::vulkan_renderer::wrapper