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:
authorAntony Riakiotakis <kalast@gmail.com>2013-04-12 21:56:07 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-04-12 21:56:07 +0400
commitd0beabb642ea8acb8e3d69aa3fc503ad703e7dfd (patch)
tree35684f2a142bd21b4e1c380ad61a8d8ff9df25c9 /source/blender/gpu
parenta305452275207a555d2812c3a5ea6647f0f594e4 (diff)
Add function to query maximum texture size. Also, make texture upload
functions aware of this limit.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_extensions.h2
-rw-r--r--source/blender/gpu/intern/gpu_draw.c14
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c8
3 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 0ae45775473..6037f0fa1ed 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -66,6 +66,8 @@ int GPU_non_power_of_two_support(void);
int GPU_color_depth(void);
void GPU_code_generate_glsl_lib(void);
int GPU_bicubic_bump_support(void);
+int GPU_max_texture_size (void);
+
/* GPU Types */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index e95bcab5f03..62b371cf495 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -196,17 +196,21 @@ static bool is_power_of_2_resolution(int w, int h)
static bool is_over_resolution_limit(int w, int h)
{
- if (U.glreslimit != 0)
- return (w > U.glreslimit || h > U.glreslimit);
+ int reslimit = (U.glreslimit != 0)?
+ min_ii(U.glreslimit, GPU_max_texture_size()) :
+ GPU_max_texture_size();
- return false;
+ return (w > reslimit || h > reslimit);
}
static int smaller_power_of_2_limit(int num)
{
+ int reslimit = (U.glreslimit != 0)?
+ min_ii(U.glreslimit, GPU_max_texture_size()) :
+ GPU_max_texture_size();
/* take texture clamping into account */
- if (U.glreslimit != 0 && num > U.glreslimit)
- return U.glreslimit;
+ if (num > reslimit)
+ return reslimit;
return power_of_2_min_i(num);
}
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 7ac852f551a..dfd4b5f2b83 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -79,6 +79,7 @@ typedef struct GPUShaders {
} GPUShaders;
static struct GPUGlobal {
+ GLint maxtexsize;
GLint maxtextures;
GLuint currentfb;
int glslsupport;
@@ -107,6 +108,11 @@ void GPU_extensions_disable(void)
GG.extdisabled = 1;
}
+int GPU_max_texture_size ()
+{
+ return GG.maxtexsize;
+}
+
void GPU_extensions_init(void)
{
GLint r, g, b;
@@ -124,6 +130,8 @@ void GPU_extensions_init(void)
if (GLEW_ARB_multitexture)
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &GG.maxtextures);
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
+
GG.glslsupport = 1;
if (!GLEW_ARB_multitexture) GG.glslsupport = 0;
if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0;