Global UBO (#2292)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Alex Cristici
2024-04-24 17:14:18 +03:00
committed by GitHub
parent 54a07f4b9c
commit d22362ab22
115 changed files with 966 additions and 659 deletions

View File

@@ -486,6 +486,29 @@ bool Context::emplaceOrUpdateUniformBuffer(gfx::UniformBufferPtr& buffer,
return true;
}
}
void Context::bindGlobalUniformBuffers(gfx::RenderPass&) const noexcept {
for (size_t id = 0; id < globalUniformBuffers.allocatedSize(); id++) {
const auto& globalUniformBuffer = globalUniformBuffers.get(id);
if (!globalUniformBuffer) continue;
GLint binding = static_cast<GLint>(id);
const auto& uniformBufferGL = static_cast<const UniformBufferGL&>(*globalUniformBuffer);
MBGL_CHECK_ERROR(glBindBufferRange(GL_UNIFORM_BUFFER,
binding,
uniformBufferGL.getID(),
uniformBufferGL.getManagedBuffer().getBindingOffset(),
uniformBufferGL.getSize()));
}
}
void Context::unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept {
for (size_t id = 0; id < globalUniformBuffers.allocatedSize(); id++) {
const auto& globalUniformBuffer = globalUniformBuffers.get(id);
if (!globalUniformBuffer) continue;
GLint binding = static_cast<GLint>(id);
MBGL_CHECK_ERROR(glBindBufferBase(GL_UNIFORM_BUFFER, binding, 0));
}
}
#endif
void Context::setDirtyState() {

View File

@@ -19,6 +19,7 @@
#include <mbgl/gl/fence.hpp>
#include <mbgl/gl/buffer_allocator.hpp>
#include <mbgl/gfx/texture2d.hpp>
#include <mbgl/gl/uniform_buffer_gl.hpp>
#endif
#include <array>
@@ -134,6 +135,18 @@ public:
const void* data,
std::size_t size,
bool persistent) override;
/// Get the global uniform buffers
const gfx::UniformBufferArray& getGlobalUniformBuffers() const override { return globalUniformBuffers; };
/// Get the mutable global uniform buffer array
gfx::UniformBufferArray& mutableGlobalUniformBuffers() override { return globalUniformBuffers; };
/// Bind the global uniform buffers
void bindGlobalUniformBuffers(gfx::RenderPass&) const noexcept override;
/// Unbind the global uniform buffers
void unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept override;
#endif
void setDirtyState() override;
@@ -147,6 +160,7 @@ private:
std::shared_ptr<gl::Fence> frameInFlightFence;
std::unique_ptr<gl::UniformBufferAllocator> uboAllocator;
size_t frameNum = 0;
UniformBufferArrayGL globalUniformBuffers;
#endif
public:

View File

@@ -55,6 +55,10 @@ Context::~Context() noexcept {
clipMaskUniformsBuffer.reset();
stencilStateRenderable = nullptr;
for (size_t i = 0; i < globalUniformBuffers.allocatedSize(); i++) {
globalUniformBuffers.set(i, nullptr);
}
#if !defined(NDEBUG)
Log::Debug(Event::General, "Rendering Stats:\n" + stats.toString("\n"));
#endif
@@ -607,5 +611,17 @@ MTLDepthStencilStatePtr Context::makeDepthStencilState(const gfx::DepthMode& dep
return NS::TransferPtr(device->newDepthStencilState(depthStencilDescriptor.get()));
}
void Context::bindGlobalUniformBuffers(gfx::RenderPass& renderPass) const noexcept {
for (size_t id = 0; id < globalUniformBuffers.allocatedSize(); id++) {
const auto& globalUniformBuffer = globalUniformBuffers.get(id);
if (!globalUniformBuffer) continue;
const auto& buffer = static_cast<UniformBuffer&>(*globalUniformBuffer.get());
const auto& resource = buffer.getBufferResource();
auto& mtlRenderPass = static_cast<RenderPass&>(renderPass);
mtlRenderPass.bindVertex(resource, 0, id);
mtlRenderPass.bindFragment(resource, 0, id);
}
}
} // namespace mtl
} // namespace mbgl

View File

