From 31c77a14af7cac2bc52ecaffde1bae9775dc47ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 5 Sep 2020 17:31:53 +0200 Subject: GPUTexture: Add support for samplers This just add back the support. This commit also includes a bit of cleanup. # Conflicts: # source/blender/gpu/GPU_texture.h --- source/blender/gpu/intern/gpu_backend.hh | 2 ++ source/blender/gpu/intern/gpu_extensions.cc | 2 -- source/blender/gpu/intern/gpu_texture.cc | 16 ++++------------ 3 files changed, 6 insertions(+), 14 deletions(-) (limited to 'source/blender/gpu/intern') diff --git a/source/blender/gpu/intern/gpu_backend.hh b/source/blender/gpu/intern/gpu_backend.hh index 06aff94dffe..330c7d59b6d 100644 --- a/source/blender/gpu/intern/gpu_backend.hh +++ b/source/blender/gpu/intern/gpu_backend.hh @@ -43,6 +43,8 @@ class GPUBackend { static GPUBackend *get(void); + virtual void samplers_update(void) = 0; + virtual GPUContext *context_alloc(void *ghost_window) = 0; virtual Batch *batch_alloc(void) = 0; diff --git a/source/blender/gpu/intern/gpu_extensions.cc b/source/blender/gpu/intern/gpu_extensions.cc index 6fe08d81cda..b473e719211 100644 --- a/source/blender/gpu/intern/gpu_extensions.cc +++ b/source/blender/gpu/intern/gpu_extensions.cc @@ -386,13 +386,11 @@ void gpu_extensions_init(void) } GPU_invalid_tex_init(); - GPU_samplers_init(); } void gpu_extensions_exit(void) { GPU_invalid_tex_free(); - GPU_samplers_free(); } bool GPU_mem_stats_supported(void) diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 9d431ef4648..d75dc9b728a 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -482,6 +482,7 @@ void GPU_texture_bind_ex(GPUTexture *tex_, const bool UNUSED(set_number)) { Texture *tex = reinterpret_cast(tex_); + state = (state >= GPU_SAMPLER_MAX) ? tex->sampler_state : state; GPU_context_active_get()->state_manager->texture_bind(tex, state, unit); } @@ -717,19 +718,10 @@ void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *r_size) * Override texture sampler state for one sampler unit only. * \{ */ -void GPU_samplers_init(void) +/* Update user defined sampler states. */ +void GPU_samplers_update(void) { - /* TODO(fclem) port samplers to GLTextures. */ -} - -void GPU_sampler_icon_bind(int UNUSED(unit)) -{ - /* TODO(fclem) port samplers to GLTextures. */ -} - -void GPU_samplers_free(void) -{ - /* TODO(fclem) port samplers to GLTextures. */ + GPUBackend::get()->samplers_update(); } /** \} */ -- cgit v1.2.3