Fix Drawable Linux CI (clang-tidy, render tests)
Fix Drawable / Legacy renderer matrix Linux CI
This commit is contained in:
12
.github/workflows/ios-ci.yml
vendored
12
.github/workflows/ios-ci.yml
vendored
@@ -120,14 +120,14 @@ jobs:
|
||||
# size test
|
||||
|
||||
- name: Build app for size test & output size
|
||||
if: ${{ matrix.renderer }} == "legacy"
|
||||
if: matrix.renderer == 'legacy'
|
||||
working-directory: ./
|
||||
run: |
|
||||
bazel build --compilation_mode=opt //platform/ios:size --//:maplibre_platform=ios
|
||||
cp "$(bazel cquery --compilation_mode=opt --output=files //platform/ios:size --//:maplibre_platform=ios)" ./size
|
||||
|
||||
- name: Upload size test result
|
||||
if: ${{ matrix.renderer }} == "legacy"
|
||||
if: matrix.renderer == 'legacy'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
if-no-files-found: error
|
||||
@@ -138,7 +138,7 @@ jobs:
|
||||
# render test
|
||||
|
||||
- name: Build RenderTest .ipa and .xctest for AWS Device Farm
|
||||
if: ${{ matrix.renderer }} == "legacy"
|
||||
if: matrix.renderer == 'legacy'
|
||||
run: |
|
||||
set -e
|
||||
bazel run //platform/ios:xcodeproj
|
||||
@@ -155,7 +155,7 @@ jobs:
|
||||
echo render_test_artifacts_dir="$render_test_app_dir" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: ${{ matrix.renderer }} == "legacy"
|
||||
if: matrix.renderer == 'legacy'
|
||||
with:
|
||||
name: ios-render-test
|
||||
retention-days: 3
|
||||
@@ -167,7 +167,7 @@ jobs:
|
||||
# C++ unit tests
|
||||
|
||||
- name: Build CppUnitTests .ipa and .xctest for AWS Device Farm
|
||||
if: ${{ matrix.renderer }} == "legacy"
|
||||
if: matrix.renderer == 'legacy'
|
||||
run: |
|
||||
set -e
|
||||
bazel run //platform/ios:xcodeproj
|
||||
@@ -184,7 +184,7 @@ jobs:
|
||||
echo ios_cpp_test_artifacts_dir="$ios_cpp_test_app_dir" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: ${{ matrix.renderer }} == "legacy"
|
||||
if: matrix.renderer == 'legacy'
|
||||
with:
|
||||
name: ios-cpp-unit-tests
|
||||
retention-days: 3
|
||||
|
||||
111
.github/workflows/linux-ci.yml
vendored
111
.github/workflows/linux-ci.yml
vendored
@@ -39,11 +39,11 @@ jobs:
|
||||
".bazelrc",
|
||||
".bazelversion"]
|
||||
|
||||
linux-build:
|
||||
linux-build-and-test:
|
||||
if: needs.pre_job.outputs.should_skip != 'true'
|
||||
needs: pre_job
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: true
|
||||
matrix:
|
||||
renderer: [legacy, drawable]
|
||||
runs-on: MapLibre_Native_Linux_16_core
|
||||
@@ -77,12 +77,13 @@ jobs:
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
libglfw3-dev \
|
||||
libwebp-dev
|
||||
libwebp-dev \
|
||||
libopengl0
|
||||
|
||||
- if: ${{ matrix.renderer }} == "drawable"
|
||||
- if: matrix.renderer == 'drawable'
|
||||
run: echo renderer_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON >> "$GITHUB_ENV"
|
||||
|
||||
- if: ${{ matrix.renderer }} == "legacy"
|
||||
- if: matrix.renderer == 'legacy'
|
||||
run: echo renderer_flag_cmake=-DMLN_LEGACY_RENDERER=ON >> "$GITHUB_ENV"
|
||||
|
||||
- name: Build MapLibre Native Core
|
||||
@@ -98,95 +99,20 @@ jobs:
|
||||
with:
|
||||
category: "/language:cpp"
|
||||
|
||||
- name: Archive mbgl-test-runner
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mbgl-test-runner
|
||||
path: build/mbgl-test-runner
|
||||
retention-days: 1
|
||||
# unit tests
|
||||
|
||||
- name: Archive mbgl-render-test-runner
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mbgl-render-test-runner
|
||||
path: build/mbgl-render-test-runner
|
||||
retention-days: 1
|
||||
|
||||
- name: Archive mbgl-expression-test
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mbgl-expression-test
|
||||
path: build/expression-test/mbgl-expression-test
|
||||
retention-days: 1
|
||||
|
||||
linux-test:
|
||||
if: needs.pre_job.outputs.should_skip != 'true'
|
||||
needs:
|
||||
- pre_job
|
||||
- linux-build
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libopengl0
|
||||
|
||||
- name: Download mbgl-test-runner
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: mbgl-test-runner
|
||||
|
||||
- run: chmod +x ./mbgl-test-runner
|
||||
- run: chmod +x build/mbgl-test-runner
|
||||
|
||||
- name: Run C++ tests
|
||||
run: xvfb-run -a ./mbgl-test-runner
|
||||
run: xvfb-run -a build/mbgl-test-runner
|
||||
|
||||
linux-expression-test:
|
||||
if: needs.pre_job.outputs.should_skip != 'true'
|
||||
needs:
|
||||
- pre_job
|
||||
- linux-build
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download mbgl-expression-test
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: mbgl-expression-test
|
||||
# render tests
|
||||
|
||||
- run: chmod +x ./mbgl-expression-test
|
||||
|
||||
- name: Run expression test
|
||||
run: ./mbgl-expression-test
|
||||
|
||||
linux-render-test:
|
||||
if: needs.pre_job.outputs.should_skip != 'true'
|
||||
needs:
|
||||
- pre_job
|
||||
- linux-build
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libopengl0
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Download mbgl-render-test-runner
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: mbgl-render-test-runner
|
||||
|
||||
- run: chmod +x ./mbgl-render-test-runner
|
||||
- run: chmod +x build/mbgl-render-test-runner
|
||||
|
||||
- name: Run render test
|
||||
id: render_test
|
||||
run: xvfb-run -a ./mbgl-render-test-runner --manifestPath=metrics/linux-gcc8-release-style.json
|
||||
run: xvfb-run -a build/mbgl-render-test-runner --manifestPath=metrics/linux-${{ matrix.renderer }}.json
|
||||
|
||||
- name: Upload render test result
|
||||
if: always() && steps.render_test.outcome == 'failure'
|
||||
@@ -195,6 +121,13 @@ jobs:
|
||||
name: render-test-result
|
||||
path: |
|
||||
metrics/linux-gcc8-release-style.html
|
||||
|
||||
# expression tests
|
||||
|
||||
- run: chmod +x build/expression-test/mbgl-expression-test
|
||||
|
||||
- name: Run expression test
|
||||
run: build/expression-test/mbgl-expression-test
|
||||
|
||||
linux-coverage:
|
||||
runs-on: ubuntu-22.04
|
||||
@@ -254,11 +187,9 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
needs:
|
||||
- pre_job
|
||||
- linux-build
|
||||
- linux-test
|
||||
- linux-render-test
|
||||
- linux-build-and-test
|
||||
- linux-coverage
|
||||
steps:
|
||||
- name: Mark result as failed
|
||||
if: needs.linux-build.result != 'success' || needs.linux-test.result != 'success' || needs.linux-render-test.result != 'success' || needs.linux-coverage.result != 'success'
|
||||
if: needs.linux-build-and-test.result != 'success' || needs.linux-coverage.result != 'success'
|
||||
run: exit 1
|
||||
@@ -14,7 +14,7 @@ repos:
|
||||
hooks:
|
||||
- id: buildifier
|
||||
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
|
||||
rev: v1.6.25.9
|
||||
rev: v1.6.26.11
|
||||
hooks:
|
||||
- id: actionlint
|
||||
additional_dependencies: [shellcheck-py]
|
||||
|
||||
@@ -57,6 +57,10 @@ add_library(
|
||||
|
||||
set(UBSAN_BLACKLIST ${PROJECT_SOURCE_DIR}/scripts/ubsan.blacklist)
|
||||
|
||||
if (MLN_DRAWABLE_RENDERER)
|
||||
set(MLN_LEGACY_RENDERER OFF)
|
||||
endif()
|
||||
|
||||
target_compile_options(
|
||||
mbgl-compiler-options
|
||||
INTERFACE
|
||||
|
||||
@@ -239,8 +239,9 @@ public:
|
||||
const gfx::UniqueVertexBufferResource& getBuffer() const { return buffer; }
|
||||
void setBuffer(gfx::UniqueVertexBufferResource&& value) { buffer = std::move(value); }
|
||||
|
||||
protected:
|
||||
VertexAttribute& operator=(const VertexAttribute&) = delete;
|
||||
|
||||
protected:
|
||||
VertexAttribute& operator=(VertexAttribute&& other) {
|
||||
index = other.index;
|
||||
dataType = other.dataType;
|
||||
@@ -386,7 +387,7 @@ public:
|
||||
|
||||
auto& attributeNameID = DataDrivenPaintProperty::AttributeNameIDs[attrIndex];
|
||||
if (!attributeNameID) {
|
||||
attributeNameID = StringIndexer::get(attributePrefix + attributeName.data());
|
||||
attributeNameID = stringIndexer().get(attributePrefix + attributeName.data());
|
||||
}
|
||||
|
||||
const auto vertexCount = binder->getVertexCount();
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
additionalDefines.reserve(propertiesAsUniforms.size() * 48);
|
||||
for (const auto nameID : propertiesAsUniforms) {
|
||||
// We expect the names to be prefixed by "a_", but we need just the base here.
|
||||
const auto prefixedAttrName = StringIndexer::get(nameID);
|
||||
const auto prefixedAttrName = stringIndexer().get(nameID);
|
||||
const auto* prefix = prefixedAttrName.data();
|
||||
if (prefix[0] == 'a' && prefix[1] == '_') {
|
||||
prefix += 2;
|
||||
|
||||
@@ -15,36 +15,28 @@ using StringIdentity = std::size_t;
|
||||
|
||||
class StringIndexer {
|
||||
public:
|
||||
StringIndexer();
|
||||
|
||||
StringIndexer(StringIndexer const&) = delete;
|
||||
StringIndexer(StringIndexer&&) = delete;
|
||||
void operator=(StringIndexer const&) = delete;
|
||||
|
||||
static StringIdentity get(std::string_view);
|
||||
|
||||
static std::string get(const StringIdentity id);
|
||||
|
||||
static void clear();
|
||||
|
||||
static size_t size();
|
||||
|
||||
protected:
|
||||
StringIndexer();
|
||||
~StringIndexer() = default;
|
||||
|
||||
using MapType = std::unordered_map<std::string_view, StringIdentity>;
|
||||
using VectorType = std::vector<std::size_t>;
|
||||
using BufferType = std::vector<char>;
|
||||
StringIdentity get(std::string_view);
|
||||
|
||||
static StringIndexer& instance() {
|
||||
static StringIndexer inst;
|
||||
return inst;
|
||||
}
|
||||
std::string get(const StringIdentity id);
|
||||
|
||||
MapType stringToIdentity;
|
||||
VectorType identityToString;
|
||||
BufferType buffer;
|
||||
size_t size();
|
||||
|
||||
protected:
|
||||
std::unordered_map<std::string_view, StringIdentity> stringToIdentity;
|
||||
std::vector<StringIdentity> identityToString;
|
||||
std::vector<char> buffer;
|
||||
|
||||
std::shared_mutex sharedMutex;
|
||||
};
|
||||
|
||||
/// StringIndexer singleton
|
||||
StringIndexer& stringIndexer();
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
3
metrics/ignores/linux-drawable.json
Normal file
3
metrics/ignores/linux-drawable.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"render-tests/regressions/mapbox-gl-js#3426": "https://github.com/maplibre/maplibre-native/issues/1734"
|
||||
}
|
||||
16
metrics/linux-drawable.json
Normal file
16
metrics/linux-drawable.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"base_test_path": "integration",
|
||||
"cache_path": "cache-style.db",
|
||||
"expectation_paths": [
|
||||
"expectations/platform-all"
|
||||
],
|
||||
"ignore_paths": [
|
||||
"ignores/platform-all.json",
|
||||
"ignores/platform-linux.json",
|
||||
"ignores/linux-drawable.json"
|
||||
],
|
||||
"metric_path": "linux-gcc8-release",
|
||||
"probes": [
|
||||
"probeNetwork"
|
||||
]
|
||||
}
|
||||
16
metrics/linux-legacy.json
Normal file
16
metrics/linux-legacy.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"base_test_path": "integration",
|
||||
"cache_path": "cache-style.db",
|
||||
"expectation_paths": [
|
||||
"expectations/platform-all"
|
||||
],
|
||||
"ignore_paths": [
|
||||
"ignores/platform-all.json",
|
||||
"ignores/platform-linux.json"
|
||||
],
|
||||
"metric_path": "linux-gcc8-release",
|
||||
"probes": [
|
||||
"probeGFX",
|
||||
"probeNetwork"
|
||||
]
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS")
|
||||
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
|
||||
load(
|
||||
"@build_bazel_rules_swift//swift:swift.bzl",
|
||||
"swift_library",
|
||||
)
|
||||
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS")
|
||||
|
||||
objc_library(
|
||||
name = "ios_tests_objc_srcs",
|
||||
@@ -54,6 +54,7 @@ swift_library(
|
||||
|
||||
ios_unit_test(
|
||||
name = "ios_test",
|
||||
timeout = "long",
|
||||
minimum_os_version = "12.0",
|
||||
runner = "@build_bazel_rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
|
||||
visibility = [
|
||||
@@ -63,11 +64,11 @@ ios_unit_test(
|
||||
"ios_tests_objc_srcs",
|
||||
"ios_tests_objcpp_srcs",
|
||||
"ios_tests_swift_srcs",
|
||||
"//platform/darwin:darwin_objc_hdrs",
|
||||
"//platform/darwin:darwin_objcpp_hdrs",
|
||||
"//platform/darwin:shared_tests_objc_srcs",
|
||||
"//platform/darwin:shared_tests_objcpp_srcs",
|
||||
"//platform/darwin:shared_tests_swift_srcs",
|
||||
"//platform/darwin:darwin_objc_hdrs",
|
||||
"//platform/darwin:darwin_objcpp_hdrs",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace gfx {
|
||||
|
||||
DrawableBuilder::DrawableBuilder(std::string name_)
|
||||
: name(std::move(name_)),
|
||||
vertexAttrNameId(StringIndexer::get("a_pos")),
|
||||
vertexAttrNameId(stringIndexer().get("a_pos")),
|
||||
renderPass(mbgl::RenderPass::Opaque),
|
||||
impl(std::make_unique<Impl>()) {}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
|
||||
#include <mbgl/gfx/renderable.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ void DrawableGL::bindUniformBuffers() const {
|
||||
using namespace std::string_literals;
|
||||
const auto tileIDStr = getTileID() ? util::toString(*getTileID()) : "<no tile>";
|
||||
Log::Error(Event::General,
|
||||
"bindUniformBuffers: UBO "s + std::string(StringIndexer::get(element.first)) +
|
||||
"bindUniformBuffers: UBO "s + std::string(stringIndexer().get(element.first)) +
|
||||
" not found for " + util::toString(getID()) + " / " + getName() + " / " + tileIDStr +
|
||||
". skipping.");
|
||||
assert(false);
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
gfx::CullFaceMode cullFaceMode;
|
||||
GLfloat pointSize = 0.0f;
|
||||
|
||||
StringIdentity idVertexAttrName = StringIndexer::get("a_pos");
|
||||
StringIdentity idVertexAttrName = stringIndexer().get("a_pos");
|
||||
};
|
||||
|
||||
struct DrawableGL::DrawSegmentGL final : public gfx::Drawable::DrawSegment {
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
texture->setSize(size);
|
||||
texture->setFormat(gfx::TexturePixelType::RGBA, type);
|
||||
texture->setSamplerConfiguration(
|
||||
{gfx::TextureFilterType::Nearest, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
||||
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||
// something else, the binding is invalid
|
||||
// TODO: throw?
|
||||
Log::Warning(Event::General,
|
||||
"Got " + util::toString(rawData.size()) + " bytes for attribute '" + StringIndexer::get(id) +
|
||||
"Got " + util::toString(rawData.size()) + " bytes for attribute '" + stringIndexer().get(id) +
|
||||
"' (" + util::toString(defaultGL.getIndex()) + "), expected " + util::toString(stride) +
|
||||
" or " + util::toString(stride * vertexCount));
|
||||
return;
|
||||
|
||||
@@ -331,7 +331,7 @@ void Drawable::setVertices(std::vector<uint8_t>&& data, std::size_t count, gfx::
|
||||
using namespace std::string_literals;
|
||||
Log::Warning(
|
||||
Event::General,
|
||||
"Vertex attribute type mismatch: "s + name + " / " + StringIndexer::get(impl->idVertexAttrName));
|
||||
"Vertex attribute type mismatch: "s + name + " / " + stringIndexer().get(impl->idVertexAttrName));
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void Drawable::bindUniformBuffers(const RenderPass& renderPass) const {
|
||||
const auto tileID = getTileID() ? util::toString(*getTileID()) : "<no tile>";
|
||||
const auto tileLabel = util::toString(getID()) + "/" + getName() + "/" + tileID;
|
||||
Log::Error(Event::General,
|
||||
"bindUniformBuffers: UBO "s + StringIndexer::get(element.first) + " not found on " +
|
||||
"bindUniformBuffers: UBO "s + stringIndexer().get(element.first) + " not found on " +
|
||||
tileLabel + ". skipping.");
|
||||
assert(false);
|
||||
continue;
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
gfx::StencilMode stencilMode;
|
||||
gfx::CullFaceMode cullFaceMode;
|
||||
// GLfloat pointSize = 0.0f;
|
||||
StringIdentity idVertexAttrName = StringIndexer::get("a_pos");
|
||||
StringIdentity idVertexAttrName = stringIndexer().get("a_pos");
|
||||
|
||||
gfx::UniqueVertexBufferResource noBindingBuffer;
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ using namespace shaders;
|
||||
#if !defined(NDEBUG)
|
||||
constexpr auto BackgroundPatternShaderName = "BackgroundPatternShader";
|
||||
#endif
|
||||
static const StringIdentity idBackgroundDrawableUBOName = StringIndexer::get("BackgroundDrawableUBO");
|
||||
static const StringIdentity idBackgroundLayerUBOName = StringIndexer::get("BackgroundLayerUBO");
|
||||
static const StringIdentity idTexUniformName = StringIndexer::get("u_image");
|
||||
static const StringIdentity idBackgroundDrawableUBOName = stringIndexer().get("BackgroundDrawableUBO");
|
||||
static const StringIdentity idBackgroundLayerUBOName = stringIndexer().get("BackgroundLayerUBO");
|
||||
static const StringIdentity idTexUniformName = stringIndexer().get("u_image");
|
||||
|
||||
void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const RenderTree&, const PaintParameters& parameters) {
|
||||
const auto& state = parameters.state;
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
static const StringIdentity idCircleDrawableUBOName = StringIndexer::get("CircleDrawableUBO");
|
||||
static const StringIdentity idCirclePaintParamsUBOName = StringIndexer::get("CirclePaintParamsUBO");
|
||||
static const StringIdentity idCircleEvaluatedPropsUBOName = StringIndexer::get("CircleEvaluatedPropsUBO");
|
||||
static const StringIdentity idCircleDrawableUBOName = stringIndexer().get("CircleDrawableUBO");
|
||||
static const StringIdentity idCirclePaintParamsUBOName = stringIndexer().get("CirclePaintParamsUBO");
|
||||
static const StringIdentity idCircleEvaluatedPropsUBOName = stringIndexer().get("CircleEvaluatedPropsUBO");
|
||||
|
||||
static const StringIdentity idExpressionInputsUBOName = StringIndexer::get("ExpressionInputsUBO");
|
||||
static const StringIdentity idCirclePermutationUBOName = StringIndexer::get("CirclePermutationUBO");
|
||||
static const StringIdentity idExpressionInputsUBOName = stringIndexer().get("ExpressionInputsUBO");
|
||||
static const StringIdentity idCirclePermutationUBOName = stringIndexer().get("CirclePermutationUBO");
|
||||
|
||||
void CircleLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
const RenderTree& renderTree,
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
const StringIdentity CollisionLayerTweaker::idCollisionCircleUBOName = StringIndexer::get(CollisionCircleUBOName);
|
||||
const StringIdentity CollisionLayerTweaker::idCollisionBoxUBOName = StringIndexer::get(CollisionBoxUBOName);
|
||||
const StringIdentity CollisionLayerTweaker::idCollisionCircleUBOName = stringIndexer().get(CollisionCircleUBOName);
|
||||
const StringIdentity CollisionLayerTweaker::idCollisionBoxUBOName = stringIndexer().get(CollisionBoxUBOName);
|
||||
|
||||
void CollisionLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
const RenderTree& renderTree,
|
||||
|
||||
@@ -26,17 +26,17 @@ using namespace shaders;
|
||||
using namespace style;
|
||||
|
||||
namespace {
|
||||
const StringIdentity idFillExtrusionDrawableUBOName = StringIndexer::get("FillExtrusionDrawableUBO");
|
||||
const StringIdentity idFillExtrusionDrawablePropsUBOName = StringIndexer::get("FillExtrusionDrawablePropsUBO");
|
||||
const StringIdentity idExpressionInputsUBOName = StringIndexer::get("ExpressionInputsUBO");
|
||||
const StringIdentity idFillExtrusionPermutationUBOName = StringIndexer::get("FillExtrusionPermutationUBO");
|
||||
const StringIdentity idTexImageName = StringIndexer::get("u_image");
|
||||
const StringIdentity idFillExtrusionDrawableUBOName = stringIndexer().get("FillExtrusionDrawableUBO");
|
||||
const StringIdentity idFillExtrusionDrawablePropsUBOName = stringIndexer().get("FillExtrusionDrawablePropsUBO");
|
||||
const StringIdentity idExpressionInputsUBOName = stringIndexer().get("ExpressionInputsUBO");
|
||||
const StringIdentity idFillExtrusionPermutationUBOName = stringIndexer().get("FillExtrusionPermutationUBO");
|
||||
const StringIdentity idTexImageName = stringIndexer().get("u_image");
|
||||
|
||||
} // namespace
|
||||
|
||||
const StringIdentity FillExtrusionLayerTweaker::idFillExtrusionTilePropsUBOName = StringIndexer::get(
|
||||
const StringIdentity FillExtrusionLayerTweaker::idFillExtrusionTilePropsUBOName = stringIndexer().get(
|
||||
"FillExtrusionDrawableTilePropsUBO");
|
||||
const StringIdentity FillExtrusionLayerTweaker::idFillExtrusionInterpolateUBOName = StringIndexer::get(
|
||||
const StringIdentity FillExtrusionLayerTweaker::idFillExtrusionInterpolateUBOName = stringIndexer().get(
|
||||
"FillExtrusionInterpolateUBO");
|
||||
|
||||
void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
|
||||
@@ -24,40 +24,41 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
static const StringIdentity idFillDrawableUBOName = StringIndexer::get("FillDrawableUBO");
|
||||
static const StringIdentity idFillDrawablePropsUBOName = StringIndexer::get("FillDrawablePropsUBO");
|
||||
static const StringIdentity idFillEvaluatedPropsUBOName = StringIndexer::get("FillEvaluatedPropsUBO");
|
||||
static const StringIdentity idFillPermutationUBOName = StringIndexer::get("FillPermutationUBO");
|
||||
static const StringIdentity idFillDrawableUBOName = stringIndexer().get("FillDrawableUBO");
|
||||
static const StringIdentity idFillDrawablePropsUBOName = stringIndexer().get("FillDrawablePropsUBO");
|
||||
static const StringIdentity idFillEvaluatedPropsUBOName = stringIndexer().get("FillEvaluatedPropsUBO");
|
||||
static const StringIdentity idFillPermutationUBOName = stringIndexer().get("FillPermutationUBO");
|
||||
|
||||
const StringIdentity FillLayerTweaker::idFillTilePropsUBOName = StringIndexer::get("FillDrawableTilePropsUBO");
|
||||
const StringIdentity FillLayerTweaker::idFillInterpolateUBOName = StringIndexer::get("FillInterpolateUBO");
|
||||
const StringIdentity FillLayerTweaker::idFillOutlineInterpolateUBOName = StringIndexer::get(
|
||||
const StringIdentity FillLayerTweaker::idFillTilePropsUBOName = stringIndexer().get("FillDrawableTilePropsUBO");
|
||||
const StringIdentity FillLayerTweaker::idFillInterpolateUBOName = stringIndexer().get("FillInterpolateUBO");
|
||||
const StringIdentity FillLayerTweaker::idFillOutlineInterpolateUBOName = stringIndexer().get(
|
||||
"FillOutlineInterpolateUBO");
|
||||
|
||||
static const StringIdentity idFillOutlineDrawableUBOName = StringIndexer::get("FillOutlineDrawableUBO");
|
||||
static const StringIdentity idFillOutlineEvaluatedPropsUBOName = StringIndexer::get("FillOutlineEvaluatedPropsUBO");
|
||||
static const StringIdentity idFillOutlinePermutationUBOName = StringIndexer::get("FillOutlinePermutationUBO");
|
||||
static const StringIdentity idFillOutlineDrawableUBOName = stringIndexer().get("FillOutlineDrawableUBO");
|
||||
static const StringIdentity idFillOutlineEvaluatedPropsUBOName = stringIndexer().get("FillOutlineEvaluatedPropsUBO");
|
||||
static const StringIdentity idFillOutlinePermutationUBOName = stringIndexer().get("FillOutlinePermutationUBO");
|
||||
|
||||
static const StringIdentity idFillOutlineInterpolateUBOName = StringIndexer::get("FillOutlineInterpolateUBO");
|
||||
static const StringIdentity idFillOutlineInterpolateUBOName = stringIndexer().get("FillOutlineInterpolateUBO");
|
||||
|
||||
static const StringIdentity idFillPatternDrawableUBOName = StringIndexer::get("FillPatternDrawableUBO");
|
||||
static const StringIdentity idFillPatternPermutationUBOName = StringIndexer::get("FillPatternPermutationUBO");
|
||||
static const StringIdentity idFillPatternInterpolateUBOName = StringIndexer::get("FillPatternInterpolateUBO");
|
||||
static const StringIdentity idFillPatternEvaluatedPropsUBOName = StringIndexer::get("FillPatternEvaluatedPropsUBO");
|
||||
static const StringIdentity idFillPatternTilePropsUBOName = StringIndexer::get("FillPatternTilePropsUBO");
|
||||
static const StringIdentity idFillPatternDrawableUBOName = stringIndexer().get("FillPatternDrawableUBO");
|
||||
static const StringIdentity idFillPatternPermutationUBOName = stringIndexer().get("FillPatternPermutationUBO");
|
||||
static const StringIdentity idFillPatternInterpolateUBOName = stringIndexer().get("FillPatternInterpolateUBO");
|
||||
static const StringIdentity idFillPatternEvaluatedPropsUBOName = stringIndexer().get("FillPatternEvaluatedPropsUBO");
|
||||
static const StringIdentity idFillPatternTilePropsUBOName = stringIndexer().get("FillPatternTilePropsUBO");
|
||||
|
||||
static const StringIdentity idFillOutlinePatternDrawableUBOName = StringIndexer::get("FillOutlinePatternDrawableUBO");
|
||||
static const StringIdentity idFillOutlinePatternPermutationUBOName = StringIndexer::get(
|
||||
static const StringIdentity idFillOutlinePatternDrawableUBOName = stringIndexer().get("FillOutlinePatternDrawableUBO");
|
||||
static const StringIdentity idFillOutlinePatternPermutationUBOName = stringIndexer().get(
|
||||
"FillOutlinePatternPermutationUBO");
|
||||
static const StringIdentity idFillOutlinePatternInterpolateUBOName = StringIndexer::get(
|
||||
static const StringIdentity idFillOutlinePatternInterpolateUBOName = stringIndexer().get(
|
||||
"FillOutlinePatternInterpolateUBO");
|
||||
static const StringIdentity idFillOutlinePatternEvaluatedPropsUBOName = StringIndexer::get(
|
||||
static const StringIdentity idFillOutlinePatternEvaluatedPropsUBOName = stringIndexer().get(
|
||||
"FillOutlinePatternEvaluatedPropsUBO");
|
||||
static const StringIdentity idFillOutlinePatternTilePropsUBOName = StringIndexer::get("FillOutlinePatternTilePropsUBO");
|
||||
static const StringIdentity idFillOutlinePatternTilePropsUBOName = stringIndexer().get(
|
||||
"FillOutlinePatternTilePropsUBO");
|
||||
|
||||
static const StringIdentity idExpressionInputsUBOName = StringIndexer::get("ExpressionInputsUBO");
|
||||
static const StringIdentity idExpressionInputsUBOName = stringIndexer().get("ExpressionInputsUBO");
|
||||
|
||||
static const StringIdentity idTexImageName = StringIndexer::get("u_image");
|
||||
static const StringIdentity idTexImageName = stringIndexer().get("u_image");
|
||||
using namespace shaders;
|
||||
|
||||
void FillLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
static const StringIdentity idHeatmapDrawableUBOName = StringIndexer::get("HeatmapDrawableUBO");
|
||||
static const StringIdentity idHeatmapEvaluatedPropsUBOName = StringIndexer::get("HeatmapEvaluatedPropsUBO");
|
||||
static const StringIdentity idHeatmapPermutationUBOName = StringIndexer::get("HeatmapPermutationUBO");
|
||||
static const StringIdentity idExpressionInputsUBOName = StringIndexer::get("ExpressionInputsUBO");
|
||||
static const StringIdentity idHeatmapDrawableUBOName = stringIndexer().get("HeatmapDrawableUBO");
|
||||
static const StringIdentity idHeatmapEvaluatedPropsUBOName = stringIndexer().get("HeatmapEvaluatedPropsUBO");
|
||||
static const StringIdentity idHeatmapPermutationUBOName = stringIndexer().get("HeatmapPermutationUBO");
|
||||
static const StringIdentity idExpressionInputsUBOName = stringIndexer().get("ExpressionInputsUBO");
|
||||
|
||||
void HeatmapLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
const RenderTree& renderTree,
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
static const StringIdentity idHeatmapTextureDrawableUBOName = StringIndexer::get("HeatmapTextureDrawableUBO");
|
||||
static const StringIdentity idHeatmapTextureDrawableUBOName = stringIndexer().get("HeatmapTextureDrawableUBO");
|
||||
|
||||
void HeatmapTextureLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
[[maybe_unused]] const RenderTree& renderTree,
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
static const StringIdentity idHillshadeDrawableUBOName = StringIndexer::get("HillshadeDrawableUBO");
|
||||
static const StringIdentity idHillshadeEvaluatedPropsUBOName = StringIndexer::get("HillshadeEvaluatedPropsUBO");
|
||||
static const StringIdentity idHillshadeDrawableUBOName = stringIndexer().get("HillshadeDrawableUBO");
|
||||
static const StringIdentity idHillshadeEvaluatedPropsUBOName = stringIndexer().get("HillshadeEvaluatedPropsUBO");
|
||||
|
||||
std::array<float, 2> getLatRange(const UnwrappedTileID& id) {
|
||||
const LatLng latlng0 = LatLng(id);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
static const StringIdentity idHillshadePrepareDrawableUBOName = StringIndexer::get("HillshadePrepareDrawableUBO");
|
||||
static const StringIdentity idHillshadePrepareDrawableUBOName = stringIndexer().get("HillshadePrepareDrawableUBO");
|
||||
|
||||
const std::array<float, 4>& getUnpackVector(Tileset::DEMEncoding encoding) {
|
||||
// https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
|
||||
|
||||
@@ -24,18 +24,18 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
static const StringIdentity idLineUBOName = StringIndexer::get("LineUBO");
|
||||
static const StringIdentity idLinePropertiesUBOName = StringIndexer::get("LinePropertiesUBO");
|
||||
static const StringIdentity idLineGradientUBOName = StringIndexer::get("LineGradientUBO");
|
||||
static const StringIdentity idLineGradientPropertiesUBOName = StringIndexer::get("LineGradientPropertiesUBO");
|
||||
static const StringIdentity idLinePatternUBOName = StringIndexer::get("LinePatternUBO");
|
||||
static const StringIdentity idLinePatternPropertiesUBOName = StringIndexer::get("LinePatternPropertiesUBO");
|
||||
static const StringIdentity idLineSDFUBOName = StringIndexer::get("LineSDFUBO");
|
||||
static const StringIdentity idLineSDFPropertiesUBOName = StringIndexer::get("LineSDFPropertiesUBO");
|
||||
static const StringIdentity idTexImageName = StringIndexer::get("u_image");
|
||||
static const StringIdentity idLineUBOName = stringIndexer().get("LineUBO");
|
||||
static const StringIdentity idLinePropertiesUBOName = stringIndexer().get("LinePropertiesUBO");
|
||||
static const StringIdentity idLineGradientUBOName = stringIndexer().get("LineGradientUBO");
|
||||
static const StringIdentity idLineGradientPropertiesUBOName = stringIndexer().get("LineGradientPropertiesUBO");
|
||||
static const StringIdentity idLinePatternUBOName = stringIndexer().get("LinePatternUBO");
|
||||
static const StringIdentity idLinePatternPropertiesUBOName = stringIndexer().get("LinePatternPropertiesUBO");
|
||||
static const StringIdentity idLineSDFUBOName = stringIndexer().get("LineSDFUBO");
|
||||
static const StringIdentity idLineSDFPropertiesUBOName = stringIndexer().get("LineSDFPropertiesUBO");
|
||||
static const StringIdentity idTexImageName = stringIndexer().get("u_image");
|
||||
|
||||
static const StringIdentity idExpressionInputsUBOName = StringIndexer::get("ExpressionInputsUBO");
|
||||
static const StringIdentity idLinePermutationUBOName = StringIndexer::get("LinePermutationUBO");
|
||||
static const StringIdentity idExpressionInputsUBOName = stringIndexer().get("ExpressionInputsUBO");
|
||||
static const StringIdentity idLinePermutationUBOName = stringIndexer().get("LinePermutationUBO");
|
||||
|
||||
void LineLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
const RenderTree& renderTree,
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
using namespace shaders;
|
||||
|
||||
static const StringIdentity idRasterDrawableUBOName = StringIndexer::get("RasterDrawableUBO");
|
||||
static const StringIdentity idRasterDrawableUBOName = stringIndexer().get("RasterDrawableUBO");
|
||||
|
||||
void RasterLayerTweaker::execute([[maybe_unused]] LayerGroupBase& layerGroup,
|
||||
[[maybe_unused]] const RenderTree& renderTree,
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <mbgl/renderer/update_parameters.hpp>
|
||||
#include <mbgl/shaders/circle_layer_ubo.hpp>
|
||||
#include <mbgl/shaders/shader_program_base.hpp>
|
||||
#include <mbgl/gfx/drawable_builder.hpp>
|
||||
#include <mbgl/util/string_indexer.hpp>
|
||||
#endif
|
||||
|
||||
@@ -272,8 +271,8 @@ bool RenderCircleLayer::queryIntersectsFeature(const GeometryCoordinates& queryG
|
||||
namespace {
|
||||
|
||||
constexpr auto CircleShaderGroupName = "CircleShader";
|
||||
static const StringIdentity idCircleInterpolateUBOName = StringIndexer::get("CircleInterpolateUBO");
|
||||
static const StringIdentity idVertexAttribName = StringIndexer::get("a_pos");
|
||||
const StringIdentity idCircleInterpolateUBOName = stringIndexer().get("CircleInterpolateUBO");
|
||||
const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ using namespace shaders;
|
||||
namespace {
|
||||
|
||||
#if MLN_DRAWABLE_RENDERER
|
||||
static const StringIdentity idPosAttribName = StringIndexer::get("a_pos");
|
||||
static const StringIdentity idNormAttribName = StringIndexer::get("a_normal_ed");
|
||||
const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
const StringIdentity idNormAttribName = stringIndexer().get("a_normal_ed");
|
||||
|
||||
static const StringIdentity idIconTextureName = StringIndexer::get("u_image");
|
||||
const StringIdentity idIconTextureName = stringIndexer().get("u_image");
|
||||
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
|
||||
@@ -46,15 +46,14 @@ constexpr auto FillOutlineShaderName = "FillOutlineShader";
|
||||
constexpr auto FillPatternShaderName = "FillPatternShader";
|
||||
constexpr auto FillOutlinePatternShaderName = "FillOutlinePatternShader";
|
||||
|
||||
static const StringIdentity idFillOutlineInterpolateUBOName = StringIndexer::get("FillOutlineInterpolateUBO");
|
||||
static const StringIdentity idFillPatternInterpolateUBOName = StringIndexer::get("FillPatternInterpolateUBO");
|
||||
static const StringIdentity idFillPatternTilePropsUBOName = StringIndexer::get("FillPatternTilePropsUBO");
|
||||
static const StringIdentity idFillOutlinePatternInterpolateUBOName = StringIndexer::get(
|
||||
"FillOutlinePatternInterpolateUBO");
|
||||
static const StringIdentity idFillOutlinePatternTilePropsUBOName = StringIndexer::get("FillOutlinePatternTilePropsUBO");
|
||||
const StringIdentity idFillOutlineInterpolateUBOName = stringIndexer().get("FillOutlineInterpolateUBO");
|
||||
const StringIdentity idFillPatternInterpolateUBOName = stringIndexer().get("FillPatternInterpolateUBO");
|
||||
const StringIdentity idFillPatternTilePropsUBOName = stringIndexer().get("FillPatternTilePropsUBO");
|
||||
const StringIdentity idFillOutlinePatternInterpolateUBOName = stringIndexer().get("FillOutlinePatternInterpolateUBO");
|
||||
const StringIdentity idFillOutlinePatternTilePropsUBOName = stringIndexer().get("FillOutlinePatternTilePropsUBO");
|
||||
|
||||
static const StringIdentity idPosAttribName = StringIndexer::get("a_pos");
|
||||
static const StringIdentity idIconTextureName = StringIndexer::get("u_image");
|
||||
const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
const StringIdentity idIconTextureName = stringIndexer().get("u_image");
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
inline const FillLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
|
||||
@@ -609,6 +608,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
fillBuilder->setShader(fillShader);
|
||||
if (outlineBuilder) {
|
||||
fillBuilder->setVertexAttributes(vertexAttrs);
|
||||
outlineBuilder->setVertexAttributes(std::move(vertexAttrs));
|
||||
} else {
|
||||
fillBuilder->setVertexAttributes(std::move(vertexAttrs));
|
||||
}
|
||||
@@ -621,7 +621,6 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
}
|
||||
if (outlineBuilder && bucket.sharedLines->elements()) {
|
||||
outlineBuilder->setShader(outlineShader);
|
||||
outlineBuilder->setVertexAttributes(std::move(vertexAttrs));
|
||||
outlineBuilder->setRawVertices({}, vertexCount, gfx::AttributeDataType::Short2);
|
||||
outlineBuilder->setSegments(
|
||||
gfx::Lines(2), bucket.sharedLines, bucket.lineSegments.data(), bucket.lineSegments.size());
|
||||
@@ -704,6 +703,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
patternBuilder->setRenderPass(renderPass);
|
||||
if (outlinePatternBuilder) {
|
||||
patternBuilder->setVertexAttributes(vertexAttrs);
|
||||
outlinePatternBuilder->setVertexAttributes(std::move(vertexAttrs));
|
||||
} else {
|
||||
patternBuilder->setVertexAttributes(std::move(vertexAttrs));
|
||||
}
|
||||
@@ -722,7 +722,6 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
|
||||
if (outlinePatternBuilder && bucket.sharedLines->elements()) {
|
||||
outlinePatternBuilder->setShader(outlineShader);
|
||||
outlinePatternBuilder->setRenderPass(renderPass);
|
||||
outlinePatternBuilder->setVertexAttributes(std::move(vertexAttrs));
|
||||
outlinePatternBuilder->setRawVertices({}, vertexCount, gfx::AttributeDataType::Short2);
|
||||
outlinePatternBuilder->setSegments(
|
||||
gfx::Lines(2), bucket.sharedLines, bucket.lineSegments.data(), bucket.lineSegments.size());
|
||||
|
||||
@@ -280,10 +280,10 @@ namespace {
|
||||
|
||||
constexpr auto HeatmapShaderGroupName = "HeatmapShader";
|
||||
constexpr auto HeatmapTextureShaderGroupName = "HeatmapTextureShader";
|
||||
static const StringIdentity idHeatmapInterpolateUBOName = StringIndexer::get("HeatmapInterpolateUBO");
|
||||
static const StringIdentity idVertexAttribName = StringIndexer::get("a_pos");
|
||||
static const StringIdentity idTexImageName = StringIndexer::get("u_image");
|
||||
static const StringIdentity idTexColorRampName = StringIndexer::get("u_color_ramp");
|
||||
const StringIdentity idHeatmapInterpolateUBOName = stringIndexer().get("HeatmapInterpolateUBO");
|
||||
const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
|
||||
const StringIdentity idTexImageName = stringIndexer().get("u_image");
|
||||
const StringIdentity idTexColorRampName = stringIndexer().get("u_color_ramp");
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -299,9 +299,9 @@ void RenderHillshadeLayer::removeRenderTargets(UniqueChangeRequestVec& changes)
|
||||
static const std::string HillshadePrepareShaderGroupName = "HillshadePrepareShader";
|
||||
static const std::string HillshadeShaderGroupName = "HillshadeShader";
|
||||
|
||||
static const StringIdentity idPosAttribName = StringIndexer::get("a_pos");
|
||||
static const StringIdentity idTexturePosAttribName = StringIndexer::get("a_texture_pos");
|
||||
static const StringIdentity idTexImageName = StringIndexer::get("u_image");
|
||||
static const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
static const StringIdentity idTexturePosAttribName = stringIndexer().get("a_texture_pos");
|
||||
static const StringIdentity idTexImageName = stringIndexer().get("u_image");
|
||||
|
||||
void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders,
|
||||
gfx::Context& context,
|
||||
@@ -500,8 +500,7 @@ void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders,
|
||||
// Rebuild segments, since they're not shared.
|
||||
std::vector<std::unique_ptr<gfx::Drawable::DrawSegment>> drawSegments;
|
||||
drawSegments.reserve(segments->size());
|
||||
for (std::size_t i = 0; i < segments->size(); ++i) {
|
||||
const auto& seg = segments->data()[i];
|
||||
for (const auto& seg : *segments) {
|
||||
auto segCopy = SegmentBase{
|
||||
// no copy constructor
|
||||
seg.vertexOffset,
|
||||
|
||||
@@ -47,8 +47,8 @@ inline const LineLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& imp
|
||||
|
||||
#if MLN_DRAWABLE_RENDERER
|
||||
|
||||
static const StringIdentity idVertexAttribName = StringIndexer::get("a_pos_normal");
|
||||
static const StringIdentity idDataAttribName = StringIndexer::get("a_data");
|
||||
const StringIdentity idVertexAttribName = stringIndexer().get("a_pos_normal");
|
||||
const StringIdentity idDataAttribName = stringIndexer().get("a_data");
|
||||
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
@@ -357,15 +357,15 @@ float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature,
|
||||
|
||||
#if MLN_DRAWABLE_RENDERER
|
||||
/// Property interpolation UBOs
|
||||
static const StringIdentity idLineInterpolationUBOName = StringIndexer::get("LineInterpolationUBO");
|
||||
static const StringIdentity idLineGradientInterpolationUBOName = StringIndexer::get("LineGradientInterpolationUBO");
|
||||
static const StringIdentity idLinePatternInterpolationUBOName = StringIndexer::get("LinePatternInterpolationUBO");
|
||||
static const StringIdentity idLineSDFInterpolationUBOName = StringIndexer::get("LineSDFInterpolationUBO");
|
||||
static const StringIdentity idLineInterpolationUBOName = stringIndexer().get("LineInterpolationUBO");
|
||||
static const StringIdentity idLineGradientInterpolationUBOName = stringIndexer().get("LineGradientInterpolationUBO");
|
||||
static const StringIdentity idLinePatternInterpolationUBOName = stringIndexer().get("LinePatternInterpolationUBO");
|
||||
static const StringIdentity idLineSDFInterpolationUBOName = stringIndexer().get("LineSDFInterpolationUBO");
|
||||
|
||||
/// Evaluated properties that depend on the tile
|
||||
static const StringIdentity idLinePatternTilePropertiesUBOName = StringIndexer::get("LinePatternTilePropertiesUBO");
|
||||
static const StringIdentity idLinePatternTilePropertiesUBOName = stringIndexer().get("LinePatternTilePropertiesUBO");
|
||||
|
||||
static const StringIdentity idLineImageUniformName = StringIndexer::get("u_image");
|
||||
static const StringIdentity idLineImageUniformName = stringIndexer().get("u_image");
|
||||
|
||||
void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
|
||||
gfx::Context& context,
|
||||
|
||||
@@ -246,10 +246,10 @@ void RenderRasterLayer::layerIndexChanged(int32_t newLayerIndex, UniqueChangeReq
|
||||
changeLayerIndex(imageLayerGroup, newLayerIndex, changes);
|
||||
}
|
||||
|
||||
static const StringIdentity idPosAttribName = StringIndexer::get("a_pos");
|
||||
static const StringIdentity idTexturePosAttribName = StringIndexer::get("a_texture_pos");
|
||||
static const StringIdentity idTexImage0Name = StringIndexer::get("u_image0");
|
||||
static const StringIdentity idTexImage1Name = StringIndexer::get("u_image1");
|
||||
static const StringIdentity idPosAttribName = stringIndexer().get("a_pos");
|
||||
static const StringIdentity idTexturePosAttribName = stringIndexer().get("a_texture_pos");
|
||||
static const StringIdentity idTexImage0Name = stringIndexer().get("u_image0");
|
||||
static const StringIdentity idTexImage1Name = stringIndexer().get("u_image1");
|
||||
|
||||
void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
|
||||
gfx::Context& context,
|
||||
@@ -476,7 +476,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
if (geometryChanged) {
|
||||
removeTile(renderPass, tileID);
|
||||
cleared = true;
|
||||
// cleared = true;
|
||||
} else if (0 < updated) {
|
||||
// If we modified drawables without removing them, we're done with this tile.
|
||||
continue;
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <mbgl/renderer/update_parameters.hpp>
|
||||
#include <mbgl/shaders/shader_program_base.hpp>
|
||||
#include <mbgl/shaders/symbol_layer_ubo.hpp>
|
||||
#include <mbgl/gfx/collision_drawable_data.hpp>
|
||||
#include <mbgl/renderer/layers/collision_layer_tweaker.hpp>
|
||||
#endif // MLN_DRAWABLE_RENDERER
|
||||
|
||||
@@ -749,14 +748,14 @@ SymbolDrawableTilePropsUBO buildTileUBO(const SymbolBucket& bucket,
|
||||
};
|
||||
}
|
||||
|
||||
static const auto idDataAttibName = StringIndexer::get("a_data");
|
||||
static const auto posOffsetAttribName = "a_pos_offset";
|
||||
static const auto idPosOffsetAttribName = StringIndexer::get(posOffsetAttribName);
|
||||
static const auto idPixOffsetAttribName = StringIndexer::get("a_pixeloffset");
|
||||
static const auto idProjPosAttribName = StringIndexer::get("a_projected_pos");
|
||||
static const auto idFadeOpacityAttribName = StringIndexer::get("a_fade_opacity");
|
||||
static const auto idTexUniformName = StringIndexer::get("u_texture");
|
||||
static const auto idTexIconUniformName = StringIndexer::get("u_texture_icon");
|
||||
const auto idDataAttibName = stringIndexer().get("a_data");
|
||||
const auto posOffsetAttribName = "a_pos_offset";
|
||||
const auto idPosOffsetAttribName = stringIndexer().get(posOffsetAttribName);
|
||||
const auto idPixOffsetAttribName = stringIndexer().get("a_pixeloffset");
|
||||
const auto idProjPosAttribName = stringIndexer().get("a_projected_pos");
|
||||
const auto idFadeOpacityAttribName = stringIndexer().get("a_fade_opacity");
|
||||
const auto idTexUniformName = stringIndexer().get("u_texture");
|
||||
const auto idTexIconUniformName = stringIndexer().get("u_texture_icon");
|
||||
|
||||
void updateTileAttributes(const SymbolBucket::Buffer& buffer,
|
||||
const bool isText,
|
||||
@@ -866,11 +865,11 @@ void updateTileDrawable(gfx::Drawable& drawable,
|
||||
drawable.setVertexAttributes(std::move(attribs));
|
||||
}
|
||||
|
||||
static const StringIdentity idCollisionPosAttribName = StringIndexer::get("a_pos");
|
||||
static const StringIdentity idCollisionAnchorPosAttribName = StringIndexer::get("a_anchor_pos");
|
||||
static const StringIdentity idCollisionExtrudeAttribName = StringIndexer::get("a_extrude");
|
||||
static const StringIdentity idCollisionPlacedAttribName = StringIndexer::get("a_placed");
|
||||
static const StringIdentity idCollisionShiftAttribName = StringIndexer::get("a_shift");
|
||||
const StringIdentity idCollisionPosAttribName = stringIndexer().get("a_pos");
|
||||
const StringIdentity idCollisionAnchorPosAttribName = stringIndexer().get("a_anchor_pos");
|
||||
const StringIdentity idCollisionExtrudeAttribName = stringIndexer().get("a_extrude");
|
||||
const StringIdentity idCollisionPlacedAttribName = stringIndexer().get("a_placed");
|
||||
const StringIdentity idCollisionShiftAttribName = stringIndexer().get("a_shift");
|
||||
|
||||
gfx::VertexAttributeArray getCollisionVertexAttributes(const SymbolBucket::CollisionBuffer& buffer, bool staticCopy) {
|
||||
gfx::VertexAttributeArray vertexAttrs;
|
||||
@@ -1144,7 +1143,7 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const auto& collisionBox = isText ? bucket.textCollisionBox : bucket.iconCollisionBox;
|
||||
if (const auto shader = std::static_pointer_cast<gfx::ShaderProgramBase>(
|
||||
collisionBoxGroup->getOrCreateShader(
|
||||
context, {}, StringIndexer::get(idCollisionPosAttribName)))) {
|
||||
context, {}, stringIndexer().get(idCollisionPosAttribName)))) {
|
||||
collisionBuilder->setDrawableName(layerCollisionPrefix + suffix + "box");
|
||||
collisionBuilder->setShader(shader);
|
||||
addVertices(collisionBox->vertices().vector(), staticVertexAndAttributes);
|
||||
@@ -1162,7 +1161,7 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
const auto& collisionCircle = isText ? bucket.textCollisionCircle : bucket.iconCollisionCircle;
|
||||
if (const auto shader = std::static_pointer_cast<gfx::ShaderProgramBase>(
|
||||
collisionCircleGroup->getOrCreateShader(
|
||||
context, {}, StringIndexer::get(idCollisionPosAttribName)))) {
|
||||
context, {}, stringIndexer().get(idCollisionPosAttribName)))) {
|
||||
collisionBuilder->setDrawableName(layerCollisionPrefix + suffix + "circle");
|
||||
collisionBuilder->setShader(shader);
|
||||
addVertices(collisionCircle->vertices().vector(), staticVertexAndAttributes);
|
||||
|
||||
@@ -44,10 +44,10 @@ std::array<float, 2> toArray(const Size& s) {
|
||||
return util::cast<float>(std::array<uint32_t, 2>{s.width, s.height});
|
||||
}
|
||||
|
||||
const StringIdentity idTexUniformName = StringIndexer::get("u_texture");
|
||||
const StringIdentity idTexIconUniformName = StringIndexer::get("u_texture_icon");
|
||||
const StringIdentity idExpressionInputsUBOName = StringIndexer::get("ExpressionInputsUBO");
|
||||
const StringIdentity idSymbolPermutationUBOName = StringIndexer::get("SymbolPermutationUBO");
|
||||
const StringIdentity idTexUniformName = stringIndexer().get("u_texture");
|
||||
const StringIdentity idTexIconUniformName = stringIndexer().get("u_texture_icon");
|
||||
const StringIdentity idExpressionInputsUBOName = stringIndexer().get("ExpressionInputsUBO");
|
||||
const StringIdentity idSymbolPermutationUBOName = stringIndexer().get("SymbolPermutationUBO");
|
||||
|
||||
SymbolDrawablePaintUBO buildPaintUBO(bool isText, const SymbolPaintProperties::PossiblyEvaluated& evaluated) {
|
||||
return {
|
||||
@@ -64,12 +64,12 @@ SymbolDrawablePaintUBO buildPaintUBO(bool isText, const SymbolPaintProperties::P
|
||||
|
||||
} // namespace
|
||||
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawableUBOName = StringIndexer::get("SymbolDrawableUBO");
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDynamicUBOName = StringIndexer::get("SymbolDynamicUBO");
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawablePaintUBOName = StringIndexer::get("SymbolDrawablePaintUBO");
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawableTilePropsUBOName = StringIndexer::get(
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawableUBOName = stringIndexer().get("SymbolDrawableUBO");
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDynamicUBOName = stringIndexer().get("SymbolDynamicUBO");
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawablePaintUBOName = stringIndexer().get("SymbolDrawablePaintUBO");
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawableTilePropsUBOName = stringIndexer().get(
|
||||
"SymbolDrawableTilePropsUBO");
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawableInterpolateUBOName = StringIndexer::get(
|
||||
const StringIdentity SymbolLayerTweaker::idSymbolDrawableInterpolateUBOName = stringIndexer().get(
|
||||
"SymbolDrawableInterpolateUBO");
|
||||
|
||||
void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup,
|
||||
|
||||
@@ -187,6 +187,7 @@ std::size_t RenderLayer::removeAllDrawables() {
|
||||
|
||||
void RenderLayer::updateRenderTileIDs() {
|
||||
const auto oldMap = std::move(renderTileIDs);
|
||||
renderTileIDs = std::unordered_map<OverscaledTileID, util::SimpleIdentity>{};
|
||||
if (renderTiles) {
|
||||
renderTileIDs.reserve(renderTiles->size());
|
||||
for (const auto& tile : *renderTiles) {
|
||||
|
||||
@@ -67,8 +67,8 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
}
|
||||
|
||||
// create a builder
|
||||
static const StringIdentity idVertexAttribName = StringIndexer::get("a_pos");
|
||||
static const StringIdentity idDebugUBOName = StringIndexer::get("DebugUBO");
|
||||
static const StringIdentity idVertexAttribName = stringIndexer().get("a_pos");
|
||||
static const StringIdentity idDebugUBOName = stringIndexer().get("DebugUBO");
|
||||
std::unique_ptr<gfx::DrawableBuilder> builder = context.createDrawableBuilder("debug-builder");
|
||||
builder->setShader(debugShader);
|
||||
builder->setRenderPass(renderPass);
|
||||
@@ -109,7 +109,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
texture->setImage(emptyImage);
|
||||
texture->setSamplerConfiguration(
|
||||
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp});
|
||||
static const StringIdentity idDebugOverlayUniformName = StringIndexer::get("u_overlay");
|
||||
static const StringIdentity idDebugOverlayUniformName = stringIndexer().get("u_overlay");
|
||||
samplerLocation = debugShader->getSamplerLocation(idDebugOverlayUniformName);
|
||||
}
|
||||
assert(samplerLocation.has_value());
|
||||
|
||||
@@ -158,7 +158,7 @@ std::shared_ptr<ShaderProgramGL> ShaderProgramGL::create(Context& context,
|
||||
MBGL_CHECK_ERROR(glGetActiveUniformBlockiv(program, index, GL_UNIFORM_BLOCK_DATA_SIZE, &size));
|
||||
assert(length > 0 && size > 0);
|
||||
MBGL_CHECK_ERROR(glUniformBlockBinding(program, index, binding));
|
||||
uniformBlocks.add(StringIndexer::get(name.data()), index, size);
|
||||
uniformBlocks.add(stringIndexer().get(name.data()), index, size);
|
||||
}
|
||||
|
||||
SamplerLocationMap samplerLocations;
|
||||
@@ -178,7 +178,7 @@ std::shared_ptr<ShaderProgramGL> ShaderProgramGL::create(Context& context,
|
||||
GLint location = MBGL_CHECK_ERROR(glGetUniformLocation(program, name.data()));
|
||||
assert(location != -1);
|
||||
if (location != -1) {
|
||||
samplerLocations[StringIndexer::get(name.data())] = location;
|
||||
samplerLocations[stringIndexer().get(name.data())] = location;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,7 +198,7 @@ std::shared_ptr<ShaderProgramGL> ShaderProgramGL::create(Context& context,
|
||||
continue;
|
||||
}
|
||||
const GLint location = MBGL_CHECK_ERROR(glGetAttribLocation(program, name.data()));
|
||||
addAttr(attrs, StringIndexer::get(name.data()), location, length, size, glType);
|
||||
addAttr(attrs, stringIndexer().get(name.data()), location, length, size, glType);
|
||||
}
|
||||
|
||||
return std::make_shared<ShaderProgramGL>(
|
||||
|
||||
@@ -31,7 +31,7 @@ shaders::AttributeInfo::AttributeInfo(std::size_t index_,
|
||||
dataType(dataType_),
|
||||
count(count_),
|
||||
name(name_),
|
||||
nameID(StringIndexer::get(name_)) {}
|
||||
nameID(stringIndexer().get(name_)) {}
|
||||
|
||||
shaders::UniformBlockInfo::UniformBlockInfo(
|
||||
std::size_t index_, bool vertex_, bool fragment_, std::size_t size_, std::string_view name_)
|
||||
@@ -40,12 +40,12 @@ shaders::UniformBlockInfo::UniformBlockInfo(
|
||||
fragment(fragment_),
|
||||
size(size_),
|
||||
name(name_),
|
||||
nameID(StringIndexer::get(name_)) {}
|
||||
nameID(stringIndexer().get(name_)) {}
|
||||
|
||||
shaders::TextureInfo::TextureInfo(std::size_t index_, std::string_view name_)
|
||||
: index(index_),
|
||||
name(name_),
|
||||
nameID(StringIndexer::get(name_)) {}
|
||||
nameID(stringIndexer().get(name_)) {}
|
||||
|
||||
namespace mtl {
|
||||
namespace {
|
||||
@@ -206,7 +206,7 @@ void ShaderProgram::initAttribute(const shaders::AttributeInfo& info) {
|
||||
[&](auto, const gfx::VertexAttribute& attrib) { assert(attrib.getIndex() != index); });
|
||||
uniformBlocks.visit([&](auto, const gfx::UniformBlock& block) { assert(block.getIndex() != index); });
|
||||
#endif
|
||||
vertexAttributes.add(StringIndexer::get(info.name), index, info.dataType, info.count);
|
||||
vertexAttributes.add(stringIndexer().get(info.name), index, info.dataType, info.count);
|
||||
}
|
||||
|
||||
void ShaderProgram::initUniformBlock(const shaders::UniformBlockInfo& info) {
|
||||
@@ -217,7 +217,7 @@ void ShaderProgram::initUniformBlock(const shaders::UniformBlockInfo& info) {
|
||||
[&](auto, const gfx::VertexAttribute& attrib) { assert(attrib.getIndex() != index); });
|
||||
uniformBlocks.visit([&](auto, const gfx::UniformBlock& block) { assert(block.getIndex() != index); });
|
||||
#endif
|
||||
if (const auto& block_ = uniformBlocks.add(StringIndexer::get(info.name), index, info.size)) {
|
||||
if (const auto& block_ = uniformBlocks.add(stringIndexer().get(info.name), index, info.size)) {
|
||||
auto& block = static_cast<UniformBlock&>(*block_);
|
||||
block.setBindVertex(info.vertex);
|
||||
block.setBindFragment(info.fragment);
|
||||
@@ -225,7 +225,7 @@ void ShaderProgram::initUniformBlock(const shaders::UniformBlockInfo& info) {
|
||||
}
|
||||
|
||||
void ShaderProgram::initTexture(const shaders::TextureInfo& info) {
|
||||
textureBindings[StringIndexer::get(info.name.data())] = info.index;
|
||||
textureBindings[stringIndexer().get(info.name.data())] = info.index;
|
||||
}
|
||||
|
||||
} // namespace mtl
|
||||
|
||||
@@ -19,10 +19,7 @@ StringIndexer::StringIndexer() {
|
||||
|
||||
StringIdentity StringIndexer::get(std::string_view string) {
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> readerLock(instance().sharedMutex);
|
||||
|
||||
const auto& stringToIdentity = instance().stringToIdentity;
|
||||
[[maybe_unused]] const auto& identityToString = instance().identityToString;
|
||||
std::shared_lock<std::shared_mutex> readerLock(sharedMutex);
|
||||
assert(stringToIdentity.size() == identityToString.size());
|
||||
|
||||
if (const auto it = stringToIdentity.find(string); it != stringToIdentity.end()) {
|
||||
@@ -31,15 +28,11 @@ StringIdentity StringIndexer::get(std::string_view string) {
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> writerLock(instance().sharedMutex);
|
||||
|
||||
auto& stringToIdentity = instance().stringToIdentity;
|
||||
auto& identityToString = instance().identityToString;
|
||||
std::unique_lock<std::shared_mutex> writerLock(sharedMutex);
|
||||
assert(stringToIdentity.size() == identityToString.size());
|
||||
|
||||
if (const auto it = stringToIdentity.find(string); it == stringToIdentity.end()) {
|
||||
// this writer to insert
|
||||
auto& buffer = instance().buffer;
|
||||
const auto previousCapacity = buffer.capacity();
|
||||
|
||||
const StringIdentity id = identityToString.size();
|
||||
@@ -67,30 +60,24 @@ StringIdentity StringIndexer::get(std::string_view string) {
|
||||
}
|
||||
|
||||
std::string StringIndexer::get(const StringIdentity id) {
|
||||
std::shared_lock<std::shared_mutex> readerLock(instance().sharedMutex);
|
||||
std::shared_lock<std::shared_mutex> readerLock(sharedMutex);
|
||||
|
||||
const auto& identityToString = instance().identityToString;
|
||||
assert(id < identityToString.size());
|
||||
|
||||
return id < identityToString.size() ? (instance().buffer.data() + identityToString[id]) : empty;
|
||||
}
|
||||
|
||||
void StringIndexer::clear() {
|
||||
std::unique_lock<std::shared_mutex> writerLock(instance().sharedMutex);
|
||||
|
||||
instance().stringToIdentity.clear();
|
||||
instance().identityToString.clear();
|
||||
instance().buffer.clear();
|
||||
return id < identityToString.size() ? (buffer.data() + identityToString[id]) : empty;
|
||||
}
|
||||
|
||||
size_t StringIndexer::size() {
|
||||
std::shared_lock<std::shared_mutex> readerLock(instance().sharedMutex);
|
||||
std::shared_lock<std::shared_mutex> readerLock(sharedMutex);
|
||||
|
||||
[[maybe_unused]] auto& stringToIdentity = instance().stringToIdentity;
|
||||
auto& identityToString = instance().identityToString;
|
||||
assert(stringToIdentity.size() == identityToString.size());
|
||||
|
||||
return identityToString.size();
|
||||
}
|
||||
|
||||
StringIndexer& stringIndexer() {
|
||||
static StringIndexer inst;
|
||||
return inst;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -6,47 +6,51 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
TEST(StringIndexer, AddStrings) {
|
||||
StringIndexer::clear();
|
||||
EXPECT_EQ(StringIndexer::size(), 0);
|
||||
TEST(StringIndexer, SingletonStringIndexer) {
|
||||
EXPECT_GE(stringIndexer().size(), 0);
|
||||
}
|
||||
|
||||
const auto id1 = StringIndexer::get("test string1");
|
||||
TEST(StringIndexer, AddStrings) {
|
||||
StringIndexer strIndexer;
|
||||
EXPECT_EQ(strIndexer.size(), 0);
|
||||
|
||||
const auto id1 = strIndexer.get("test string1");
|
||||
EXPECT_EQ(id1, 0);
|
||||
EXPECT_EQ(StringIndexer::size(), 1);
|
||||
EXPECT_EQ(strIndexer.size(), 1);
|
||||
|
||||
const std::string_view s2 = "test string2";
|
||||
const auto id2 = StringIndexer::get(s2);
|
||||
const auto id2 = strIndexer.get(s2);
|
||||
EXPECT_EQ(id2, 1);
|
||||
EXPECT_EQ(StringIndexer::size(), 2);
|
||||
EXPECT_EQ(strIndexer.size(), 2);
|
||||
}
|
||||
|
||||
TEST(StringIndexer, GetString) {
|
||||
StringIndexer::clear();
|
||||
EXPECT_EQ(StringIndexer::size(), 0);
|
||||
StringIndexer strIndexer;
|
||||
EXPECT_EQ(strIndexer.size(), 0);
|
||||
|
||||
constexpr auto str = "test string1";
|
||||
|
||||
const auto id1 = StringIndexer::get(str);
|
||||
const auto id1 = strIndexer.get(str);
|
||||
EXPECT_EQ(id1, 0);
|
||||
EXPECT_EQ(StringIndexer::size(), 1);
|
||||
EXPECT_EQ(strIndexer.size(), 1);
|
||||
|
||||
const auto str1 = StringIndexer::get(id1);
|
||||
const auto str1 = strIndexer.get(id1);
|
||||
EXPECT_EQ(str, str1);
|
||||
|
||||
const auto str2 = str;
|
||||
const auto id2 = StringIndexer::get(str2);
|
||||
const auto id2 = strIndexer.get(str2);
|
||||
EXPECT_EQ(id1, id2);
|
||||
}
|
||||
|
||||
TEST(StringIndexer, Reallocate) {
|
||||
StringIndexer::clear();
|
||||
EXPECT_EQ(StringIndexer::size(), 0);
|
||||
StringIndexer strIndexer;
|
||||
EXPECT_EQ(strIndexer.size(), 0);
|
||||
|
||||
constexpr auto str = "reallocate test string1";
|
||||
|
||||
const auto id1 = StringIndexer::get(str);
|
||||
const auto id1 = strIndexer.get(str);
|
||||
EXPECT_EQ(id1, 0);
|
||||
EXPECT_EQ(StringIndexer::size(), 1);
|
||||
EXPECT_EQ(strIndexer.size(), 1);
|
||||
|
||||
// force reallocation. assume capacity: 100 strings, 100 * 32 bytes buffer space
|
||||
constexpr auto N = 1000;
|
||||
@@ -55,31 +59,31 @@ TEST(StringIndexer, Reallocate) {
|
||||
return "1234567890"s + "1234567890"s + "1234567890"s + "---" + std::to_string(i);
|
||||
};
|
||||
for (auto i = 1; i < N; ++i) {
|
||||
StringIndexer::get(string_for_i(i));
|
||||
strIndexer.get(string_for_i(i));
|
||||
}
|
||||
|
||||
EXPECT_EQ(StringIndexer::size(), N);
|
||||
EXPECT_EQ(strIndexer.size(), N);
|
||||
|
||||
const auto str1 = StringIndexer::get(id1);
|
||||
const auto str1 = strIndexer.get(id1);
|
||||
EXPECT_EQ(str, str1);
|
||||
|
||||
for (auto i = 1; i < N; ++i) {
|
||||
const auto strN1 = StringIndexer::get(i);
|
||||
const auto strN1 = strIndexer.get(i);
|
||||
EXPECT_EQ(strN1, string_for_i(i));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(StringIndexer, GetOOBIdentity) {
|
||||
StringIndexer::clear();
|
||||
EXPECT_EQ(StringIndexer::size(), 0);
|
||||
StringIndexer strIndexer;
|
||||
EXPECT_EQ(strIndexer.size(), 0);
|
||||
|
||||
std::string str;
|
||||
#ifndef NDEBUG
|
||||
EXPECT_DEATH_IF_SUPPORTED(str = StringIndexer::get(42), "id < identityToString.size()");
|
||||
EXPECT_DEATH_IF_SUPPORTED(str = strIndexer.get(42), "id < identityToString.size()");
|
||||
#endif
|
||||
EXPECT_TRUE(str.empty());
|
||||
#ifndef NDEBUG
|
||||
EXPECT_DEATH_IF_SUPPORTED(str = StringIndexer::get(-1), "id < identityToString.size()");
|
||||
EXPECT_DEATH_IF_SUPPORTED(str = strIndexer.get(-1), "id < identityToString.size()");
|
||||
#endif
|
||||
EXPECT_TRUE(str.empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user