diff --git a/drape/gl_includes.hpp b/drape/gl_includes.hpp index f407dacf4e..c3f0106bd8 100644 --- a/drape/gl_includes.hpp +++ b/drape/gl_includes.hpp @@ -3,9 +3,11 @@ #include "std/target_os.hpp" #if defined(OMIM_OS_IPHONE) + #define GL_SILENCE_DEPRECATION #include #include #elif defined(OMIM_OS_MAC) + #define GL_SILENCE_DEPRECATION #include #include #elif defined(OMIM_OS_WINDOWS) diff --git a/drape/graphics_context.hpp b/drape/graphics_context.hpp index c87d9261b5..6c1b88c83e 100644 --- a/drape/graphics_context.hpp +++ b/drape/graphics_context.hpp @@ -7,12 +7,14 @@ namespace dp { -enum ClearBits: uint32_t +enum ClearBits : uint32_t { ColorBit = 1, DepthBit = 1 << 1, StencilBit = 1 << 2 }; + +uint32_t constexpr kClearBitsStoreAll = ClearBits::ColorBit | ClearBits::DepthBit | ClearBits::StencilBit; enum class TestFunction : uint8_t { @@ -65,9 +67,12 @@ public: virtual ApiVersion GetApiVersion() const = 0; virtual std::string GetRendererName() const = 0; virtual std::string GetRendererVersion() const = 0; + + virtual void PushDebugLabel(std::string const & label) = 0; + virtual void PopDebugLabel() = 0; virtual void SetClearColor(Color const & color) = 0; - virtual void Clear(uint32_t clearBits) = 0; + virtual void Clear(uint32_t clearBits, uint32_t storeBits) = 0; virtual void Flush() = 0; virtual void SetViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h) = 0; virtual void SetDepthTestEnabled(bool enabled) = 0; @@ -76,5 +81,6 @@ public: virtual void SetStencilFunction(StencilFace face, TestFunction stencilFunction) = 0; virtual void SetStencilActions(StencilFace face, StencilAction stencilFailAction, StencilAction depthFailAction, StencilAction passAction) = 0; + virtual void SetStencilReferenceValue(uint32_t stencilReferenceValue) = 0; }; } // namespace dp diff --git a/drape/metal/metal_base_context.hpp b/drape/metal/metal_base_context.hpp index 7354a2ecb4..88d694c970 100644 --- a/drape/metal/metal_base_context.hpp +++ b/drape/metal/metal_base_context.hpp @@ -38,8 +38,11 @@ public: std::string GetRendererName() const override; std::string GetRendererVersion() const override; + void PushDebugLabel(std::string const & label) override; + void PopDebugLabel() override; + void SetClearColor(Color const & color) override; - void Clear(uint32_t clearBits) override; + void Clear(uint32_t clearBits, uint32_t storeBits) override; void Flush() override {} void SetViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h) override; void SetDepthTestEnabled(bool enabled) override; @@ -48,6 +51,7 @@ public: void SetStencilFunction(StencilFace face, TestFunction stencilFunction) override; void SetStencilActions(StencilFace face, StencilAction stencilFailAction, StencilAction depthFailAction, StencilAction passAction) override; + void SetStencilReferenceValue(uint32_t stencilReferenceValue) override { m_stencilReferenceValue = stencilReferenceValue; } id GetMetalDevice() const; id GetCommandEncoder() const; @@ -81,6 +85,8 @@ protected: id m_currentCommandEncoder; MetalCleaner m_cleaner; + + uint32_t m_stencilReferenceValue = 1; }; } // namespace metal } // namespace dp diff --git a/drape/metal/metal_base_context.mm b/drape/metal/metal_base_context.mm index 3038ed8c44..d6b5459506 100644 --- a/drape/metal/metal_base_context.mm +++ b/drape/metal/metal_base_context.mm @@ -112,6 +112,20 @@ std::string MetalBaseContext::GetRendererVersion() const return "Unknown"; } +void MetalBaseContext::PushDebugLabel(std::string const & label) +{ + if (m_currentCommandEncoder == nil) + return; + [m_currentCommandEncoder pushDebugGroup:@(label.c_str())]; +} + +void MetalBaseContext::PopDebugLabel() +{ + if (m_currentCommandEncoder == nil) + return; + [m_currentCommandEncoder popDebugGroup]; +} + void MetalBaseContext::Resize(int w, int h) { if (m_depthTexture && m_depthTexture->GetWidth() == w && m_depthTexture->GetHeight() == h) @@ -177,7 +191,7 @@ void MetalBaseContext::ApplyFramebuffer(std::string const & framebufferLabel) // Default rendering options. [m_currentCommandEncoder setFrontFacingWinding:MTLWindingClockwise]; [m_currentCommandEncoder setCullMode:MTLCullModeBack]; - [m_currentCommandEncoder setStencilReferenceValue:1]; + [m_currentCommandEncoder setStencilReferenceValue:m_stencilReferenceValue]; } void MetalBaseContext::SetClearColor(dp::Color const & color) @@ -187,7 +201,7 @@ void MetalBaseContext::SetClearColor(dp::Color const & color) MTLClearColorMake(color.GetRedF(), color.GetGreenF(), color.GetBlueF(), color.GetAlphaF()); } -void MetalBaseContext::Clear(uint32_t clearBits) +void MetalBaseContext::Clear(uint32_t clearBits, uint32_t storeBits) { if (m_currentCommandEncoder != nil) { @@ -203,20 +217,38 @@ void MetalBaseContext::Clear(uint32_t clearBits) } else { + // Here, if we do not clear attachments, we load data ONLY if we store it afterwards, otherwise we use 'DontCare' option + // to improve performance. if (clearBits & ClearBits::ColorBit) m_renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear; else - m_renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionLoad; + m_renderPassDescriptor.colorAttachments[0].loadAction = (storeBits & ClearBits::ColorBit) ? MTLLoadActionLoad : MTLLoadActionDontCare; if (clearBits & ClearBits::DepthBit) m_renderPassDescriptor.depthAttachment.loadAction = MTLLoadActionClear; else - m_renderPassDescriptor.depthAttachment.loadAction = MTLLoadActionLoad; + m_renderPassDescriptor.depthAttachment.loadAction = (storeBits & ClearBits::DepthBit) ? MTLLoadActionLoad : MTLLoadActionDontCare; if (clearBits & ClearBits::StencilBit) m_renderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionClear; else - m_renderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionLoad; + m_renderPassDescriptor.stencilAttachment.loadAction = (storeBits & ClearBits::StencilBit) ? MTLLoadActionLoad : MTLLoadActionDontCare; + + // Apply storing mode. + if (storeBits & ClearBits::ColorBit) + m_renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore; + else + m_renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionDontCare; + + if (storeBits & ClearBits::DepthBit) + m_renderPassDescriptor.depthAttachment.storeAction = MTLStoreActionStore; + else + m_renderPassDescriptor.depthAttachment.storeAction = MTLStoreActionDontCare; + + if (storeBits & ClearBits::StencilBit) + m_renderPassDescriptor.stencilAttachment.storeAction = MTLStoreActionStore; + else + m_renderPassDescriptor.stencilAttachment.storeAction = MTLStoreActionDontCare; } } diff --git a/drape/oglcontext.cpp b/drape/oglcontext.cpp index d9d8644b1c..bb220f90a2 100644 --- a/drape/oglcontext.cpp +++ b/drape/oglcontext.cpp @@ -87,8 +87,10 @@ void OGLContext::SetClearColor(dp::Color const & color) GLFunctions::glClearColor(color.GetRedF(), color.GetGreenF(), color.GetBlueF(), color.GetAlphaF()); } -void OGLContext::Clear(uint32_t clearBits) +void OGLContext::Clear(uint32_t clearBits, uint32_t storeBits) { + UNUSED_VALUE(storeBits); + glConst glBits = 0; if (clearBits & ClearBits::ColorBit) glBits |= gl_const::GLColorBit; diff --git a/drape/oglcontext.hpp b/drape/oglcontext.hpp index 2692e662a8..4a2a452b66 100644 --- a/drape/oglcontext.hpp +++ b/drape/oglcontext.hpp @@ -12,9 +12,12 @@ public: std::string GetRendererName() const override; std::string GetRendererVersion() const override; void ApplyFramebuffer(std::string const & framebufferLabel) override {} + + void PushDebugLabel(std::string const & label) override {} + void PopDebugLabel() override {} void SetClearColor(dp::Color const & color) override; - void Clear(uint32_t clearBits) override; + void Clear(uint32_t clearBits, uint32_t storeBits) override; void Flush() override; void SetViewport(uint32_t x, uint32_t y, uint32_t w, uint32_t h) override; void SetDepthTestEnabled(bool enabled) override; @@ -23,5 +26,8 @@ public: void SetStencilFunction(StencilFace face, TestFunction stencilFunction) override; void SetStencilActions(StencilFace face, StencilAction stencilFailAction, StencilAction depthFailAction, StencilAction passAction) override; + + // Do not use custom stencil reference value in OpenGL rendering. + void SetStencilReferenceValue(uint32_t stencilReferenceValue) override {} }; } // namespace dp diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 122b1b1eda..a1de29cd02 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -114,6 +114,30 @@ struct RemoveTilePredicate return false; } }; + +class DebugLabelGuard +{ +public: + DebugLabelGuard(ref_ptr context, std::string const & label) + : m_context(context) + { + m_context->PushDebugLabel(label); + } + + ~DebugLabelGuard() + { + m_context->PopDebugLabel(); + } + +private: + ref_ptr m_context; +}; + +#if defined(DEBUG) || defined(DEBUG_DRAPE_XCODE) +#define DEBUG_LABEL(labelName, context, labelText) DebugLabelGuard labelName(context, labelText); +#else +#define DEBUG_LABEL(labelName, context, labelText) +#endif } // namespace FrontendRenderer::FrontendRenderer(Params && params) @@ -1242,10 +1266,26 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram #endif CHECK(m_context != nullptr, ()); + + PreRender3dLayer(modelView); + if (m_postprocessRenderer->BeginFrame(m_context, activeFrame)) { RefreshBgColor(); - m_context->Clear(dp::ClearBits::ColorBit | dp::ClearBits::DepthBit | dp::ClearBits::StencilBit); + + uint32_t clearBits = dp::ClearBits::ColorBit | dp::ClearBits::DepthBit; + if (m_apiVersion == dp::ApiVersion::OpenGLES2 || m_apiVersion == dp::ApiVersion::OpenGLES3) + clearBits = clearBits | dp::ClearBits::StencilBit; + + uint32_t storeBits = dp::ClearBits::ColorBit; + if (m_postprocessRenderer->IsEffectEnabled(PostprocessRenderer::Effect::Antialiasing)) + { + clearBits = clearBits | dp::ClearBits::StencilBit; + storeBits = storeBits | dp::ClearBits::StencilBit; + m_context->SetStencilReferenceValue(2 /* write this value to the stencil buffer */); + } + + m_context->Clear(clearBits, storeBits); m_context->ApplyFramebuffer("Static frame"); m_viewport.Apply(m_context); @@ -1257,17 +1297,17 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram RenderTrafficLayer(modelView); if (!HasTransitRouteData()) RenderRouteLayer(modelView); - Render3dLayer(modelView, true /* useFramebuffer */); + Render3dLayer(modelView); } else { - Render3dLayer(modelView, false /* useFramebuffer */); + Render3dLayer(modelView); RenderTrafficLayer(modelView); if (!HasTransitRouteData()) RenderRouteLayer(modelView); } - m_context->Clear(dp::ClearBits::DepthBit); + m_context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); if (m_selectionShape != nullptr) { @@ -1345,52 +1385,61 @@ void FrontendRenderer::Render2dLayer(ScreenBase const & modelView) layer2d.Sort(make_ref(m_overlayTree)); CHECK(m_context != nullptr, ()); + DEBUG_LABEL(render2dLayerLabel, m_context, "2D Layer"); for (drape_ptr const & group : layer2d.m_renderGroups) RenderSingleGroup(m_context, modelView, make_ref(group)); } -void FrontendRenderer::Render3dLayer(ScreenBase const & modelView, bool useFramebuffer) +void FrontendRenderer::PreRender3dLayer(ScreenBase const & modelView) +{ + if (!m_buildingsFramebuffer->IsSupported()) + return; + + RenderLayer & layer = m_layers[static_cast(DepthLayer::Geometry3dLayer)]; + if (layer.m_renderGroups.empty()) + return; + + m_context->SetFramebuffer(make_ref(m_buildingsFramebuffer)); + m_context->SetClearColor(dp::Color::Transparent()); + m_context->Clear(dp::ClearBits::ColorBit | dp::ClearBits::DepthBit, dp::ClearBits::ColorBit /* storeBits */); + m_context->ApplyFramebuffer("Buildings"); + m_viewport.Apply(m_context); + + layer.Sort(make_ref(m_overlayTree)); + for (drape_ptr const & group : layer.m_renderGroups) + RenderSingleGroup(m_context, modelView, make_ref(group)); +} + +void FrontendRenderer::Render3dLayer(ScreenBase const & modelView) { RenderLayer & layer = m_layers[static_cast(DepthLayer::Geometry3dLayer)]; if (layer.m_renderGroups.empty()) return; - CHECK(m_context != nullptr, ()); - float const kOpacity = 0.7f; - if (useFramebuffer) + DEBUG_LABEL(render3dLayerLabel, m_context, "3D Layer"); + if (m_buildingsFramebuffer->IsSupported()) { - ASSERT(m_buildingsFramebuffer->IsSupported(), ()); - m_context->SetFramebuffer(make_ref(m_buildingsFramebuffer)); - m_context->SetClearColor(dp::Color::Transparent()); - m_context->Clear(dp::ClearBits::ColorBit | dp::ClearBits::DepthBit); - m_context->ApplyFramebuffer("Buildings"); - m_viewport.Apply(m_context); - } - else - { - m_context->Clear(dp::ClearBits::DepthBit); - } - - layer.Sort(make_ref(m_overlayTree)); - for (drape_ptr const & group : layer.m_renderGroups) - RenderSingleGroup(m_context, modelView, make_ref(group)); - - if (useFramebuffer) - { - m_buildingsFramebuffer->ApplyFallback(); - m_context->Clear(dp::ClearBits::DepthBit); - m_context->ApplyFramebuffer("Static frame (after buildings)"); - m_viewport.Apply(m_context); - + float const kOpacity = 0.7f; m_screenQuadRenderer->RenderTexture(m_context, make_ref(m_gpuProgramManager), m_buildingsFramebuffer->GetTexture(), kOpacity); } + else + { + // Fallback for devices which do not support rendering to the texture. + CHECK(m_context != nullptr, ()); + m_context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); + + layer.Sort(make_ref(m_overlayTree)); + for (drape_ptr const & group : layer.m_renderGroups) + RenderSingleGroup(m_context, modelView, make_ref(group)); + } } void FrontendRenderer::RenderOverlayLayer(ScreenBase const & modelView) { CHECK(m_context != nullptr, ()); + DEBUG_LABEL(renderOverlayLayerLabel, m_context, "Overlay Layer"); RenderLayer & overlay = m_layers[static_cast(DepthLayer::OverlayLayer)]; BuildOverlayTree(modelView); for (drape_ptr & group : overlay.m_renderGroups) @@ -1403,6 +1452,7 @@ void FrontendRenderer::RenderOverlayLayer(ScreenBase const & modelView) void FrontendRenderer::RenderNavigationOverlayLayer(ScreenBase const & modelView) { CHECK(m_context != nullptr, ()); + DEBUG_LABEL(renderNavigationOverlayLayerLabel, m_context, "Navigation Overlay Layer"); RenderLayer & navOverlayLayer = m_layers[static_cast(DepthLayer::NavigationLayer)]; for (auto & group : navOverlayLayer.m_renderGroups) { @@ -1426,7 +1476,8 @@ void FrontendRenderer::RenderTransitSchemeLayer(ScreenBase const & modelView) CHECK(m_context != nullptr, ()); if (m_transitSchemeEnabled && m_transitSchemeRenderer->IsSchemeVisible(m_currentZoomLevel)) { - m_context->Clear(dp::ClearBits::DepthBit); + DEBUG_LABEL(renderTransitSchemeLayerLabel, m_context, "Transit Scheme"); + m_context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); RenderTransitBackground(); m_transitSchemeRenderer->RenderTransit(m_context, make_ref(m_gpuProgramManager), modelView, make_ref(m_postprocessRenderer), m_frameValues, @@ -1439,7 +1490,8 @@ void FrontendRenderer::RenderTrafficLayer(ScreenBase const & modelView) CHECK(m_context != nullptr, ()); if (m_trafficRenderer->HasRenderData()) { - m_context->Clear(dp::ClearBits::DepthBit); + DEBUG_LABEL(renderTrafficLayerLabel, m_context, "Traffic Layer"); + m_context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); m_trafficRenderer->RenderTraffic(m_context, make_ref(m_gpuProgramManager), modelView, m_currentZoomLevel, 1.0f /* opacity */, m_frameValues); } @@ -1450,13 +1502,15 @@ void FrontendRenderer::RenderTransitBackground() if (!m_finishTexturesInitialization) return; + CHECK(m_context != nullptr, ()); + DEBUG_LABEL(renderTransitBackgroundLabel, m_context, "Transit Background"); + dp::TextureManager::ColorRegion region; m_texMng->GetColorRegion(df::GetColorConstant(kTransitBackgroundColor), region); CHECK(region.GetTexture() != nullptr, ("Texture manager is not initialized")); if (!m_transitBackground->IsInitialized()) m_transitBackground->SetTextureRect(region.GetTexRect()); - CHECK(m_context != nullptr, ()); m_transitBackground->RenderTexture(m_context, make_ref(m_gpuProgramManager), region.GetTexture(), 1.0f /* opacity */, false /* invertV */); } @@ -1469,7 +1523,8 @@ void FrontendRenderer::RenderRouteLayer(ScreenBase const & modelView) if (m_routeRenderer->HasData() || m_routeRenderer->HasPreviewData()) { CHECK(m_context != nullptr, ()); - m_context->Clear(dp::ClearBits::DepthBit); + DEBUG_LABEL(renderRouteLayerLabel, m_context, "Route Layer"); + m_context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); m_routeRenderer->RenderRoute(m_context, make_ref(m_gpuProgramManager), modelView, m_trafficRenderer->HasRenderData(), m_frameValues); } @@ -1482,7 +1537,8 @@ void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView, DepthL return; CHECK(m_context != nullptr, ()); - m_context->Clear(dp::ClearBits::DepthBit); + DEBUG_LABEL(renderUserMarksLayerLabel, m_context, "User Marks: " + DebugPrint(layerId)); + m_context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); for (drape_ptr & group : renderGroups) RenderSingleGroup(m_context, modelView, make_ref(group)); @@ -1509,7 +1565,7 @@ void FrontendRenderer::RenderEmptyFrame() m_context->SetFramebuffer(nullptr /* default */); auto const c = dp::Extract(drule::rules().GetBgColor(1 /* scale */), 255); m_context->SetClearColor(c); - m_context->Clear(dp::ClearBits::ColorBit); + m_context->Clear(dp::ClearBits::ColorBit, dp::ClearBits::ColorBit /* storeBits */); m_context->ApplyFramebuffer("Empty frame"); m_viewport.Apply(m_context); @@ -2108,7 +2164,7 @@ void FrontendRenderer::Routine::Do() m_renderer.OnContextCreate(); -#ifdef DEBUG +#if defined(DEBUG) || defined(DEBUG_DRAPE_XCODE) gui::DrapeGui::Instance().GetScaleFpsHelper().SetVisible(true); #endif diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index 568979769a..98b8d888f2 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -161,7 +161,8 @@ private: }; // Render part of scene void Render2dLayer(ScreenBase const & modelView); - void Render3dLayer(ScreenBase const & modelView, bool useFramebuffer); + void PreRender3dLayer(ScreenBase const & modelView); + void Render3dLayer(ScreenBase const & modelView); void RenderOverlayLayer(ScreenBase const & modelView); void RenderNavigationOverlayLayer(ScreenBase const & modelView); void RenderUserMarksLayer(ScreenBase const & modelView, DepthLayer layerId); diff --git a/drape_frontend/postprocess_renderer.cpp b/drape_frontend/postprocess_renderer.cpp index 8a07d3765f..4b97863671 100644 --- a/drape_frontend/postprocess_renderer.cpp +++ b/drape_frontend/postprocess_renderer.cpp @@ -283,10 +283,14 @@ bool PostprocessRenderer::EndFrame(ref_ptr context, // Render edges to texture. { context->SetFramebuffer(make_ref(m_edgesFramebuffer)); - context->Clear(dp::ClearBits::ColorBit); - context->SetStencilFunction(dp::StencilFace::FrontAndBack, dp::TestFunction::NotEqual); + context->Clear(dp::ClearBits::ColorBit, dp::ClearBits::ColorBit | dp::ClearBits::StencilBit /* storeBits */); + if (m_apiVersion == dp::ApiVersion::Metal) + context->SetStencilFunction(dp::StencilFace::FrontAndBack, dp::TestFunction::Greater); + else + context->SetStencilFunction(dp::StencilFace::FrontAndBack, dp::TestFunction::NotEqual); context->SetStencilActions(dp::StencilFace::FrontAndBack, dp::StencilAction::Zero, dp::StencilAction::Zero, dp::StencilAction::Replace); + context->SetStencilReferenceValue(1); context->ApplyFramebuffer("SMAA edges"); viewport.Apply(context); @@ -301,7 +305,7 @@ bool PostprocessRenderer::EndFrame(ref_ptr context, // Render blending weight to texture. { context->SetFramebuffer(make_ref(m_blendingWeightFramebuffer)); - context->Clear(dp::ClearBits::ColorBit); + context->Clear(dp::ClearBits::ColorBit, dp::ClearBits::ColorBit | dp::ClearBits::StencilBit /* storeBits */); context->SetStencilFunction(dp::StencilFace::FrontAndBack, dp::TestFunction::Equal); context->SetStencilActions(dp::StencilFace::FrontAndBack, dp::StencilAction::Keep, dp::StencilAction::Keep, dp::StencilAction::Keep); @@ -323,7 +327,7 @@ bool PostprocessRenderer::EndFrame(ref_ptr context, context->SetStencilTestEnabled(false); { context->SetFramebuffer(make_ref(m_smaaFramebuffer)); - context->Clear(dp::ClearBits::ColorBit); + context->Clear(dp::ClearBits::ColorBit, dp::ClearBits::ColorBit /* storeBits */); context->ApplyFramebuffer("SMAA final"); viewport.Apply(context); @@ -350,7 +354,7 @@ bool PostprocessRenderer::EndFrame(ref_ptr context, bool m_wasRendered = false; if (m_framebufferFallback()) { - context->Clear(dp::ClearBits::ColorBit); + context->Clear(dp::ClearBits::ColorBit, dp::ClearBits::ColorBit /* storeBits */); context->ApplyFramebuffer("Dynamic frame"); viewport.Apply(context); diff --git a/drape_frontend/render_state_extension.hpp b/drape_frontend/render_state_extension.hpp index 9986610c8a..68afd0966c 100644 --- a/drape_frontend/render_state_extension.hpp +++ b/drape_frontend/render_state_extension.hpp @@ -49,4 +49,26 @@ public: extern DepthLayer GetDepthLayer(dp::RenderState const & state); extern dp::RenderState CreateRenderState(gpu::Program program, DepthLayer depthLayer); + +inline std::string DebugPrint(DepthLayer layer) +{ + switch (layer) + { + case DepthLayer::GeometryLayer: return "GeometryLayer"; + case DepthLayer::Geometry3dLayer: return "Geometry3dLayer"; + case DepthLayer::UserLineLayer: return "UserLineLayer"; + case DepthLayer::OverlayLayer: return "OverlayLayer"; + case DepthLayer::LocalAdsMarkLayer: return "LocalAdsMarkLayer"; + case DepthLayer::TransitSchemeLayer: return "TransitSchemeLayer"; + case DepthLayer::UserMarkLayer: return "UserMarkLayer"; + case DepthLayer::NavigationLayer: return "NavigationLayer"; + case DepthLayer::TransitMarkLayer: return "TransitMarkLayer"; + case DepthLayer::RoutingMarkLayer: return "RoutingMarkLayer"; + case DepthLayer::SearchMarkLayer: return "SearchMarkLayer"; + case DepthLayer::GuiLayer: return "GuiLayer"; + case DepthLayer::LayersCount: CHECK(false, ("Try to output LayersCount")); + } + CHECK(false, ("Unknown layer")); + return {}; +} } // namespace df diff --git a/drape_frontend/transit_scheme_builder.cpp b/drape_frontend/transit_scheme_builder.cpp index f338cdd3d5..6da0e315f6 100644 --- a/drape_frontend/transit_scheme_builder.cpp +++ b/drape_frontend/transit_scheme_builder.cpp @@ -543,7 +543,7 @@ void TransitSchemeBuilder::GenerateShapes(ref_ptr context, { MwmSchemeData const & scheme = m_schemes[mwmId]; - uint32_t const kBatchSize = 5000; + uint32_t const kBatchSize = 65000; dp::Batcher batcher(kBatchSize, kBatchSize); { dp::SessionGuard guard(context, batcher, [this, &mwmId, &scheme](dp::RenderState const & state, diff --git a/drape_frontend/transit_scheme_renderer.cpp b/drape_frontend/transit_scheme_renderer.cpp index a3f7ab0915..10ce45a81c 100644 --- a/drape_frontend/transit_scheme_renderer.cpp +++ b/drape_frontend/transit_scheme_renderer.cpp @@ -187,7 +187,7 @@ void TransitSchemeRenderer::RenderLinesCaps(ref_ptr context ScreenBase const & screen, FrameValues const & frameValues, float pixelHalfWidth) { - context->Clear(dp::ClearBits::DepthBit); + context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); for (auto & renderData : m_linesCapsRenderData) { ref_ptr program = mng->GetProgram(renderData.m_state.GetProgram()); @@ -232,7 +232,7 @@ void TransitSchemeRenderer::RenderMarkers(ref_ptr context, ScreenBase const & screen, FrameValues const & frameValues, float pixelHalfWidth) { - context->Clear(dp::ClearBits::DepthBit); + context->Clear(dp::ClearBits::DepthBit, dp::kClearBitsStoreAll); for (auto & renderData : m_markersRenderData) { auto program = mng->GetProgram(renderData.m_state.GetProgram()); diff --git a/iphone/Maps/Classes/MetalContextFactory.mm b/iphone/Maps/Classes/MetalContextFactory.mm index 35333cea3c..b6826d5aa1 100644 --- a/iphone/Maps/Classes/MetalContextFactory.mm +++ b/iphone/Maps/Classes/MetalContextFactory.mm @@ -40,7 +40,7 @@ public: } void SetClearColor(dp::Color const & color) override {} - void Clear(uint32_t clearBits) override {} + void Clear(uint32_t clearBits, uint32_t storeBits) override {} void Flush() override {} void SetDepthTestEnabled(bool enabled) override {} void SetDepthTestFunction(dp::TestFunction depthFunction) override {} diff --git a/shaders/Metal/map.metal b/shaders/Metal/map.metal index 47ff342646..ddfd131cf0 100644 --- a/shaders/Metal/map.metal +++ b/shaders/Metal/map.metal @@ -384,7 +384,7 @@ fragment CapJoinFragment_Output fsCapJoin(const CapJoinFragment_T in [[stage_in] if (out.color.a < 0.001) out.depth = 1.0; else - out.depth = in.position.z; + out.depth = in.position.z * in.position.w; return out; } @@ -638,7 +638,7 @@ fragment ColoredSymbolOut_T fsColoredSymbol(const ColoredSymbolFragment_T in [[s if (finalColor.a == 0.0) out.depth = 1.0; else - out.depth = in.position.z; + out.depth = in.position.z * in.position.w; out.color = finalColor; return out; @@ -828,7 +828,7 @@ fragment UserMarkOut_T fsUserMark(const UserMarkFragment_T in [[stage_in]], if (finalColor.a < 0.001) out.depth = 1.0; else - out.depth = in.position.z; + out.depth = in.position.z * in.position.w; out.color = finalColor; return out; } diff --git a/shaders/Metal/traffic.metal b/shaders/Metal/traffic.metal index da55fd266a..2196c154b2 100644 --- a/shaders/Metal/traffic.metal +++ b/shaders/Metal/traffic.metal @@ -199,7 +199,7 @@ fragment TrafficCircleOut_T fsTrafficCircle(const TrafficCircleFragment_T in [[s if (color.a < 0.001) out.depth = 1.0; else - out.depth = in.position.z; + out.depth = in.position.z * in.position.w; out.color = color; return out; } diff --git a/shaders/Metal/transit.metal b/shaders/Metal/transit.metal index 8411749f0d..602be7f70a 100644 --- a/shaders/Metal/transit.metal +++ b/shaders/Metal/transit.metal @@ -146,7 +146,7 @@ fragment TransitCircleOut_T fsTransitCircle(const TransitCircleFragment_T in [[s if (finalColor.a < 0.001) out.depth = 1.0; else - out.depth = in.position.z; + out.depth = in.position.z * in.position.w; out.color = finalColor; diff --git a/xcode/drape/drape.xcodeproj/project.pbxproj b/xcode/drape/drape.xcodeproj/project.pbxproj index 05d351dcf7..732afc4886 100644 --- a/xcode/drape/drape.xcodeproj/project.pbxproj +++ b/xcode/drape/drape.xcodeproj/project.pbxproj @@ -625,6 +625,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", "U_DISABLE_RENAMING=1", + DEBUG_DRAPE_XCODE, ); HEADER_SEARCH_PATHS = ( "$(inherited)", diff --git a/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj b/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj index e56311ac57..d7002bd699 100644 --- a/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj +++ b/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj @@ -959,6 +959,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", "U_DISABLE_RENAMING=1", + DEBUG_DRAPE_XCODE, ); HEADER_SEARCH_PATHS = ( "$(OMIM_ROOT)", diff --git a/xcode/shaders/shaders.xcodeproj/project.pbxproj b/xcode/shaders/shaders.xcodeproj/project.pbxproj index acc6aa9bda..302e57c533 100644 --- a/xcode/shaders/shaders.xcodeproj/project.pbxproj +++ b/xcode/shaders/shaders.xcodeproj/project.pbxproj @@ -728,6 +728,7 @@ 4598438021394BE000F8CAB2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; SUPPORTED_PLATFORMS = "macosx iphoneos"; }; name = Debug;