From 9bb5fd64776ac8a7e4b012ac2de340ddfa09a2c9 Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 9 Feb 2026 14:28:46 +0100 Subject: feat: GPU procedural Phase 4 - texture composition Multi-input composite shaders with sampler support. - Dynamic bind group layouts (N input textures + 1 sampler) - dispatch_composite() for multi-input compute dispatch - create_gpu_composite_texture() API - gen_blend.wgsl and gen_mask.wgsl shaders Guarded with #if !defined(STRIP_GPU_COMPOSITE) for easy removal. Tests: - Blend two noise textures - Mask noise with grid - Multi-stage composite (composite of composites) Size: ~830 bytes (2 shaders + dispatch logic) handoff(Claude): GPU procedural Phase 4 complete --- src/gpu/texture_manager.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/gpu/texture_manager.h') diff --git a/src/gpu/texture_manager.h b/src/gpu/texture_manager.h index 63c2947..86d1f63 100644 --- a/src/gpu/texture_manager.h +++ b/src/gpu/texture_manager.h @@ -51,6 +51,17 @@ class TextureManager { void create_gpu_grid_texture(const std::string& name, const GpuProceduralParams& params); +#if !defined(STRIP_GPU_COMPOSITE) + // GPU composite generation (multi-input textures) + void create_gpu_composite_texture(const std::string& name, + const std::string& shader_func, + const char* shader_code, + const void* uniform_data, + size_t uniform_size, + int width, int height, + const std::vector& input_names); +#endif + #if !defined(STRIP_ALL) // On-demand lazy generation (stripped in final builds) WGPUTextureView get_or_generate_gpu_texture(const std::string& name, @@ -65,17 +76,29 @@ class TextureManager { WGPUComputePipeline pipeline; const char* shader_code; size_t uniform_size; + int num_input_textures; }; WGPUComputePipeline get_or_create_compute_pipeline(const std::string& func_name, const char* shader_code, - size_t uniform_size); + size_t uniform_size, + int num_input_textures = 0); void dispatch_compute(const std::string& func_name, WGPUTexture target, const GpuProceduralParams& params, const void* uniform_data, size_t uniform_size); +#if !defined(STRIP_GPU_COMPOSITE) + void dispatch_composite(const std::string& func_name, WGPUTexture target, + const GpuProceduralParams& params, + const void* uniform_data, size_t uniform_size, + const std::vector& input_views); +#endif + WGPUDevice device_; WGPUQueue queue_; std::map textures_; std::map compute_pipelines_; +#if !defined(STRIP_GPU_COMPOSITE) + WGPUSampler linear_sampler_; +#endif }; -- cgit v1.2.3