Add function to query maximum texture size. Also, make texture upload

functions aware of this limit.
This commit is contained in:
Antony Riakiotakis 2013-04-12 17:56:07 +00:00
parent a305452275
commit d0beabb642
7 changed files with 26 additions and 8 deletions

@ -31,6 +31,7 @@ set(INC
../makesrna
../python
../imbuf
../gpu
../../../intern/guardedalloc
../../../intern/locale
)

@ -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);

@ -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;

@ -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 */

@ -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);
}

@ -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;

@ -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);