Vertex attribute by index instead of map (#2116)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Alex Cristici
2024-02-16 20:29:53 +02:00
committed by GitHub
parent d6db72e8ba
commit 7387bb8c02
77 changed files with 781 additions and 575 deletions

View File

@@ -13,12 +13,12 @@
#include <mbgl/gfx/cull_face_mode.hpp>
#include <mbgl/gfx/drawable.hpp>
#include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/gfx/shader_group.hpp>
#include <mbgl/renderer/layer_group.hpp>
#include <mbgl/renderer/render_static_data.hpp>
#include <mbgl/shaders/debug_layer_ubo.hpp>
#include <mbgl/shaders/shader_program_base.hpp>
#include <mbgl/util/convert.hpp>
#include <mbgl/util/string_indexer.hpp>
#include <mbgl/tile/geojson_tile_data.hpp>
#include <mbgl/gfx/polyline_generator.hpp>
#include <mbgl/style/types.hpp>
@@ -65,7 +65,6 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
if (!debugShader) {
return;
}
static const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
std::unique_ptr<gfx::DrawableBuilder> debugBuilder = [&]() -> std::unique_ptr<gfx::DrawableBuilder> {
auto builder = context.createDrawableBuilder("debug-builder");
builder->setShader(debugShader);
@@ -73,7 +72,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
builder->setEnableDepth(false);
builder->setColorMode(gfx::ColorMode::unblended());
builder->setCullFaceMode(gfx::CullFaceMode::disabled());
builder->setVertexAttrNameId(idVertexAttribName);
builder->setVertexAttrId(idDebugPosVertexAttribute);
return builder;
}();
@@ -83,14 +82,14 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
gfx::ShaderPtr polylineShader;
const auto createPolylineShader = [&]() -> gfx::ShaderPtr {
gfx::ShaderGroupPtr shaderGroup = shaders.getShaderGroup("LineShader");
const mbgl::unordered_set<StringIdentity> propertiesAsUniforms{
stringIndexer().get("a_color"),
stringIndexer().get("a_blur"),
stringIndexer().get("a_opacity"),
stringIndexer().get("a_gapwidth"),
stringIndexer().get("a_offset"),
stringIndexer().get("a_width"),
};
const StringIDSetsPair propertiesAsUniforms{
{"a_color", "a_blur", "a_opacity", "a_gapwidth", "a_offset", "a_width"},
{idLineColorVertexAttribute,
idLineBlurVertexAttribute,
idLineOpacityVertexAttribute,
idLineGapWidthVertexAttribute,
idLineOffsetVertexAttribute,
idLineWidthVertexAttribute}};
return shaderGroup->getOrCreateShader(context, propertiesAsUniforms);
};
@@ -102,7 +101,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
builder->setEnableDepth(false);
builder->setColorMode(gfx::ColorMode::alphaBlended());
builder->setCullFaceMode(gfx::CullFaceMode::disabled());
builder->setVertexAttrNameId(idVertexAttribName);
builder->setVertexAttrId(idLinePosNormalVertexAttribute);
return builder;
};