diff options
author | Aleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com> | 2019-07-19 10:16:14 +0300 |
---|---|---|
committer | Aleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com> | 2019-07-19 13:02:05 +0300 |
commit | 93adb81b45f239ca9411a6f6021e2344460d7e14 (patch) | |
tree | 2877f52f27b597211adba12f25b2211ad2f98ce9 | |
parent | 264c5c1882b05141ef780dbe4ff4a8f78a054e76 (diff) | |
download | qtlocation-mapboxgl-93adb81b45f239ca9411a6f6021e2344460d7e14.tar.gz |
[core][cp] Backport #15065 to nectar
-rw-r--r-- | platform/node/test/ignores.json | 18 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_layer.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/renderer/paint_parameters.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/renderer/paint_parameters.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/renderer/render_layer.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/renderer/render_tile.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/renderer_impl.cpp | 7 |
9 files changed, 29 insertions, 29 deletions
diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json index acc8724a29..fe470cc1b7 100644 --- a/platform/node/test/ignores.json +++ b/platform/node/test/ignores.json @@ -124,25 +124,7 @@ "render-tests/text-rotate/with-offset": "https://github.com/mapbox/mapbox-gl-native/issues/11872", "render-tests/video/default": "skip - https://github.com/mapbox/mapbox-gl-native/issues/601", "render-tests/background-color/colorSpace-hcl": "needs issue", - "render-tests/combinations/fill-extrusion-translucent--heatmap-translucent": "needs investigation", "render-tests/combinations/heatmap-translucent--background-opaque": "needs investigation", - "render-tests/combinations/heatmap-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/background-opaque--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/background-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/circle-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/fill-extrusion-translucent--background-translucent": "needs investigation", - "render-tests/combinations/fill-extrusion-translucent--circle-translucent": "needs investigation", - "render-tests/combinations/fill-extrusion-translucent--hillshade-translucent": "needs investigation", - "render-tests/combinations/fill-extrusion-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/fill-extrusion-translucent--fill-translucent": "needs investigation", - "render-tests/combinations/fill-extrusion-translucent--line-translucent": "needs investigation", - "render-tests/combinations/fill-extrusion-translucent--symbol-translucent": "needs investigation", - "render-tests/combinations/hillshade-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/fill-opaque--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/fill-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/line-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/raster-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/combinations/symbol-translucent--fill-extrusion-translucent": "needs investigation", "render-tests/feature-state/composite-expression": "https://github.com/mapbox/mapbox-gl-native/issues/12613", "render-tests/feature-state/data-expression": "https://github.com/mapbox/mapbox-gl-native/issues/12613", "render-tests/feature-state/set-paint-property": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue", diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 5c2bcbe155..97aacbe3f4 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -56,6 +56,10 @@ bool RenderFillExtrusionLayer::hasCrossfade() const { return getCrossfade<FillExtrusionLayerProperties>(evaluatedProperties).t != 1; } +bool RenderFillExtrusionLayer::is3D() const { + return true; +} + void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*) { if (parameters.pass != RenderPass::Translucent) { return; diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp index fa50ac6f2c..67d40aa927 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp @@ -17,6 +17,7 @@ private: void evaluate(const PropertyEvaluationParameters&) override; bool hasTransition() const override; bool hasCrossfade() const override; + bool is3D() const override; void render(PaintParameters&, RenderSource*) override; bool queryIntersectsFeature( diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index e3f2f918f6..80b414a95f 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -129,10 +129,10 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) { ); }; - // Only draw the fill when it's opaque and we're drawing opaque fragments, - // or when it's translucent and we're drawing translucent fragments. - if ((evaluated.get<FillColor>().constantOr(Color()).a >= 1.0f - && evaluated.get<FillOpacity>().constantOr(0) >= 1.0f) == (parameters.pass == RenderPass::Opaque)) { + auto fillRenderPass = (evaluated.get<FillColor>().constantOr(Color()).a >= 1.0f + && evaluated.get<FillOpacity>().constantOr(0) >= 1.0f + && parameters.currentLayer >= parameters.opaquePassCutoff) ? RenderPass::Opaque : RenderPass::Translucent; + if (parameters.pass == fillRenderPass) { draw(parameters.programs.getFillLayerPrograms().fill, gfx::Triangles(), parameters.depthModeForSublayer(1, parameters.pass == RenderPass::Opaque diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp index 38cdb11f9f..11d849d959 100644 --- a/src/mbgl/renderer/paint_parameters.cpp +++ b/src/mbgl/renderer/paint_parameters.cpp @@ -43,10 +43,11 @@ PaintParameters::PaintParameters(gfx::Context& context_, // odd viewport sizes. state.getProjMatrix(alignedProjMatrix, 1, true); - // Calculate a second projection matrix with the near plane clipped to 100 so as - // not to waste lots of depth buffer precision on very close empty space, for layer - // types (fill-extrusion) that use the depth buffer to emulate real-world space. - state.getProjMatrix(nearClippedProjMatrix, 100); + // Calculate a second projection matrix with the near plane moved further, + // to a tenth of the far value, so as not to waste depth buffer precision on + // very close empty space, for layer types (fill-extrusion) that use the + // depth buffer to emulate real-world space. + state.getProjMatrix(nearClippedProjMatrix, 0.1 * state.getCameraToCenterDistance()); pixelsToGLUnits = {{ 2.0f / state.getSize().width, -2.0f / state.getSize().height }}; @@ -65,6 +66,9 @@ mat4 PaintParameters::matrixForTile(const UnwrappedTileID& tileID, bool aligned) } gfx::DepthMode PaintParameters::depthModeForSublayer(uint8_t n, gfx::DepthMaskType mask) const { + if (currentLayer < opaquePassCutoff) { + return gfx::DepthMode::disabled(); + } float nearDepth = ((1 + currentLayer) * numSublayers + n) * depthEpsilon; float farDepth = nearDepth + depthRangeSize; return gfx::DepthMode { gfx::DepthFunctionType::LessEqual, mask, { nearDepth, farDepth } }; diff --git a/src/mbgl/renderer/paint_parameters.hpp b/src/mbgl/renderer/paint_parameters.hpp index 245f6704d2..410029cdc2 100644 --- a/src/mbgl/renderer/paint_parameters.hpp +++ b/src/mbgl/renderer/paint_parameters.hpp @@ -93,8 +93,7 @@ public: uint32_t currentLayer; float depthRangeSize; const float depthEpsilon = 1.0f / (1 << 16); - - + uint32_t opaquePassCutoff = 0; float symbolFadeChange; }; diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp index 37a8d27c9f..deed8420e7 100644 --- a/src/mbgl/renderer/render_layer.hpp +++ b/src/mbgl/renderer/render_layer.hpp @@ -52,6 +52,9 @@ public: // Returns instance of RenderLayerSymbolInterface if RenderLayer supports it. virtual const RenderLayerSymbolInterface* getSymbolInterface() const; + // Returns true if layer writes to depth buffer by drawing using PaintParameters::depthModeFor3D(). + virtual bool is3D() const { return false; } + const std::string& getID() const; // Checks whether this layer needs to be rendered in the given render pass. diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp index 828163bd6e..f8a069b4f6 100644 --- a/src/mbgl/renderer/render_tile.cpp +++ b/src/mbgl/renderer/render_tile.cpp @@ -85,7 +85,7 @@ void RenderTile::prepare(PaintParameters& parameters) { } // Calculate two matrices for this tile: matrix is the standard tile matrix; nearClippedMatrix - // clips the near plane to 100 to save depth buffer precision + // has near plane moved further, to enhance depth buffer precision parameters.state.matrixFor(matrix, id); parameters.state.matrixFor(nearClippedMatrix, id); matrix::multiply(matrix, parameters.projMatrix, matrix); diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index ad9fe1f43a..d4757fd31f 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -398,8 +398,15 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { *lineAtlas, }; + auto opaquePassCutoffEstimation = renderItems.size(); for (auto& renderItem : renderItems) { RenderLayer& renderLayer = renderItem.layer; + if (parameters.opaquePassCutoff == 0) { + --opaquePassCutoffEstimation; + if (renderLayer.is3D()) { + parameters.opaquePassCutoff = uint32_t(opaquePassCutoffEstimation); + } + } if (renderLayer.hasRenderPass(RenderPass::Upload)) { renderLayer.upload(*uploadPass, uploadParameters); } |