diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2010-06-30 10:43:52 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2010-06-30 10:51:11 (GMT) |
commit | 0ee2330ec237cf5baeabe4833fb8b6cad503fb7c (patch) | |
tree | 9226fd3e3d1d7fd328a0c555b1e8d5514b0650a0 /tests/benchmarks/opengl | |
parent | cde3f39cb75ba69185cca8176ea7126f8441f042 (diff) | |
download | Qt-0ee2330ec237cf5baeabe4833fb8b6cad503fb7c.zip Qt-0ee2330ec237cf5baeabe4833fb8b6cad503fb7c.tar.gz Qt-0ee2330ec237cf5baeabe4833fb8b6cad503fb7c.tar.bz2 |
Added textureUpload benchmark to the GL benchmarks
Diffstat (limited to 'tests/benchmarks/opengl')
-rw-r--r-- | tests/benchmarks/opengl/main.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/benchmarks/opengl/main.cpp b/tests/benchmarks/opengl/main.cpp index beb4d43..c042fce 100644 --- a/tests/benchmarks/opengl/main.cpp +++ b/tests/benchmarks/opengl/main.cpp @@ -75,6 +75,10 @@ private slots: void gradients_data(); void gradients(); + void textureUpload_data(); + void textureUpload(); + + private: QGLPixelBuffer *pb; }; @@ -374,6 +378,53 @@ void OpenGLBench::gradients() } } +void OpenGLBench::textureUpload_data() +{ + QTest::addColumn<int>("size"); + QTest::addColumn<int>("flags"); + QTest::addColumn<int>("format"); + + int sizes[] = { 8, 10, 16, 20, 32, 50, 64, 100, 128, 200, 256, 500, 512, 1000, 1024, 2000, 2048, -1 }; + int flags[] = { QGLContext::InternalBindOption, + QGLContext::DefaultBindOption, + -1 }; + int formats[] = { GL_RGB, GL_RGBA, -1 }; + + for (int s = 0; sizes[s] != -1; ++s) { + for (int f = 0; flags[f] != -1; ++f) { + for (int a = 0; formats[a] != -1; ++a) { + QByteArray name; + name.append("size=").append(QByteArray::number(sizes[s])); + name.append(", flags=").append(f == 0 ? "internal" : "default"); + name.append(", format=").append(a == 0 ? "RGB" : "RGBA"); + QTest::newRow(name.constData()) << sizes[s] << flags[f] << formats[a]; + } + } + } +} + +void OpenGLBench::textureUpload() +{ + QFETCH(int, size); + QFETCH(int, flags); + QFETCH(int, format); + + QPixmap pixmap(size, size); + + if (format == GL_RGB) + pixmap.fill(Qt::red); + else + pixmap.fill(Qt::transparent); + + pb->makeCurrent(); + QGLContext *context = const_cast<QGLContext *>(QGLContext::currentContext()); + QTime time; + + time.start(); + context->bindTexture(pixmap, GL_TEXTURE_2D, format, (QGLContext::BindOptions) flags); + QTest::setBenchmarkResult(time.elapsed(), QTest::WalltimeMilliseconds); +} + QTEST_MAIN(OpenGLBench) #include "main.moc" |