*/
/**
- * Measure glTexSubImage2D rate
+ * Measure glTex[Sub]Image2D() and glGetTexImage() rate
*
* Brian Paul
* 16 Sep 2009
enum {
MODE_CREATE_TEXIMAGE,
MODE_TEXIMAGE,
- MODE_TEXSUBIMAGE
+ MODE_TEXSUBIMAGE,
+ MODE_GETTEXIMAGE,
+ MODE_COUNT
};
-static const char *mode_name[] =
+static const char *mode_name[MODE_COUNT] =
{
"Create_TexImage",
"TexImage",
- "TexSubImage"
+ "TexSubImage",
+ "GetTexImage"
};
TexSrcFormat, TexSrcType, TexImage);
/* reset the unpacking state */
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-
}
else {
/* replace whole texture image at once */
}
+static void
+GetTexImage2D(unsigned count)
+{
+ unsigned i;
+ GLubyte *buf = (GLubyte *) malloc(TexSize * TexSize * 4);
+ for (i = 0; i < count; i++) {
+ glGetTexImage(GL_TEXTURE_2D, 0,
+ TexSrcFormat, TexSrcType, buf);
+ }
+ glFinish();
+ free(buf);
+}
+
+
/* XXX any other formats to measure? */
static const struct {
GLenum format, type;
GLuint texel_size;
GLboolean full_test;
} SrcFormats[] = {
- { GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA, "RGBA/ubyte", 4, GL_TRUE },
- { GL_RGB, GL_UNSIGNED_BYTE, GL_RGB, "RGB/ubyte", 3, GL_FALSE },
- { GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB, "RGB/565", 2, GL_FALSE },
- { GL_BGRA, GL_UNSIGNED_BYTE, GL_RGBA, "BGRA/ubyte", 4, GL_FALSE },
- { GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE, "L/ubyte", 1, GL_FALSE },
+ { GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA, "RGBA/ubyte", 4, GL_TRUE },
+ { GL_RGB, GL_UNSIGNED_BYTE, GL_RGB, "RGB/ubyte", 3, GL_FALSE },
+ { GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB, "RGB/565", 2, GL_FALSE },
+ { GL_BGRA, GL_UNSIGNED_BYTE, GL_RGBA, "BGRA/ubyte", 4, GL_FALSE },
+ { GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE, "L/ubyte", 1, GL_FALSE },
{ 0, 0, 0, NULL, 0, 0 }
};
+
+/** Called from test harness/main */
void
PerfNextRound(void)
{
TexSrcType = SrcFormats[fmt].type;
/* loop over glTexImage, glTexSubImage */
- for (mode = 0; mode < 3; mode++) {
+ for (mode = 0; mode < MODE_COUNT; mode++) {
GLuint minsz, maxsz;
if (SrcFormats[fmt].full_test) {
rate = PerfMeasureRate(UploadTexSubImage2D);
break;
+ case MODE_GETTEXIMAGE:
+ glTexImage2D(GL_TEXTURE_2D, 0, TexIntFormat,
+ TexSize, TexSize, 0,
+ TexSrcFormat, TexSrcType, TexImage);
+ rate = PerfMeasureRate(GetTexImage2D);
+ break;
+
default:
exit(1);
}