diff options
Diffstat (limited to 'drape')
-rw-r--r-- | drape/render_state.cpp | 6 | ||||
-rw-r--r-- | drape/support_manager.cpp | 36 | ||||
-rw-r--r-- | drape/support_manager.hpp | 17 | ||||
-rw-r--r-- | drape/texture.cpp | 6 | ||||
-rw-r--r-- | drape/texture.hpp | 1 | ||||
-rw-r--r-- | drape/texture_manager.cpp | 10 | ||||
-rw-r--r-- | drape/vulkan/vulkan_base_context.cpp | 2 | ||||
-rw-r--r-- | drape/vulkan/vulkan_base_context.hpp | 2 |
8 files changed, 48 insertions, 32 deletions
diff --git a/drape/render_state.cpp b/drape/render_state.cpp index 749ee03729..93ab82baa8 100644 --- a/drape/render_state.cpp +++ b/drape/render_state.cpp @@ -283,7 +283,9 @@ void ApplyState(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program, R ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ()); GLFunctions::glLineWidth(static_cast<uint32_t>(state.GetLineWidth())); } - - //TODO(@rokuz, @darina): Check if Vulkan support line width. + else if (apiVersion == dp::ApiVersion::Vulkan) + { + //TODO(@rokuz, @darina): Implement. + } } } // namespace dp diff --git a/drape/support_manager.cpp b/drape/support_manager.cpp index c12ccec6cf..3e8ab410c0 100644 --- a/drape/support_manager.cpp +++ b/drape/support_manager.cpp @@ -1,5 +1,6 @@ #include "drape/support_manager.hpp" #include "drape/gl_functions.hpp" +#include "drape/vulkan/vulkan_base_context.hpp" #include "platform/settings.hpp" @@ -19,17 +20,15 @@ char const * kSupportedAntialiasing = "Antialiasing"; void SupportManager::Init(ref_ptr<GraphicsContext> context) { + std::lock_guard<std::mutex> 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)); - // On Android the engine may be recreated. Here we guarantee that GPU info is sent once per session. - static bool gpuInfoSent = false; - if (!gpuInfoSent) - { - alohalytics::Stats::Instance().LogEvent("GPU", renderer); - gpuInfoSent = true; - } + alohalytics::Stats::Instance().LogEvent("GPU", renderer); m_isSamsungGoogleNexus = (renderer == "PowerVR SGX 540" && version.find("GOOGLENEXUS.ED945322") != string::npos); if (m_isSamsungGoogleNexus) @@ -53,15 +52,26 @@ void SupportManager::Init(ref_ptr<GraphicsContext> context) if (m_isTegra) LOG(LINFO, ("NVidia Tegra device detected.")); - // Metal does not support thick lines. auto const apiVersion = context->GetApiVersion(); if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) { - m_maxLineWidth = std::max(1, GLFunctions::glGetMaxLineWidth()); - LOG(LINFO, ("Max line width =", m_maxLineWidth)); + m_maxLineWidth = static_cast<float>(std::max(1, GLFunctions::glGetMaxLineWidth())); + m_maxTextureSize = static_cast<uint32_t>(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize)); } - - //TODO(@rokuz, @darina): Check if Vulkan support line width. + 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<dp::vulkan::VulkanBaseContext> 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. @@ -78,6 +88,8 @@ void SupportManager::Init(ref_ptr<GraphicsContext> context) //#endif // settings::Set(kSupportedAntialiasing, m_isAntialiasingEnabledByDefault); // } + + m_isInitialized = true; } SupportManager & SupportManager::Instance() diff --git a/drape/support_manager.hpp b/drape/support_manager.hpp index 71b933a458..f12a997880 100644 --- a/drape/support_manager.hpp +++ b/drape/support_manager.hpp @@ -5,6 +5,9 @@ #include "base/macros.hpp" +#include <cstdint> +#include <mutex> + namespace dp { extern char const * kSupportedAntialiasing; @@ -16,23 +19,33 @@ public: static SupportManager & Instance(); // Initialization must be called only when graphics context is created. + // Initialization happens once per application launch, so SupportManager + // must not contain any properties which can be changed in the case of contexts + // reinitialization. void Init(ref_ptr<GraphicsContext> context); bool IsSamsungGoogleNexus() const { return m_isSamsungGoogleNexus; } bool IsAdreno200Device() const { return m_isAdreno200; } bool IsTegraDevice() const { return m_isTegra; } - int GetMaxLineWidth() const { return m_maxLineWidth; } bool IsAntialiasingEnabledByDefault() const { return m_isAntialiasingEnabledByDefault; } + float GetMaxLineWidth() const { return m_maxLineWidth; } + uint32_t GetMaxTextureSize() const { return m_maxTextureSize; } + private: SupportManager() = default; bool m_isSamsungGoogleNexus = false; bool m_isAdreno200 = false; bool m_isTegra = false; - int m_maxLineWidth = 1; bool m_isAntialiasingEnabledByDefault = false; + float m_maxLineWidth = 1; + uint32_t m_maxTextureSize = 1024; + + bool m_isInitialized = false; + std::mutex m_mutex; + DISALLOW_COPY_AND_MOVE(SupportManager); }; } // namespace dp diff --git a/drape/texture.cpp b/drape/texture.cpp index 5a3d43e6fa..a74c15b5fb 100644 --- a/drape/texture.cpp +++ b/drape/texture.cpp @@ -85,12 +85,6 @@ void Texture::SetFilter(TextureFilter filter) } // static -uint32_t Texture::GetMaxTextureSize() -{ - return static_cast<uint32_t>(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize)); -} - -// static bool Texture::IsPowerOfTwo(uint32_t width, uint32_t height) { return glm::isPowerOfTwo(static_cast<int>(width)) && glm::isPowerOfTwo(static_cast<int>(height)); diff --git a/drape/texture.hpp b/drape/texture.hpp index e3f62610b8..aede9bbfcb 100644 --- a/drape/texture.hpp +++ b/drape/texture.hpp @@ -72,7 +72,6 @@ public: ref_ptr<HWTexture> GetHardwareTexture() const; - static uint32_t GetMaxTextureSize(); static bool IsPowerOfTwo(uint32_t width, uint32_t height); protected: diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp index a8fdd98369..2276b9e807 100644 --- a/drape/texture_manager.cpp +++ b/drape/texture_manager.cpp @@ -5,6 +5,7 @@ #include "drape/stipple_pen_resource.hpp" #include "drape/texture_of_colors.hpp" #include "drape/gl_functions.hpp" +#include "drape/support_manager.hpp" #include "drape/utils/glyph_usage_tracker.hpp" #include "platform/platform.hpp" @@ -477,17 +478,10 @@ void TextureManager::Init(ref_ptr<dp::GraphicsContext> context, Params const & p m_resPostfix = params.m_resPostfix; m_textureAllocator = CreateAllocator(context); + m_maxTextureSize = std::min(kMaxTextureSize, dp::SupportManager::Instance().GetMaxTextureSize()); auto const apiVersion = context->GetApiVersion(); if (apiVersion == dp::ApiVersion::OpenGLES2 || apiVersion == dp::ApiVersion::OpenGLES3) - { - m_maxTextureSize = std::min(kMaxTextureSize, - static_cast<uint32_t>(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize))); GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1); - } - else - { - m_maxTextureSize = kMaxTextureSize; - } // Initialize symbols. for (size_t i = 0; i < ARRAY_SIZE(kSymbolTextures); ++i) diff --git a/drape/vulkan/vulkan_base_context.cpp b/drape/vulkan/vulkan_base_context.cpp index 2c00cc9e4f..b7dcb234c4 100644 --- a/drape/vulkan/vulkan_base_context.cpp +++ b/drape/vulkan/vulkan_base_context.cpp @@ -50,6 +50,8 @@ void VulkanBaseContext::SetSurface(VkSurfaceKHR surface, VkFormat surfaceFormat, void VulkanBaseContext::ResetSurface() { + vkDeviceWaitIdle(m_device); + //TODO: reset swapchains, image views and so on. m_surface.reset(); } diff --git a/drape/vulkan/vulkan_base_context.hpp b/drape/vulkan/vulkan_base_context.hpp index a41d09acf9..e2e5552ed1 100644 --- a/drape/vulkan/vulkan_base_context.hpp +++ b/drape/vulkan/vulkan_base_context.hpp @@ -54,6 +54,7 @@ public: void ResetSurface(); VkDevice GetDevice() const { return m_device; } + VkPhysicalDeviceProperties const & GetGpuProperties() const { return m_gpuProperties; } protected: VkInstance const m_vulkanInstance; @@ -63,7 +64,6 @@ protected: VkPhysicalDeviceProperties m_gpuProperties; boost::optional<VkSurfaceKHR> m_surface; - m2::PointU m_maxTextureSize; uint32_t m_stencilReferenceValue = 1; }; |