diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 50a2e41dc..24292e0fc 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -934,6 +934,7 @@ void IrrDriver::applyResolutionSettings() // initDevice will drop the current device. delete m_renderer; SharedGPUObjects::reset(); + SP::setMaxTextureSize(); initDevice(); #ifndef SERVER_ONLY diff --git a/src/graphics/sp/sp_base.cpp b/src/graphics/sp/sp_base.cpp index bcc681f6e..01fb646eb 100644 --- a/src/graphics/sp/sp_base.cpp +++ b/src/graphics/sp/sp_base.cpp @@ -97,6 +97,8 @@ std::array g_samplers; // Check sp_shader.cpp for the name std::array sp_prefilled_tex; // ---------------------------------------------------------------------------- +std::atomic sp_max_texture_size(2048); +// ---------------------------------------------------------------------------- std::vector g_bounding_boxes; // ---------------------------------------------------------------------------- std::vector > g_dy_dc; @@ -1435,6 +1437,15 @@ void uploadSPM(irr::scene::IMesh* mesh) } } // uploadSPM +// ---------------------------------------------------------------------------- +void setMaxTextureSize() +{ + const unsigned max = + (UserConfigParams::m_high_definition_textures & 0x01) == 0 ? + UserConfigParams::m_max_texture_size : 2048; + sp_max_texture_size.store(max); +} // setMaxTextureSize + } #endif diff --git a/src/graphics/sp/sp_base.hpp b/src/graphics/sp/sp_base.hpp index 85c9c7d7e..26f954112 100644 --- a/src/graphics/sp/sp_base.hpp +++ b/src/graphics/sp/sp_base.hpp @@ -26,6 +26,7 @@ #include "vector3d.h" #include +#include #include #include #include @@ -88,6 +89,7 @@ class SPMeshBuffer; extern GLuint sp_mat_ubo[MAX_PLAYER_COUNT][3]; extern GLuint sp_fog_ubo; extern std::array sp_prefilled_tex; +extern std::atomic sp_max_texture_size; extern unsigned sp_solid_poly_count; extern unsigned sp_shadow_poly_count; extern int sp_cur_shadow_cascade; @@ -139,6 +141,14 @@ SPMesh* convertEVTStandard(irr::scene::IMesh* mesh, // ---------------------------------------------------------------------------- void uploadSPM(irr::scene::IMesh* mesh); // ---------------------------------------------------------------------------- +#ifdef SERVER_ONLY +inline void setMaxTextureSize() {} +#else +void setMaxTextureSize(); +#endif +// ---------------------------------------------------------------------------- +inline void unsetMaxTextureSize() { sp_max_texture_size.store(2048); } +// ---------------------------------------------------------------------------- inline uint8_t srgbToLinear(float color_srgb) { int ret; diff --git a/src/graphics/sp/sp_texture.cpp b/src/graphics/sp/sp_texture.cpp index 2dd39becb..f6ec22bc3 100644 --- a/src/graphics/sp/sp_texture.cpp +++ b/src/graphics/sp/sp_texture.cpp @@ -167,8 +167,8 @@ std::shared_ptr SPTexture::getTextureImage() const core::dimension2du img_size = image->getDimension(); core::dimension2du tex_size = img_size.getOptimalSize (true/*requirePowerOfTwo*/, false/*requireSquare*/, false/*larger*/); - const core::dimension2du& max_size = irr_driver->getVideoDriver() - ->getDriverAttributes().getAttributeAsDimension2d("MAX_TEXTURE_SIZE"); + unsigned max = sp_max_texture_size.load(); + core::dimension2du max_size = core::dimension2du(max, max); if (tex_size.Width > max_size.Width) { diff --git a/src/main.cpp b/src/main.cpp index a73aa073e..6d8345138 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1654,14 +1654,14 @@ void initUserConfig() //============================================================================= void initRest() { - + SP::setMaxTextureSize(); irr_driver = new IrrDriver(); - + if (irr_driver->getDevice() == NULL) { Log::fatal("main", "Couldn't initialise irrlicht device. Quitting.\n"); } - + StkTime::init(); // grabs the timer object from the irrlicht device // Now create the actual non-null device in the irrlicht driver