mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fix assertion
This commit is contained in:
parent
c6f0b35ee9
commit
9a9149ed9e
@ -4773,6 +4773,26 @@ get_internal_image_format(Texture *tex) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: GLGraphicsStateGuardian::is_mipmap_filter
|
||||||
|
// Access: Protected, Static
|
||||||
|
// Description: Returns true if the indicated GL minfilter type
|
||||||
|
// represents a mipmap format, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool CLP(GraphicsStateGuardian)::
|
||||||
|
is_mipmap_filter(GLenum min_filter) {
|
||||||
|
switch (min_filter) {
|
||||||
|
case GL_NEAREST_MIPMAP_NEAREST:
|
||||||
|
case GL_LINEAR_MIPMAP_NEAREST:
|
||||||
|
case GL_NEAREST_MIPMAP_LINEAR:
|
||||||
|
case GL_LINEAR_MIPMAP_LINEAR:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: GLGraphicsStateGuardian::is_compressed_format
|
// Function: GLGraphicsStateGuardian::is_compressed_format
|
||||||
// Access: Protected, Static
|
// Access: Protected, Static
|
||||||
@ -6653,6 +6673,9 @@ get_texture_memory_size(Texture *tex) const {
|
|||||||
scale = 6;
|
scale = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLint minfilter;
|
||||||
|
GLP(GetTexParameteriv)(target, GL_TEXTURE_MIN_FILTER, &minfilter);
|
||||||
|
|
||||||
GLint internal_format;
|
GLint internal_format;
|
||||||
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
||||||
|
|
||||||
@ -6706,7 +6729,12 @@ get_texture_memory_size(Texture *tex) const {
|
|||||||
size_t num_bits = (red_size + green_size + blue_size + alpha_size + luminance_size + depth_size + intensity_size);
|
size_t num_bits = (red_size + green_size + blue_size + alpha_size + luminance_size + depth_size + intensity_size);
|
||||||
size_t num_bytes = (num_bits + 7) / 8;
|
size_t num_bytes = (num_bits + 7) / 8;
|
||||||
|
|
||||||
return num_bytes * width * height * depth * scale;
|
size_t result = num_bytes * width * height * depth * scale;
|
||||||
|
if (is_mipmap_filter(minfilter)) {
|
||||||
|
result = (result * 4) / 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -247,6 +247,7 @@ protected:
|
|||||||
static GLenum get_component_type(Texture::ComponentType component_type);
|
static GLenum get_component_type(Texture::ComponentType component_type);
|
||||||
GLint get_external_image_format(Texture *tex) const;
|
GLint get_external_image_format(Texture *tex) const;
|
||||||
GLint get_internal_image_format(Texture *tex) const;
|
GLint get_internal_image_format(Texture *tex) const;
|
||||||
|
static bool is_mipmap_filter(GLenum min_filter);
|
||||||
static bool is_compressed_format(GLenum format);
|
static bool is_compressed_format(GLenum format);
|
||||||
static GLint get_texture_apply_mode_type(TextureStage::Mode am);
|
static GLint get_texture_apply_mode_type(TextureStage::Mode am);
|
||||||
static GLint get_texture_combine_type(TextureStage::CombineMode cm);
|
static GLint get_texture_combine_type(TextureStage::CombineMode cm);
|
||||||
|
@ -31,6 +31,8 @@ TypeHandle CLP(TextureContext)::_type_handle;
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
size_t CLP(TextureContext)::
|
size_t CLP(TextureContext)::
|
||||||
estimate_texture_memory() {
|
estimate_texture_memory() {
|
||||||
nassertr(_texture_memory_size != 0, TextureContext::estimate_texture_memory());
|
if (_texture_memory_size == 0) {
|
||||||
|
return TextureContext::estimate_texture_memory();
|
||||||
|
}
|
||||||
return _texture_memory_size;
|
return _texture_memory_size;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user