Share identical uniform buffers across drawables for background, line. (#1346)
This commit is contained in:
committed by
Bart Louwers
parent
3056f28756
commit
4eef2e3529
@@ -399,25 +399,25 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
/* .padding = */ 0,
|
||||
0};
|
||||
|
||||
// TODO: only update if properties re-evaluated?
|
||||
const FillDrawableTilePropsUBO tileProps = {
|
||||
/* pattern_from = */ patternPosA ? util::cast<float>(patternPosA->tlbr()) : std::array<float, 4>{0},
|
||||
/* pattern_to = */ patternPosB ? util::cast<float>(patternPosB->tlbr()) : std::array<float, 4>{0},
|
||||
};
|
||||
|
||||
// If we already have drawables for this tile, update them.
|
||||
if (tileLayerGroup->getDrawableCount(renderPass, tileID) > 0) {
|
||||
// TODO: Share buffers
|
||||
tileLayerGroup->observeDrawables(renderPass, tileID, [&](gfx::Drawable& drawable) {
|
||||
drawable.mutableUniformBuffers().createOrUpdate(
|
||||
FillLayerTweaker::FillInterpolateUBOName, &interpolateUBO, context);
|
||||
drawable.mutableUniformBuffers().createOrUpdate(
|
||||
FillLayerTweaker::FillTilePropsUBOName, &tileProps, context);
|
||||
});
|
||||
|
||||
auto updateExisting = [&](gfx::Drawable& drawable) {
|
||||
auto& uniforms = drawable.mutableUniformBuffers();
|
||||
uniforms.createOrUpdate(FillLayerTweaker::FillInterpolateUBOName, &interpolateUBO, context);
|
||||
uniforms.createOrUpdate(FillLayerTweaker::FillTilePropsUBOName, &tileProps, context);
|
||||
};
|
||||
if (0 < tileLayerGroup->observeDrawables(renderPass, tileID, std::move(updateExisting))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Share UBO buffers among any drawables created for this tile
|
||||
const auto interpBuffer = context.createUniformBuffer(&interpolateUBO, sizeof(interpolateUBO));
|
||||
const auto tilePropsBuffer = context.createUniformBuffer(&tileProps, sizeof(tileProps));
|
||||
|
||||
// `Fill*Program` all use `style::FillPaintProperties`
|
||||
gfx::VertexAttributeArray vertexAttrs;
|
||||
const auto uniformProps =
|
||||
|
||||
Reference in New Issue
Block a user