From 2840782d8478f1c37c2aa91cc7f12c8e1f4dca0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 16 Jul 2020 20:56:17 +0200 Subject: Cleanup: GPU: Make icon drawing use GPUTexture This remove all gl function calls. Adds a new sampler only for icon drawing. --- source/blender/gpu/GPU_texture.h | 2 ++ source/blender/gpu/intern/gpu_texture.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index a13f61177e6..f9e129b2f7a 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -298,6 +298,8 @@ int GPU_texture_opengl_bindcode(const GPUTexture *tex); void GPU_texture_get_mipmap_size(GPUTexture *tex, int lvl, int *size); +void GPU_sampler_icon_bind(int number); + #ifdef __cplusplus } #endif diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 56e82b94fd2..251a4d71597 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -52,6 +52,7 @@ static struct GPUTextureGlobal { GPUTexture *invalid_tex_3D; /** Sampler objects used to replace internal texture parameters. */ GLuint samplers[GPU_SAMPLER_MAX]; + GLuint icon_sampler; } GG = {NULL}; /* Maximum number of FBOs a texture can be attached to. */ @@ -2176,11 +2177,23 @@ void GPU_samplers_init(void) * - GL_TEXTURE_LOD_BIAS is 0.0f. **/ } + + /* Custom sampler for icons. */ + glGenSamplers(1, &GG.icon_sampler); + glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glSamplerParameteri(GG.icon_sampler, GL_TEXTURE_LOD_BIAS, -0.5f); +} + +void GPU_sampler_icon_bind(int unit) +{ + glBindSampler(unit, GG.icon_sampler); } void GPU_samplers_free(void) { glDeleteSamplers(GPU_SAMPLER_MAX, GG.samplers); + glDeleteSamplers(1, &GG.icon_sampler); } /** \} */ -- cgit v1.2.3