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
parenta305452275207a555d2812c3a5ea6647f0f594e4 (diff)
Add function to query maximum texture size. Also, make texture upload
functions aware of this limit.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenfont/CMakeLists.txt1
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c4
-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
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c2
7 files changed, 26 insertions, 8 deletions
diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt
index 7bb80c34323..936dd708cfb 100644
--- a/source/blender/blenfont/CMakeLists.txt
+++ b/source/blender/blenfont/CMakeLists.txt
@@ -31,6 +31,7 @@ set(INC
../makesrna
../python
../imbuf
+ ../gpu
../../../intern/guardedalloc
../../../intern/locale
)
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index a6b04b24399..142acf755fc 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -55,6 +55,7 @@
#include "blf_internal_types.h"
#include "blf_internal.h"
+#include "GPU_extensions.h"
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi)
{
@@ -381,7 +382,7 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
GlyphCacheBLF *gc = font->glyph_cache;
if (font->max_tex_size == -1)
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size);
+ font->max_tex_size = GPU_max_texture_size();
if (gc->cur_tex == -1) {
blf_glyph_cache_texture(font, gc);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 8c1b590cdda..5fc0cc454e2 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -88,6 +88,8 @@
#include "ED_view3d.h"
#include "ED_mesh.h"
+#include "GPU_extensions.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -4411,7 +4413,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", filename);
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
+ maxsize = GPU_max_texture_size();
if (w > maxsize) w = maxsize;
if (h > maxsize) h = maxsize;
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;
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 444f8cc57c8..e437d7c0958 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -463,7 +463,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
for (x = 0; x < triple->nx; x++) {
/* proxy texture is only guaranteed to test for the cases that
* there is only one texture in use, which may not be the case */
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
+ maxsize = GPU_max_texture_size();
if (triple->x[x] > maxsize || triple->y[y] > maxsize) {
glBindTexture(triple->target, 0);