diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-13 13:28:02 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-13 13:28:02 +0100 |
| commit | 2fd58be11246772dd50ede6188a4ab960e6ffc0e (patch) | |
| tree | 18aaf8c682b902754bc0cf053526d7cca7fcc726 | |
| parent | 8a41ac7cb95c65d68892810d89c9c80a0463f06d (diff) | |
Add test asset support with STRIP_ALL guards
Fixes test_assets.cc compilation by adding missing test asset IDs and
procedural generators. Test-specific code is protected with DEMO_STRIP_ALL
to exclude from release builds.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| -rw-r--r-- | src/procedural/generator.cc | 14 | ||||
| -rw-r--r-- | src/procedural/generator.h | 10 | ||||
| -rw-r--r-- | src/util/asset_manager.cc | 4 | ||||
| -rw-r--r-- | tools/asset_packer.cc | 4 | ||||
| -rw-r--r-- | workspaces/test/assets.txt | 7 | ||||
| -rw-r--r-- | workspaces/test/test_assets/test_asset_1.txt | 1 | ||||
| -rw-r--r-- | workspaces/test/test_assets/test_image.png | bin | 0 -> 82 bytes | |||
| -rw-r--r-- | workspaces/test/test_assets/test_image.tga | bin | 0 -> 34 bytes |
8 files changed, 40 insertions, 0 deletions
diff --git a/src/procedural/generator.cc b/src/procedural/generator.cc index 18ad133..7c165db 100644 --- a/src/procedural/generator.cc +++ b/src/procedural/generator.cc @@ -191,4 +191,18 @@ bool make_periodic(uint8_t* buffer, int w, int h, const float* params, return true; } +#if !defined(DEMO_STRIP_ALL) +// Test-only: 256x256 noise generator +bool gen_noise_256(uint8_t* buffer, int w, int h, const float* params, + int num_params) { + return gen_noise(buffer, w, h, params, num_params); +} + +// Test-only: Failing generator +bool gen_fail(uint8_t* buffer, int w, int h, const float* params, + int num_params) { + return false; +} +#endif + } // namespace procedural diff --git a/src/procedural/generator.h b/src/procedural/generator.h index e57ef61..96d7651 100644 --- a/src/procedural/generator.h +++ b/src/procedural/generator.h @@ -38,4 +38,14 @@ bool gen_grid(uint8_t* buffer, int w, int h, const float* params, bool make_periodic(uint8_t* buffer, int w, int h, const float* params, int num_params); +#if !defined(DEMO_STRIP_ALL) +// Test-only: 256x256 noise generator +bool gen_noise_256(uint8_t* buffer, int w, int h, const float* params, + int num_params); + +// Test-only: Failing generator +bool gen_fail(uint8_t* buffer, int w, int h, const float* params, + int num_params); +#endif + } // namespace procedural diff --git a/src/util/asset_manager.cc b/src/util/asset_manager.cc index 5067ebe..274f0f9 100644 --- a/src/util/asset_manager.cc +++ b/src/util/asset_manager.cc @@ -28,6 +28,10 @@ static const ProcGenEntry kAssetManagerProcGenFuncs[] = { {"gen_perlin", procedural::gen_perlin}, {"gen_grid", procedural::gen_grid}, {"make_periodic", procedural::make_periodic}, +#if !defined(DEMO_STRIP_ALL) + {"gen_noise_256", procedural::gen_noise_256}, + {"gen_fail", procedural::gen_fail}, +#endif }; static const size_t kNumProcGenFuncs = sizeof(kAssetManagerProcGenFuncs) / sizeof(kAssetManagerProcGenFuncs[0]); diff --git a/tools/asset_packer.cc b/tools/asset_packer.cc index e7f678b..af89a88 100644 --- a/tools/asset_packer.cc +++ b/tools/asset_packer.cc @@ -31,6 +31,10 @@ static const std::map<std::string, ProcGenFunc> kAssetPackerProcGenFuncMap = { {"gen_noise", procedural::gen_noise}, {"gen_grid", procedural::gen_grid}, {"make_periodic", procedural::make_periodic}, +#if !defined(DEMO_STRIP_ALL) + {"gen_noise_256", procedural::gen_noise_256}, + {"gen_fail", procedural::gen_fail}, +#endif }; static bool HasImageExtension(const std::string& filename) { diff --git a/workspaces/test/assets.txt b/workspaces/test/assets.txt index c9d077a..1389993 100644 --- a/workspaces/test/assets.txt +++ b/workspaces/test/assets.txt @@ -61,3 +61,10 @@ SHADER_COMPUTE_GEN_MASK, NONE, ../../common/shaders/compute/gen_mask.wgsl, "GPU CIRCLE_MASK_COMPUTE_SHADER, NONE, shaders/circle_mask_compute.wgsl, "Circle mask compute shader" CIRCLE_MASK_RENDER_SHADER, NONE, shaders/circle_mask_render.wgsl, "Circle mask render shader" MASKED_CUBE_SHADER, NONE, shaders/masked_cube.wgsl, "Masked cube shader" + +# --- Test Assets (for test_assets.cc) --- +TEST_ASSET_1, NONE, test_assets/test_asset_1.txt, "Test static asset" +TEST_IMAGE, NONE, test_assets/test_image.png, "Test 2x2 RGBA PNG image" +PROC_NOISE_256, PROC(gen_noise_256, 42, 0), _, "Procedural 256x256 noise" +PROC_UNKNOWN, PROC(unknown_func, 0, 0), _, "Unknown procedural function" +PROC_FAIL, PROC(gen_fail, 0, 0), _, "Failing procedural function" diff --git a/workspaces/test/test_assets/test_asset_1.txt b/workspaces/test/test_assets/test_asset_1.txt new file mode 100644 index 0000000..ce6fe83 --- /dev/null +++ b/workspaces/test/test_assets/test_asset_1.txt @@ -0,0 +1 @@ +This is a test asset file. diff --git a/workspaces/test/test_assets/test_image.png b/workspaces/test/test_assets/test_image.png Binary files differnew file mode 100644 index 0000000..3dd3fe7 --- /dev/null +++ b/workspaces/test/test_assets/test_image.png diff --git a/workspaces/test/test_assets/test_image.tga b/workspaces/test/test_assets/test_image.tga Binary files differnew file mode 100644 index 0000000..21009e9 --- /dev/null +++ b/workspaces/test/test_assets/test_image.tga |
