diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-25 17:50:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-25 17:50:46 +0300 |
commit | 8e6ab562dd62383d191806e88548e89b4d0a9d65 (patch) | |
tree | 36fa576cdb6ff9aa950ec04165eab095f794f385 | |
parent | e195e09e86d18c45676431813f98c56d85cc8201 (diff) | |
download | plus-8e6ab562dd62383d191806e88548e89b4d0a9d65.tar.gz plus-8e6ab562dd62383d191806e88548e89b4d0a9d65.tar.bz2 plus-8e6ab562dd62383d191806e88548e89b4d0a9d65.tar.xz plus-8e6ab562dd62383d191806e88548e89b4d0a9d65.zip |
Add support for simple texture size detection.
This test check from 1024 to max texture size reported by driver.
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/graphicsmanager.cpp | 5 | ||||
-rw-r--r-- | src/graphicsmanager.h | 12 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_video.cpp | 5 | ||||
-rw-r--r-- | src/resources/atlasmanager.cpp | 7 | ||||
-rw-r--r-- | src/resources/openglimagehelper.cpp | 4 | ||||
-rw-r--r-- | src/test/testlauncher.cpp | 37 | ||||
-rw-r--r-- | src/test/testlauncher.h | 2 | ||||
-rw-r--r-- | src/test/testmain.cpp | 32 | ||||
-rw-r--r-- | src/test/testmain.h | 12 |
10 files changed, 104 insertions, 13 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index f34220c0b..a6e458905 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -363,6 +363,7 @@ DefaultsData* getConfigDefaults() AddDEF("addwatermark", true); AddDEF("hidesupport", false); AddDEF("showserverpos", false); + AddDEF("textureSize", 1024); return configData; } diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 11db52974..6af2e454c 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -104,6 +104,10 @@ const std::string densityNames[] = "xxhigh" }; +#ifdef USE_OPENGL +GLenum GraphicsManager::mLastError(GL_NO_ERROR); +#endif + GraphicsManager::GraphicsManager() : mExtensions(), mPlatformExtensions(), @@ -928,6 +932,7 @@ GLenum GraphicsManager::getLastError() while (tmp != GL_NO_ERROR) { error = tmp; + mLastError = tmp; tmp = glGetError(); } return error; diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h index 8e5aba51f..ff70e7634 100644 --- a/src/graphicsmanager.h +++ b/src/graphicsmanager.h @@ -148,7 +148,7 @@ class GraphicsManager final bool isUseTextureSampler() const A_WARN_UNUSED { return mUseTextureSampler; } - static GLenum getLastError() A_WARN_UNUSED; + static GLenum getLastError(); static std::string errorToString(const GLenum error) A_WARN_UNUSED; @@ -156,6 +156,12 @@ class GraphicsManager final std::string getGLVersion() const { return mGlVersionString; } + + GLenum getLastErrorCached() const + { return mLastError; } + + void resetCachedError() + { mLastError = GL_NO_ERROR; } #endif private: @@ -169,6 +175,10 @@ class GraphicsManager final std::string mGlRenderer; +#ifdef USE_OPENGL + static GLenum mLastError; +#endif + int mMinor; int mMajor; diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index c72b4a3ed..f33f410aa 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -446,12 +446,15 @@ void Setup_Video::action(const ActionEvent &event) TestMain *test = graphicsManager.startDetection(); if (test) { - const int val = test->getConfig().getValueInt("opengl", -1); + Configuration &conf = test->getConfig(); + const int val = conf.getValueInt("opengl", -1); if (val >= 0 && static_cast<unsigned int>(val) < sizeof(renderToIndex) / sizeof(int)) { mOpenGLDropDown->setSelected(renderToIndex[val]); } + config.setValue("textureSize", + conf.getValueInt("textureSize", 1024)); delete test; } } diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index 49607786e..c60d6465d 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -24,6 +24,8 @@ #include "resources/atlasmanager.h" +#include "configuration.h" + #include "render/surfacegraphics.h" #include "utils/mathutils.h" @@ -53,7 +55,10 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, AtlasResource *resource = new AtlasResource; loadImages(files, images); - const int maxSize = OpenGLImageHelper::getTextureSize(); + int maxSize = OpenGLImageHelper::getTextureSize(); + const int sz = config.getIntValue("textureSize"); + if (maxSize > sz) + maxSize = sz; // sorting images on atlases. simpleSort(name, atlases, images, maxSize); diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index 7c4e08501..7421dc852 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -133,7 +133,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, return nullptr; // Flush current error flag. - glGetError(); + graphicsManager.getLastError(); if (!width) width = tmpImage->w; @@ -273,7 +273,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, if (oldImage) MSDL_FreeSurface(tmpImage); - GLenum error = glGetError(); + GLenum error = graphicsManager.getLastError(); if (error) { std::string errmsg = GraphicsManager::errorToString(error); 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<size_t>(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<int>(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<int>(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); |