Class TextureLoader

Inheritance Relationships

Base Type

Class Documentation

class TextureLoader : public portal::resources::ResourceLoader

Public Functions

TextureLoader(ResourceRegistry &registry, const renderer::vulkan::VulkanContext &context)
virtual Reference<Resource> load(const SourceMetadata &meta, const ResourceSource &source) override

Load a resource from source data.

This method blocks the calling thread (job system worker) until the resource is fully loaded and ready for use. It reads bytes from the source, decodes the format, creates GPU resources if needed, and returns a Reference to the loaded resource.

If the resource depends on other resources, the loader can request them from the registry. The registry will handle scheduling those loads appropriately.

Error Handling: If loading fails (corrupt data, unsupported format, out of memory, etc.), the loader should log the error and return nullptr. The registry will move the resource to ResourceState::Error.

Note

The returned resource is managed by Reference (std::shared_ptr)

Note

Implementations should be thread-safe for reading from the source

Parameters:
  • meta – Metadata about the resource (type, format, dependencies, etc.)

  • source – Abstraction for reading the source bytes (file, memory, etc.)

Returns:

Reference<Resource> if successful, nullptr on error

Public Static Functions

static void enrich_metadata(SourceMetadata &meta, const ResourceSource &source)

Protected Functions

void create_standalone_texture(const StringId &id, std::span<uint32_t> data, vk::Extent3D extent) const

Creates a “standalone” texture in the registry, a texture without an associated ResourceSource This is used to create some default all white, all black, and “missing” textures

Parameters:
  • id – The texture id

  • data – The texture data

  • extent – The texture extent