[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:
John Firebaugh
2017-07-06 08:06:12 -07:00
parent d7bdc7a60d
commit de91e68090
13 changed files with 59 additions and 26 deletions

View File

@@ -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,