diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-08 10:13:01 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-08 10:13:01 +0100 |
| commit | 1438cfe727adc7b6a5d84c76b0878ed77ef254a8 (patch) | |
| tree | a0493499f5281413b57f677979365fc98e96bac0 | |
| parent | fa7d2d7f3aa40d581ca2ad97e39fe944769ee5a3 (diff) | |
feat: WGSL asset load-from-disk in dev mode
- asset_packer: include WGSL in --disk_load path storage (alongside SPEC/MP3)
- asset_manager: disk-load WGSL assets at runtime when !DEMO_STRIP_ALL
- DemoCodegen: pass ASSET_PACKER_FLAGS to pack_test_assets so test assets
also use disk-load paths in dev mode (fixes pre-existing SPEC/WGSL test failures)
- test_shader_composer: fix stale assertions (fn test_wgsl → fn snippet_a,
correct ordering check)
35/35 tests passing.
handoff(Claude): WGSL disk-loading implemented. Shaders now loaded from disk
in dev mode, enabling hot-reload without rebuild. Tests fixed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | cmake/DemoCodegen.cmake | 2 | ||||
| -rw-r--r-- | src/tests/gpu/test_shader_composer.cc | 6 | ||||
| -rw-r--r-- | src/util/asset_manager.cc | 6 | ||||
| -rw-r--r-- | tools/asset_packer.cc | 3 |
4 files changed, 10 insertions, 7 deletions
diff --git a/cmake/DemoCodegen.cmake b/cmake/DemoCodegen.cmake index 4d0d271..aaf54a3 100644 --- a/cmake/DemoCodegen.cmake +++ b/cmake/DemoCodegen.cmake @@ -106,7 +106,7 @@ function(pack_test_assets NAME INPUT_TXT HEADER_VAR DATA_CC_VAR TARGET_NAME) add_custom_command( OUTPUT ${OUT_H} ${OUT_CC} COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/src/generated_test - COMMAND ${ASSET_PACKER_CMD} ${INPUT_TXT} ${OUT_H} ${OUT_CC} + COMMAND ${ASSET_PACKER_CMD} ${INPUT_TXT} ${OUT_H} ${OUT_CC} ${ASSET_PACKER_FLAGS} DEPENDS ${ASSET_PACKER_DEPENDS} ${INPUT_TXT} ${ASSET_FILE_DEPS} COMMENT "Generating assets for test ${NAME}..." ) diff --git a/src/tests/gpu/test_shader_composer.cc b/src/tests/gpu/test_shader_composer.cc index 6e0b707..2f87e57 100644 --- a/src/tests/gpu/test_shader_composer.cc +++ b/src/tests/gpu/test_shader_composer.cc @@ -56,11 +56,11 @@ void test_asset_composition() { "fn main() -> f32 { return test_wgsl(); }"; std::string result = sc.Compose({"TEST_WGSL"}, main_code); - assert(result.find("fn test_wgsl()") != std::string::npos); + assert(result.find("fn snippet_a()") != std::string::npos); assert(result.find("fn main()") != std::string::npos); - size_t pos_a = result.find("test_wgsl"); - size_t pos_main = result.find("main"); + size_t pos_a = result.find("snippet_a"); + size_t pos_main = result.find("fn main()"); assert(pos_a < pos_main); diff --git a/src/util/asset_manager.cc b/src/util/asset_manager.cc index 6cad083..1c02626 100644 --- a/src/util/asset_manager.cc +++ b/src/util/asset_manager.cc @@ -78,7 +78,8 @@ const uint8_t* GetAsset(AssetId asset_id, size_t* out_size) { #if !defined(DEMO_STRIP_ALL) if (source_record.type == AssetType::SPEC || - source_record.type == AssetType::MP3) { + source_record.type == AssetType::MP3 || + source_record.type == AssetType::WGSL) { const char* path = (const char*)source_record.data; FILE* f = fopen(path, "rb"); if (!f) { @@ -224,7 +225,8 @@ void DropAsset(AssetId asset_id, const uint8_t* asset) { #if !defined(DEMO_STRIP_ALL) if (g_asset_cache[index].data == asset && (g_asset_cache[index].type == AssetType::SPEC || - g_asset_cache[index].type == AssetType::MP3)) { + g_asset_cache[index].type == AssetType::MP3 || + g_asset_cache[index].type == AssetType::WGSL)) { delete[] g_asset_cache[index].data; g_asset_cache[index] = {}; } diff --git a/tools/asset_packer.cc b/tools/asset_packer.cc index e28d71f..37d2a57 100644 --- a/tools/asset_packer.cc +++ b/tools/asset_packer.cc @@ -488,7 +488,8 @@ int main(int argc, char* argv[]) { std::string full_path = combined_path.lexically_normal().string(); if (disk_load_mode && - (info.asset_type == "SPEC" || info.asset_type == "MP3")) { + (info.asset_type == "SPEC" || info.asset_type == "MP3" || + info.asset_type == "WGSL")) { fprintf(assets_data_cc_file, "alignas(16) static const char %s[] = \"%s\";\n", info.data_array_name.c_str(), full_path.c_str()); |
