summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-07-19 10:16:14 +0300
committerAleksandar Stojiljkovic <aleksandar.stojiljkovic@mapbox.com>2019-07-19 14:01:30 +0300
commit97cd09c45799fd356ff1f71216039f9024a317b5 (patch)
treeeedbdfb476e94db9eafb577e31c9882bd9ccb62a
parent5f38438074e5eefd5ce4ac95c1ed8f5d2216d233 (diff)
downloadqtlocation-mapboxgl-upstream/astojilj-cp-oolong-15065.tar.gz
[core][cp] Backport #15065 to oolongupstream/astojilj-cp-oolong-15065
-rw-r--r--platform/node/test/ignores.json18
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp4
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp1
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.cpp9
-rw-r--r--src/mbgl/renderer/paint_parameters.cpp12
-rw-r--r--src/mbgl/renderer/paint_parameters.hpp3
-rw-r--r--src/mbgl/renderer/render_layer.hpp3
-rw-r--r--src/mbgl/renderer/render_tile.cpp2
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp7
9 files changed, 29 insertions, 30 deletions
diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json
index b3fb4b5a51..99aa481257 100644
--- a/platform/node/test/ignores.json
+++ b/platform/node/test/ignores.json
@@ -88,25 +88,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/vector-source": "https://github.com/mapbox/mapbox-gl-native/issues/12613",
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
index b8f7938721..7d3a226370 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) {
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 9118601581..8bd1f52adf 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&) override;
bool queryIntersectsFeature(
diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp
index e63fcf3325..fa774ce29a 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.cpp
@@ -129,11 +129,10 @@ void RenderFillLayer::render(PaintParameters& parameters) {
);
};
- // 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 (bucket.triangleIndexBuffer &&
- (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 (bucket.triangleIndexBuffer && 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 badd60a53e..1d4eb412ed 100644
--- a/src/mbgl/renderer/paint_parameters.cpp
+++ b/src/mbgl/renderer/paint_parameters.cpp
@@ -19,10 +19,11 @@ TransformParameters::TransformParameters(const TransformState& state_)
// 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());
}
PaintParameters::PaintParameters(gfx::Context& context_,
@@ -70,6 +71,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 depth = depthRangeSize + ((1 + currentLayer) * numSublayers + n) * depthEpsilon;
return gfx::DepthMode { gfx::DepthFunctionType::LessEqual, mask, { depth, depth } };
}
diff --git a/src/mbgl/renderer/paint_parameters.hpp b/src/mbgl/renderer/paint_parameters.hpp
index 89084e9e52..2d52820e44 100644
--- a/src/mbgl/renderer/paint_parameters.hpp
+++ b/src/mbgl/renderer/paint_parameters.hpp
@@ -102,8 +102,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 a452d073f3..a386c1f5e3 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -66,6 +66,9 @@ public:
// Returns true is the layer is subject to placement.
bool needsPlacement() 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 f1f6a4ac45..74a92515a3 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -121,7 +121,7 @@ void RenderTile::prepare(const SourcePrepareParameters& 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
const auto& transform = parameters.transform;
transform.state.matrixFor(matrix, id);
transform.state.matrixFor(nearClippedMatrix, id);
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index 1424c5b238..5ac77978b1 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -391,8 +391,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);
}