Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2016-01-07 19:21:08 +0300
committerMike Erwin <significant.bit@gmail.com>2016-01-08 00:32:35 +0300
commit0df1bdc26832f331be5559b08de3bc06b58e0e68 (patch)
tree86ef08cfdd87e6d20aa363bec9677f5a6073d2f7 /source/blender
parent1aff22b81d7c2264dcd88b20730851658fda9dff (diff)
OpenGL: fix max texture anisotropy check
Query max supported on init, use that to clamp user-set values.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/gpu/GPU_extensions.h1
-rw-r--r--source/blender/gpu/intern/gpu_draw.c5
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c11
3 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index f3be52f324b..fda12a43a5d 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 54389cce451..7208a3ac5b7 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 b0ecf35735a..45bde9d7391 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);