diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-09 13:59:07 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-09 13:59:07 +0100 |
| commit | 744bcadfe8f4bb1b2d4f1daf9f880fa511d65405 (patch) | |
| tree | 49ec05f0b4d6f04d04ab7904164fb602bcd7bee7 /src/tests | |
| parent | c712874ece1ca7073904f5fb84cc866d28084de0 (diff) | |
feat(gpu): Phase 2 - Add gen_perlin and gen_grid GPU compute shaders
Complete Phase 2 implementation:
- gen_perlin.wgsl: FBM with configurable octaves, amplitude decay
- gen_grid.wgsl: Grid pattern with configurable spacing/thickness
- TextureManager extensions: create_gpu_perlin_texture(), create_gpu_grid_texture()
- Asset packer now validates gen_noise, gen_perlin, gen_grid for PROC_GPU()
- 3 compute pipelines (lazy-init on first use)
Shader parameters:
- gen_perlin: seed, frequency, amplitude, amplitude_decay, octaves (32 bytes)
- gen_grid: width, height, grid_size, thickness (16 bytes)
test_3d_render migration:
- Replaced CPU sky texture (gen_perlin) with GPU version
- Replaced CPU noise texture (gen_noise) with GPU version
- Added new GPU grid texture (256x256, 32px grid, 2px lines)
Size impact:
- gen_perlin.wgsl: ~200 bytes (compressed)
- gen_grid.wgsl: ~100 bytes (compressed)
- Total Phase 2 code: ~300 bytes
- Cumulative (Phase 1+2): ~600 bytes
Testing:
- All 34 tests passing (100%)
- test_gpu_procedural validates all generators
- test_3d_render uses 3 GPU textures (noise, perlin, grid)
Next: Phase 3 - Variable dimensions, async generation, pipeline caching
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/test_3d_render.cc | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/tests/test_3d_render.cc b/src/tests/test_3d_render.cc index fa13a43..eee46ba 100644 --- a/src/tests/test_3d_render.cc +++ b/src/tests/test_3d_render.cc @@ -220,25 +220,36 @@ int main(int argc, char** argv) { g_renderer.resize(platform_state.width, platform_state.height); g_textures.init(g_device, g_queue); - ProceduralTextureDef noise_def; - noise_def.width = 256; - noise_def.height = 256; - noise_def.gen_func = gen_periodic_noise; - noise_def.params.push_back(1234.0f); - noise_def.params.push_back(16.0f); - g_textures.create_procedural_texture("noise", noise_def); + // GPU Noise texture (replaces CPU procedural) + GpuProceduralParams noise_params = {}; + noise_params.width = 256; + noise_params.height = 256; + float noise_vals[2] = {1234.0f, 16.0f}; + noise_params.params = noise_vals; + noise_params.num_params = 2; + g_textures.create_gpu_noise_texture("noise", noise_params); g_renderer.set_noise_texture(g_textures.get_texture_view("noise")); - ProceduralTextureDef sky_def; - sky_def.width = 512; - sky_def.height = 256; - sky_def.gen_func = procedural::gen_perlin; - sky_def.params = {42.0f, 4.0f, 1.0f, 0.5f, 6.0f}; - g_textures.create_procedural_texture("sky", sky_def); - + // GPU Perlin texture for sky (replaces CPU procedural) + GpuProceduralParams sky_params = {}; + sky_params.width = 512; + sky_params.height = 256; + float sky_vals[5] = {42.0f, 4.0f, 1.0f, 0.5f, 6.0f}; + sky_params.params = sky_vals; + sky_params.num_params = 5; + g_textures.create_gpu_perlin_texture("sky", sky_params); g_renderer.set_sky_texture(g_textures.get_texture_view("sky")); + // GPU Grid texture (new!) + GpuProceduralParams grid_params = {}; + grid_params.width = 256; + grid_params.height = 256; + float grid_vals[2] = {32.0f, 2.0f}; // grid_size, thickness + grid_params.params = grid_vals; + grid_params.num_params = 2; + g_textures.create_gpu_grid_texture("grid", grid_params); + setup_scene(); g_camera.position = vec3(0, 5, 10); |
