mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[drape] Faster RenderBucket
Signed-off-by: x7z4w <x7z4w@noreply.codeberg.org>
This commit is contained in:
@@ -88,6 +88,11 @@ else()
|
|||||||
add_compile_options(-ffast-math $<$<CXX_COMPILER_ID:GNU>:-Wno-psabi>)
|
add_compile_options(-ffast-math $<$<CXX_COMPILER_ID:GNU>:-Wno-psabi>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Needed for std::execution::par
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
add_compile_options(-fexperimental-library)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (PLATFORM_WIN)
|
if (PLATFORM_WIN)
|
||||||
add_definitions(
|
add_definitions(
|
||||||
-DWIN32_LEAN_AND_MEAN
|
-DWIN32_LEAN_AND_MEAN
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
#include "drape/batcher.hpp"
|
#include "drape/batcher.hpp"
|
||||||
#include "drape/batcher_helpers.hpp"
|
#include "drape/batcher_helpers.hpp"
|
||||||
#include "drape/cpu_buffer.hpp"
|
|
||||||
#include "drape/index_storage.hpp"
|
#include "drape/index_storage.hpp"
|
||||||
#include "drape/vertex_array_buffer.hpp"
|
#include "drape/vertex_array_buffer.hpp"
|
||||||
|
|
||||||
#include "base/assert.hpp"
|
#include "base/assert.hpp"
|
||||||
#include "base/stl_helpers.hpp"
|
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -190,14 +188,6 @@ void Batcher::ResetSession()
|
|||||||
m_buckets.clear();
|
m_buckets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batcher::SetFeatureMinZoom(int minZoom)
|
|
||||||
{
|
|
||||||
m_featureMinZoom = minZoom;
|
|
||||||
|
|
||||||
for (auto const & bucket : m_buckets)
|
|
||||||
bucket.second->SetFeatureMinZoom(m_featureMinZoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Batcher::SetBatcherHash(uint64_t batcherHash)
|
void Batcher::SetBatcherHash(uint64_t batcherHash)
|
||||||
{
|
{
|
||||||
m_batcherHash = batcherHash;
|
m_batcherHash = batcherHash;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "base/macros.hpp"
|
#include "base/macros.hpp"
|
||||||
|
|
||||||
|
#include <execution>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -68,7 +69,13 @@ public:
|
|||||||
|
|
||||||
void SetBatcherHash(uint64_t batcherHash);
|
void SetBatcherHash(uint64_t batcherHash);
|
||||||
|
|
||||||
void SetFeatureMinZoom(int minZoom);
|
inline void SetFeatureMinZoom(int minZoom)
|
||||||
|
{
|
||||||
|
m_featureMinZoom = minZoom;
|
||||||
|
|
||||||
|
std::for_each(std::execution::par_unseq, m_buckets.begin(), m_buckets.end(),
|
||||||
|
[this](auto const & bucket) { bucket.second->SetFeatureMinZoom(m_featureMinZoom); });
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename TBatcher, typename... TArgs>
|
template <typename TBatcher, typename... TArgs>
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
#include "base/logging.hpp"
|
#include "base/logging.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
|
||||||
#include <iterator>
|
|
||||||
|
|
||||||
#include "font_constants.hpp"
|
#include "font_constants.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "drape/gl_gpu_program.hpp"
|
#include "drape/gl_gpu_program.hpp"
|
||||||
#include "drape/gl_functions.hpp"
|
#include "drape/gl_functions.hpp"
|
||||||
#include "drape/render_state.hpp"
|
#include "drape/render_state.hpp"
|
||||||
#include "drape/support_manager.hpp"
|
|
||||||
|
|
||||||
#include "base/logging.hpp"
|
#include "base/logging.hpp"
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@
|
|||||||
#include "drape/pointers.hpp"
|
#include "drape/pointers.hpp"
|
||||||
#include "drape/shader.hpp"
|
#include "drape/shader.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace dp
|
namespace dp
|
||||||
{
|
{
|
||||||
@@ -30,7 +29,7 @@ public:
|
|||||||
glConst m_type = gl_const::GLFloatType;
|
glConst m_type = gl_const::GLFloatType;
|
||||||
};
|
};
|
||||||
|
|
||||||
using UniformsInfo = std::map<std::string, UniformInfo>;
|
using UniformsInfo = std::unordered_map<std::string, UniformInfo>;
|
||||||
UniformsInfo const & GetUniformsInfo() const;
|
UniformsInfo const & GetUniformsInfo() const;
|
||||||
uint32_t GetNumericUniformsCount() const { return m_numericUniformsCount; }
|
uint32_t GetNumericUniformsCount() const { return m_numericUniformsCount; }
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "base/stl_helpers.hpp"
|
#include "base/stl_helpers.hpp"
|
||||||
#include "base/string_utils.hpp"
|
#include "base/string_utils.hpp"
|
||||||
|
|
||||||
|
#include <execution>
|
||||||
|
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include <hb-ft.h>
|
#include <hb-ft.h>
|
||||||
#include <unicode/unistr.h>
|
#include <unicode/unistr.h>
|
||||||
@@ -203,9 +205,9 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
|
|
||||||
static void Close(FT_Stream) {}
|
static void Close(FT_Stream) {}
|
||||||
|
|
||||||
void MarkGlyphReady(uint16_t glyphId) { m_readyGlyphs.emplace(glyphId); }
|
inline void MarkGlyphReady(uint16_t glyphId) { m_readyGlyphs.emplace(glyphId); }
|
||||||
|
|
||||||
bool IsGlyphReady(uint16_t glyphId) const { return m_readyGlyphs.find(glyphId) != m_readyGlyphs.end(); }
|
inline bool IsGlyphReady(uint16_t glyphId) const { return m_readyGlyphs.find(glyphId) != m_readyGlyphs.end(); }
|
||||||
|
|
||||||
std::string GetName() const { return std::string(m_fontFace->family_name) + ':' + m_fontFace->style_name; }
|
std::string GetName() const { return std::string(m_fontFace->family_name) + ':' + m_fontFace->style_name; }
|
||||||
|
|
||||||
@@ -229,7 +231,9 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
hb_glyph_info_t const * glyphInfo = hb_buffer_get_glyph_infos(hbBuffer, &glyphCount);
|
hb_glyph_info_t const * glyphInfo = hb_buffer_get_glyph_infos(hbBuffer, &glyphCount);
|
||||||
hb_glyph_position_t const * glyphPos = hb_buffer_get_glyph_positions(hbBuffer, &glyphCount);
|
hb_glyph_position_t const * glyphPos = hb_buffer_get_glyph_positions(hbBuffer, &glyphCount);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < glyphCount; ++i)
|
auto const range = std::ranges::views::iota(0u, glyphCount);
|
||||||
|
|
||||||
|
std::for_each(std::execution::par_unseq, range.begin(), range.end(), [&, this](auto const i)
|
||||||
{
|
{
|
||||||
// TODO(AB): Check for missing glyph ID?
|
// TODO(AB): Check for missing glyph ID?
|
||||||
auto const glyphId = static_cast<uint16_t>(glyphInfo[i].codepoint);
|
auto const glyphId = static_cast<uint16_t>(glyphInfo[i].codepoint);
|
||||||
@@ -247,7 +251,7 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
// yAdvance is always zero for horizontal text layouts.
|
// yAdvance is always zero for horizontal text layouts.
|
||||||
|
|
||||||
outMetrics.AddGlyphMetrics(static_cast<int16_t>(fontIndex), glyphId, xOffset, yOffset, xAdvance, fontPixelSize);
|
outMetrics.AddGlyphMetrics(static_cast<int16_t>(fontIndex), glyphId, xOffset, yOffset, xAdvance, fontPixelSize);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -255,7 +259,7 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
FT_StreamRec_ m_stream;
|
FT_StreamRec_ m_stream;
|
||||||
FT_Face m_fontFace;
|
FT_Face m_fontFace;
|
||||||
|
|
||||||
std::set<uint16_t> m_readyGlyphs;
|
std::unordered_set<uint16_t> m_readyGlyphs;
|
||||||
|
|
||||||
hb_font_t * m_harfbuzzFont{nullptr};
|
hb_font_t * m_harfbuzzFont{nullptr};
|
||||||
};
|
};
|
||||||
@@ -332,7 +336,6 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
using is_transparent = void;
|
using is_transparent = void;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(AB): Compare performance with std::map.
|
|
||||||
std::unordered_map<std::string, text::TextMetrics, StringHash, std::equal_to<>> m_textMetricsCache;
|
std::unordered_map<std::string, text::TextMetrics, StringHash, std::equal_to<>> m_textMetricsCache;
|
||||||
hb_buffer_t * m_harfbuzzBuffer;
|
hb_buffer_t * m_harfbuzzBuffer;
|
||||||
};
|
};
|
||||||
@@ -598,7 +601,7 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
|
|
||||||
allGlyphs.m_glyphs.reserve(strings::CountChar(utf8));
|
allGlyphs.m_glyphs.reserve(strings::CountChar(utf8));
|
||||||
|
|
||||||
for (auto const & substring : segments)
|
std::for_each(std::execution::par_unseq, segments.begin(), segments.end(), [&, this](auto const & substring)
|
||||||
{
|
{
|
||||||
hb_buffer_clear_contents(m_impl->m_harfbuzzBuffer);
|
hb_buffer_clear_contents(m_impl->m_harfbuzzBuffer);
|
||||||
|
|
||||||
@@ -626,7 +629,7 @@ FreetypeError constexpr g_FT_Errors[] =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (u32CharacterIter != end);
|
while (u32CharacterIter != end);
|
||||||
}
|
});
|
||||||
|
|
||||||
// Uncomment utf8 printing for debugging if necessary. It crashes JNI with non-modified UTF-8 strings on Android 5
|
// Uncomment utf8 printing for debugging if necessary. It crashes JNI with non-modified UTF-8 strings on Android 5
|
||||||
// and 6. See https://github.com/organicmaps/organicmaps/issues/10685
|
// and 6. See https://github.com/organicmaps/organicmaps/issues/10685
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "drape/overlay_tree.hpp"
|
#include "drape/overlay_tree.hpp"
|
||||||
#include "drape/vertex_array_buffer.hpp"
|
#include "drape/vertex_array_buffer.hpp"
|
||||||
|
|
||||||
#include "base/stl_helpers.hpp"
|
#include <execution>
|
||||||
|
|
||||||
namespace dp
|
namespace dp
|
||||||
{
|
{
|
||||||
@@ -51,23 +51,25 @@ void RenderBucket::AddOverlayHandle(drape_ptr<OverlayHandle> && handle)
|
|||||||
|
|
||||||
void RenderBucket::BeforeUpdate()
|
void RenderBucket::BeforeUpdate()
|
||||||
{
|
{
|
||||||
for (auto & overlayHandle : m_overlay)
|
std::for_each(std::execution::par_unseq, m_overlay.begin(), m_overlay.end(),
|
||||||
overlayHandle->BeforeUpdate();
|
[](auto & overlayHandle) { overlayHandle->BeforeUpdate(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBucket::Update(ScreenBase const & modelView)
|
void RenderBucket::Update(ScreenBase const & modelView)
|
||||||
{
|
{
|
||||||
BeforeUpdate();
|
BeforeUpdate();
|
||||||
for (auto & overlayHandle : m_overlay)
|
std::for_each(std::execution::par_unseq, m_overlay.begin(), m_overlay.end(), [&modelView](auto & overlayHandle)
|
||||||
|
{
|
||||||
if (overlayHandle->IsVisible())
|
if (overlayHandle->IsVisible())
|
||||||
overlayHandle->Update(modelView);
|
overlayHandle->Update(modelView);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBucket::CollectOverlayHandles(ref_ptr<OverlayTree> tree)
|
void RenderBucket::CollectOverlayHandles(ref_ptr<OverlayTree> tree)
|
||||||
{
|
{
|
||||||
BeforeUpdate();
|
BeforeUpdate();
|
||||||
for (auto const & overlayHandle : m_overlay)
|
std::for_each(std::execution::par_unseq, m_overlay.begin(), m_overlay.end(),
|
||||||
tree->Add(make_ref(overlayHandle));
|
[&tree](auto & overlayHandle) { tree->Add(make_ref(overlayHandle)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderBucket::HasOverlayHandles() const
|
bool RenderBucket::HasOverlayHandles() const
|
||||||
@@ -102,7 +104,8 @@ void RenderBucket::Render(ref_ptr<GraphicsContext> context, bool drawAsLine)
|
|||||||
ref_ptr<AttributeBufferMutator> rfpAttrib = make_ref(&attributeMutator);
|
ref_ptr<AttributeBufferMutator> rfpAttrib = make_ref(&attributeMutator);
|
||||||
|
|
||||||
bool hasIndexMutation = false;
|
bool hasIndexMutation = false;
|
||||||
for (drape_ptr<OverlayHandle> const & handle : m_overlay)
|
std::for_each(std::execution::par_unseq, m_overlay.begin(), m_overlay.end(),
|
||||||
|
[&, this](drape_ptr<OverlayHandle> const & handle)
|
||||||
{
|
{
|
||||||
if (handle->IndexesRequired())
|
if (handle->IndexesRequired())
|
||||||
{
|
{
|
||||||
@@ -113,7 +116,7 @@ void RenderBucket::Render(ref_ptr<GraphicsContext> context, bool drawAsLine)
|
|||||||
|
|
||||||
if (handle->HasDynamicAttributes())
|
if (handle->HasDynamicAttributes())
|
||||||
handle->GetAttributeMutation(rfpAttrib);
|
handle->GetAttributeMutation(rfpAttrib);
|
||||||
}
|
});
|
||||||
|
|
||||||
m_buffer->ApplyMutation(context, hasIndexMutation ? rfpIndex : nullptr, rfpAttrib);
|
m_buffer->ApplyMutation(context, hasIndexMutation ? rfpIndex : nullptr, rfpAttrib);
|
||||||
}
|
}
|
||||||
@@ -129,7 +132,7 @@ void RenderBucket::SetFeatureMinZoom(int minZoom)
|
|||||||
void RenderBucket::RenderDebug(ref_ptr<GraphicsContext> context, ScreenBase const & screen,
|
void RenderBucket::RenderDebug(ref_ptr<GraphicsContext> context, ScreenBase const & screen,
|
||||||
ref_ptr<DebugRenderer> debugRectRenderer) const
|
ref_ptr<DebugRenderer> debugRectRenderer) const
|
||||||
{
|
{
|
||||||
if (!debugRectRenderer || !debugRectRenderer->IsEnabled() || m_overlay.empty())
|
if (m_overlay.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto const & handle : m_overlay)
|
for (auto const & handle : m_overlay)
|
||||||
|
|||||||
@@ -264,39 +264,4 @@ void SymbolsTexture::Fail(ref_ptr<dp::GraphicsContext> context)
|
|||||||
|
|
||||||
Create(context, p, make_ref(&alphaTexture));
|
Create(context, p, make_ref(&alphaTexture));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SymbolsTexture::IsSymbolContained(std::string const & symbolName) const
|
|
||||||
{
|
|
||||||
return m_definition.find(symbolName) != m_definition.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SymbolsTexture::DecodeToMemory(std::string const & skinPathName, std::string const & textureName,
|
|
||||||
std::vector<uint8_t> & symbolsSkin, std::map<std::string, m2::RectU> & symbolsIndex,
|
|
||||||
uint32_t & skinWidth, uint32_t & skinHeight)
|
|
||||||
{
|
|
||||||
auto definitionInserter = [&symbolsIndex](std::string const & name, m2::RectF const & rect)
|
|
||||||
{ symbolsIndex.insert(make_pair(name, m2::RectU(rect))); };
|
|
||||||
|
|
||||||
bool result = true;
|
|
||||||
auto completionHandler =
|
|
||||||
[&result, &symbolsSkin, &skinWidth, &skinHeight](unsigned char * data, uint32_t width, uint32_t height)
|
|
||||||
{
|
|
||||||
size_t size = 4 * width * height;
|
|
||||||
symbolsSkin.resize(size);
|
|
||||||
memcpy(symbolsSkin.data(), data, size);
|
|
||||||
skinWidth = width;
|
|
||||||
skinHeight = height;
|
|
||||||
result = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
auto failureHandler = [&result](std::string const & reason)
|
|
||||||
{
|
|
||||||
LOG(LERROR, (reason));
|
|
||||||
result = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
LoadSymbols(skinPathName, textureName, false /* convertToUV */, definitionInserter, completionHandler,
|
|
||||||
failureHandler);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} // namespace dp
|
} // namespace dp
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "drape/texture.hpp"
|
#include "drape/texture.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -39,19 +39,17 @@ public:
|
|||||||
void Invalidate(ref_ptr<dp::GraphicsContext> context, std::string const & skinPathName,
|
void Invalidate(ref_ptr<dp::GraphicsContext> context, std::string const & skinPathName,
|
||||||
ref_ptr<HWTextureAllocator> allocator, std::vector<drape_ptr<HWTexture>> & internalTextures);
|
ref_ptr<HWTextureAllocator> allocator, std::vector<drape_ptr<HWTexture>> & internalTextures);
|
||||||
|
|
||||||
bool IsSymbolContained(std::string const & symbolName) const;
|
inline bool IsSymbolContained(std::string const & symbolName) const
|
||||||
|
{
|
||||||
static bool DecodeToMemory(std::string const & skinPathName, std::string const & textureName,
|
return m_definition.find(symbolName) != m_definition.end();
|
||||||
std::vector<uint8_t> & symbolsSkin, std::map<std::string, m2::RectU> & symbolsIndex,
|
}
|
||||||
uint32_t & skinWidth, uint32_t & skinHeight);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Fail(ref_ptr<dp::GraphicsContext> context);
|
void Fail(ref_ptr<dp::GraphicsContext> context);
|
||||||
void Load(ref_ptr<dp::GraphicsContext> context, std::string const & skinPathName,
|
void Load(ref_ptr<dp::GraphicsContext> context, std::string const & skinPathName,
|
||||||
ref_ptr<HWTextureAllocator> allocator);
|
ref_ptr<HWTextureAllocator> allocator);
|
||||||
|
|
||||||
using TSymDefinition = std::map<std::string, SymbolInfo>;
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
mutable TSymDefinition m_definition;
|
mutable std::unordered_map<std::string, SymbolInfo> m_definition;
|
||||||
};
|
};
|
||||||
} // namespace dp
|
} // namespace dp
|
||||||
|
|||||||
@@ -539,12 +539,6 @@ GlyphFontAndId TextureManager::GetSpaceGlyph() const
|
|||||||
return m_spaceGlyph;
|
return m_spaceGlyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureManager::AreGlyphsReady(TGlyphs const & glyphs) const
|
|
||||||
{
|
|
||||||
CHECK(m_isInitialized, ());
|
|
||||||
return m_glyphManager->AreGlyphsReady(glyphs);
|
|
||||||
}
|
|
||||||
|
|
||||||
ref_ptr<Texture> TextureManager::GetSymbolsTexture() const
|
ref_ptr<Texture> TextureManager::GetSymbolsTexture() const
|
||||||
{
|
{
|
||||||
CHECK(m_isInitialized, ());
|
CHECK(m_isInitialized, ());
|
||||||
|
|||||||
@@ -95,7 +95,11 @@ public:
|
|||||||
TMultilineGlyphsBuffer & multilineGlyphRegions);
|
TMultilineGlyphsBuffer & multilineGlyphRegions);
|
||||||
|
|
||||||
// This method must be called only on Frontend renderer's thread.
|
// This method must be called only on Frontend renderer's thread.
|
||||||
bool AreGlyphsReady(TGlyphs const & glyphs) const;
|
inline bool AreGlyphsReady(TGlyphs const & glyphs) const
|
||||||
|
{
|
||||||
|
CHECK(m_isInitialized, ());
|
||||||
|
return m_glyphManager->AreGlyphsReady(glyphs);
|
||||||
|
}
|
||||||
|
|
||||||
GlyphFontAndId GetSpaceGlyph() const;
|
GlyphFontAndId GetSpaceGlyph() const;
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,15 @@
|
|||||||
#include "drape/vulkan/vulkan_base_context.hpp"
|
#include "drape/vulkan/vulkan_base_context.hpp"
|
||||||
#include "drape/vulkan/vulkan_gpu_buffer_impl.hpp"
|
#include "drape/vulkan/vulkan_gpu_buffer_impl.hpp"
|
||||||
#include "drape/vulkan/vulkan_param_descriptor.hpp"
|
#include "drape/vulkan/vulkan_param_descriptor.hpp"
|
||||||
#include "drape/vulkan/vulkan_utils.hpp"
|
|
||||||
|
|
||||||
#include "base/assert.hpp"
|
#include "base/assert.hpp"
|
||||||
#include "base/macros.hpp"
|
#include "base/macros.hpp"
|
||||||
|
#include "drape/vulkan/vulkan_staging_buffer.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace dp
|
namespace dp
|
||||||
{
|
{
|
||||||
@@ -44,11 +43,11 @@ public:
|
|||||||
|
|
||||||
void RenderRange(ref_ptr<GraphicsContext> context, bool drawAsLine, IndicesRange const & range) override
|
void RenderRange(ref_ptr<GraphicsContext> context, bool drawAsLine, IndicesRange const & range) override
|
||||||
{
|
{
|
||||||
CHECK(m_vertexArrayBuffer->HasBuffers(), ());
|
ASSERT(m_vertexArrayBuffer->HasBuffers(), ());
|
||||||
|
|
||||||
ref_ptr<dp::vulkan::VulkanBaseContext> vulkanContext = context;
|
ref_ptr<dp::vulkan::VulkanBaseContext> vulkanContext = context;
|
||||||
VkCommandBuffer commandBuffer = vulkanContext->GetCurrentRenderingCommandBuffer();
|
VkCommandBuffer commandBuffer = vulkanContext->GetCurrentRenderingCommandBuffer();
|
||||||
CHECK(commandBuffer != nullptr, ());
|
ASSERT(commandBuffer != nullptr, ());
|
||||||
|
|
||||||
vulkanContext->SetPrimitiveTopology(drawAsLine ? VK_PRIMITIVE_TOPOLOGY_LINE_LIST
|
vulkanContext->SetPrimitiveTopology(drawAsLine ? VK_PRIMITIVE_TOPOLOGY_LINE_LIST
|
||||||
: VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
: VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
||||||
@@ -71,24 +70,23 @@ public:
|
|||||||
for (auto & buffer : m_vertexArrayBuffer->m_staticBuffers)
|
for (auto & buffer : m_vertexArrayBuffer->m_staticBuffers)
|
||||||
{
|
{
|
||||||
ref_ptr<VulkanGpuBufferImpl> b = buffer.second->GetBuffer();
|
ref_ptr<VulkanGpuBufferImpl> b = buffer.second->GetBuffer();
|
||||||
CHECK_LESS(bufferIndex, kMaxBuffersCount, ());
|
ASSERT_LESS(bufferIndex, kMaxBuffersCount, ());
|
||||||
buffers[bufferIndex++] = b->GetVulkanBuffer();
|
buffers[bufferIndex++] = b->GetVulkanBuffer();
|
||||||
}
|
}
|
||||||
for (auto & buffer : m_vertexArrayBuffer->m_dynamicBuffers)
|
for (auto & buffer : m_vertexArrayBuffer->m_dynamicBuffers)
|
||||||
{
|
{
|
||||||
ref_ptr<VulkanGpuBufferImpl> b = buffer.second->GetBuffer();
|
ref_ptr<VulkanGpuBufferImpl> b = buffer.second->GetBuffer();
|
||||||
CHECK_LESS(bufferIndex, kMaxBuffersCount, ());
|
ASSERT_LESS(bufferIndex, kMaxBuffersCount, ());
|
||||||
buffers[bufferIndex++] = b->GetVulkanBuffer();
|
buffers[bufferIndex++] = b->GetVulkanBuffer();
|
||||||
}
|
}
|
||||||
vkCmdBindVertexBuffers(commandBuffer, 0, bufferIndex, buffers.data(), offsets.data());
|
vkCmdBindVertexBuffers(commandBuffer, 0, bufferIndex, buffers.data(), offsets.data());
|
||||||
|
|
||||||
ref_ptr<VulkanGpuBufferImpl> ib = m_vertexArrayBuffer->m_indexBuffer->GetBuffer();
|
vkCmdBindIndexBuffer(
|
||||||
VkBuffer vulkanIndexBuffer = ib->GetVulkanBuffer();
|
commandBuffer, ref_ptr<VulkanGpuBufferImpl>(m_vertexArrayBuffer->m_indexBuffer->GetBuffer())->GetVulkanBuffer(),
|
||||||
auto const indexType = dp::IndexStorage::IsSupported32bit() ? VK_INDEX_TYPE_UINT32 : VK_INDEX_TYPE_UINT16;
|
0, m_indexType);
|
||||||
vkCmdBindIndexBuffer(commandBuffer, vulkanIndexBuffer, 0, indexType);
|
|
||||||
|
|
||||||
CHECK_LESS_OR_EQUAL(range.m_idxStart + range.m_idxCount,
|
ASSERT_LESS_OR_EQUAL(range.m_idxStart + range.m_idxCount,
|
||||||
m_objectManager->GetMemoryManager().GetDeviceLimits().maxDrawIndexedIndexValue, ());
|
m_objectManager->GetMemoryManager().GetDeviceLimits().maxDrawIndexedIndexValue, ());
|
||||||
|
|
||||||
vkCmdDrawIndexed(commandBuffer, range.m_idxCount, 1, range.m_idxStart, 0, 0);
|
vkCmdDrawIndexed(commandBuffer, range.m_idxCount, 1, range.m_idxStart, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -99,6 +97,7 @@ private:
|
|||||||
BindingInfoArray m_bindingInfo;
|
BindingInfoArray m_bindingInfo;
|
||||||
uint8_t m_bindingInfoCount = 0;
|
uint8_t m_bindingInfoCount = 0;
|
||||||
ParamDescriptorUpdater m_descriptorUpdater;
|
ParamDescriptorUpdater m_descriptorUpdater;
|
||||||
|
VkIndexType const m_indexType = dp::IndexStorage::IsSupported32bit() ? VK_INDEX_TYPE_UINT32 : VK_INDEX_TYPE_UINT16;
|
||||||
};
|
};
|
||||||
} // namespace vulkan
|
} // namespace vulkan
|
||||||
|
|
||||||
|
|||||||
@@ -37,14 +37,8 @@
|
|||||||
#include "std/target_os.hpp"
|
#include "std/target_os.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
|
||||||
#include <chrono>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <functional>
|
#include <execution>
|
||||||
#include <limits>
|
|
||||||
#include <memory>
|
|
||||||
#include <thread>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace df
|
namespace df
|
||||||
{
|
{
|
||||||
@@ -1813,14 +1807,17 @@ void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
BeginUpdateOverlayTree(modelView);
|
BeginUpdateOverlayTree(modelView);
|
||||||
for (auto const layerId :
|
constexpr std::array<uint8_t, 3> layers = {static_cast<uint8_t>(DepthLayer::OverlayLayer),
|
||||||
{DepthLayer::OverlayLayer, DepthLayer::RoutingBottomMarkLayer, DepthLayer::RoutingMarkLayer})
|
static_cast<uint8_t>(DepthLayer::RoutingBottomMarkLayer),
|
||||||
|
static_cast<uint8_t>(DepthLayer::RoutingMarkLayer)};
|
||||||
|
|
||||||
|
std::for_each(std::execution::par_unseq, layers.begin(), layers.end(), [this, &modelView](uint8_t const layerId)
|
||||||
{
|
{
|
||||||
RenderLayer & overlay = m_layers[static_cast<size_t>(layerId)];
|
RenderLayer & overlay = m_layers[layerId];
|
||||||
overlay.Sort(make_ref(m_overlayTree));
|
overlay.Sort(make_ref(m_overlayTree));
|
||||||
for (auto & group : overlay.m_renderGroups)
|
std::for_each(std::execution::par_unseq, overlay.m_renderGroups.begin(), overlay.m_renderGroups.end(),
|
||||||
UpdateOverlayTree(modelView, group);
|
[this, &modelView](auto & group) { UpdateOverlayTree(modelView, group); });
|
||||||
}
|
});
|
||||||
if (m_transitSchemeRenderer->IsSchemeVisible(GetCurrentZoom()) && !HasTransitRouteData())
|
if (m_transitSchemeRenderer->IsSchemeVisible(GetCurrentZoom()) && !HasTransitRouteData())
|
||||||
m_transitSchemeRenderer->CollectOverlays(make_ref(m_overlayTree), modelView);
|
m_transitSchemeRenderer->CollectOverlays(make_ref(m_overlayTree), modelView);
|
||||||
EndUpdateOverlayTree();
|
EndUpdateOverlayTree();
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ namespace df
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
double constexpr kValidPathSplineTurn = 15 * math::pi / 180;
|
double constexpr kValidPathSplineTurn = 15 * math::pi / 180;
|
||||||
double constexpr kCosTurn = 0.999989561; // cos(kValidPathSplineTurn)
|
double constexpr kCosTurn = 0.999989561; // cos(kValidPathSplineTurn)
|
||||||
double constexpr kSinTurn = 0.004569245; // sin(kValidPathSplineTurn)
|
double constexpr kSinTurn = 0.004569245; // sin(kValidPathSplineTurn)
|
||||||
double constexpr kRoundStep = 23;
|
double constexpr kRoundStep = 23;
|
||||||
int constexpr kMaxStepsCount = 7;
|
int constexpr kMaxStepsCount = 7;
|
||||||
|
|
||||||
@@ -122,11 +122,6 @@ ref_ptr<PathTextLayout> const PathTextContext::GetLayout() const
|
|||||||
return make_ref(m_layout);
|
return make_ref(m_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathTextContext::BeforeUpdate()
|
|
||||||
{
|
|
||||||
m_updated = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<double> const & PathTextContext::GetOffsets() const
|
std::vector<double> const & PathTextContext::GetOffsets() const
|
||||||
{
|
{
|
||||||
return m_globalOffsets;
|
return m_globalOffsets;
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ public:
|
|||||||
|
|
||||||
bool GetPivot(size_t textIndex, m2::PointD & pivot, m2::Spline::iterator & centerPointIter) const;
|
bool GetPivot(size_t textIndex, m2::PointD & pivot, m2::Spline::iterator & centerPointIter) const;
|
||||||
|
|
||||||
void BeforeUpdate();
|
// TODO: these are unused?
|
||||||
|
inline void BeforeUpdate() { m_updated = false; }
|
||||||
void Update(ScreenBase const & screen);
|
void Update(ScreenBase const & screen);
|
||||||
|
|
||||||
std::vector<double> const & GetOffsets() const;
|
std::vector<double> const & GetOffsets() const;
|
||||||
|
|||||||
@@ -8,9 +8,8 @@
|
|||||||
|
|
||||||
#include "geometry/screenbase.hpp"
|
#include "geometry/screenbase.hpp"
|
||||||
|
|
||||||
#include "base/stl_helpers.hpp"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <execution>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -43,8 +42,8 @@ void RenderGroup::CollectOverlay(ref_ptr<dp::OverlayTree> tree)
|
|||||||
if (CanBeDeleted())
|
if (CanBeDeleted())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto & renderBucket : m_renderBuckets)
|
std::for_each(std::execution::par_unseq, m_renderBuckets.begin(), m_renderBuckets.end(),
|
||||||
renderBucket->CollectOverlayHandles(tree);
|
[&](auto & renderBucket) { renderBucket->CollectOverlayHandles(tree); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderGroup::HasOverlayHandles() const
|
bool RenderGroup::HasOverlayHandles() const
|
||||||
@@ -78,8 +77,9 @@ void RenderGroup::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Prog
|
|||||||
programPtr->Bind();
|
programPtr->Bind();
|
||||||
dp::ApplyState(context, programPtr, m_state);
|
dp::ApplyState(context, programPtr, m_state);
|
||||||
|
|
||||||
for (auto & renderBucket : m_renderBuckets)
|
std::for_each(std::execution::par_unseq, m_renderBuckets.begin(), m_renderBuckets.end(),
|
||||||
renderBucket->GetBuffer()->Build(context, programPtr);
|
[&context, &programPtr](auto const & renderBucket)
|
||||||
|
{ renderBucket->GetBuffer()->Build(context, programPtr); });
|
||||||
|
|
||||||
auto const program = m_state.GetProgram<gpu::Program>();
|
auto const program = m_state.GetProgram<gpu::Program>();
|
||||||
auto const program3d = m_state.GetProgram3d<gpu::Program>();
|
auto const program3d = m_state.GetProgram3d<gpu::Program>();
|
||||||
@@ -100,8 +100,9 @@ void RenderGroup::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Prog
|
|||||||
m_params.m_isOutlinePass = 1.0f;
|
m_params.m_isOutlinePass = 1.0f;
|
||||||
|
|
||||||
mng->GetParamsSetter()->Apply(context, programPtr, m_params);
|
mng->GetParamsSetter()->Apply(context, programPtr, m_params);
|
||||||
for (auto & renderBucket : m_renderBuckets)
|
std::for_each(std::execution::par_unseq, m_renderBuckets.begin(), m_renderBuckets.end(),
|
||||||
renderBucket->Render(context, m_state.GetDrawAsLine());
|
[&context, this](auto const & renderBucket)
|
||||||
|
{ renderBucket->Render(context, m_state.GetDrawAsLine()); });
|
||||||
|
|
||||||
m_params.m_contrastGamma = glsl::vec2(glyphParams.m_contrast, glyphParams.m_gamma);
|
m_params.m_contrastGamma = glsl::vec2(glyphParams.m_contrast, glyphParams.m_gamma);
|
||||||
m_params.m_isOutlinePass = 0.0f;
|
m_params.m_isOutlinePass = 0.0f;
|
||||||
@@ -112,11 +113,14 @@ void RenderGroup::Render(ref_ptr<dp::GraphicsContext> context, ref_ptr<gpu::Prog
|
|||||||
}
|
}
|
||||||
|
|
||||||
mng->GetParamsSetter()->Apply(context, programPtr, m_params);
|
mng->GetParamsSetter()->Apply(context, programPtr, m_params);
|
||||||
for (auto & renderBucket : m_renderBuckets)
|
std::for_each(std::execution::par_unseq, m_renderBuckets.begin(), m_renderBuckets.end(),
|
||||||
renderBucket->Render(context, m_state.GetDrawAsLine());
|
[&context, this](auto const & renderBucket)
|
||||||
|
{ renderBucket->Render(context, m_state.GetDrawAsLine()); });
|
||||||
|
|
||||||
for (auto const & renderBucket : m_renderBuckets)
|
if (debugRectRenderer && debugRectRenderer->IsEnabled())
|
||||||
renderBucket->RenderDebug(context, screen, debugRectRenderer);
|
std::for_each(std::execution::par_unseq, m_renderBuckets.begin(), m_renderBuckets.end(),
|
||||||
|
[&context, &screen, &debugRectRenderer](auto const & renderBucket)
|
||||||
|
{ renderBucket->RenderDebug(context, screen, debugRectRenderer); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderGroup::AddBucket(drape_ptr<dp::RenderBucket> && bucket)
|
void RenderGroup::AddBucket(drape_ptr<dp::RenderBucket> && bucket)
|
||||||
|
|||||||
Reference in New Issue
Block a user