#include "drape/support_manager.hpp" #include "drape/gl_functions.hpp" #include "drape/vulkan/vulkan_base_context.hpp" #include "platform/settings.hpp" #include "base/logging.hpp" #include "3party/Alohalytics/src/alohalytics.h" #include "std/target_os.hpp" #include #include #include namespace dp { char const * kSupportedAntialiasing = "Antialiasing"; void SupportManager::Init(ref_ptr context) { std::lock_guard lock(m_mutex); if (m_isInitialized) return; std::string const renderer = context->GetRendererName(); std::string const version = context->GetRendererVersion(); LOG(LINFO, ("Renderer =", renderer, "| Api =", context->GetApiVersion(), "| Version =", version)); alohalytics::Stats::Instance().LogEvent("GPU", renderer); m_isSamsungGoogleNexus = (renderer == "PowerVR SGX 540" && version.find("GOOGLENEXUS.ED945322") != string::npos); if (m_isSamsungGoogleNexus) LOG(LINFO, ("Samsung Google Nexus detected.")); if (renderer.find("Adreno") != std::string::npos) { std::vector const models = { "200", "203", "205", "220", "225" }; for (auto const & model : models) { if (renderer.find(model) != std::string::npos) { LOG(LINFO, ("Adreno 200 device detected.")); m_isAdreno200 = true; break; } } } m_isTegra = (renderer.find("Tegra") != std::string::npos); if (m_isTegra) LOG(LINFO, ("NVidia Tegra device detected.")); auto const apiVersion = context->GetApiVersion(); if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) { m_maxLineWidth = static_cast(std::max(1, GLFunctions::glGetMaxLineWidth())); m_maxTextureSize = static_cast(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize)); } else if (apiVersion == dp::ApiVersion::Metal) { // Metal does not support thick lines. m_maxLineWidth = 1.0f; m_maxTextureSize = 4096; } else if (apiVersion == dp::ApiVersion::Vulkan) { ref_ptr vulkanContext = context; auto const & props = vulkanContext->GetGpuProperties(); m_maxLineWidth = std::max(props.limits.lineWidthRange[0], props.limits.lineWidthRange[1]); m_maxTextureSize = vulkanContext->GetGpuProperties().limits.maxImageDimension2D; } LOG(LINFO, ("Max line width =", m_maxLineWidth,"| Max texture size =", m_maxTextureSize)); // Set up default antialiasing value. // Turn off AA for a while by energy-saving issues. // bool val; // if (!settings::Get(kSupportedAntialiasing, val)) // { //#ifdef OMIM_OS_ANDROID // std::vector const models = {"Mali-G71", "Mali-T880", "Adreno (TM) 540", // "Adreno (TM) 530", "Adreno (TM) 430"}; // m_isAntialiasingEnabledByDefault = // (std::find(models.begin(), models.end(), renderer) != models.end()); //#else // m_isAntialiasingEnabledByDefault = true; //#endif // settings::Set(kSupportedAntialiasing, m_isAntialiasingEnabledByDefault); // } m_isInitialized = true; } SupportManager & SupportManager::Instance() { static SupportManager manager; return manager; } } // namespace dp