EDIT: IBL async
This commit is contained in:
@@ -13,7 +13,7 @@ Data Flow
|
||||
- `VulkanEngine::init_vulkan()` creates an `IBLManager`, calls `init(context)`, and publishes it via `EngineContext::ibl`.
|
||||
- The engine optionally loads default IBL assets (`IBLPaths` in `src/core/engine.cpp`), typically a BRDF LUT plus a specular environment `.ktx2`.
|
||||
- Loading (IBLManager):
|
||||
- `IBLManager::load(const IBLPaths&)`:
|
||||
- `IBLManager::load(const IBLPaths&)` (synchronous, mostly used in tools/tests):
|
||||
- Specular:
|
||||
- Tries `ktxutil::load_ktx2_cubemap` first. If successful, uploads via `ResourceManager::create_image_compressed_layers` with `VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT`.
|
||||
- If cubemap loading fails, falls back to 2D `.ktx2` via `ktxutil::load_ktx2_2d` and `create_image_compressed`. The image is treated as equirectangular with prefiltered mips.
|
||||
@@ -28,6 +28,12 @@ Data Flow
|
||||
- Loaded as 2D `.ktx2` via `ktxutil::load_ktx2_2d` and uploaded with `create_image_compressed`.
|
||||
- Fallbacks:
|
||||
- If `diffuseCube` is missing but a specular env exists, `_diff` is aliased to `_spec`.
|
||||
- `IBLManager::load_async(const IBLPaths&)` + `IBLManager::pump_async()` (runtime path used by the engine):
|
||||
- `load_async` runs KTX2 file I/O and SH bake on a worker thread and stores a prepared CPU-side description (`PreparedIBLData`).
|
||||
- `pump_async` is called on the main thread once per frame (after the previous frame is idle) to:
|
||||
- Destroy old IBL images/SH via `destroy_images_and_sh()`.
|
||||
- Create new GPU images with `create_image_compressed(_layers)` and upload the SH buffer.
|
||||
- This avoids stalls in the main/game loop when switching IBL volumes or loading the default environment at startup.
|
||||
- `IBLManager::unload()` releases GPU images, the SH buffer, and the descriptor set layout.
|
||||
- Descriptor layout:
|
||||
- `IBLManager::ensureLayout()` builds a descriptor set layout (set=3) with:
|
||||
|
||||
@@ -101,7 +101,7 @@ Image‑Based Lighting (IBL) Textures
|
||||
- Specular:
|
||||
- If `specularCube` is a cubemap `.ktx2`, `IBLManager` uses `ktxutil::load_ktx2_cubemap` and uploads via `ResourceManager::create_image_compressed_layers`, preserving the file’s format and mip chain.
|
||||
- If cubemap load fails, it falls back to 2D `.ktx2` via `ktxutil::load_ktx2_2d` + `ResourceManager::create_image_compressed`. The image is treated as equirectangular with prefiltered mips and sampled with explicit LOD in shaders.
|
||||
- If the format is float HDR (`R16G16B16A16_SFLOAT` or `R32G32B32A32_SFLOAT`) and the aspect ratio is 2:1, `IBLManager` additionally computes 2nd‑order SH coefficients (9×`vec3`) on the CPU for diffuse irradiance and uploads them to a UBO (`_shBuffer`).
|
||||
- If the format is float HDR (`R16G16B16A16_SFLOAT` or `R32G32B32A32_SFLOAT`) and the aspect ratio is 2:1, `IBLManager` additionally computes 2nd‑order SH coefficients (9×`vec3`) on a worker thread and uploads them to a UBO (`_shBuffer`) when `pump_async()` is called on the main thread.
|
||||
- Diffuse (optional):
|
||||
- If `diffuseCube` is provided and valid, it is uploaded as a cubemap using `create_image_compressed_layers`. Current shaders use the SH buffer for diffuse; this cubemap can be wired into a future path if you want to sample it directly.
|
||||
- BRDF LUT:
|
||||
|
||||
Reference in New Issue
Block a user