@@ -53,22 +53,16 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintPara
auto& layerUniforms = layerGroup.mutableUniformBuffers();
if (hasPattern) {
const Size atlasSize = parameters.patternAtlas.getPixelSize();
const BackgroundPatternLayerUBO layerUBO = {
/* .pattern_tl_a = */ util::cast<float>(imagePosA->tl()),
/* .pattern_br_a = */ util::cast<float>(imagePosA->br()),
/* .pattern_tl_b = */ util::cast<float>(imagePosB->tl()),
/* .pattern_br_b = */ util::cast<float>(imagePosB->br()),
/* .texsize = */ {static_cast<float>(atlasSize.width), static_cast<float>(atlasSize.height)},
/* .pattern_size_a = */ imagePosA->displaySize(),
/* .pattern_size_b = */ imagePosB->displaySize(),
/* .scale_a = */ crossfade.fromScale,
/* .scale_b = */ crossfade.toScale,
/* .mix = */ crossfade.t,
/* .opacity = */ evaluated.get<BackgroundOpacity>(),
/* .pad1/2 = */ 0,
0};
const BackgroundPatternLayerUBO layerUBO = {/* .pattern_tl_a = */ util::cast<float>(imagePosA->tl()),
/* .pattern_br_a = */ util::cast<float>(imagePosA->br()),
/* .pattern_tl_b = */ util::cast<float>(imagePosB->tl()),
/* .pattern_br_b = */ util::cast<float>(imagePosB->br()),
/* .pattern_size_a = */ imagePosA->displaySize(),
/* .pattern_size_b = */ imagePosB->displaySize(),
/* .scale_a = */ crossfade.fromScale,
/* .scale_b = */ crossfade.toScale,
/* .mix = */ crossfade.t,
/* .opacity = */ evaluated.get<BackgroundOpacity>()};
layerUniforms.createOrUpdate(idBackgroundLayerUBO, &layerUBO, context);
} else {
const BackgroundLayerUBO layerUBO = {/* .color = */ evaluated.get<BackgroundColor>(),

View File

@@ -34,16 +34,6 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
const auto debugGroup = parameters.encoder->createDebugGroup(label.c_str());
#endif
// Updated every frame, but shared across drawables
const CirclePaintParamsUBO paintParamsUBO = {
/* .camera_to_center_distance = */ parameters.state.getCameraToCenterDistance(),
/* .padding = */ 0,
0,
0};
auto& layerUniforms = layerGroup.mutableUniformBuffers();
layerUniforms.createOrUpdate(idCirclePaintParamsUBO, &paintParamsUBO, context);
const auto zoom = parameters.state.getZoom();
const bool pitchWithMap = evaluated.get<CirclePitchAlignment>() == AlignmentType::Map;
const bool scaleWithMap = evaluated.get<CirclePitchScale>() == CirclePitchScaleType::Map;
@@ -64,6 +54,7 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &evaluatedPropsUBO);
propertiesUpdated = false;
}
auto& layerUniforms = layerGroup.mutableUniformBuffers();
layerUniforms.set(idCircleEvaluatedPropsUBO, evaluatedPropsUniformBuffer);
visitLayerGroupDrawables(layerGroup, [&](gfx::Drawable& drawable) {

View File

@@ -61,8 +61,8 @@ void CollisionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParam
const CollisionUBO drawableUBO = {
/*.matrix=*/util::cast<float>(matrix),
/*.extrude_scale*/ extrudeScale,
/*.camera_to_center_distance*/ parameters.state.getCameraToCenterDistance(),
/*.overscale_factor*/ static_cast<float>(drawable.getTileID()->overscaleFactor())};
/*.overscale_factor*/ static_cast<float>(drawable.getTileID()->overscaleFactor()),
/*.pad*/ 0};
auto& drawableUniforms = drawable.mutableUniformBuffers();
drawableUniforms.createOrUpdate(idCollisionUBO, &drawableUBO, context);

View File

@@ -54,9 +54,9 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP
/* .vertical_gradient = */ evaluated.get<FillExtrusionVerticalGradient>() ? 1.0f : 0.0f,
/* .opacity = */ evaluated.get<FillExtrusionOpacity>(),
/* .fade = */ crossfade.t,
/* .pad = */ 0,
0,
0};
/* .from_scale = */ crossfade.fromScale,
/* .to_scale = */ crossfade.toScale,
/* .pad = */ 0};
auto& layerUniforms = layerGroup.mutableUniformBuffers();
layerUniforms.createOrUpdate(idFillExtrusionPropsUBO, &propsUBO, context);
@@ -82,7 +82,6 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP
const auto pixelX = static_cast<int32_t>(tileSizeAtNearestZoom *
(tileID.canonical.x + tileID.wrap * zoomScale));
const auto pixelY = static_cast<int32_t>(tileSizeAtNearestZoom * tileID.canonical.y);
const auto pixelRatio = parameters.pixelRatio;
const auto numTiles = std::pow(2, tileID.canonical.z);
const auto heightFactor = static_cast<float>(-numTiles / util::tileSize_D / 8.0);
@@ -93,12 +92,11 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP
const FillExtrusionDrawableUBO drawableUBO = {
/* .matrix = */ util::cast<float>(matrix),
/* .scale = */ {pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale},
/* .texsize = */ {static_cast<float>(textureSize.width), static_cast<float>(textureSize.height)},
/* .pixel_coord_upper = */ {static_cast<float>(pixelX >> 16), static_cast<float>(pixelY >> 16)},
/* .pixel_coord_lower = */ {static_cast<float>(pixelX & 0xFFFF), static_cast<float>(pixelY & 0xFFFF)},
/* .height_factor = */ heightFactor,
/* .pad = */ 0};
/* .tile_ratio = */ tileRatio};
auto& drawableUniforms = drawable.mutableUniformBuffers();
drawableUniforms.createOrUpdate(idFillExtrusionDrawableUBO, &drawableUBO, context);

