core: Avoid unnecessary raster buffer updates (#4085)

This commit is contained in:
Adrian Cojocaru
2026-02-04 19:01:30 +02:00
committed by GitHub
parent cc88843db7
commit 7ba69ce52b
4 changed files with 22 additions and 11 deletions

View File

@@ -94,7 +94,7 @@ protected:
virtual void initCommandPool(); virtual void initCommandPool();
virtual void initFrameCapture(); virtual void initFrameCapture();
virtual void destroyResources(); void destroyResources();
protected: protected:
vk::DynamicLoader dynamicLoader; vk::DynamicLoader dynamicLoader;

View File

@@ -187,8 +187,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
[&](const gfx::UniqueDrawableBuilder& builder, gfx::Drawable* drawable, const RasterBucket& bucket) { [&](const gfx::UniqueDrawableBuilder& builder, gfx::Drawable* drawable, const RasterBucket& bucket) {
// The bucket may later add, remove, or change masking. In that case, the tile's // The bucket may later add, remove, or change masking. In that case, the tile's
// shared data and segments are not updated, and it needs to be re-created. // shared data and segments are not updated, and it needs to be re-created.
if (drawable && if (drawable && bucket.sharedVertices->isModifiedAfter(drawable->createTime)) {
(bucket.sharedVertices->isModifiedAfter(drawable->createTime) || bucket.sharedTriangles->getDirty())) {
return false; return false;
} }
@@ -311,7 +310,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
} }
}); });
if (tileUpdateTime && (bucket.vertices.isModifiedAfter(*tileUpdateTime) || bucket.indices.getDirty())) { if (tileUpdateTime && (bucket.vertices.isModifiedAfter(*tileUpdateTime))) {
removeTile(renderPass, tileID); removeTile(renderPass, tileID);
cleared = true; cleared = true;
} }

View File

@@ -42,8 +42,9 @@ constexpr uint32_t drawableUniformDescriptorPoolSize = 3 * 1024;
constexpr uint32_t drawableImageDescriptorPoolSize = drawableUniformDescriptorPoolSize / 2; constexpr uint32_t drawableImageDescriptorPoolSize = drawableUniformDescriptorPoolSize / 2;
namespace { namespace {
std::mutex glslangMutex;
uint32_t glslangRefCount = 0; uint32_t glslangRefCount = 0;
} } // namespace
class RenderbufferResource : public gfx::RenderbufferResource { class RenderbufferResource : public gfx::RenderbufferResource {
public: public:
@@ -54,8 +55,11 @@ Context::Context(RendererBackend& backend_)
: gfx::Context(vulkan::maximumVertexBindingCount), : gfx::Context(vulkan::maximumVertexBindingCount),
backend(backend_), backend(backend_),
globalUniformBuffers(DescriptorSetType::Global, 0, 0, shaders::globalUBOCount) { globalUniformBuffers(DescriptorSetType::Global, 0, 0, shaders::globalUBOCount) {
if (glslangRefCount++ == 0) { {
glslang::InitializeProcess(); std::scoped_lock lock(glslangMutex);
if (glslangRefCount++ == 0) {
glslang::InitializeProcess();
}
} }
initFrameResources(); initFrameResources();
@@ -66,8 +70,11 @@ Context::~Context() noexcept {
destroyResources(); destroyResources();
if (--glslangRefCount == 0) { {
glslang::FinalizeProcess(); std::scoped_lock lock(glslangMutex);
if (--glslangRefCount == 0) {
glslang::FinalizeProcess();
}
} }
#if !defined(NDEBUG) #if !defined(NDEBUG)

View File

@@ -40,13 +40,18 @@
#define VMA_DEBUG_DETECT_CORRUPTION 1 #define VMA_DEBUG_DETECT_CORRUPTION 1
#define VMA_DEBUG_INITIALIZE_ALLOCATIONS 1 #define VMA_DEBUG_INITIALIZE_ALLOCATIONS 1
#define VMA_LEAK_LOG_FORMAT(format, ...) \ #define VMA_HEAVY_ASSERT(expr) VMA_ASSERT(expr)
#define VMA_DEBUG_LOG_FORMAT(format, ...) \
{ \ { \
char buffer[4096]; \ char buffer[4096]; \
sprintf(buffer, format, __VA_ARGS__); \ sprintf(buffer, format, __VA_ARGS__); \
mbgl::Log::Info(mbgl::Event::Render, buffer); \ mbgl::Log::Info(mbgl::Event::Render, buffer); \
} }
#define VMA_DEBUG_LOG(str) VMA_DEBUG_LOG_FORMAT("%s", (str))
#define VMA_LEAK_LOG_FORMAT(...) VMA_DEBUG_LOG_FORMAT(__VA_ARGS__)
#endif #endif
#define VMA_IMPLEMENTATION #define VMA_IMPLEMENTATION
@@ -100,7 +105,7 @@ RendererBackend::RendererBackend(const gfx::ContextMode contextMode_)
allocator(nullptr) {} allocator(nullptr) {}
RendererBackend::~RendererBackend() { RendererBackend::~RendererBackend() {
destroyResources(); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall) destroyResources();
} }
std::unique_ptr<gfx::Context> RendererBackend::createContext() { std::unique_ptr<gfx::Context> RendererBackend::createContext() {