|
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
|
Threaded asynchronous file loader engine (Format-agnostic). More...
#include "asset_manager.h"#include "gl_common.h"#include <stdbool.h>#include <stdint.h>#include "app_subsystem.h"Go to the source code of this file.
Data Structures | |
| struct | AsyncRequest |
| Données de la requête asynchrone transférées entre les threads. More... | |
Macros | |
| #define | ASYNC_MAX_PATH 256 |
| #define | APP_ASYNC_LOADER_DESCRIPTOR {"async_loader", async_loader_subsys_init, async_loader_subsys_cleanup} |
Enumerations | |
| enum | AsyncState { ASYNC_IDLE = 0 , ASYNC_PENDING , ASYNC_LOADING , ASYNC_WAITING_FOR_PBO , ASYNC_CONVERTING , ASYNC_READY , ASYNC_FAILED } |
Functions | |
| AsyncLoader * | async_loader_create (struct TracyManager *mgr) |
| Initialize the asynchronous loader subsystem. | |
| void | async_loader_destroy (AsyncLoader *loader) |
| Tear down the asynchronous loader subsystem. | |
| bool | async_loader_request (AsyncLoader *loader, const AssetHandle *asset) |
| Request a new asset to be loaded asynchronously. | |
| bool | async_loader_poll (AsyncLoader *loader, AsyncRequest *out_req) |
| Poll the status of the current request. | |
| void | async_loader_provide_pbo (AsyncLoader *loader, void *mapped_ptr, GLuint pbo_id) |
| Provide the mapped memory address and GL buffer ID for PBO writing. | |
| void | async_loader_cancel (AsyncLoader *loader) |
| Cancel a loading request waiting for PBO input. | |
| int | async_loader_subsys_init (struct App *app) |
| void | async_loader_subsys_cleanup (struct App *app) |
Threaded asynchronous file loader engine (Format-agnostic).
| #define APP_ASYNC_LOADER_DESCRIPTOR {"async_loader", async_loader_subsys_init, async_loader_subsys_cleanup} |
| #define ASYNC_MAX_PATH 256 |
| enum AsyncState |
| void async_loader_cancel | ( | AsyncLoader * | loader | ) |
Cancel a loading request waiting for PBO input.
Aborts the current request if it is still waiting for the main thread to provide a PBO.
| loader | Loader instance. |
State transitions:
Concurrency: Thread-safe. Acquires request_mutex.
| AsyncLoader * async_loader_create | ( | struct TracyManager * | mgr | ) |
Initialize the asynchronous loader subsystem.
Allocates resources, initializes synchronization primitives (mutex, condvar), and spawns the background worker thread.
| mgr | Tracy profiler manager instance. |
Concurrency: Thread-safe. Lock initialized inside. Initial state: ASYNC_IDLE.
| void async_loader_destroy | ( | AsyncLoader * | loader | ) |
Tear down the asynchronous loader subsystem.
Signals the worker thread to exit, waits for its completion (joins it), releases any pending resources/requests, and destroys synchronization primitives.
| loader | Loader instance to destroy. Can be NULL (no-op). |
Concurrency: Safe to call from the main thread during cleanup. Post-condition: Mutex/condvar are destroyed and memory is freed.
| bool async_loader_poll | ( | AsyncLoader * | loader, |
| AsyncRequest * | out_req | ||
| ) |
Poll the status of the current request.
Checks if the request is ready for GPU upload, waiting for PBO allocation, or has failed. This is meant to be called periodically from the main thread.
| loader | Loader instance. |
| out_req | Destination structure to copy the request snapshot if ready/waiting. |
State transitions:
Concurrency: Thread-safe. Acquires request_mutex.
| void async_loader_provide_pbo | ( | AsyncLoader * | loader, |
| void * | mapped_ptr, | ||
| GLuint | pbo_id | ||
| ) |
Provide the mapped memory address and GL buffer ID for PBO writing.
Called by the main thread after detecting ASYNC_WAITING_FOR_PBO during poll. Maps the CPU pointer to the PBO and allows the worker to perform the conversion.
| loader | Loader instance. |
| mapped_ptr | Pointer to the mapped buffer memory (CPU visible). |
| pbo_id | OpenGL buffer object ID (or 0 for CPU-only malloc fallback). |
State transitions:
Concurrency: Thread-safe. Acquires request_mutex.
| bool async_loader_request | ( | AsyncLoader * | loader, |
| const AssetHandle * | asset | ||
| ) |
Request a new asset to be loaded asynchronously.
Accepts a loading task if the loader is idle or finished with the previous one.
| loader | Loader instance. |
| asset | Path and format metadata of the asset. |
State transitions:
Concurrency: Thread-safe. Acquires request_mutex.
| void async_loader_subsys_cleanup | ( | struct App * | app | ) |
| int async_loader_subsys_init | ( | struct App * | app | ) |