View File

@@ -46,8 +46,8 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
/* .outline_color = */ evaluated.get<FillOutlineColor>().constantOr(FillOutlineColor::defaultValue()),
/* .opacity = */ evaluated.get<FillOpacity>().constantOr(FillOpacity::defaultValue()),
/* .fade = */ crossfade.t,
/* .width = */ 1.f,
0,
/* .from_scale = */ crossfade.fromScale,
/* .to_scale = */ crossfade.toScale,
};
context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &propsUBO);
propertiesUpdated = false;
@@ -57,10 +57,7 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
const auto& translation = evaluated.get<FillTranslate>();
const auto anchor = evaluated.get<FillTranslateAnchor>();
const auto renderableSize = parameters.backend.getDefaultRenderable().getSize();
const auto intZoom = parameters.state.getIntegerZoom();
const auto pixelRatio = parameters.pixelRatio;
visitLayerGroupDrawables(layerGroup, [&](gfx::Drawable& drawable) {
if (!drawable.getTileID() || !checkTweakDrawable(drawable)) {
@@ -97,22 +94,17 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
break;
}
case RenderFillLayer::FillVariant::FillOutline: {
const FillOutlineDrawableUBO drawableUBO = {
/*.matrix=*/util::cast<float>(matrix),
/*.world=*/{(float)renderableSize.width, (float)renderableSize.height},
/* pad1 */ 0,
/* pad2 */ 0};
const FillOutlineDrawableUBO drawableUBO = {/*.matrix=*/util::cast<float>(matrix)};
drawableUniforms.createOrUpdate(idFillDrawableUBO, &drawableUBO, context);
break;
}
case RenderFillLayer::FillVariant::FillPattern: {
const FillPatternDrawableUBO drawableUBO = {
/*.matrix=*/util::cast<float>(matrix),
/*.scale=*/{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale},
/*.pixel_coord_upper=*/{static_cast<float>(pixelX >> 16), static_cast<float>(pixelY >> 16)},
/*.pixel_coord_lower=*/{static_cast<float>(pixelX & 0xFFFF), static_cast<float>(pixelY & 0xFFFF)},
/*.texsize=*/{static_cast<float>(textureSize.width), static_cast<float>(textureSize.height)},
0,
/*.tile_ratio = */ tileRatio,
0,
};
drawableUniforms.createOrUpdate(idFillDrawableUBO, &drawableUBO, context);
@@ -121,20 +113,20 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
case RenderFillLayer::FillVariant::FillOutlinePattern: {
const FillOutlinePatternDrawableUBO drawableUBO = {
/*.matrix=*/util::cast<float>(matrix),
/*.scale=*/{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale},
/*.world=*/{(float)renderableSize.width, (float)renderableSize.height},
/*.pixel_coord_upper=*/{static_cast<float>(pixelX >> 16), static_cast<float>(pixelY >> 16)},
/*.pixel_coord_lower=*/{static_cast<float>(pixelX & 0xFFFF), static_cast<float>(pixelY & 0xFFFF)},
/*.texsize=*/{static_cast<float>(textureSize.width), static_cast<float>(textureSize.height)},
};
/*.tile_ratio = */ tileRatio,
0};
drawableUniforms.createOrUpdate(idFillDrawableUBO, &drawableUBO, context);
break;
}
case RenderFillLayer::FillVariant::FillOutlineTriangulated: {
const FillOutlineTriangulatedDrawableUBO drawableUBO = {
/*.matrix=*/util::cast<float>(matrix),
/*.units_to_pixels=*/{1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
/*.ratio=*/1.0f / tileID.pixelsToTileUnits(1.0f, parameters.state.getZoom()),
0,
0,
0};
drawableUniforms.createOrUpdate(idFillDrawableUBO, &drawableUBO, context);
break;

View File

@@ -29,15 +29,15 @@ void HeatmapTextureLayerTweaker::execute(LayerGroupBase& layerGroup, const Paint
propertiesUpdated = false;
mat4 matrix;
const auto& size = parameters.staticData.backendSize;
mat4 viewportMat;
matrix::ortho(viewportMat, 0, size.width, size.height, 0, -1, 1);
const HeatmapTexturePropsUBO propsUBO = {
/* .matrix = */ util::cast<float>(viewportMat),
/* .world = */ {static_cast<float>(size.width), static_cast<float>(size.height)},
/* .opacity = */ evaluated.get<HeatmapOpacity>(),
/* .pad1 = */ 0,
};
matrix::ortho(matrix, 0, size.width, size.height, 0, -1, 1);
const HeatmapTexturePropsUBO propsUBO = {/* .matrix = */ util::cast<float>(matrix),
/* .opacity = */ evaluated.get<HeatmapOpacity>(),
/* .pad1,2,3 = */ 0,
0,
0};
auto& layerUniforms = layerGroup.mutableUniformBuffers();
layerUniforms.createOrUpdate(idHeatmapTexturePropsUBO, &propsUBO, parameters.context);
}

View File

@@ -44,12 +44,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &propsUBO);
propertiesUpdated = false;
}
const LineDynamicUBO dynamicUBO = {
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, 0, 0};
auto& layerUniforms = layerGroup.mutableUniformBuffers();
layerUniforms.createOrUpdate(idLineDynamicUBO, &dynamicUBO, context);
layerUniforms.set(idLineEvaluatedPropsUBO, evaluatedPropsUniformBuffer);
visitLayerGroupDrawables(layerGroup, [&](gfx::Drawable& drawable) {

View File

@@ -72,18 +72,10 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &propsUBO);
propertiesUpdated = false;
}
const auto camDist = state.getCameraToCenterDistance();
const SymbolDynamicUBO dynamicUBO = {/*.fade_change=*/parameters.symbolFadeChange,
/*.camera_to_center_distance=*/camDist,
/*.aspect_ratio=*/state.getSize().aspectRatio(),
0};
auto& layerUniforms = layerGroup.mutableUniformBuffers();
layerUniforms.createOrUpdate(idSymbolDynamicUBO, &dynamicUBO, context);
layerUniforms.set(idSymbolEvaluatedPropsUBO, evaluatedPropsUniformBuffer);
const auto camDist = state.getCameraToCenterDistance();
visitLayerGroupDrawables(layerGroup, [&](gfx::Drawable& drawable) {
if (!drawable.getTileID() || !drawable.getData()) {
return;

View File

@@ -247,6 +247,21 @@ void Renderer::Impl::render(const RenderTree& renderTree,
// Upload the Debug layer group
orchestrator.visitDebugLayerGroups([&](LayerGroupBase& layerGroup) { layerGroup.upload(*uploadPass); });
}
const Size atlasSize = parameters.patternAtlas.getPixelSize();
const auto& worldSize = parameters.staticData.backendSize;
const shaders::GlobalPaintParamsUBO globalPaintParamsUBO = {
/* .pattern_atlas_texsize = */ {static_cast<float>(atlasSize.width), static_cast<float>(atlasSize.height)},
/* .units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
/* .world_size = */ {static_cast<float>(worldSize.width), static_cast<float>(worldSize.height)},
/* .camera_to_center_distance = */ parameters.state.getCameraToCenterDistance(),
/* .symbol_fade_change = */ parameters.symbolFadeChange,
/* .aspect_ratio = */ parameters.state.getSize().aspectRatio(),
/* .pixel_ratio = */ parameters.pixelRatio,
/* .pad1/2 = */ 0,
0};
auto& globalUniforms = context.mutableGlobalUniformBuffers();
globalUniforms.createOrUpdate(shaders::idGlobalPaintParamsUBO, &globalPaintParamsUBO, context);
#endif
// - 3D PASS
@@ -446,6 +461,7 @@ void Renderer::Impl::render(const RenderTree& renderTree,
}
drawableTargetsPass();
commonClearPass();
context.bindGlobalUniformBuffers(*parameters.renderPass);
drawableOpaquePass();
drawableTranslucentPass();
drawableDebugOverlays();
@@ -465,6 +481,7 @@ void Renderer::Impl::render(const RenderTree& renderTree,
#if MLN_DRAWABLE_RENDERER
// Give the layers a chance to do cleanup
orchestrator.visitLayerGroups([&](LayerGroupBase& layerGroup) { layerGroup.postRender(orchestrator, parameters); });
context.unbindGlobalUniformBuffers(*parameters.renderPass);
#endif
// Ends the RenderPass

View File

@@ -203,11 +203,6 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
const auto matrix = LayerTweaker::getTileMatrix(
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
const shaders::LineDynamicUBO dynamicUBO = {
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]},
0,
0};
const shaders::LineDrawableUBO drawableUBO = {/*matrix = */ util::cast<float>(matrix),
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
0,
@@ -222,7 +217,6 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
0,
0};
auto& drawableUniforms = drawable.mutableUniformBuffers();
drawableUniforms.createOrUpdate(idLineDynamicUBO, &dynamicUBO, parameters.context);
drawableUniforms.createOrUpdate(idLineDrawableUBO, &drawableUBO, parameters.context);
drawableUniforms.createOrUpdate(idLineInterpolationUBO, &lineInterpolationUBO, parameters.context);
drawableUniforms.createOrUpdate(idLineEvaluatedPropsUBO, &linePropertiesUBO, parameters.context);

View File

@@ -31,6 +31,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::BackgroundShader, gfx::Backen
// Background Pattern
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"BackgroundPatternDrawableUBO", idBackgroundDrawableUBO},
UniformBlockInfo{"BackgroundPatternLayerUBO", idBackgroundLayerUBO},
};
@@ -44,8 +45,8 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::BackgroundPatternShader, gfx:
// Circle
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"CircleDrawableUBO", idCircleDrawableUBO},
UniformBlockInfo{"CirclePaintParamsUBO", idCirclePaintParamsUBO},
UniformBlockInfo{"CircleEvaluatedPropsUBO", idCircleEvaluatedPropsUBO},
UniformBlockInfo{"CircleInterpolateUBO", idCircleInterpolateUBO},
};
@@ -64,7 +65,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::CircleShader, gfx::Backend::T
// Collision Box
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
{
UniformBlockInfo{"CollisionBoxUBO", idCollisionUBO},
UniformBlockInfo{"CollisionUBO", idCollisionUBO},
};
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::CollisionBoxShader, gfx::Backend::Type::OpenGL>::attributes = {
AttributeInfo{"a_pos", idCollisionPosVertexAttribute},
@@ -78,7 +79,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::CollisionBoxShader, gfx::Back
// Collision Circle
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"CollisionCircleUBO", idCollisionUBO},
UniformBlockInfo{"CollisionUBO", idCollisionUBO},
};
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::CollisionCircleShader, gfx::Backend::Type::OpenGL>::attributes = {
AttributeInfo{"a_pos", idCollisionPosVertexAttribute},
@@ -129,6 +130,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillShader, gfx::Backend::Typ
// Fill Outline
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::FillOutlineShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
{
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"FillOutlineDrawableUBO", idFillDrawableUBO},
UniformBlockInfo{"FillOutlineInterpolateUBO", idFillInterpolateUBO},
UniformBlockInfo{"FillEvaluatedPropsUBO", idFillEvaluatedPropsUBO},
@@ -143,6 +145,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillOutlineShader, gfx::Backe
// Fill Pattern
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::FillPatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
{
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"FillPatternDrawableUBO", idFillDrawableUBO},
UniformBlockInfo{"FillPatternTilePropsUBO", idFillTilePropsUBO},
UniformBlockInfo{"FillPatternInterpolateUBO", idFillInterpolateUBO},
@@ -161,6 +164,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillPatternShader, gfx::Backe
// Fill Outline Pattern
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"FillOutlinePatternDrawableUBO", idFillDrawableUBO},
UniformBlockInfo{"FillOutlinePatternTilePropsUBO", idFillTilePropsUBO},
UniformBlockInfo{"FillOutlinePatternInterpolateUBO", idFillInterpolateUBO},
@@ -180,6 +184,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillOutlinePatternShader, gfx
// Fill Outline Triangulated
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"FillOutlineTriangulatedDrawableUBO", idFillDrawableUBO},
UniformBlockInfo{"FillEvaluatedPropsUBO", idFillEvaluatedPropsUBO},
};
@@ -211,6 +216,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::FillExtrusionShader, gfx::Bac
// Fill Extrusion Pattern
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"FillExtrusionDrawableUBO", idFillExtrusionDrawableUBO},
UniformBlockInfo{"FillExtrusionPropsUBO", idFillExtrusionPropsUBO},
UniformBlockInfo{"FillExtrusionTilePropsUBO", idFillExtrusionTilePropsUBO},
@@ -245,6 +251,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::HeatmapShader, gfx::Backend::
// Heatmap Texture
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"HeatmapTexturePropsUBO", idHeatmapTexturePropsUBO},
};
const std::vector<AttributeInfo> ShaderInfo<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::OpenGL>::attributes = {
@@ -283,7 +290,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::HillshadeShader, gfx::Backend
// Line
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"LineDrawableUBO", idLineDrawableUBO},
UniformBlockInfo{"LineInterpolationUBO", idLineInterpolationUBO},
UniformBlockInfo{"LineEvaluatedPropsUBO", idLineEvaluatedPropsUBO},
@@ -303,7 +310,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineShader, gfx::Backend::Typ
// Line Gradient
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineGradientShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
{
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"LineGradientDrawableUBO", idLineDrawableUBO},
UniformBlockInfo{"LineGradientInterpolationUBO", idLineInterpolationUBO},
UniformBlockInfo{"LineEvaluatedPropsUBO", idLineEvaluatedPropsUBO},
@@ -324,7 +331,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::LineGradientShader, gfx::Back
// Line Pattern
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LinePatternShader, gfx::Backend::Type::OpenGL>::uniformBlocks =
{
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"LinePatternDrawableUBO", idLineDrawableUBO},
UniformBlockInfo{"LinePatternInterpolationUBO", idLineInterpolationUBO},
UniformBlockInfo{"LinePatternTilePropertiesUBO", idLineTilePropertiesUBO},
@@ -347,7 +354,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::LinePatternShader, gfx::Backe
// Line SDF
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::LineSDFShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"LineDynamicUBO", idLineDynamicUBO},
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"LineSDFDrawableUBO", idLineDrawableUBO},
UniformBlockInfo{"LineSDFInterpolationUBO", idLineInterpolationUBO},
UniformBlockInfo{"LineEvaluatedPropsUBO", idLineEvaluatedPropsUBO},
@@ -383,7 +390,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::RasterShader, gfx::Backend::T
// Symbol Icon
const std::vector<UniformBlockInfo> ShaderInfo<BuiltIn::SymbolIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"SymbolDynamicUBO", idSymbolDynamicUBO},
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"SymbolDrawableUBO", idSymbolDrawableUBO},
UniformBlockInfo{"SymbolTilePropsUBO", idSymbolTilePropsUBO},
UniformBlockInfo{"SymbolInterpolateUBO", idSymbolInterpolateUBO},
@@ -404,7 +411,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::SymbolIconShader, gfx::Backen
// Symbol SDF
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"SymbolDynamicUBO", idSymbolDynamicUBO},
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"SymbolDrawableUBO", idSymbolDrawableUBO},
UniformBlockInfo{"SymbolTilePropsUBO", idSymbolTilePropsUBO},
UniformBlockInfo{"SymbolInterpolateUBO", idSymbolInterpolateUBO},
@@ -429,7 +436,7 @@ const std::vector<TextureInfo> ShaderInfo<BuiltIn::SymbolSDFIconShader, gfx::Bac
// Symbol Text & Icon
const std::vector<UniformBlockInfo>
ShaderInfo<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::OpenGL>::uniformBlocks = {
UniformBlockInfo{"SymbolDynamicUBO", idSymbolDynamicUBO},
UniformBlockInfo{"GlobalPaintParamsUBO", idGlobalPaintParamsUBO},
UniformBlockInfo{"SymbolDrawableUBO", idSymbolDrawableUBO},
UniformBlockInfo{"SymbolTilePropsUBO", idSymbolTilePropsUBO},
UniformBlockInfo{"SymbolInterpolateUBO", idSymbolInterpolateUBO},

View File

@@ -4,8 +4,9 @@
namespace mbgl {
namespace shaders {
const std::array<UniformBlockInfo, 2>
const std::array<UniformBlockInfo, 3>
ShaderSource<BuiltIn::BackgroundPatternShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{false, true, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, false, sizeof(BackgroundPatternDrawableUBO), idBackgroundDrawableUBO},
UniformBlockInfo{true, true, sizeof(BackgroundPatternLayerUBO), idBackgroundLayerUBO},
};

View File

@@ -4,8 +4,8 @@ namespace mbgl {
namespace shaders {
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::CircleShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, false, sizeof(CircleDrawableUBO), idCircleDrawableUBO},
UniformBlockInfo{true, true, sizeof(CirclePaintParamsUBO), idCirclePaintParamsUBO},
UniformBlockInfo{true, true, sizeof(CircleEvaluatedPropsUBO), idCircleEvaluatedPropsUBO},
UniformBlockInfo{true, false, sizeof(CircleInterpolateUBO), idCircleInterpolateUBO},
};

View File

@@ -15,7 +15,8 @@ const std::array<AttributeInfo, 3> ShaderSource<BuiltIn::FillShader, gfx::Backen
};
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::FillShader, gfx::Backend::Type::Metal>::textures = {};
const std::array<UniformBlockInfo, 3> ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Metal>::uniforms = {
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, false, sizeof(FillOutlineDrawableUBO), idFillDrawableUBO},
UniformBlockInfo{true, false, sizeof(FillOutlineInterpolateUBO), idFillInterpolateUBO},
UniformBlockInfo{true, true, sizeof(FillEvaluatedPropsUBO), idFillEvaluatedPropsUBO},
@@ -27,7 +28,8 @@ const std::array<AttributeInfo, 3> ShaderSource<BuiltIn::FillOutlineShader, gfx:
};
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::FillOutlineShader, gfx::Backend::Type::Metal>::textures = {};
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::Metal>::uniforms = {
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::FillPatternShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(FillPatternDrawableUBO), idFillDrawableUBO},
UniformBlockInfo{true, true, sizeof(FillPatternTilePropsUBO), idFillTilePropsUBO},
UniformBlockInfo{true, false, sizeof(FillPatternInterpolateUBO), idFillInterpolateUBO},
@@ -43,8 +45,9 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::FillPatternShader, gfx::B
TextureInfo{0, idFillImageTexture},
};
const std::array<UniformBlockInfo, 4>
const std::array<UniformBlockInfo, 5>
ShaderSource<BuiltIn::FillOutlinePatternShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(FillOutlinePatternDrawableUBO), idFillDrawableUBO},
UniformBlockInfo{true, true, sizeof(FillOutlinePatternTilePropsUBO), idFillTilePropsUBO},
UniformBlockInfo{true, false, sizeof(FillOutlinePatternInterpolateUBO), idFillInterpolateUBO},
@@ -62,8 +65,9 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::FillOutlinePatternShader,
TextureInfo{0, idFillImageTexture},
};
const std::array<UniformBlockInfo, 2>
const std::array<UniformBlockInfo, 3>
ShaderSource<BuiltIn::FillOutlineTriangulatedShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, false, sizeof(FillOutlineTriangulatedDrawableUBO), idFillDrawableUBO},
UniformBlockInfo{true, true, sizeof(FillEvaluatedPropsUBO), idFillEvaluatedPropsUBO},
};

