summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2010-11-25 08:19:44 +0100
committerGunnar Sletta <gunnar.sletta@nokia.com>2010-11-25 08:19:44 +0100
commitc9d0b05de7688906009587f1a14a21f9026c6ca8 (patch)
tree46b1168290b1ec5142c61f8e57a16fc34c44b89d
parent02b9fe805dacbc9f4793d418bc225a2ede9184b4 (diff)
Fix debug output of texture upload timing a bit
-rw-r--r--src/scenegraph/3d/qgltextureutils.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/scenegraph/3d/qgltextureutils.cpp b/src/scenegraph/3d/qgltextureutils.cpp
index 1a68f82..a098bb7 100644
--- a/src/scenegraph/3d/qgltextureutils.cpp
+++ b/src/scenegraph/3d/qgltextureutils.cpp
@@ -264,6 +264,12 @@ void QGLBoundTexture::uploadFace
{
GLenum internalFormat(format);
+#ifdef QGL_BIND_TEXTURE_DEBUG
+ QTime time;
+ time.start();
+#endif
+
+
// Resolve the texture-related extensions for the current context.
QGLTextureExtensions *extensions = QGLTextureExtensions::extensions();
if (!extensions)
@@ -277,10 +283,10 @@ void QGLBoundTexture::uploadFace
}
QImage img(image);
if (size != image.size()) {
+ img = img.scaled(size);
#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - scaling up to %dx%d (%d ms) \n", size.width(), size.height(), time.elapsed());
+ printf(" - scaled up to %dx%d (%d ms) \n", size.width(), size.height(), time.elapsed());
#endif
- img = img.scaled(size);
}
m_size = size;
@@ -304,7 +310,7 @@ void QGLBoundTexture::uploadFace
if (premul) {
img = img.convertToFormat(target_format = QImage::Format_ARGB32_Premultiplied);
#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting ARGB32 -> ARGB32_Premultiplied (%d ms) \n", time.elapsed());
+ printf(" - converted ARGB32 -> ARGB32_Premultiplied (%d ms) \n", time.elapsed());
#endif
}
break;
@@ -312,7 +318,7 @@ void QGLBoundTexture::uploadFace
if (!premul) {
img = img.convertToFormat(target_format = QImage::Format_ARGB32);
#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting ARGB32_Premultiplied -> ARGB32 (%d ms)\n", time.elapsed());
+ printf(" - converted ARGB32_Premultiplied -> ARGB32 (%d ms)\n", time.elapsed());
#endif
}
break;
@@ -329,20 +335,17 @@ void QGLBoundTexture::uploadFace
? QImage::Format_ARGB32_Premultiplied
: QImage::Format_ARGB32);
#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting to 32-bit alpha format (%d ms)\n", time.elapsed());
+ printf(" - converted to 32-bit alpha format (%d ms)\n", time.elapsed());
#endif
} else {
img = img.convertToFormat(QImage::Format_RGB32);
#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - converting to 32-bit (%d ms)\n", time.elapsed());
+ printf(" - converted to 32-bit (%d ms)\n", time.elapsed());
#endif
}
}
if (m_options & QGLContext::InvertedYBindOption) {
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - flipping bits over y (%d ms)\n", time.elapsed());
-#endif
if (img.isDetached()) {
int ipl = img.bytesPerLine() / 4;
int h = img.height();
@@ -359,6 +362,9 @@ void QGLBoundTexture::uploadFace
// data twice. This version should only do it once.
img = img.mirrored();
}
+#ifdef QGL_BIND_TEXTURE_DEBUG
+ printf(" - flipping bits over y (%d ms)\n", time.elapsed());
+#endif
}
if (externalFormat == GL_RGBA) {
@@ -385,6 +391,11 @@ void QGLBoundTexture::uploadFace
glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
pixel_type, constRef.bits());
+#ifdef QGL_BIND_TEXTURE_DEBUG
+ printf(" - total time: %d ms\n", time.elapsed());
+#endif
+
+
m_hasAlpha = (internalFormat != GL_RGB);
}
@@ -404,9 +415,6 @@ void QGLBoundTexture::finishUpload(GLenum target)
// OpenGL/ES 2.0 needs to generate mipmaps after all cubemap faces
// have been uploaded.
if (m_options & QGLContext::MipmapBindOption) {
-#ifdef QGL_BIND_TEXTURE_DEBUG
- printf(" - generating mipmaps (%d ms)\n", time.elapsed());
-#endif
glGenerateMipmap(target);
}
#endif
@@ -417,12 +425,6 @@ void QGLBoundTexture::finishUpload(GLenum target)
qWarning(" - texture upload failed, error code 0x%x, enum: %d (%x)\n", error, target, target);
}
#endif
-
-#ifdef QGL_BIND_TEXTURE_DEBUG
- static int totalUploadTime = 0;
- totalUploadTime += time.elapsed();
- printf(" - upload done in (%d ms) time=%d\n", time.elapsed(), totalUploadTime);
-#endif
}
// DDS format structure