- Timestamp:
- 08/20/11 19:56:12 (13 years ago)
- File:
-
- 1 edited
-
ps/trunk/source/lib/res/graphics/ogl_tex.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/lib/res/graphics/ogl_tex.cpp
r9962 r10043 78 78 79 79 80 static bool filter_uses_mipmaps(GLint filter) 81 { 80 static bool are_mipmaps_needed(size_t width, size_t height, GLint filter) 81 { 82 // can't upload the entire texture; we're going to skip some 83 // levels until it no longer exceeds the OpenGL dimension limit. 84 if((GLint)width > ogl_max_tex_size || (GLint)height > ogl_max_tex_size) 85 return true; 86 82 87 switch(filter) 83 88 { … … 467 472 if(w == 0 || h == 0) 468 473 WARN_RETURN(ERR::_11); 469 // .. greater than max supported tex dimension.470 // no-op if ogl_Init not yet called471 if(w > (size_t)ogl_max_tex_size || h > (size_t)ogl_max_tex_size)472 WARN_RETURN(ERR::_12);473 474 // .. not power-of-2. 474 475 // note: we can't work around this because both NV_texture_rectangle … … 477 478 if(!is_pow2(w) || !is_pow2(h)) 478 479 WARN_RETURN(ERR::_13); 480 481 // no longer verify dimensions are less than ogl_max_tex_size, 482 // because we just use the higher mip levels in that case. 479 483 } 480 484 … … 755 759 // decisions: 756 760 // .. does filter call for uploading mipmaps? 757 const bool need_mipmaps = filter_uses_mipmaps(filter);761 const bool need_mipmaps = are_mipmaps_needed(t->w, t->h, filter); 758 762 // .. does the image data include mipmaps? (stored as separate 759 763 // images after the regular texels) … … 799 803 if(*plevels_to_skip == 0) 800 804 { 805 // if OpenGL's texture dimension limit is too small, use the 806 // higher mipmap levels. NB: the minimum guaranteed size is 807 // far too low, and menu background textures may be large. 808 GLint w = (GLint)t->w, h = (GLint)t->h; 809 while(w > ogl_max_tex_size || h > ogl_max_tex_size) 810 { 811 (*plevels_to_skip)++; 812 w /= 2; h /= 2; // doesn't matter if either dimension drops to 0 813 } 814 801 815 // this saves texture memory by skipping some of the lower 802 816 // (high-resolution) mip levels. … … 805 819 // require uploading unused levels, which is wasteful. 806 820 // .. can be expanded to reduce to 1/4, 1/8 by encoding factor in q_flags. 807 const size_t reduce = (q_flags & OGL_TEX_HALF_RES)? 2 : 1;808 *plevels_to_skip = (int)ceil_log2(reduce);821 if(q_flags & OGL_TEX_HALF_RES) 822 (*plevels_to_skip)++; 809 823 } 810 824
Note:
See TracChangeset
for help on using the changeset viewer.