View File

@@ -4,8 +4,9 @@
namespace mbgl {
namespace shaders {
const std::array<UniformBlockInfo, 4>
const std::array<UniformBlockInfo, 5>
ShaderSource<BuiltIn::FillExtrusionPatternShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(FillExtrusionDrawableUBO), idFillExtrusionDrawableUBO},
UniformBlockInfo{true, true, sizeof(FillExtrusionPropsUBO), idFillExtrusionPropsUBO},
UniformBlockInfo{true, true, sizeof(FillExtrusionTilePropsUBO), idFillExtrusionTilePropsUBO},

View File

@@ -3,8 +3,9 @@
namespace mbgl {
namespace shaders {
const std::array<UniformBlockInfo, 1> ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Metal>::uniforms =
const std::array<UniformBlockInfo, 2> ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Metal>::uniforms =
{
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(HeatmapTexturePropsUBO), idHeatmapTexturePropsUBO},
};
const std::array<AttributeInfo, 1> ShaderSource<BuiltIn::HeatmapTextureShader, gfx::Backend::Type::Metal>::attributes =

View File

@@ -4,7 +4,7 @@ namespace mbgl {
namespace shaders {
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(LineDynamicUBO), idLineDynamicUBO},
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, false, sizeof(idLineDrawableUBO), idLineDrawableUBO},
UniformBlockInfo{true, false, sizeof(LineInterpolationUBO), idLineInterpolationUBO},
UniformBlockInfo{true, true, sizeof(LineEvaluatedPropsUBO), idLineEvaluatedPropsUBO},
@@ -22,7 +22,7 @@ const std::array<AttributeInfo, 8> ShaderSource<BuiltIn::LineShader, gfx::Backen
const std::array<TextureInfo, 0> ShaderSource<BuiltIn::LineShader, gfx::Backend::Type::Metal>::textures = {};
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineGradientShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(LineDynamicUBO), idLineDynamicUBO},
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, false, sizeof(LineGradientDrawableUBO), idLineDrawableUBO},
UniformBlockInfo{true, false, sizeof(LineGradientInterpolationUBO), idLineInterpolationUBO},
UniformBlockInfo{true, true, sizeof(LineEvaluatedPropsUBO), idLineEvaluatedPropsUBO},
@@ -41,7 +41,7 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LineGradientShader, gfx::
};
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::LinePatternShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(LineDynamicUBO), idLineDynamicUBO},
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(LinePatternDrawableUBO), idLineDrawableUBO},
UniformBlockInfo{true, false, sizeof(LinePatternInterpolationUBO), idLineInterpolationUBO},
UniformBlockInfo{true, true, sizeof(LinePatternTilePropertiesUBO), idLineTilePropertiesUBO},
@@ -63,7 +63,7 @@ const std::array<TextureInfo, 1> ShaderSource<BuiltIn::LinePatternShader, gfx::B
};
const std::array<UniformBlockInfo, 4> ShaderSource<BuiltIn::LineSDFShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, false, sizeof(LineDynamicUBO), idLineDynamicUBO},
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(LineSDFDrawableUBO), idLineDrawableUBO},
UniformBlockInfo{true, false, sizeof(LineSDFInterpolationUBO), idLineInterpolationUBO},
UniformBlockInfo{true, true, sizeof(LineEvaluatedPropsUBO), idLineEvaluatedPropsUBO},

