Fix texture::estimate_texture_memory

This commit is contained in:
tobspr 2016-01-04 18:26:48 +01:00 committed by rdb
parent a9e18f9d24
commit 817a002ac6

View File

@ -489,7 +489,7 @@ read(const Filename &fullpath, const Filename &alpha_fullpath,
size_t Texture::
estimate_texture_memory() const {
CDReader cdata(_cycler);
size_t pixels = cdata->_x_size * cdata->_y_size;
size_t pixels = cdata->_x_size * cdata->_y_size * cdata->_z_size;
size_t bpp = 4;
switch (cdata->_format) {
@ -503,6 +503,7 @@ estimate_texture_memory() const {
case Texture::F_blue:
case Texture::F_luminance:
case Texture::F_sluminance:
case Texture::F_r8i:
bpp = 1;
break;
@ -519,6 +520,8 @@ estimate_texture_memory() const {
case Texture::F_rgb5:
case Texture::F_rgba5:
case Texture::F_srgb:
// Most of the above formats have only 3 bytes, but they are most likely to
// get padded by the driver
bpp = 4;
break;
@ -536,9 +539,15 @@ estimate_texture_memory() const {
break;
case Texture::F_depth_component:
case Texture::F_depth_component16:
bpp = 2;
break;
case Texture::F_depth_component24: // Gets padded
case Texture::F_depth_component32:
bpp = 4;
break;
case Texture::F_rgba12:
case Texture::F_rgb12:
bpp = 8;
@ -552,7 +561,6 @@ estimate_texture_memory() const {
break;
case Texture::F_r16:
case Texture::F_r8i:
case Texture::F_rg8i:
bpp = 2;
break;
@ -564,17 +572,16 @@ estimate_texture_memory() const {
break;
case Texture::F_r32i:
bpp = 4;
break;
case Texture::F_r32:
bpp = 4;
break;
case Texture::F_rg32:
bpp = 8;
break;
case Texture::F_rgb32:
bpp = 12;
bpp = 16;
break;
case Texture::F_r11_g11_b10:
@ -582,6 +589,8 @@ estimate_texture_memory() const {
break;
default:
gobj_cat.warning() << "Unhandled format in estimate_texture_memory(): "
<< cdata->_format << "\n";
break;
}