$darkmode
#include "async_loader.h"#include "log.h"#include "perf_timer.h"#include "profiler.h"#include "simd_utils.h"#include "texture.h"#include "tracy_manager.h"#include "utils.h"#include <pthread.h>#include <stb_image.h>#include <stdbool.h>#include <string.h>Data Structures | |
| struct | AsyncLoader |
| Opaque handle to the asynchronous loader context. More... | |
Macros | |
| #define | transition_tracy_state(s) tracy_manager_async_transition(loader->tracy_mgr, s) |
| #define | cleanup_tracy_states() tracy_manager_async_end(loader->tracy_mgr) |
Enumerations | |
| enum | { MSG_BUF_SIZE = 128 } |
Functions | |
| static bool | async_load_data (const char *path, float **out_data, int *width, int *height, int *channels) |
| static void | async_perform_conversion (AsyncLoader *loader) |
| static void | async_handle_io (AsyncLoader *loader, char *path_to_load) |
| static void * | async_worker_func (void *arg) |
| AsyncLoader * | async_loader_create (struct TracyManager *mgr) |
| Creates and initializes a new async loader instance. More... | |
| void | async_loader_destroy (AsyncLoader *loader) |
| Destroys the async loader and frees resources. More... | |
| bool | async_loader_request (AsyncLoader *loader, const char *path) |
| Submits a new file path for background loading. More... | |
| bool | async_loader_poll (AsyncLoader *loader, AsyncRequest *out_req) |
| Polls the loader for any completed requests. More... | |
| void | async_loader_provide_pbo (AsyncLoader *loader, void *mapped_ptr, GLuint pbo_id) |
| Provides a mapped PBO pointer to the async loader for conversion. More... | |
| void | async_loader_cancel (AsyncLoader *loader) |
| Cancels the current request if it is waiting for a PBO. More... | |
| #define cleanup_tracy_states | ( | ) | tracy_manager_async_end(loader->tracy_mgr) |
| #define transition_tracy_state | ( | s | ) | tracy_manager_async_transition(loader->tracy_mgr, s) |
|
static |
|
static |
| void async_loader_cancel | ( | AsyncLoader * | loader | ) |
Cancels the current request if it is waiting for a PBO.
Use this if the main thread fails to map a PBO and cannot proceed.
| loader | The loader instance. |
| AsyncLoader* async_loader_create | ( | struct TracyManager * | mgr | ) |
Creates and initializes a new async loader instance.
| mgr | The Tracy instrumentation manager. |
| void async_loader_destroy | ( | AsyncLoader * | loader | ) |
Destroys the async loader and frees resources.
| loader | The loader instance to destroy. |
| bool async_loader_poll | ( | AsyncLoader * | loader, |
| AsyncRequest * | out_req | ||
| ) |
Polls the loader for any completed requests.
This should be called from the main (OpenGL) thread once per frame.
| loader | The loader instance. | |
| [out] | out_req | Pointer to store the successfully loaded data. |
| void async_loader_provide_pbo | ( | AsyncLoader * | loader, |
| void * | mapped_ptr, | ||
| GLuint | pbo_id | ||
| ) |
Provides a mapped PBO pointer to the async loader for conversion.
Call this when async_loader_poll returns a request in ASYNC_WAITING_FOR_PBO state.
| loader | The loader instance. |
| mapped_ptr | Pointer to the mapped PBO memory. |
| pbo_id | ID of the PBO being used. |
| bool async_loader_request | ( | AsyncLoader * | loader, |
| const char * | path | ||
| ) |
Submits a new file path for background loading.
| loader | The loader instance. |
| path | The absolute path to the HDR/texture file. |
|
static |
|
static |