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/gpu/texture_manager.h | |
| 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/gpu/texture_manager.h')
| -rw-r--r-- | src/gpu/texture_manager.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gpu/texture_manager.h b/src/gpu/texture_manager.h index 0cffe0c..b2dea84 100644 --- a/src/gpu/texture_manager.h +++ b/src/gpu/texture_manager.h @@ -46,6 +46,10 @@ class TextureManager { // GPU procedural generation void create_gpu_noise_texture(const std::string& name, const GpuProceduralParams& params); + void create_gpu_perlin_texture(const std::string& name, + const GpuProceduralParams& params); + void create_gpu_grid_texture(const std::string& name, + const GpuProceduralParams& params); #if !defined(STRIP_ALL) // On-demand lazy generation (stripped in final builds) @@ -59,8 +63,14 @@ class TextureManager { private: void dispatch_noise_compute(WGPUTexture target, const GpuProceduralParams& params); + void dispatch_perlin_compute(WGPUTexture target, + const GpuProceduralParams& params); + void dispatch_grid_compute(WGPUTexture target, + const GpuProceduralParams& params); WGPUDevice device_; WGPUQueue queue_; std::map<std::string, GpuTexture> textures_; WGPUComputePipeline noise_compute_pipeline_ = nullptr; + WGPUComputePipeline perlin_compute_pipeline_ = nullptr; + WGPUComputePipeline grid_compute_pipeline_ = nullptr; }; |
