Skip to content

Asset Loading

EntropyPortal employs a designated service pipeline for loading assets, separating the concerns of fetching, parsing, and GPU upload.

The asset pipeline is split into three distinct layers:

graph TD
    Network[Network / VFS] -->|Raw Bytes| Loader[AssetLoaderService]
    Loader -->|Cached Bytes| Parser[Canvas SDK Parsers]
    
    Parser -->|TextureData| TexService[TextureService]
    Parser -->|MeshData| MeshService[MeshService]
    Parser -->|Slang Source| ShaderService[ShaderCompilerService]
    
    TexService -->|Upload| GPU[GpuRenderDevice]
    MeshService -->|Upload| GPU
    ShaderService -->|Compile & Create PSO| GPU

The AssetLoaderService is responsible for retrieving raw asset data from the source (Network or Disk).

  • Resolution: Uses AssetClient to resolve AssetId to a URI (e.g., https://... or file://...).
  • Caching: Maintains an LRU cache of decrypted, ready-to-use bytes.
  • Security: Handles AES-256-GCM decryption and hash verification transparently.

Once raw bytes are retrieved, they are parsed by the EntropyCanvas SDK.

  • Textures: Parsed into EntropyCanvas::TextureData (pixel formatting, dimensions).
  • Meshes: Parsed into EntropyCanvas::MeshData (vertex streams, indices).

The resource services take parsed data and manage the GPU lifecycle.

  • Meshes/Textures: Schedule non-blocking transfers to the GPU.
  • Shaders: The ShaderCompilerService manages a pool of compilers to asynchronously compile Slang source into GPU bytecode (SPIR-V/DXIL/MSL) and create Pipeline State Objects (PSOs).
  • Lookup: All services provide getByAssetId lookups.
// 1. Fetch (Async)
assetLoader->loadAsset(assetId, [](const AssetLoadResult& result) {
// 2. Parse (e.g., Texture)
auto textureData = EntropyCanvas::TextureLoader::parse(result.data);
// 3. Create GPU Resource
auto texture = textureService->createTextureFromData(textureData);
// 4. Register for Lookup
textureService->registerTextureWithAssetId(texture.get(), assetId);
// 5. Schedule Upload
textureService->requestTextureUpload(texture, std::move(textureData));
});