[Bf-blender-cvs] [0df1bdc] master: OpenGL: fix max texture anisotropy check

Mike Erwin noreply at git.blender.org
Thu Jan 7 22:38:55 CET 2016


Commit: 0df1bdc26832f331be5559b08de3bc06b58e0e68
Author: Mike Erwin
Date:   Thu Jan 7 11:21:08 2016 -0500
Branches: master
https://developer.blender.org/rB0df1bdc26832f331be5559b08de3bc06b58e0e68

OpenGL: fix max texture anisotropy check

Query max supported on init, use that to clamp user-set values.

===================================================================

M	source/blender/gpu/GPU_extensions.h
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_extensions.c

===================================================================

diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index f3be52f..fda12a4 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -51,6 +51,7 @@ bool GPU_instanced_drawing_support(void);
 
 int GPU_max_texture_size(void);
 int GPU_max_textures(void);
+float GPU_max_texture_anisotropy(void);
 int GPU_max_color_texture_samples(void);
 int GPU_color_depth(void);
 void GPU_get_dfdy_factors(float fac[2]);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 54389cc..7208a3a 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -365,8 +365,9 @@ void GPU_set_anisotropic(float value)
 		GPU_free_images();
 
 		/* Clamp value to the maximum value the graphics card supports */
-		if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
-			value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT;
+		const float max = GPU_max_texture_anisotropy();
+		if (value > max)
+			value = max;
 
 		GTS.anisotropic = value;
 	}
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index b0ecf35..45bde9d 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -84,6 +84,7 @@ static struct GPUGlobal {
 	float dfdyfactors[2]; /* workaround for different calculation of dfdy factors on GPUs. Some GPUs/drivers
 	                         calculate dfdy in shader differently when drawing to an offscreen buffer. First
 	                         number is factor on screen and second is off-screen */
+	float max_anisotropy;
 } GG = {1, 0};
 
 /* GPU Types */
@@ -110,6 +111,11 @@ int GPU_max_textures(void)
 	return GG.maxtextures;
 }
 
+float GPU_max_texture_anisotropy(void)
+{
+	return GG.max_anisotropy;
+}
+
 int GPU_max_color_texture_samples(void)
 {
 	return GG.samples_color_texture_max;
@@ -129,6 +135,11 @@ void gpu_extensions_init(void)
 
 	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
 
+	if (GLEW_EXT_texture_filter_anisotropic)
+		glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GG.max_anisotropy);
+	else
+		GG.max_anisotropy = 1.0f;
+
 	GLint r, g, b;
 	glGetIntegerv(GL_RED_BITS, &r);
 	glGetIntegerv(GL_GREEN_BITS, &g);




More information about the Bf-blender-cvs mailing list