Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Sort cross-tile symbol segments using symbol-sort-key
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshalamov committed Apr 17, 2019
1 parent 2a169b0 commit 113e96e
Show file tree
Hide file tree
Showing 3 changed files with 422 additions and 285 deletions.
78 changes: 56 additions & 22 deletions src/mbgl/programs/symbol_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,48 @@ class SymbolProgram : public SymbolProgramBase {
return allAttributeBindings.activeCount();
}

template <class DrawMode>
void draw(gfx::Context& context,
gfx::RenderPass& renderPass,
const DrawMode& drawMode,
const gfx::DepthMode& depthMode,
const gfx::StencilMode& stencilMode,
const gfx::ColorMode& colorMode,
const gfx::CullFaceMode& cullFaceMode,
const gfx::IndexBuffer& indexBuffer,
const Segment<AttributeList>& segment,
const UniformValues& uniformValues,
const AttributeBindings& allAttributeBindings,
const TextureBindings& textureBindings,
const std::string& layerID) {
static_assert(Primitive == gfx::PrimitiveTypeOf<DrawMode>::value, "incompatible draw mode");

if (!program) {
return;
}

auto drawScopeIt = segment.drawScopes.find(layerID);
if (drawScopeIt == segment.drawScopes.end()) {
drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first;
}

program->draw(
context,
renderPass,
drawMode,
depthMode,
stencilMode,
colorMode,
cullFaceMode,
uniformValues,
drawScopeIt->second,
allAttributeBindings.offset(segment.vertexOffset),
textureBindings,
indexBuffer,
segment.indexOffset,
segment.indexLength);
}

template <class DrawMode>
void draw(gfx::Context& context,
gfx::RenderPass& renderPass,
Expand All @@ -318,28 +360,20 @@ class SymbolProgram : public SymbolProgramBase {
return;
}

for (auto& segment : segments) {
auto drawScopeIt = segment.drawScopes.find(layerID);

if (drawScopeIt == segment.drawScopes.end()) {
drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first;
}

program->draw(
context,
renderPass,
drawMode,
depthMode,
stencilMode,
colorMode,
cullFaceMode,
uniformValues,
drawScopeIt->second,
allAttributeBindings.offset(segment.vertexOffset),
textureBindings,
indexBuffer,
segment.indexOffset,
segment.indexLength);
for (const auto& segment : segments) {
draw(context,
renderPass,
drawMode,
depthMode,
stencilMode,
colorMode,
cullFaceMode,
indexBuffer,
segment,
uniformValues,
allAttributeBindings,
textureBindings,
layerID);
}
}
};
Expand Down
Loading

0 comments on commit 113e96e

Please sign in to comment.