[core] Per-segment-per-layer vertex arrays
Reduces rebinding, matches gl-js, and works around the buggy VAO implementation on PowerVR SGX544 GPUs.
This commit is contained in:
@@ -58,7 +58,8 @@ public:
|
||||
const SegmentVector<Attributes>& segments,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const typename PaintProperties::Evaluated& currentProperties,
|
||||
float currentZoom) {
|
||||
float currentZoom,
|
||||
const std::string& layerID) {
|
||||
typename AllUniforms::Values allUniformValues = uniformValues
|
||||
.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
|
||||
@@ -66,8 +67,10 @@ public:
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
|
||||
for (auto& segment : segments) {
|
||||
if (!segment.vertexArray) {
|
||||
segment.vertexArray = context.createVertexArray();
|
||||
optional<gl::VertexArray>& vertexArray = segment.vertexArrays[layerID];
|
||||
|
||||
if (!vertexArray) {
|
||||
vertexArray = context.createVertexArray();
|
||||
}
|
||||
|
||||
program.draw(
|
||||
@@ -77,7 +80,7 @@ public:
|
||||
std::move(stencilMode),
|
||||
std::move(colorMode),
|
||||
allUniformValues,
|
||||
*segment.vertexArray,
|
||||
*vertexArray,
|
||||
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
|
||||
indexBuffer,
|
||||
segment.indexOffset,
|
||||
|
||||
@@ -28,7 +28,14 @@ public:
|
||||
std::size_t vertexLength;
|
||||
std::size_t indexLength;
|
||||
|
||||
mutable optional<gl::VertexArray> vertexArray;
|
||||
// One VertexArray per layer ID. This minimizes rebinding in cases where
|
||||
// several layers share buckets but have different sets of active attributes.
|
||||
// This can happen:
|
||||
// * when two layers have the same layout properties, but differing
|
||||
// data-driven paint properties
|
||||
// * when two fill layers have the same layout properties, but one
|
||||
// uses fill-color and the other uses fill-pattern
|
||||
mutable std::map<std::string, optional<gl::VertexArray>> vertexArrays;
|
||||
};
|
||||
|
||||
template <class Attributes>
|
||||
|
||||
@@ -360,7 +360,8 @@ public:
|
||||
const SegmentVector<Attributes>& segments,
|
||||
const PaintPropertyBinders& paintPropertyBinders,
|
||||
const typename PaintProperties::Evaluated& currentProperties,
|
||||
float currentZoom) {
|
||||
float currentZoom,
|
||||
const std::string& layerID) {
|
||||
typename AllUniforms::Values allUniformValues = uniformValues
|
||||
.concat(symbolSizeBinder.uniformValues(currentZoom))
|
||||
.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
@@ -370,8 +371,10 @@ public:
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
|
||||
for (auto& segment : segments) {
|
||||
if (!segment.vertexArray) {
|
||||
segment.vertexArray = context.createVertexArray();
|
||||
optional<gl::VertexArray>& vertexArray = segment.vertexArrays[layerID];
|
||||
|
||||
if (!vertexArray) {
|
||||
vertexArray = context.createVertexArray();
|
||||
}
|
||||
|
||||
program.draw(
|
||||
@@ -381,7 +384,7 @@ public:
|
||||
std::move(stencilMode),
|
||||
std::move(colorMode),
|
||||
allUniformValues,
|
||||
*segment.vertexArray,
|
||||
*vertexArray,
|
||||
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
|
||||
indexBuffer,
|
||||
segment.indexOffset,
|
||||
|
||||
@@ -353,16 +353,23 @@ void Painter::renderPass(PaintParameters& parameters,
|
||||
const PaintProperties<>::Evaluated properties{};
|
||||
|
||||
parameters.programs.extrusionTexture.draw(
|
||||
context, gl::Triangles(), gl::DepthMode::disabled(), gl::StencilMode::disabled(),
|
||||
context,
|
||||
gl::Triangles(),
|
||||
gl::DepthMode::disabled(),
|
||||
gl::StencilMode::disabled(),
|
||||
colorModeForRenderPass(),
|
||||
ExtrusionTextureProgram::UniformValues{
|
||||
uniforms::u_matrix::Value{ viewportMat }, uniforms::u_world::Value{ size },
|
||||
uniforms::u_image::Value{ 0 },
|
||||
uniforms::u_opacity::Value{ layer.as<RenderFillExtrusionLayer>()
|
||||
->evaluated.get<FillExtrusionOpacity>() } },
|
||||
extrusionTextureVertexBuffer, quadTriangleIndexBuffer, extrusionTextureSegments,
|
||||
ExtrusionTextureProgram::PaintPropertyBinders{ properties, 0 }, properties,
|
||||
state.getZoom());
|
||||
extrusionTextureVertexBuffer,
|
||||
quadTriangleIndexBuffer,
|
||||
extrusionTextureSegments,
|
||||
ExtrusionTextureProgram::PaintPropertyBinders{ properties, 0 },
|
||||
properties,
|
||||
state.getZoom(),
|
||||
layer.getID());
|
||||
} else {
|
||||
for (auto& tileRef : item.tiles) {
|
||||
auto& tile = tileRef.get();
|
||||
|
||||
@@ -53,7 +53,8 @@ void Painter::renderBackground(PaintParameters& parameters, const RenderBackgrou
|
||||
tileTriangleSegments,
|
||||
paintAttibuteData,
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -73,7 +74,8 @@ void Painter::renderBackground(PaintParameters& parameters, const RenderBackgrou
|
||||
tileTriangleSegments,
|
||||
paintAttibuteData,
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ void Painter::renderCircle(PaintParameters& parameters,
|
||||
bucket.segments,
|
||||
bucket.paintPropertyBinders.at(layer.getID()),
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ void Painter::renderClippingMask(const UnwrappedTileID& tileID, const ClipID& cl
|
||||
tileTriangleSegments,
|
||||
paintAttibuteData,
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
"clipping"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ void Painter::renderTileDebug(const RenderTile& renderTile) {
|
||||
segments,
|
||||
paintAttibuteData,
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
"debug"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
segments,
|
||||
bucket.paintPropertyBinders.at(layer.getID()),
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
};
|
||||
|
||||
@@ -104,7 +105,8 @@ void Painter::renderFill(PaintParameters& parameters,
|
||||
segments,
|
||||
bucket.paintPropertyBinders.at(layer.getID()),
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ void Painter::renderFillExtrusion(PaintParameters& parameters,
|
||||
bucket.triangleSegments,
|
||||
bucket.paintPropertyBinders.at(layer.getID()),
|
||||
properties,
|
||||
state.getZoom());
|
||||
state.getZoom(),
|
||||
layer.getID());
|
||||
|
||||
} else {
|
||||
parameters.programs.fillExtrusion.get(properties).draw(
|
||||
@@ -80,7 +81,8 @@ void Painter::renderFillExtrusion(PaintParameters& parameters,
|
||||
bucket.triangleSegments,
|
||||
bucket.paintPropertyBinders.at(layer.getID()),
|
||||
properties,
|
||||
state.getZoom());
|
||||
state.getZoom(),
|
||||
layer.getID());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ void Painter::renderLine(PaintParameters& parameters,
|
||||
bucket.segments,
|
||||
bucket.paintPropertyBinders.at(layer.getID()),
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -81,7 +81,8 @@ void Painter::renderRaster(PaintParameters& parameters,
|
||||
rasterSegments,
|
||||
paintAttributeData,
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,8 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
buffers.segments,
|
||||
binders,
|
||||
paintProperties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
};
|
||||
|
||||
@@ -156,7 +157,8 @@ void Painter::renderSymbol(PaintParameters& parameters,
|
||||
bucket.collisionBox.segments,
|
||||
paintAttributeData,
|
||||
properties,
|
||||
state.getZoom()
|
||||
state.getZoom(),
|
||||
layer.getID()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user