[Bf-blender-cvs] [0449d2f427e] tmp-texture-sampler: GPU: Texture: Avoid using anisotropic filtering on all textures.
Clément Foucault
noreply at git.blender.org
Mon May 25 10:49:45 CEST 2020
Commit: 0449d2f427e16b883f559436b58174fda04bbe6d
Author: Clément Foucault
Date: Sat May 23 12:45:10 2020 +0200
Branches: tmp-texture-sampler
https://developer.blender.org/rB0449d2f427e16b883f559436b58174fda04bbe6d
GPU: Texture: Avoid using anisotropic filtering on all textures.
This limits anisotropic filtering to image textures (comming from
GPU_texture_from_bindcode).
===================================================================
M source/blender/gpu/GPU_texture.h
M source/blender/gpu/intern/gpu_texture.c
===================================================================
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 5c86ec0d990..a1e00793857 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -55,8 +55,9 @@ typedef enum eGPUSamplerState {
GPU_SAMPLER_REPEAT_R = (1 << 4),
GPU_SAMPLER_CLAMP_BORDER = (1 << 5), /* Clamp to border color instead of border texel. */
GPU_SAMPLER_COMPARE = (1 << 6),
+ GPU_SAMPLER_ANISO = (1 << 7),
/* Don't use that. */
- GPU_SAMPLER_MAX = (1 << 7),
+ GPU_SAMPLER_MAX = (1 << 8),
} eGPUSamplerState;
#define GPU_SAMPLER_DEFAULT GPU_SAMPLER_FILTER
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index d58ced3f956..6f3b7baa4d6 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -1181,7 +1181,7 @@ GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode)
tex->target = textarget;
tex->target_base = textarget;
tex->samples = 0;
- tex->sampler_state = GPU_SAMPLER_REPEAT;
+ tex->sampler_state = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO;
if (GPU_get_mipmap()) {
tex->sampler_state |= (GPU_SAMPLER_MIPMAP | GPU_SAMPLER_FILTER);
}
@@ -2024,6 +2024,9 @@ void GPU_samplers_init(void)
((state & GPU_SAMPLER_MIPMAP) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) :
((state & GPU_SAMPLER_MIPMAP) ? GL_NEAREST_MIPMAP_LINEAR : GL_NEAREST);
GLenum compare_mode = (state & GPU_SAMPLER_COMPARE) ? GL_COMPARE_REF_TO_TEXTURE : GL_NONE;
+ float aniso_filter = ((state & GPU_SAMPLER_MIPMAP) && (state & GPU_SAMPLER_ANISO)) ?
+ GPU_get_anisotropic() :
+ 1.0f;
glSamplerParameteri(GG.samplers[i], GL_TEXTURE_WRAP_S, wrap_s);
glSamplerParameteri(GG.samplers[i], GL_TEXTURE_WRAP_T, wrap_t);
@@ -2032,9 +2035,7 @@ void GPU_samplers_init(void)
glSamplerParameteri(GG.samplers[i], GL_TEXTURE_MAG_FILTER, mag_filter);
glSamplerParameteri(GG.samplers[i], GL_TEXTURE_COMPARE_MODE, compare_mode);
glSamplerParameteri(GG.samplers[i], GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
- if (state & GPU_SAMPLER_MIPMAP) {
- glSamplerParameterf(GG.samplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
- }
+ glSamplerParameterf(GG.samplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso_filter);
/** Other states are left to default:
* - GL_TEXTURE_BORDER_COLOR is {0, 0, 0, 0}.
More information about the Bf-blender-cvs
mailing list