summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-04-02 14:11:37 +0200
committerKonstantin Käfer <mail@kkaefer.com>2019-05-28 16:11:05 +0200
commit12d8948c2a94df752edfcd492a8c256f65908c5c (patch)
treedfb8b503d1e63551ad2a5733717ad3a2f60d5fe2 /src
parente52ce34fb578e2c9f9f61fcea11e1ebb2251b6f4 (diff)
downloadqtlocation-mapboxgl-12d8948c2a94df752edfcd492a8c256f65908c5c.tar.gz
[core] ensure gfx::DrawScopes are unique
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/layers/render_background_layer.cpp10
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp25
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.cpp3
3 files changed, 22 insertions, 16 deletions
diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp
index 37386c2532..818b458145 100644
--- a/src/mbgl/renderer/layers/render_background_layer.cpp
+++ b/src/mbgl/renderer/layers/render_background_layer.cpp
@@ -68,7 +68,7 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) {
const Properties<>::PossiblyEvaluated properties;
const BackgroundProgram::Binders paintAttributeData(properties, 0);
- auto draw = [&](auto& program, auto&& uniformValues, const auto& textureBindings) {
+ auto draw = [&](auto& program, auto&& uniformValues, const auto& textureBindings, const UnwrappedTileID& id) {
const auto allUniformValues = program.computeAllUniformValues(
std::move(uniformValues),
paintAttributeData,
@@ -96,7 +96,7 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) {
allUniformValues,
allAttributeBindings,
textureBindings,
- getID()
+ getID() + "/" + util::toString(id)
);
};
const auto& evaluated = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).evaluated;
@@ -123,7 +123,8 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) {
),
BackgroundPatternProgram::TextureBindings{
textures::image::Value{ parameters.imageManager.textureBinding() },
- }
+ },
+ tileID
);
}
} else {
@@ -135,7 +136,8 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) {
uniforms::color::Value( evaluated.get<BackgroundColor>() ),
uniforms::opacity::Value( evaluated.get<BackgroundOpacity>() ),
},
- BackgroundProgram::TextureBindings{}
+ BackgroundProgram::TextureBindings{},
+ tileID
);
}
}
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
index 88c2edc1c2..6355479193 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
@@ -77,7 +77,8 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
const auto& uniformValues,
const optional<ImagePosition>& patternPositionA,
const optional<ImagePosition>& patternPositionB,
- const auto& textureBindings) {
+ const auto& textureBindings,
+ const std::string& uniqueName) {
const auto& paintPropertyBinders = tileBucket.paintPropertyBinders.at(getID());
paintPropertyBinders.setPatternParameters(patternPositionA, patternPositionB, crossfade_);
@@ -108,12 +109,12 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
allUniformValues,
allAttributeBindings,
textureBindings,
- getID());
+ getID() + "/" + uniqueName);
};
if (unevaluated.get<FillExtrusionPattern>().isUndefined()) {
// Draw solid color extrusions
- auto drawTiles = [&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_) {
+ auto drawTiles = [&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_, const std::string& name) {
for (const RenderTile& tile : renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
if (!renderData) {
@@ -137,28 +138,29 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
),
{},
{},
- FillExtrusionProgram::TextureBindings{}
+ FillExtrusionProgram::TextureBindings{},
+ name
);
}
};
if (evaluated.get<FillExtrusionOpacity>() == 1) {
// Draw opaque extrusions
- drawTiles(gfx::StencilMode::disabled(), parameters.colorModeForRenderPass());
+ drawTiles(gfx::StencilMode::disabled(), parameters.colorModeForRenderPass(), "color");
} else {
// Draw transparent buildings in two passes so that only the closest surface is drawn.
// First draw all the extrusions into only the depth buffer. No colors are drawn.
- drawTiles(gfx::StencilMode::disabled(), gfx::ColorMode::disabled());
+ drawTiles(gfx::StencilMode::disabled(), gfx::ColorMode::disabled(), "depth");
// Then draw all the extrusions a second time, only coloring fragments if they have the
// same depth value as the closest fragment in the previous pass. Use the stencil buffer
// to prevent the second draw in cases where we have coincident polygons.
- drawTiles(parameters.stencilModeFor3D(), parameters.colorModeForRenderPass());
+ drawTiles(parameters.stencilModeFor3D(), parameters.colorModeForRenderPass(), "color");
}
} else {
// Draw textured extrusions
const auto fillPatternValue = evaluated.get<FillExtrusionPattern>().constantOr(mbgl::Faded<std::basic_string<char> >{"", ""});
- auto drawTiles = [&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_) {
+ auto drawTiles = [&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_, const std::string& name) {
for (const RenderTile& tile : renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
if (!renderData) {
@@ -192,19 +194,20 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
patternPosB,
FillExtrusionPatternProgram::TextureBindings{
textures::image::Value{ tile.getIconAtlasTexture().getResource(), gfx::TextureFilterType::Linear },
- }
+ },
+ name
);
}
};
// Draw transparent buildings in two passes so that only the closest surface is drawn.
// First draw all the extrusions into only the depth buffer. No colors are drawn.
- drawTiles(gfx::StencilMode::disabled(), gfx::ColorMode::disabled());
+ drawTiles(gfx::StencilMode::disabled(), gfx::ColorMode::disabled(), "depth");
// Then draw all the extrusions a second time, only coloring fragments if they have the
// same depth value as the closest fragment in the previous pass. Use the stencil buffer
// to prevent the second draw in cases where we have coincident polygons.
- drawTiles(parameters.stencilModeFor3D(), parameters.colorModeForRenderPass());
+ drawTiles(parameters.stencilModeFor3D(), parameters.colorModeForRenderPass(), "color");
}
}
diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp
index af9022189a..9811899d83 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.cpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.cpp
@@ -146,6 +146,7 @@ void RenderRasterLayer::render(PaintParameters& parameters) {
RasterBucket& bucket = *imageData->bucket;
assert(bucket.texture);
+ size_t i = 0;
for (const auto& matrix_ : *imageData->matrices) {
draw(matrix_,
*bucket.vertexBuffer,
@@ -155,7 +156,7 @@ void RenderRasterLayer::render(PaintParameters& parameters) {
textures::image0::Value{ bucket.texture->getResource(), filter },
textures::image1::Value{ bucket.texture->getResource(), filter },
},
- bucket.drawScopeID);
+ bucket.drawScopeID + std::to_string(i++));
}
} else {
for (const RenderTile& tile : renderTiles) {