Fixed metal vertex attribute update render tests (#1867)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Alex Cristici
2023-11-15 17:36:21 +02:00
committed by GitHub
parent 1200046f0c
commit 15cfb3570c
3 changed files with 18 additions and 2 deletions

View File

@@ -56,6 +56,9 @@ public:
return newAttrs;
}
/// Indicates whether any values have changed
bool isDirty() const override;
private:
gfx::UniqueVertexAttribute create(int index, gfx::AttributeDataType dataType, std::size_t count) const override {
return gfx::UniqueVertexAttribute(new VertexAttribute(index, dataType, count));

View File

@@ -6,11 +6,11 @@
#include <mbgl/gfx/program.hpp>
#include <mbgl/gfx/uniform.hpp>
#include <mbgl/gfx/uniform_buffer.hpp>
#include <mbgl/gfx/vertex_attribute.hpp>
#include <mbgl/mtl/mtl_fwd.hpp>
#include <mbgl/mtl/render_pass.hpp>
#include <mbgl/mtl/uniform_buffer.hpp>
#include <mbgl/mtl/upload_pass.hpp>
#include <mbgl/mtl/vertex_attribute.hpp>
#include <mbgl/mtl/vertex_buffer_resource.hpp>
#include <mbgl/programs/segment.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
@@ -44,7 +44,7 @@ public:
gfx::IndexVectorBasePtr indexes;
std::size_t vertexCount = 0;
gfx::AttributeDataType vertexType = gfx::AttributeDataType::Invalid;
gfx::VertexAttributeArray vertexAttributes;
VertexAttributeArray vertexAttributes;
std::vector<gfx::UniqueVertexBufferResource> attributeBuffers;

View File

@@ -33,5 +33,18 @@ const gfx::UniqueVertexBufferResource& VertexAttribute::getBuffer(gfx::VertexAtt
return attrib_.getBuffer();
}
bool VertexAttributeArray::isDirty() const {
return std::any_of(attrs.begin(), attrs.end(), [](const auto& kv) {
if (kv.second) {
// If we have shared data, the dirty flag from that overrides ours
const auto& attrib = static_cast<const VertexAttribute&>(*kv.second);
if (const auto& shared = attrib.getSharedRawData()) {
return shared->getDirty();
}
}
return kv.second && kv.second->isDirty();
});
}
} // namespace mtl
} // namespace mbgl