From 8398b3de477c45098ade454fe1eeff79a755a1fb Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 9 Feb 2026 14:08:52 +0100 Subject: refactor: Unify TextureManager compute pipeline management Replace individual pipeline pointers with map-based system. - Changed from 3 pointers to std::map - Unified get_or_create_compute_pipeline() for lazy init - Unified dispatch_compute() for all shaders - Simplified create_gpu_*_texture() methods (~390 lines removed) handoff(Claude): GPU procedural texture refactoring complete --- src/gpu/texture_manager.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/gpu/texture_manager.h') diff --git a/src/gpu/texture_manager.h b/src/gpu/texture_manager.h index b2dea84..63c2947 100644 --- a/src/gpu/texture_manager.h +++ b/src/gpu/texture_manager.h @@ -61,16 +61,21 @@ class TextureManager { WGPUTextureView get_texture_view(const std::string& name); 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); + struct ComputePipelineInfo { + WGPUComputePipeline pipeline; + const char* shader_code; + size_t uniform_size; + }; + + WGPUComputePipeline get_or_create_compute_pipeline(const std::string& func_name, + const char* shader_code, + size_t uniform_size); + void dispatch_compute(const std::string& func_name, WGPUTexture target, + const GpuProceduralParams& params, const void* uniform_data, + size_t uniform_size); + WGPUDevice device_; WGPUQueue queue_; std::map textures_; - WGPUComputePipeline noise_compute_pipeline_ = nullptr; - WGPUComputePipeline perlin_compute_pipeline_ = nullptr; - WGPUComputePipeline grid_compute_pipeline_ = nullptr; + std::map compute_pipelines_; }; -- cgit v1.2.3