Drawable Renderer (#1570), CI warnings

This commit is contained in:
Tim Sylvester
2023-06-12 14:22:51 -07:00
committed by Bart Louwers
parent 3937ace95a
commit e7a82f78bc
11 changed files with 45 additions and 42 deletions

View File

@@ -11,8 +11,7 @@
namespace mbgl {
class Color;
template <typename VertexType>
class Segment;
class SegmentBase;
namespace gfx {
@@ -136,7 +135,7 @@ public:
std::size_t vertexOffset,
std::size_t vertexLength);
void setSegments(gfx::DrawMode, std::vector<uint16_t> indexes, const std::vector<Segment<void>>&);
void setSegments(gfx::DrawMode, std::vector<uint16_t> indexes, const std::vector<SegmentBase>&);
/// Add lines based on existing vertices
void addLines(const std::vector<uint16_t>& indexes,
@@ -155,7 +154,7 @@ protected:
virtual UniqueDrawable createDrawable() const = 0;
/// Create a segment wrapper
virtual std::unique_ptr<Drawable::DrawSegment> createSegment(gfx::DrawMode, Segment<void>&&) = 0;
virtual std::unique_ptr<Drawable::DrawSegment> createSegment(gfx::DrawMode, SegmentBase&&) = 0;
/// Setup the SDK-specific aspects after all the values are present
virtual void init() = 0;

View File

@@ -6,7 +6,7 @@ namespace mbgl {
namespace gfx {
struct Drawable::DrawSegment {
DrawSegment(gfx::DrawMode mode_, Segment<void>&& segment_)
DrawSegment(gfx::DrawMode mode_, SegmentBase&& segment_)
: mode(mode_),
segment(std::move(segment_)) {}
@@ -14,12 +14,12 @@ struct Drawable::DrawSegment {
const gfx::DrawMode& getMode() const { return mode; }
Segment<void>& getSegment() { return segment; }
const Segment<void>& getSegment() const { return segment; }
SegmentBase& getSegment() { return segment; }
const SegmentBase& getSegment() const { return segment; }
protected:
gfx::DrawMode mode;
Segment<void> segment;
SegmentBase segment;
};
} // namespace gfx

View File

@@ -23,7 +23,7 @@ protected:
gfx::UniqueDrawable createDrawable() const override;
using DrawSegment = gfx::Drawable::DrawSegment;
std::unique_ptr<DrawSegment> createSegment(gfx::DrawMode, Segment<void>&&) override;
std::unique_ptr<DrawSegment> createSegment(gfx::DrawMode, SegmentBase&&) override;
/// Setup the SDK-specific aspects after all the values are present
void init() override;

View File

@@ -180,7 +180,7 @@ std::size_t DrawableBuilder::addVertices(const std::vector<std::array<int16_t, 2
void DrawableBuilder::setSegments(gfx::DrawMode mode,
std::vector<uint16_t> indexes,
const std::vector<Segment<void>>& segments) {
const std::vector<SegmentBase>& segments) {
impl->indexes = std::move(indexes);
for (const auto& seg : segments) {
#if !defined(NDEBUG)
@@ -196,7 +196,7 @@ void DrawableBuilder::setSegments(gfx::DrawMode mode,
}
#endif
auto segCopy = Segment<void>{
auto segCopy = SegmentBase{
// no copy constructor
seg.vertexOffset,
seg.indexOffset,
@@ -217,10 +217,10 @@ void DrawableBuilder::addLines(const std::vector<uint16_t>& indexes,
}
impl->segments.emplace_back(createSegment(Lines(lineWidth),
Segment<void>{/*.vertexOffset = */ 0,
/*.indexOffset = */ indexes.size(),
/*.vertexLength = */ 0,
/*.indexLength = */ indexLength}));
SegmentBase{/*.vertexOffset = */ 0,
/*.indexOffset = */ indexes.size(),
/*.vertexLength = */ 0,
/*.indexLength = */ indexLength}));
if (impl->indexes.empty()) {
impl->indexes.reserve(indexLength);
@@ -241,10 +241,10 @@ void DrawableBuilder::addTriangles(const std::vector<uint16_t>& indexes,
}
impl->segments.emplace_back(createSegment(Triangles(),
Segment<void>{/*.vertexOffset = */ 0,
/*.indexOffset = */ impl->indexes.size(),
/*.vertexLength = */ impl->vertices.elements(),
/*.indexLength = */ indexLength}));
SegmentBase{/*.vertexOffset = */ 0,
/*.indexOffset = */ impl->indexes.size(),
/*.vertexLength = */ impl->vertices.elements(),
/*.indexLength = */ indexLength}));
if (impl->indexes.empty()) {
impl->indexes.reserve(indexLength);

View File

@@ -13,7 +13,7 @@ gfx::UniqueDrawable DrawableGLBuilder::createDrawable() const {
return std::make_unique<DrawableGL>(drawableName.empty() ? name : drawableName);
};
std::unique_ptr<gfx::Drawable::DrawSegment> DrawableGLBuilder::createSegment(gfx::DrawMode mode, Segment<void>&& seg) {
std::unique_ptr<gfx::Drawable::DrawSegment> DrawableGLBuilder::createSegment(gfx::DrawMode mode, SegmentBase&& seg) {
return std::make_unique<DrawableGL::DrawSegmentGL>(mode, std::move(seg), VertexArray{{nullptr, false}});
}

View File

@@ -49,7 +49,7 @@ public:
};
struct DrawableGL::DrawSegmentGL final : public gfx::Drawable::DrawSegment {
DrawSegmentGL(gfx::DrawMode mode_, Segment<void>&& segment_, VertexArray&& vertexArray_)
DrawSegmentGL(gfx::DrawMode mode_, SegmentBase&& segment_, VertexArray&& vertexArray_)
: gfx::Drawable::DrawSegment(mode_, std::move(segment_)),
vertexArray(std::move(vertexArray_)) {}

View File

@@ -9,14 +9,13 @@
namespace mbgl {
template <class AttributeList>
class Segment {
class SegmentBase {
public:
Segment(std::size_t vertexOffset_,
std::size_t indexOffset_,
std::size_t vertexLength_ = 0,
std::size_t indexLength_ = 0,
float sortKey_ = 0.0f)
SegmentBase(std::size_t vertexOffset_,
std::size_t indexOffset_,
std::size_t vertexLength_ = 0,
std::size_t indexLength_ = 0,
float sortKey_ = 0.0f)
: vertexOffset(vertexOffset_),
indexOffset(indexOffset_),
vertexLength(vertexLength_),
@@ -28,7 +27,7 @@ public:
// explicitly defaulted move constructor does not match
// the calculated one" when marking this 'noexcept'.
// NOLINTNEXTLINE(performance-noexcept-move-constructor)
Segment(Segment&&) = default;
SegmentBase(SegmentBase&&) = default;
const std::size_t vertexOffset;
const std::size_t indexOffset;
@@ -48,6 +47,11 @@ public:
float sortKey;
};
template <class AttributeList>
class Segment : public SegmentBase {
using SegmentBase::SegmentBase;
};
template <class AttributeList>
using SegmentVector = std::vector<Segment<AttributeList>>;

View File

@@ -410,7 +410,7 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders,
circleBuilder->setSegments(gfx::Triangles(),
bucket.triangles.vector(),
reinterpret_cast<const std::vector<Segment<void>>&>(bucket.segments));
reinterpret_cast<const std::vector<SegmentBase>&>(bucket.segments));
circleBuilder->flush();

View File

@@ -32,10 +32,10 @@ using namespace style;
namespace {
static constexpr std::string_view FillShaderName = "FillShader";
static constexpr std::string_view FillOutlineShaderName = "FillOutlineShader";
static constexpr std::string_view FillPatternShaderName = "FillPatternShader";
static constexpr std::string_view FillOutlinePatternShaderName = "FillOutlinePatternShader";
constexpr std::string_view FillShaderName = "FillShader";
constexpr std::string_view FillOutlineShaderName = "FillOutlineShader";
constexpr std::string_view FillPatternShaderName = "FillPatternShader";
constexpr std::string_view FillOutlinePatternShaderName = "FillOutlinePatternShader";
inline const FillLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == FillLayer::Impl::staticTypeInfo());
@@ -493,7 +493,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
fillBuilder->addVertices(rawVerts, 0, rawVerts.size());
fillBuilder->setSegments(gfx::Triangles(),
bucket.triangles.vector(),
reinterpret_cast<const std::vector<Segment<void>>&>(bucket.triangleSegments));
reinterpret_cast<const std::vector<SegmentBase>&>(bucket.triangleSegments));
finish(*fillBuilder, tileID, interpolateUBO, tileProps);
}
if (outlineBuilder) {
@@ -503,7 +503,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
outlineBuilder->addVertices(rawVerts, 0, rawVerts.size());
outlineBuilder->setSegments(gfx::Lines(2),
bucket.lines.vector(),
reinterpret_cast<const std::vector<Segment<void>>&>(bucket.lineSegments));
reinterpret_cast<const std::vector<SegmentBase>&>(bucket.lineSegments));
finish(*outlineBuilder, tileID, interpolateUBO, tileProps);
}
} else { // FillPattern is defined
@@ -550,7 +550,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
patternBuilder->setSegments(
gfx::Triangles(),
bucket.triangles.vector(),
reinterpret_cast<const std::vector<Segment<void>>&>(bucket.triangleSegments));
reinterpret_cast<const std::vector<SegmentBase>&>(bucket.triangleSegments));
if (const auto& atlases = tile.getAtlasTextures()) {
if (const auto samplerLocation = fillShader->getSamplerLocation("u_image")) {
@@ -569,7 +569,7 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
outlinePatternBuilder->setSegments(
gfx::Lines(2),
bucket.lines.vector(),
reinterpret_cast<const std::vector<Segment<void>>&>(bucket.lineSegments));
reinterpret_cast<const std::vector<SegmentBase>&>(bucket.lineSegments));
if (const auto& atlases = tile.getAtlasTextures()) {
if (const auto samplerLocation = outlineShader->getSamplerLocation("u_image")) {

View File

@@ -288,7 +288,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
std::vector<std::array<int16_t, 2>>& vertices,
std::vector<std::array<int16_t, 2>>& attributes,
std::vector<uint16_t>& indices,
std::vector<Segment<void>>& segments) {
std::vector<SegmentBase>& segments) {
constexpr const uint16_t vertexLength = 4;
// Create the vertex buffer for the specified tile mask.
@@ -339,7 +339,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
std::vector<std::array<int16_t, 2>> vertices, attributes;
std::vector<uint16_t> indices;
std::vector<Segment<void>> segments;
std::vector<SegmentBase> segments;
buildRenderData(bucket.mask, vertices, attributes, indices, segments);
builder->addVertices(vertices, 0, vertices.size());
builder->setSegments(gfx::Triangles(), indices, segments);
@@ -370,7 +370,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
builder->setSegments(gfx::Triangles(),
bucket.indices.vector(),
reinterpret_cast<const std::vector<Segment<void>>&>(bucket.segments));
reinterpret_cast<const std::vector<SegmentBase>&>(bucket.segments));
// attributes
{

View File

@@ -25,7 +25,7 @@ public:
std::optional<T> constant() const {
return value.match([&](const T& t) { return std::optional<T>(t); },
[&](const auto&) { return std::optional<T>{}; });
[&](const auto&) { return std::nullopt; });
}
T constantOr(const T& t) const { return constant().value_or(t); }