View File

@@ -4,7 +4,7 @@ namespace mbgl {
namespace shaders {
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::SymbolIconShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, true, sizeof(SymbolDynamicUBO), idSymbolDynamicUBO},
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
UniformBlockInfo{true, true, sizeof(SymbolTilePropsUBO), idSymbolTilePropsUBO},
UniformBlockInfo{true, false, sizeof(SymbolInterpolateUBO), idSymbolInterpolateUBO},

View File

@@ -5,7 +5,7 @@ namespace shaders {
const std::array<UniformBlockInfo, 5> ShaderSource<BuiltIn::SymbolSDFIconShader, gfx::Backend::Type::Metal>::uniforms =
{
UniformBlockInfo{true, true, sizeof(SymbolDynamicUBO), idSymbolDynamicUBO},
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
UniformBlockInfo{true, true, sizeof(SymbolTilePropsUBO), idSymbolTilePropsUBO},
UniformBlockInfo{true, false, sizeof(SymbolInterpolateUBO), idSymbolInterpolateUBO},

View File

@@ -5,7 +5,7 @@ namespace shaders {
const std::array<UniformBlockInfo, 5>
ShaderSource<BuiltIn::SymbolTextAndIconShader, gfx::Backend::Type::Metal>::uniforms = {
UniformBlockInfo{true, true, sizeof(SymbolDynamicUBO), idSymbolDynamicUBO},
UniformBlockInfo{true, false, sizeof(GlobalPaintParamsUBO), idGlobalPaintParamsUBO},
UniformBlockInfo{true, true, sizeof(SymbolDrawableUBO), idSymbolDrawableUBO},
UniformBlockInfo{true, true, sizeof(SymbolTilePropsUBO), idSymbolTilePropsUBO},
UniformBlockInfo{true, false, sizeof(SymbolInterpolateUBO), idSymbolInterpolateUBO},

View File

@@ -107,9 +107,6 @@ public:
const auto matrix = LayerTweaker::getTileMatrix(
tileID, parameters, {{0, 0}}, style::TranslateAnchorType::Viewport, false, false, drawable, false);
const shaders::LineDynamicUBO dynamicUBO = {
/*units_to_pixels = */ {1.0f / parameters.pixelsToGLUnits[0], 1.0f / parameters.pixelsToGLUnits[1]}, 0, 0};
const shaders::LineDrawableUBO drawableUBO = {/*matrix = */ util::cast<float>(matrix),
/*ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom),
0,
@@ -124,7 +121,6 @@ public:
0,
0};
auto& drawableUniforms = drawable.mutableUniformBuffers();
drawableUniforms.createOrUpdate(idLineDynamicUBO, &dynamicUBO, parameters.context);
drawableUniforms.createOrUpdate(idLineDrawableUBO, &drawableUBO, parameters.context);
drawableUniforms.createOrUpdate(idLineInterpolationUBO, &lineInterpolationUBO, parameters.context);
drawableUniforms.createOrUpdate(idLineEvaluatedPropsUBO, &linePropertiesUBO, parameters.context);
@@ -230,8 +226,8 @@ public:
/* .outline_color = */ Color::white(),
/* .opacity = */ opacity,
/* .fade = */ 0.f,
/* .width = */ 0.f,
0,
/* .from_scale = */ 0.f,
/* .to_scale = */ 0.f,
};
auto& drawableUniforms = drawable.mutableUniformBuffers();
drawableUniforms.createOrUpdate(idFillDrawableUBO, &fillDrawableUBO, parameters.context);