|
@@ -2193,7 +2193,7 @@ extract_texture_data(Texture *tex) {
|
|
|
page_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
|
page_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- GLint width = 0, height = 0, depth = 0;
|
|
|
|
|
|
|
+ GLint width = 1, height = 1, depth = 1;
|
|
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_WIDTH, &width);
|
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_WIDTH, &width);
|
|
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_HEIGHT, &height);
|
|
GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_HEIGHT, &height);
|
|
|
if (_supports_3d_texture) {
|
|
if (_supports_3d_texture) {
|
|
@@ -6430,6 +6430,10 @@ upload_texture(CLP(TextureContext) *gtc) {
|
|
|
gtc->_height = height;
|
|
gtc->_height = height;
|
|
|
gtc->_depth = depth;
|
|
gtc->_depth = depth;
|
|
|
|
|
|
|
|
|
|
+#ifdef DO_PSTATS
|
|
|
|
|
+ gtc->_texture_memory_size = get_texture_memory_size(tex);
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
#ifndef NDEBUG
|
|
#ifndef NDEBUG
|
|
|
if (uses_mipmaps && CLP(save_mipmaps)) {
|
|
if (uses_mipmaps && CLP(save_mipmaps)) {
|
|
|
save_mipmap_images(tex);
|
|
save_mipmap_images(tex);
|
|
@@ -6630,6 +6634,81 @@ upload_texture_image(CLP(TextureContext) *gtc,
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: GLGraphicsStateGuardian::get_texture_memory_size
|
|
|
|
|
+// Access: Protected
|
|
|
|
|
+// Description: Asks OpenGL how much texture memory is consumed by
|
|
|
|
|
+// the indicated texture (which is also the
|
|
|
|
|
+// currently-selected texture).
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+size_t CLP(GraphicsStateGuardian)::
|
|
|
|
|
+get_texture_memory_size(Texture *tex) const {
|
|
|
|
|
+ GLenum target = get_texture_target(tex->get_texture_type());
|
|
|
|
|
+
|
|
|
|
|
+ GLenum page_target = target;
|
|
|
|
|
+ GLint scale = 1;
|
|
|
|
|
+ if (target == GL_TEXTURE_CUBE_MAP) {
|
|
|
|
|
+ // We need a particular page to get the level parameter from.
|
|
|
|
|
+ page_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
|
|
|
|
+ scale = 6;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ GLint internal_format;
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internal_format);
|
|
|
|
|
+
|
|
|
|
|
+ if (is_compressed_format(internal_format)) {
|
|
|
|
|
+ // Try to get the compressed size.
|
|
|
|
|
+ GLint image_size;
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &image_size);
|
|
|
|
|
+
|
|
|
|
|
+ GLenum error_code = GLP(GetError)();
|
|
|
|
|
+ if (error_code != GL_NO_ERROR) {
|
|
|
|
|
+ const GLubyte *error_string = GLUP(ErrorString)(error_code);
|
|
|
|
|
+ GLCAT.debug()
|
|
|
|
|
+ << "Couldn't get compressed size for " << tex->get_name();
|
|
|
|
|
+ if (error_string != (const GLubyte *)NULL) {
|
|
|
|
|
+ GLCAT.error(false)
|
|
|
|
|
+ << " : " << error_string;
|
|
|
|
|
+ }
|
|
|
|
|
+ GLCAT.debug(false)
|
|
|
|
|
+ << "\n";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return image_size * scale;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // OK, get the noncompressed size.
|
|
|
|
|
+ GLint red_size, green_size, blue_size, alpha_size, luminance_size,
|
|
|
|
|
+ depth_size, intensity_size;
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_RED_SIZE, &red_size);
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_GREEN_SIZE, &green_size);
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_BLUE_SIZE, &blue_size);
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_ALPHA_SIZE, &alpha_size);
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_LUMINANCE_SIZE, &luminance_size);
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_DEPTH_SIZE, &depth_size);
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0,
|
|
|
|
|
+ GL_TEXTURE_INTENSITY_SIZE, &intensity_size);
|
|
|
|
|
+
|
|
|
|
|
+ GLint width = 1, height = 1, depth = 1;
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_WIDTH, &width);
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_HEIGHT, &height);
|
|
|
|
|
+ if (_supports_3d_texture) {
|
|
|
|
|
+ GLP(GetTexLevelParameteriv)(page_target, 0, GL_TEXTURE_DEPTH, &depth);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+
|
|
|
|
|
+ return num_bytes * width * height * depth * scale;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: GLGraphicsStateGuardian::do_point_size
|
|
// Function: GLGraphicsStateGuardian::do_point_size
|
|
|
// Access: Protected
|
|
// Access: Protected
|