[core] ensure gfx::DrawScopes are unique
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user