From bcec00dddcaedab7afbede3c4974b6c0cd1745c5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 15 Mar 2013 16:16:11 +0000 Subject: Fix #34649: texture size limit user preference not working. --- source/blender/gpu/intern/gpu_draw.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 87e9556ab21..fc3bf75e784 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -189,30 +189,21 @@ void GPU_render_text(MTFace *tface, int mode, /* Checking powers of two for images since opengl 1.x requires it */ -static int is_pow2_limit(int num) +static bool is_power_of_2_resolution(int w, int h) { - /* take texture clamping into account */ - - /* XXX: texturepaint not global! */ -#if 0 - if (G.f & G_TEXTUREPAINT) - return 1;*/ -#endif + return is_power_of_2_i(w) && is_power_of_2_i(h); +} - if (U.glreslimit != 0 && num > U.glreslimit) - return 0; +static bool is_over_resolution_limit(int w, int h) +{ + if (U.glreslimit != 0) + return (w > U.glreslimit || h > U.glreslimit); - return is_power_of_2_i(num); + return false; } -static int smaller_pow2_limit(int num) +static int smaller_power_of_2_limit(int num) { - /* XXX: texturepaint not global! */ -#if 0 - if (G.f & G_TEXTUREPAINT) - return 1;*/ -#endif - /* take texture clamping into account */ if (U.glreslimit != 0 && num > U.glreslimit) return U.glreslimit; @@ -681,9 +672,10 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int /* scale if not a power of two. this is not strictly necessary for newer * GPUs (OpenGL version >= 2.0) since they support non-power-of-two-textures * Then don't bother scaling for hardware that supports NPOT textures! */ - if (!GPU_non_power_of_two_support() && (!is_pow2_limit(rectw) || !is_pow2_limit(recth))) { - rectw= smaller_pow2_limit(rectw); - recth= smaller_pow2_limit(recth); + if ((!GPU_non_power_of_two_support() && !is_power_of_2_resolution(rectw, recth)) || + is_over_resolution_limit(rectw, recth)) { + rectw= smaller_power_of_2_limit(rectw); + recth= smaller_power_of_2_limit(recth); if (use_high_bit_depth) { fscalerect= MEM_mallocN(rectw*recth*sizeof(*fscalerect)*4, "fscalerect"); @@ -772,7 +764,7 @@ int GPU_upload_dxt_texture(ImBuf *ibuf) return FALSE; } - if (!is_power_of_2_i(width) || !is_power_of_2_i(height)) { + if (!is_power_of_2_resolution(width, height)) { printf("Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n"); return FALSE; } -- cgit v1.2.3