Lysa  0.0
Lysa 3D Engine
Resources Class Reference

Detailed Description

Central container responsible for GPU-ready shared resources.

The Resources class owns and manages device memory arrays (vertices, indices, materials, mesh surfaces), the global sampler set, the descriptor layout/set used by draw pipelines, and texture images including fallback (blank) assets.

  • Allocate and provide access to large device-side arrays used by the renderers.
  • Maintain a descriptor set exposing materials, surfaces and textures to shaders.
  • Manage a pool of sampled images with a fixed upper bound (MAX_TEXTURES).
  • Provide default blank 2D and cube textures to avoid null bindings.
  • Track and expose an "updated" flag so dependent systems can react.

Thread-safety:

  • Public methods that mutate internal state should be guarded by the provided mutex.
  • Read-only getters may be called concurrently once initialization is complete.

Public Member Functions

 Resources (const vireo::Vireo &vireo, ResourcesConfiguration &config, const vireo::SubmitQueue &graphicQueue)
 
DeviceMemoryArraygetVertexArray ()
 
DeviceMemoryArraygetIndexArray ()
 
DeviceMemoryArraygetMaterialArray ()
 
DeviceMemoryArraygetMeshSurfaceArray ()
 
SamplersgetSamplers ()
 
uint32 addTexture (const Image &image)
 
const auto & getDescriptorSet () const
 
void flush ()
 
void update ()
 
void cleanup ()
 
void setUpdated ()
 
bool isUpdated () const
 
auto & getMutex ()
 
auto getBlankImage ()
 
auto getBlankCubeMap ()
 
 Resources (Resources &) = delete
 
Resources & operator= (Resources &) = delete
 

Static Public Attributes

static constexpr auto MAX_TEXTURES {500}
 
static constexpr uint32 SET_RESOURCES {0}
 
static constexpr vireo::DescriptorIndex BINDING_MATERIAL {0}
 
static constexpr vireo::DescriptorIndex BINDING_SURFACES {1}
 
static constexpr vireo::DescriptorIndex BINDING_TEXTURE {2}
 
static std::shared_ptr< vireo::DescriptorLayout > descriptorLayout {nullptr}
 

Constructor & Destructor Documentation

Resources ( const vireo::Vireo &  vireo,
ResourcesConfiguration config,
const vireo::SubmitQueue &  graphicQueue 
)

Constructs the resources container and allocates GPU-side structures.

Parameters
vireoGraphics backend entry point.
configHigh-level resources configuration (sizes, formats, etc.).
graphicQueueQueue used to submit upload and initialization work.
Resources ( Resources &  )
delete

Member Function Documentation

uint32 addTexture ( const Image image)

Adds a texture to the internal textures list and uploads it to the GPU. If the capacity MAX_TEXTURES is reached, an engine-defined policy applies (typically reuse or replace); callers should not rely on indices beyond the limit.

Parameters
imageCPU-side image data to upload.
Returns
Texture index suitable for shader/resource binding.
void cleanup ( )

Releases all GPU and CPU-side resources owned by this container.

void flush ( )

Flushes pending uploads to the device. Typically enqueues copy/transfer commands to make new/updated resources visible to the GPU.

auto getBlankCubeMap ( )
inline

Returns the default cubemap blank image used as a safe fallback.

auto getBlankImage ( )
inline

Returns the default 2D blank image used as a safe fallback.

const auto& getDescriptorSet ( ) const
inline

Returns the descriptor set that exposes resources to shaders.

DeviceMemoryArray& getIndexArray ( )
inline

Returns the device memory array storing index data.

DeviceMemoryArray& getMaterialArray ( )
inline

Returns the device memory array storing material parameters.

DeviceMemoryArray& getMeshSurfaceArray ( )
inline

Returns the device memory array storing mesh surface ranges/metadata.

auto& getMutex ( )
inline

Provides access to the internal mutex used to guard mutations.

Samplers& getSamplers ( )
inline

Returns the global sampler collection used by the renderer.

DeviceMemoryArray& getVertexArray ( )
inline

Returns the device memory array storing vertex data.

bool isUpdated ( ) const
inline

Returns true when an update has been flagged since the last processing.

Resources& operator= ( Resources &  )
delete
void setUpdated ( )
inline

Marks the container as updated so dependent systems can react.

void update ( )

Applies incremental updates to buffers, images, and descriptors if needed.

Member Data Documentation

constexpr vireo::DescriptorIndex BINDING_MATERIAL {0}
staticconstexpr

Descriptor binding index for the material buffer.

constexpr vireo::DescriptorIndex BINDING_SURFACES {1}
staticconstexpr

Descriptor binding index for the mesh surfaces buffer.

constexpr vireo::DescriptorIndex BINDING_TEXTURE {2}
staticconstexpr

Descriptor binding index for the textures array/sampled images.

std::shared_ptr<vireo::DescriptorLayout> descriptorLayout {nullptr}
inlinestatic

Shared descriptor layout describing the above bindings.

constexpr auto MAX_TEXTURES {500}
staticconstexpr

Maximum number of textures managed and bound by this container.

constexpr uint32 SET_RESOURCES {0}
staticconstexpr

Descriptor set index used by pipelines to bind shared resources.