diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-03-15 20:16:11 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-03-15 20:16:11 +0400 |
commit | bcec00dddcaedab7afbede3c4974b6c0cd1745c5 (patch) | |
tree | 5410c9a9239c86f75789fcf46e479f35cd4c1d6f /source | |
parent | 630798ba3c47ee8d1cead13ee0494b9645f139f7 (diff) |
Fix #34649: texture size limit user preference not working.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 36 |
1 files changed, 14 insertions, 22 deletions
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; } |