Fix updates hillshade geometry (#2842)

This commit is contained in:
Tim Sylvester
2024-09-23 08:36:00 -07:00
committed by GitHub
parent cadb8d1da0
commit 84ca231da5
28 changed files with 307 additions and 156 deletions

View File

@@ -25,6 +25,7 @@ class PaintParameters;
class PaintPropertyBindersBase;
enum class RenderPass : uint8_t;
class RenderTile;
class SegmentBase;
using LayerTweakerPtr = std::shared_ptr<LayerTweaker>;
using RenderTiles = std::shared_ptr<const std::vector<std::reference_wrapper<const RenderTile>>>;
@@ -192,7 +193,20 @@ public:
const gfx::VertexAttributeArrayPtr& getVertexAttributes() const noexcept { return vertexAttributes; }
/// Set vertex attribute array
void setVertexAttributes(gfx::VertexAttributeArrayPtr value) noexcept { vertexAttributes = std::move(value); }
void setVertexAttributes(gfx::VertexAttributeArrayPtr value) noexcept {
vertexAttributes = std::move(value);
// The attribute bindings need to be rebuilt, we can't rely on the update
// time check as these new values may not have been modified recently.
attributeUpdateTime.reset();
}
/// Update vertices, indices, and segments
virtual void updateVertexAttributes(gfx::VertexAttributeArrayPtr,
std::size_t vertexCount,
gfx::DrawMode,
gfx::IndexVectorBasePtr,
const SegmentBase* segments,
std::size_t segmentCount) = 0;
/// Get the instance attributes
const gfx::VertexAttributeArrayPtr& getInstanceAttributes() const noexcept { return instanceAttributes; }
@@ -261,6 +275,7 @@ public:
void setRenderTile(Immutable<std::vector<RenderTile>>, const RenderTile*);
const std::chrono::duration<double> createTime = util::MonotonicTimer::now();
std::optional<std::chrono::duration<double>> getAttributeUpdateTime() const { return attributeUpdateTime; }
protected:
bool enabled = true;
@@ -282,7 +297,7 @@ protected:
UniqueDrawableData drawableData{};
gfx::VertexAttributeArrayPtr vertexAttributes;
gfx::VertexAttributeArrayPtr instanceAttributes;
std::chrono::duration<double> attributeUpdateTime = util::MonotonicTimer::now();
std::optional<std::chrono::duration<double>> attributeUpdateTime;
struct Impl;
std::unique_ptr<Impl> impl;

View File

@@ -48,6 +48,13 @@ public:
void upload(gfx::UploadPass&);
void updateVertexAttributes(gfx::VertexAttributeArrayPtr,
std::size_t vertexCount,
gfx::DrawMode,
gfx::IndexVectorBasePtr,
const SegmentBase* segments,
std::size_t segmentCount) override;
protected:
class Impl;
const std::unique_ptr<Impl> impl;

View File

@@ -35,7 +35,7 @@ public:
static const std::vector<std::uint8_t>& getRaw(gfx::VertexAttribute& attr,
platform::GLenum,
std::chrono::duration<double> lastUpdate);
std::optional<std::chrono::duration<double>> lastUpdate);
private:
static int getSize(platform::GLenum glType);

View File

@@ -130,9 +130,6 @@ public:
std::size_t size,
bool persistent) override;
/// Get an empty buffer to act as a placeholder
const BufferResource& getEmptyBuffer();
/// Get a reusable buffer containing the standard fixed tile vertices (+/- `util::EXTENT`)
const BufferResource& getTileVertexBuffer();

View File

@@ -57,6 +57,13 @@ public:
void setSubLayerIndex(int32_t) override;
void setDepthType(gfx::DepthMaskType) override;
void updateVertexAttributes(gfx::VertexAttributeArrayPtr,
std::size_t vertexCount,
gfx::DrawMode,
gfx::IndexVectorBasePtr,
const SegmentBase* segments,
std::size_t segmentCount) override;
protected:
// For testing only.
Drawable(std::unique_ptr<Impl>);

View File

@@ -56,7 +56,9 @@ public:
void updateResource(BufferResource&, const void* data, std::size_t size);
const gfx::UniqueVertexBufferResource& getBuffer(const gfx::VertexVectorBasePtr&, gfx::BufferUsageType);
const gfx::UniqueVertexBufferResource& getBuffer(const gfx::VertexVectorBasePtr&,
gfx::BufferUsageType,
bool forceUpdate);
gfx::AttributeBindingArray buildAttributeBindings(
const std::size_t vertexCount,
@@ -66,7 +68,7 @@ public:
const gfx::VertexAttributeArray& defaults,
const gfx::VertexAttributeArray& overrides,
gfx::BufferUsageType,
const std::chrono::duration<double> lastUpdate,
const std::optional<std::chrono::duration<double>> lastUpdate,
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) override;
std::unique_ptr<gfx::TextureResource> createTextureResource(Size,

View File

@@ -22,7 +22,8 @@ public:
static const gfx::UniqueVertexBufferResource& getBuffer(gfx::VertexAttribute&,
UploadPass&,
const gfx::BufferUsageType);
const gfx::BufferUsageType,
bool forceUpdate);
};
/// Stores a collection of vertex attributes by name

View File

@@ -44,6 +44,13 @@ public:
void setLineWidth(int32_t value) override;
void setCullFaceMode(const gfx::CullFaceMode&) override;
void updateVertexAttributes(gfx::VertexAttributeArrayPtr,
std::size_t vertexCount,
gfx::DrawMode,
gfx::IndexVectorBasePtr,
const SegmentBase* segments,
std::size_t segmentCount) override;
protected:
void buildVulkanInputBindings() noexcept;

View File

@@ -51,7 +51,9 @@ public:
bool persistent) override;
void updateIndexBufferResource(gfx::IndexBufferResource&, const void* data, std::size_t size) override;
const gfx::UniqueVertexBufferResource& getBuffer(const gfx::VertexVectorBasePtr&, gfx::BufferUsageType);
const gfx::UniqueVertexBufferResource& getBuffer(const gfx::VertexVectorBasePtr&,
gfx::BufferUsageType,
bool forceUpdate);
gfx::AttributeBindingArray buildAttributeBindings(
const std::size_t vertexCount,
@@ -61,7 +63,7 @@ public:
const gfx::VertexAttributeArray& defaults,
const gfx::VertexAttributeArray& overrides,
gfx::BufferUsageType,
const std::chrono::duration<double> lastUpdate,
const std::optional<std::chrono::duration<double>> lastUpdate,
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) override;
std::unique_ptr<gfx::TextureResource> createTextureResource(Size,

View File

@@ -23,7 +23,8 @@ public:
static const gfx::UniqueVertexBufferResource& getBuffer(gfx::VertexAttribute&,
UploadPass&,
const gfx::BufferUsageType);
const gfx::BufferUsageType,
bool forceUpdate);
};
/// Stores a collection of vertex attributes by name