summaryrefslogtreecommitdiff
path: root/src/gpu/texture_manager.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-09 14:31:43 +0100
committerskal <pascal.massimino@gmail.com>2026-02-09 14:31:43 +0100
commitbd2ca805eeddd2688a8f1b3ed5ec8ed1677748fc (patch)
treee2b5311631354e9328ed5ce91a4261cbce7c0b93 /src/gpu/texture_manager.h
parent9bb5fd64776ac8a7e4b012ac2de340ddfa09a2c9 (diff)
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.
Diffstat (limited to 'src/gpu/texture_manager.h')
-rw-r--r--src/gpu/texture_manager.h16
1 files changed, 13 insertions, 3 deletions
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<std::string>& input_names);
+ const std::vector<std::string>& 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<WGPUTextureView>& input_views);
+ const std::vector<WGPUTextureView>& input_views,
+ SamplerType sampler_type);
#endif
WGPUDevice device_;
@@ -99,6 +108,7 @@ class TextureManager {
std::map<std::string, GpuTexture> textures_;
std::map<std::string, ComputePipelineInfo> compute_pipelines_;
#if !defined(STRIP_GPU_COMPOSITE)
- WGPUSampler linear_sampler_;
+ WGPUSampler get_or_create_sampler(SamplerType type);
+ std::map<SamplerType, WGPUSampler> samplers_;
#endif
};