MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Graphics::TextureLoom Class Reference

Portal-level texture creation and management. More...

#include <TextureLoom.hpp>

+ Collaboration diagram for MayaFlux::Portal::Graphics::TextureLoom:

Public Member Functions

 TextureLoom (const TextureLoom &)=delete
 
TextureLoomoperator= (const TextureLoom &)=delete
 
 TextureLoom (TextureLoom &&) noexcept=default
 
TextureLoomoperator= (TextureLoom &&) noexcept=default
 
bool initialize (const std::shared_ptr< Core::VulkanBackend > &backend)
 Initialize texture manager.
 
void shutdown ()
 Shutdown and cleanup all textures.
 
bool is_initialized () const
 Check if manager is initialized.
 
std::shared_ptr< Core::VKImagecreate_2d (uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr, uint32_t mip_levels=1)
 Create a 2D texture.
 
std::shared_ptr< Core::VKImagecreate_3d (uint32_t width, uint32_t height, uint32_t depth, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr)
 Create a 3D texture (volumetric)
 
std::shared_ptr< Core::VKImagecreate_cubemap (uint32_t size, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr)
 Create a cubemap texture.
 
std::shared_ptr< Core::VKImagecreate_render_target (uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8)
 Create a render target (color attachment)
 
std::shared_ptr< Core::VKImagecreate_depth_buffer (uint32_t width, uint32_t height, bool with_stencil=false)
 Create a depth buffer.
 
std::shared_ptr< Core::VKImagecreate_storage_image (uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8)
 Create a storage image (compute shader read/write)
 
void upload_data (const std::shared_ptr< Core::VKImage > &image, const void *data, size_t size)
 Upload pixel data to an existing texture.
 
void download_data (const std::shared_ptr< Core::VKImage > &image, void *data, size_t size)
 Download pixel data from a texture.
 
vk::Sampler get_or_create_sampler (const SamplerConfig &config)
 Get or create a sampler with the given configuration.
 
vk::Sampler get_default_sampler ()
 Get a default linear sampler (for convenience)
 
vk::Sampler get_nearest_sampler ()
 Get a default nearest sampler (for pixel-perfect sampling)
 

Static Public Member Functions

static TextureLoominstance ()
 
static vk::Format to_vulkan_format (ImageFormat format)
 Convert Portal ImageFormat to Vulkan format.
 
static size_t get_bytes_per_pixel (ImageFormat format)
 Get bytes per pixel for a format.
 
static size_t calculate_image_size (uint32_t width, uint32_t height, uint32_t depth, ImageFormat format)
 Calculate image data size.
 

Private Member Functions

 TextureLoom ()=default
 
 ~TextureLoom ()
 
vk::Sampler create_sampler (const SamplerConfig &config)
 

Static Private Member Functions

static size_t hash_sampler_config (const SamplerConfig &config)
 

Private Attributes

std::shared_ptr< Core::VulkanBackendm_backend
 
Core::BackendResourceManagerm_resource_manager = nullptr
 
std::vector< std::shared_ptr< Core::VKImage > > m_textures
 
std::unordered_map< size_t, vk::Sampler > m_sampler_cache
 

Static Private Attributes

static bool s_initialized = false
 

Detailed Description

Portal-level texture creation and management.

TextureLoom is the primary Portal::Graphics class for creating and managing GPU textures. It bridges between user-friendly Portal API and backend VKImage resources via BufferService registry.

Key Responsibilities:

  • Create textures (2D, 3D, cubemaps, render targets)
  • Load textures from files (delegates to IO namespace)
  • Manage sampler objects (filtering, addressing)
  • Track texture lifecycle for cleanup
  • Provide convenient format conversions

Design Philosophy:

  • Manages creation, NOT rendering (that's Pipeline/RenderPass)
  • Returns VKImage directly (no wrapping yet)
  • Simple, focused API (file loading deferred to IO)
  • Integrates with BufferService for backend independence

Usage: auto& mgr = Portal::Graphics::TextureLoom::instance();

// Create basic texture auto texture = mgr.create_2d(512, 512, ImageFormat::RGBA8);

// Create with data std::vector<uint8_t> pixels = {...}; auto texture = mgr.create_2d(512, 512, ImageFormat::RGBA8, pixels.data());

// Create render target auto target = mgr.create_render_target(1920, 1080);

// Get sampler SamplerConfig config; config.mag_filter = FilterMode::LINEAR; auto sampler = mgr.get_or_create_sampler(config);

Definition at line 68 of file TextureLoom.hpp.


The documentation for this class was generated from the following files: