From bd2ca805eeddd2688a8f1b3ed5ec8ed1677748fc Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 9 Feb 2026 14:31:43 +0100 Subject: refactor: Generic sampler system for composites Replace hardcoded linear_sampler_ with configurable sampler map. - SamplerType enum (LinearClamp, LinearRepeat, NearestClamp, NearestRepeat) - get_or_create_sampler() for lazy sampler creation - Default to LinearClamp for backward compatibility Eliminates hardcoded assumptions, more flexible for future use cases. --- src/gpu/texture_manager.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/gpu/texture_manager.h') diff --git a/src/gpu/texture_manager.h b/src/gpu/texture_manager.h index 86d1f63..5a2b9f8 100644 --- a/src/gpu/texture_manager.h +++ b/src/gpu/texture_manager.h @@ -52,6 +52,13 @@ class TextureManager { const GpuProceduralParams& params); #if !defined(STRIP_GPU_COMPOSITE) + enum class SamplerType { + LinearClamp, + LinearRepeat, + NearestClamp, + NearestRepeat + }; + // GPU composite generation (multi-input textures) void create_gpu_composite_texture(const std::string& name, const std::string& shader_func, @@ -59,7 +66,8 @@ class TextureManager { const void* uniform_data, size_t uniform_size, int width, int height, - const std::vector& input_names); + const std::vector& input_names, + SamplerType sampler = SamplerType::LinearClamp); #endif #if !defined(STRIP_ALL) @@ -91,7 +99,8 @@ class TextureManager { 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); + const std::vector& input_views, + SamplerType sampler_type); #endif WGPUDevice device_; @@ -99,6 +108,7 @@ class TextureManager { std::map textures_; std::map compute_pipelines_; #if !defined(STRIP_GPU_COMPOSITE) - WGPUSampler linear_sampler_; + WGPUSampler get_or_create_sampler(SamplerType type); + std::map samplers_; #endif }; -- cgit v1.2.3