Class GpuTexture¶
Defined in File gpu_texture.hpp
Class Documentation¶
-
class GpuTexture¶
RAII wrapper class for textures which are stored in GPU memory.
- Todo:
Support 3D textures and cube maps (implement new and separate wrappers though).
Note
The code which loads textures from files is wrapped in CpuTexture.
Public Functions
-
GpuTexture(const Device &device, const CpuTexture &cpu_texture)¶
Construct a texture from a file.
- Parameters
device – The const reference to a device RAII wrapper instance.
file_name – The name of the texture file.
name – The internal debug marker name of the 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)¶
Construct a texture from a block of memory.
- Parameters
device – The const reference to a device RAII wrapper instance.
device – The const reference to a device RAII wrapper instance.
texture_data – A pointer to the texture data.
texture_width – The width of the texture.
texture_height – The height of the texture.
texture_size – The size of the texture.
name – The internal debug marker name of the texture.
-
GpuTexture(const GpuTexture&) = delete¶
-
GpuTexture(GpuTexture&&) noexcept¶
-
~GpuTexture()¶
-
GpuTexture &operator=(const GpuTexture&) = delete¶
-
GpuTexture &operator=(GpuTexture&&) = delete¶
-
inline const std::string &name() const¶
-
inline VkImage image() const¶
-
inline VkImageView image_view() const¶
-
inline VkSampler sampler() const¶
Private Functions
-
void create_texture(void *texture_data, std::size_t texture_size)¶
Create the texture.
- Parameters
texture_data – A pointer to the texture data.
texture_size – The size of the texture.
-
void transition_image_layout(VkImage image, VkImageLayout old_layout, VkImageLayout new_layout)¶
Transform the image layout.
- Parameters
image – The image.
old_layout – The old image layout.
new_layout – The new image layout.
-
void create_texture_sampler()¶
Create the texture sampler.