From 8e6ab562dd62383d191806e88548e89b4d0a9d65 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 25 May 2014 17:50:46 +0300 Subject: Add support for simple texture size detection. This test check from 1024 to max texture size reported by driver. --- src/test/testlauncher.cpp | 37 ++++++++++++++++++++++++++++++++++++- src/test/testlauncher.h | 2 ++ src/test/testmain.cpp | 32 ++++++++++++++++++++++++++++---- src/test/testmain.h | 12 +++++++++--- 4 files changed, 75 insertions(+), 8 deletions(-) (limited to 'src/test') diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 26ad10174..f2167af24 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -35,8 +35,8 @@ #include "resources/dye.h" #include "resources/image.h" -#include "resources/imagehelper.h" #include "resources/imagewriter.h" +#include "resources/openglimagehelper.h" #include "resources/surfaceimagehelper.h" #include "resources/wallpaper.h" @@ -74,6 +74,8 @@ int TestLauncher::exec() return testFps(); else if (mTest == "11") return testBatches(); + else if (mTest == "14" || mTest == "15") + return testTextures(); else if (mTest == "99") return testVideoDetection(); else if (mTest == "100") @@ -183,6 +185,39 @@ int TestLauncher::testBatches() return 0; } +int TestLauncher::testTextures() +{ + int maxSize = 1024; + int nextSize = 1024; + int sz = OpenGLImageHelper::getTextureSize() + 1; + if (sz < 16500) + sz = 16500; + + for (nextSize = 512; nextSize < sz; nextSize *= 2) + { + SDL_Surface *const surface = imageHelper->create32BitSurface( + nextSize, nextSize); + if (!surface) + break; + graphicsManager.getLastError(); + graphicsManager.resetCachedError(); + Image *const image = imageHelper->load(surface); + if (!image) + break; + if (graphicsManager.getLastErrorCached() != GL_NO_ERROR) + break; + + delete image; + SDL_FreeSurface(surface); + + maxSize = nextSize; + } + + file << mTest << std::endl; + file << maxSize << std::endl; + return 0; +} + int TestLauncher::testInternal() { timeval start; diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h index 296cc5b29..a7ebadf4a 100644 --- a/src/test/testlauncher.h +++ b/src/test/testlauncher.h @@ -64,6 +64,8 @@ class TestLauncher final int testBatches(); + int testTextures(); + private: std::string mTest; diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp index d21cd2dac..c42efc23e 100644 --- a/src/test/testmain.cpp +++ b/src/test/testmain.cpp @@ -79,6 +79,8 @@ int TestMain::exec(const bool testAudio) int softFps = 0; int fastOpenGLFps = 0; int safeOpenGLFps = 0; + int textureSize1 = 1024; + int textureSize2 = 1024; RenderType openGLMode = RENDER_SOFTWARE; int detectMode = 0; @@ -199,6 +201,14 @@ int TestMain::exec(const bool testAudio) batchSize = readValue2(11); if (batchSize < 256) batchSize = 256; + + if (!invokeFastOpenBatchTest("14")) + textureSize1 = readValue2(14); + if (!invokeFastOpenBatchTest("15")) + textureSize2 = readValue2(15); + textureSize1 = std::min(textureSize1, textureSize2); + if (textureSize1 < 1024) + textureSize1 = 1024; } // if OpenGL implimentation is not good, disable it. @@ -206,13 +216,17 @@ int TestMain::exec(const bool testAudio) openGLMode = RENDER_SOFTWARE; writeConfig(openGLMode, rescaleTest[static_cast(openGLMode)], - soundTest, info, batchSize, detectMode); + soundTest, info, batchSize, textureSize1, detectMode); return 0; } -void TestMain::writeConfig(const RenderType openGLMode, const int rescale, - const int sound, const std::string &info, - const int batchSize A_UNUSED, const int detectMode) +void TestMain::writeConfig(const RenderType openGLMode, + const int rescale, + const int sound, + const std::string &info, + const int batchSize A_UNUSED, + const int textureSize, + const int detectMode) { mConfig.init(client->getConfigDirectory() + "/config.xml"); @@ -229,6 +243,7 @@ void TestMain::writeConfig(const RenderType openGLMode, const int rescale, mConfig.setValue("altfpslimit", 2); mConfig.setValue("safemode", false); mConfig.setValue("enableMapReduce", true); + mConfig.setValue("textureSize", textureSize); // max batch size // mConfig.setValue("batchsize", batchSize); @@ -320,6 +335,15 @@ int TestMain::invokeFastOpenBatchTest(const std::string &test) return ret; } +int TestMain::invokeMobileOpenBatchTest(const std::string &test) +{ + mConfig.setValue("opengl", static_cast(RENDER_GLES_OPENGL)); + mConfig.write(); + const int ret = execFileWait(fileName, fileName, "-t", test, 30); +// log->log("%s: %d", test.c_str(), ret); + return ret; +} + int TestMain::invokeSafeOpenGLRenderTest(const std::string &test) { mConfig.setValue("opengl", static_cast(RENDER_SAFE_OPENGL)); diff --git a/src/test/testmain.h b/src/test/testmain.h index 72411417e..d4bae14ce 100644 --- a/src/test/testmain.h +++ b/src/test/testmain.h @@ -64,13 +64,19 @@ class TestMain final int invokeFastOpenBatchTest(const std::string &test); + int invokeMobileOpenBatchTest(const std::string &test); + int invokeSafeOpenGLRenderTest(const std::string &test); void testsMain(); - void writeConfig(const RenderType openGLMode, const int rescale, - const int sound, const std::string &info, - const int batchSize, const int detectMode); + void writeConfig(const RenderType openGLMode, + const int rescale, + const int sound, + const std::string &info, + const int batchSize, + const int textureSize, + const int detectMode); int readValue2(const int ver); -- cgit v1.2.3-70-g09d2