Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:58:55 +01:00
parent 4af19165ec
commit 68073add76
12458 changed files with 12350765 additions and 2 deletions

View file

@ -0,0 +1,78 @@
#include "drape/utils/glyph_usage_tracker.hpp"
#include "platform/preferred_languages.hpp"
#include "base/assert.hpp"
#include <sstream>
namespace dp
{
std::string GlyphUsageTracker::GlyphUsageStatistic::ToString() const
{
std::ostringstream ss;
ss << " ----- Glyphs usage report ----- \n";
ss << " Current language = " << languages::GetCurrentOrig() << "\n";
ss << " Invalid glyphs count = " << m_invalidGlyphs.size() << "\n";
ss << " Invalid glyphs: { ";
for (auto const & it : m_invalidGlyphs)
ss << std::hex << static_cast<uint32_t>(it.first) << std::dec << "(" << it.second << ") ";
ss << "}\n";
ss << " Unexpected glyphs count = " << m_unexpectedGlyphs.size() << "\n";
ss << " Unexpected glyphs: {\n";
for (auto const & it : m_unexpectedGlyphs)
{
ss << " glyph = " << std::hex << static_cast<uint32_t>(it.first) << std::dec
<< ", unique usages = " << it.second.m_counter << ", group = " << it.second.m_group << ", expected groups = { ";
for (auto const & gr : it.second.m_expectedGroups)
ss << gr << " ";
ss << "}\n";
}
ss << " }\n";
ss << " ----- Glyphs usage report ----- \n";
return ss.str();
}
GlyphUsageTracker & GlyphUsageTracker::Instance()
{
static GlyphUsageTracker s_inst;
return s_inst;
}
GlyphUsageTracker::GlyphUsageStatistic GlyphUsageTracker::Report()
{
std::lock_guard<std::mutex> lock(m_mutex);
return m_glyphStat;
}
void GlyphUsageTracker::AddInvalidGlyph(strings::UniString const & str, strings::UniChar const & c)
{
std::lock_guard<std::mutex> lock(m_mutex);
if (m_processedStrings.find(strings::ToUtf8(str)) != m_processedStrings.end())
return;
++m_glyphStat.m_invalidGlyphs[c];
m_processedStrings.insert(strings::ToUtf8(str));
}
void GlyphUsageTracker::AddUnexpectedGlyph(strings::UniString const & str, strings::UniChar const & c,
size_t const group, size_t const expectedGroup)
{
std::lock_guard<std::mutex> lock(m_mutex);
if (m_processedStrings.find(strings::ToUtf8(str)) != m_processedStrings.end())
return;
UnexpectedGlyphData & data = m_glyphStat.m_unexpectedGlyphs[c];
++data.m_counter;
data.m_expectedGroups.emplace(expectedGroup);
data.m_group = group;
m_processedStrings.insert(strings::ToUtf8(str));
}
} // namespace dp

View file

@ -0,0 +1,55 @@
#pragma once
#include "drape/drape_diagnostics.hpp"
#include "base/string_utils.hpp"
#include <list>
#include <map>
#include <mutex>
#include <set>
#include <string>
#include <unordered_set>
namespace dp
{
class GlyphUsageTracker
{
public:
struct UnexpectedGlyphData
{
size_t m_counter = 0;
size_t m_group = 0;
std::set<size_t> m_expectedGroups;
};
using UnexpectedGlyphs = std::map<strings::UniChar, UnexpectedGlyphData>;
using InvalidGlyphs = std::map<strings::UniChar, size_t>;
struct GlyphUsageStatistic
{
std::string ToString() const;
InvalidGlyphs m_invalidGlyphs;
UnexpectedGlyphs m_unexpectedGlyphs;
};
static GlyphUsageTracker & Instance();
void AddInvalidGlyph(strings::UniString const & str, strings::UniChar const & c);
void AddUnexpectedGlyph(strings::UniString const & str, strings::UniChar const & c, size_t const group,
size_t const expectedGroup);
GlyphUsageStatistic Report();
private:
GlyphUsageTracker() = default;
GlyphUsageTracker(GlyphUsageTracker const & rhs) = delete;
GlyphUsageTracker(GlyphUsageTracker && rhs) = delete;
private:
GlyphUsageStatistic m_glyphStat;
std::unordered_set<std::string> m_processedStrings;
std::mutex m_mutex;
};
} // namespace dp

View file

@ -0,0 +1,99 @@
#include "drape/utils/gpu_mem_tracker.hpp"
#include <iomanip>
#include <sstream>
namespace dp
{
std::string GPUMemTracker::GPUMemorySnapshot::ToString() const
{
std::ostringstream ss;
ss << " Summary Allocated = " << m_summaryAllocatedInMb << "Mb\n";
ss << " Summary Used = " << m_summaryUsedInMb << "Mb\n";
ss << " Tags registered = " << m_tagStats.size() << "\n";
for (auto const & it : m_tagStats)
{
ss << " Tag = " << it.first << " \n";
ss << " Object count = " << it.second.m_objectsCount << "\n";
ss << " Allocated = " << it.second.m_alocatedInMb << "Mb\n";
ss << " Used = " << it.second.m_usedInMb << "Mb\n";
}
ss << " Average allocations by hashes:\n";
for (auto const & it : m_averageAllocations)
{
ss << " " << std::hex << it.first;
ss << " : " << std::dec << it.second.GetAverage() << " bytes\n";
}
return ss.str();
}
GPUMemTracker & GPUMemTracker::Inst()
{
static GPUMemTracker s_inst;
return s_inst;
}
GPUMemTracker::GPUMemorySnapshot GPUMemTracker::GetMemorySnapshot()
{
GPUMemorySnapshot memStat;
{
std::lock_guard<std::mutex> g(m_mutex);
for (auto const & kv : m_memTracker)
{
TagMemorySnapshot & tagStat = memStat.m_tagStats[kv.first.first];
tagStat.m_objectsCount++;
tagStat.m_alocatedInMb += kv.second.first;
tagStat.m_usedInMb += kv.second.second;
memStat.m_summaryAllocatedInMb += kv.second.first;
memStat.m_summaryUsedInMb += kv.second.second;
}
memStat.m_averageAllocations = m_averageAllocations;
}
auto constexpr kByteToMb = static_cast<float>(1024 * 1024);
for (auto & it : memStat.m_tagStats)
{
it.second.m_alocatedInMb /= kByteToMb;
it.second.m_usedInMb /= kByteToMb;
}
memStat.m_summaryAllocatedInMb /= kByteToMb;
memStat.m_summaryUsedInMb /= kByteToMb;
return memStat;
}
void GPUMemTracker::AddAllocated(std::string const & tag, uint32_t id, uint32_t size)
{
std::lock_guard<std::mutex> g(m_mutex);
m_memTracker[make_pair(tag, id)].first = size;
}
void GPUMemTracker::SetUsed(std::string const & tag, uint32_t id, uint32_t size)
{
std::lock_guard<std::mutex> g(m_mutex);
TAlocUsedMem & node = m_memTracker[make_pair(tag, id)];
node.second = size;
ASSERT_LESS_OR_EQUAL(node.second, node.first, ("Can't use more than allocated"));
}
void GPUMemTracker::RemoveDeallocated(std::string const & tag, uint32_t id)
{
std::lock_guard<std::mutex> g(m_mutex);
m_memTracker.erase(make_pair(tag, id));
}
void GPUMemTracker::TrackAverageAllocation(uint64_t hash, uint64_t size)
{
uint32_t constexpr kBucketMask = 0x7;
std::lock_guard<std::mutex> g(m_mutex);
auto & allocation = m_averageAllocations[hash & kBucketMask];
allocation.m_totalSizeInBytes += size;
allocation.m_count++;
}
} // namespace dp

View file

@ -0,0 +1,66 @@
#pragma once
#include "drape/drape_diagnostics.hpp"
#include "base/macros.hpp"
#include <cstdint>
#include <map>
#include <mutex>
#include <string>
#include <unordered_map>
#include <utility>
namespace dp
{
class GPUMemTracker
{
public:
struct TagMemorySnapshot
{
uint32_t m_objectsCount = 0;
uint32_t m_alocatedInMb = 0;
uint32_t m_usedInMb = 0;
};
struct AverageAllocation
{
uint64_t m_totalSizeInBytes = 0;
uint32_t m_count = 0;
uint64_t GetAverage() const { return m_count == 0 ? 0 : m_totalSizeInBytes / m_count; }
};
struct GPUMemorySnapshot
{
std::string ToString() const;
uint32_t m_summaryAllocatedInMb = 0;
uint32_t m_summaryUsedInMb = 0;
std::map<std::string, TagMemorySnapshot> m_tagStats;
std::unordered_map<uint64_t, AverageAllocation> m_averageAllocations;
};
static GPUMemTracker & Inst();
GPUMemorySnapshot GetMemorySnapshot();
void AddAllocated(std::string const & tag, uint32_t id, uint32_t size);
void SetUsed(std::string const & tag, uint32_t id, uint32_t size);
void RemoveDeallocated(std::string const & tag, uint32_t id);
void TrackAverageAllocation(uint64_t hash, uint64_t size);
private:
GPUMemTracker() = default;
using TAlocUsedMem = std::pair<uint32_t, uint32_t>;
using TMemTag = std::pair<std::string, uint32_t>;
std::map<TMemTag, TAlocUsedMem> m_memTracker;
std::unordered_map<uint64_t, AverageAllocation> m_averageAllocations;
std::mutex m_mutex;
DISALLOW_COPY_AND_MOVE(GPUMemTracker);
};
} // namespace dp

View file

@ -0,0 +1,86 @@
#pragma once
#include "base/logging.hpp"
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdint>
#include <map>
#include <sstream>
#include <string>
namespace dp
{
static size_t constexpr kLastMeasurementsCount = 30;
class Profiler
{
public:
static Profiler & Instance()
{
static Profiler profiler;
return profiler;
}
void Measure(std::string const & name, uint32_t milliseconds)
{
auto & m = m_measurements[name];
m.m_accumulator += milliseconds;
m.m_lastMeasurements[m.m_count % kLastMeasurementsCount] = milliseconds;
m.m_count++;
}
void Print()
{
LOG(LINFO, ("--- DRAPE PROFILER ---"));
for (auto const & m : m_measurements)
{
float const avg = static_cast<float>(m.second.m_accumulator) / m.second.m_count;
size_t const startIndex = m.second.m_count % kLastMeasurementsCount;
std::ostringstream ss;
ss << "[";
for (size_t i = startIndex; i < std::min(kLastMeasurementsCount, m.second.m_count); ++i)
ss << m.second.m_lastMeasurements[i] << ", ";
for (size_t i = 0; i < startIndex; ++i)
ss << m.second.m_lastMeasurements[i] << ", ";
ss << ']';
LOG(LINFO, (">", m.first, ": avg time =", avg, "count =", m.second.m_count, "last =", ss.str()));
}
LOG(LINFO, ("----------------------"));
}
protected:
struct Measurement
{
size_t m_count = 0;
uint64_t m_accumulator = 0;
std::array<uint32_t, kLastMeasurementsCount> m_lastMeasurements = {};
};
std::map<std::string, Measurement> m_measurements;
};
class ProfilerGuard
{
public:
ProfilerGuard(std::string const & name) : m_name(name) { m_start = std::chrono::steady_clock::now(); }
~ProfilerGuard()
{
auto const dur = std::chrono::steady_clock::now() - m_start;
auto ms = static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::milliseconds>(dur).count());
if (!m_skipped)
Profiler::Instance().Measure(m_name, ms);
}
void Skip() { m_skipped = true; }
private:
std::string m_name;
std::chrono::time_point<std::chrono::steady_clock> m_start;
bool m_skipped = false;
};
} // namespace dp

View file

@ -0,0 +1,33 @@
#include "drape/utils/projection.hpp"
namespace dp
{
std::array<float, 16> MakeProjection(dp::ApiVersion apiVersion, float left, float right, float bottom, float top)
{
std::array<float, 16> result = {};
// Projection matrix is calculated for [-1;1] depth-space, in some APIs (e.g. Metal)
// depth-space is [0;1], so we have to remap projection matrix.
float depthScale = 1.0f;
float depthOffset = 0.0f;
if (apiVersion == dp::ApiVersion::Metal)
{
depthScale = 0.5f;
depthOffset = 0.5f;
}
float const width = right - left;
float const height = top - bottom;
float const depth = kMaxDepth - kMinDepth;
result[0] = 2.0f / width;
result[3] = -(right + left) / width;
result[5] = 2.0f / height;
result[7] = -(top + bottom) / height;
result[10] = -2.0f * depthScale / depth;
result[11] = depthOffset - (kMaxDepth + kMinDepth) / depth;
result[15] = 1.0;
return result;
}
} // namespace dp

View file

@ -0,0 +1,19 @@
#pragma once
#include "drape/drape_global.hpp"
#include "indexer/drawing_rule_def.hpp"
#include <array>
namespace dp
{
/// @todo: asymmetric values lead to in-range polygons being clipped still, might be a bug in projection matrix?
float constexpr kMinDepth = -25000.0f;
float constexpr kMaxDepth = 25000.0f;
static_assert(kMinDepth <= drule::kMinLayeredDepthBg && drule::kMaxLayeredDepthFg <= kMaxDepth);
static_assert(kMinDepth <= -drule::kOverlaysMaxPriority && drule::kOverlaysMaxPriority <= kMaxDepth);
std::array<float, 16> MakeProjection(dp::ApiVersion apiVersion, float left, float right, float bottom, float top);
} // namespace dp

View file

@ -0,0 +1,393 @@
#include "drape/utils/vertex_decl.hpp"
namespace gpu
{
namespace
{
enum VertexType
{
Area,
Area3d,
HatchingArea,
SolidTexturing,
MaskedTexturing,
TextStatic,
TextOutlinedStatic,
TextDynamic,
Line,
DashedLine,
Route,
RouteMarker,
ColoredSymbol,
TypeCount
};
struct BindingNode
{
dp::BindingInfo m_info;
bool m_inited = false;
};
typedef dp::BindingInfo (*TInitFunction)();
dp::BindingInfo AreaBindingInit()
{
static_assert(sizeof(AreaVertex) == (sizeof(AreaVertex::TPosition) + sizeof(AreaVertex::TTexCoord)), "");
dp::BindingFiller<AreaVertex> filler(2);
filler.FillDecl<AreaVertex::TPosition>("a_position");
filler.FillDecl<AreaVertex::TTexCoord>("a_colorTexCoords");
return filler.m_info;
}
dp::BindingInfo Area3dBindingInit()
{
static_assert(sizeof(Area3dVertex) == (sizeof(Area3dVertex::TPosition) + sizeof(Area3dVertex::TNormal3d) +
sizeof(Area3dVertex::TTexCoord)),
"");
dp::BindingFiller<Area3dVertex> filler(3);
filler.FillDecl<Area3dVertex::TPosition>("a_position");
filler.FillDecl<Area3dVertex::TNormal3d>("a_normal");
filler.FillDecl<Area3dVertex::TTexCoord>("a_colorTexCoords");
return filler.m_info;
}
dp::BindingInfo HatchingAreaBindingInit()
{
static_assert(
sizeof(HatchingAreaVertex) == (sizeof(HatchingAreaVertex::TPosition) + sizeof(HatchingAreaVertex::TTexCoord) +
sizeof(HatchingAreaVertex::TMaskTexCoord)),
"");
dp::BindingFiller<HatchingAreaVertex> filler(3);
filler.FillDecl<HatchingAreaVertex::TPosition>("a_position");
filler.FillDecl<HatchingAreaVertex::TNormal>("a_colorTexCoords");
filler.FillDecl<HatchingAreaVertex::TMaskTexCoord>("a_maskTexCoords");
return filler.m_info;
}
dp::BindingInfo SolidTexturingBindingInit()
{
static_assert(
sizeof(SolidTexturingVertex) == (sizeof(SolidTexturingVertex::TPosition3d) +
sizeof(SolidTexturingVertex::TNormal) + sizeof(SolidTexturingVertex::TTexCoord)),
"");
dp::BindingFiller<SolidTexturingVertex> filler(3);
filler.FillDecl<SolidTexturingVertex::TPosition3d>("a_position");
filler.FillDecl<SolidTexturingVertex::TNormal>("a_normal");
filler.FillDecl<SolidTexturingVertex::TTexCoord>("a_colorTexCoords");
return filler.m_info;
}
dp::BindingInfo MaskedTexturingBindingInit()
{
static_assert(sizeof(MaskedTexturingVertex) ==
(sizeof(MaskedTexturingVertex::TPosition3d) + sizeof(MaskedTexturingVertex::TNormal) +
sizeof(MaskedTexturingVertex::TTexCoord) + sizeof(MaskedTexturingVertex::TTexCoord)),
"");
dp::BindingFiller<MaskedTexturingVertex> filler(4);
filler.FillDecl<SolidTexturingVertex::TPosition3d>("a_position");
filler.FillDecl<SolidTexturingVertex::TNormal>("a_normal");
filler.FillDecl<SolidTexturingVertex::TTexCoord>("a_colorTexCoords");
filler.FillDecl<SolidTexturingVertex::TTexCoord>("a_maskTexCoords");
return filler.m_info;
}
dp::BindingInfo TextStaticBindingInit()
{
static_assert(sizeof(TextStaticVertex) == (2 * sizeof(TextStaticVertex::TTexCoord)), "");
dp::BindingFiller<TextStaticVertex> filler(2);
filler.FillDecl<TextStaticVertex::TTexCoord>("a_colorTexCoord");
filler.FillDecl<TextStaticVertex::TTexCoord>("a_maskTexCoord");
return filler.m_info;
}
dp::BindingInfo TextOutlinedStaticBindingInit()
{
static_assert(sizeof(TextOutlinedStaticVertex) == (3 * sizeof(TextOutlinedStaticVertex::TTexCoord)), "");
dp::BindingFiller<TextOutlinedStaticVertex> filler(3);
filler.FillDecl<TextOutlinedStaticVertex::TTexCoord>("a_colorTexCoord");
filler.FillDecl<TextOutlinedStaticVertex::TTexCoord>("a_outlineColorTexCoord");
filler.FillDecl<TextOutlinedStaticVertex::TTexCoord>("a_maskTexCoord");
return filler.m_info;
}
dp::BindingInfo TextDynamicBindingInit()
{
static_assert(
sizeof(TextDynamicVertex) == (sizeof(TextStaticVertex::TPosition3d) + sizeof(TextDynamicVertex::TNormal)), "");
dp::BindingFiller<TextDynamicVertex> filler(2, TextDynamicVertex::GetDynamicStreamID());
filler.FillDecl<TextDynamicVertex::TPosition3d>("a_position");
filler.FillDecl<TextDynamicVertex::TNormal>("a_normal");
return filler.m_info;
}
dp::BindingInfo LineBindingInit()
{
static_assert(
sizeof(LineVertex) == sizeof(LineVertex::TPosition) + sizeof(LineVertex::TNormal) + sizeof(LineVertex::TTexCoord),
"");
dp::BindingFiller<LineVertex> filler(3);
filler.FillDecl<LineVertex::TPosition>("a_position");
filler.FillDecl<LineVertex::TNormal>("a_normal");
filler.FillDecl<LineVertex::TTexCoord>("a_colorTexCoord");
return filler.m_info;
}
dp::BindingInfo DashedLineBindingInit()
{
static_assert(sizeof(DashedLineVertex) == sizeof(DashedLineVertex::TPosition) + sizeof(DashedLineVertex::TNormal) +
sizeof(DashedLineVertex::TTexCoord) +
sizeof(DashedLineVertex::TMaskTexCoord),
"");
dp::BindingFiller<DashedLineVertex> filler(4);
filler.FillDecl<DashedLineVertex::TPosition>("a_position");
filler.FillDecl<DashedLineVertex::TNormal>("a_normal");
filler.FillDecl<DashedLineVertex::TTexCoord>("a_colorTexCoord");
filler.FillDecl<DashedLineVertex::TMaskTexCoord>("a_maskTexCoord");
return filler.m_info;
}
dp::BindingInfo RouteBindingInit()
{
static_assert(sizeof(RouteVertex) == sizeof(RouteVertex::TPosition) + sizeof(RouteVertex::TNormal) +
sizeof(RouteVertex::TLength) + sizeof(RouteVertex::TColor),
"");
dp::BindingFiller<RouteVertex> filler(4);
filler.FillDecl<RouteVertex::TPosition>("a_position");
filler.FillDecl<RouteVertex::TNormal>("a_normal");
filler.FillDecl<RouteVertex::TLength>("a_length");
filler.FillDecl<RouteVertex::TColor>("a_color");
return filler.m_info;
}
dp::BindingInfo RouteMarkerBindingInit()
{
static_assert(sizeof(RouteMarkerVertex) == sizeof(RouteMarkerVertex::TPosition) + sizeof(RouteMarkerVertex::TNormal) +
sizeof(RouteMarkerVertex::TColor),
"");
dp::BindingFiller<RouteMarkerVertex> filler(3);
filler.FillDecl<RouteMarkerVertex::TPosition>("a_position");
filler.FillDecl<RouteMarkerVertex::TNormal>("a_normal");
filler.FillDecl<RouteMarkerVertex::TColor>("a_color");
return filler.m_info;
}
dp::BindingInfo ColoredSymbolBindingInit()
{
static_assert(sizeof(ColoredSymbolVertex) == sizeof(ColoredSymbolVertex::TPosition) +
sizeof(ColoredSymbolVertex::TNormal) +
sizeof(ColoredSymbolVertex::TTexCoord),
"");
dp::BindingFiller<ColoredSymbolVertex> filler(3);
filler.FillDecl<ColoredSymbolVertex::TPosition>("a_position");
filler.FillDecl<ColoredSymbolVertex::TNormal>("a_normal");
filler.FillDecl<ColoredSymbolVertex::TTexCoord>("a_colorTexCoords");
return filler.m_info;
}
BindingNode g_bindingNodes[TypeCount];
TInitFunction g_initFunctions[TypeCount] = {&AreaBindingInit,
&Area3dBindingInit,
&HatchingAreaBindingInit,
&SolidTexturingBindingInit,
&MaskedTexturingBindingInit,
&TextStaticBindingInit,
&TextOutlinedStaticBindingInit,
&TextDynamicBindingInit,
&LineBindingInit,
&DashedLineBindingInit,
&RouteBindingInit,
&RouteMarkerBindingInit,
&ColoredSymbolBindingInit};
dp::BindingInfo const & GetBinding(VertexType type)
{
BindingNode & node = g_bindingNodes[type];
if (!node.m_inited)
{
node.m_info = g_initFunctions[type]();
node.m_inited = true;
}
return node.m_info;
}
} // namespace
AreaVertex::AreaVertex(TPosition const & position, TTexCoord const & colorTexCoord)
: m_position(position)
, m_colorTexCoord(colorTexCoord)
{}
dp::BindingInfo const & AreaVertex::GetBindingInfo()
{
return GetBinding(Area);
}
Area3dVertex::Area3dVertex(TPosition const & position, TPosition const & normal, TTexCoord const & colorTexCoord)
: m_position(position)
, m_normal(normal)
, m_colorTexCoord(colorTexCoord)
{}
dp::BindingInfo const & Area3dVertex::GetBindingInfo()
{
return GetBinding(Area3d);
}
HatchingAreaVertex::HatchingAreaVertex(TPosition const & position, TTexCoord const & colorTexCoord,
TMaskTexCoord const & maskTexCoord)
: m_position(position)
, m_colorTexCoord(colorTexCoord)
, m_maskTexCoord(maskTexCoord)
{}
dp::BindingInfo const & HatchingAreaVertex::GetBindingInfo()
{
return GetBinding(HatchingArea);
}
SolidTexturingVertex::SolidTexturingVertex(TPosition3d const & position, TNormal const & normal,
TTexCoord const & colorTexCoord)
: m_position(position)
, m_normal(normal)
, m_colorTexCoord(colorTexCoord)
{}
dp::BindingInfo const & SolidTexturingVertex::GetBindingInfo()
{
return GetBinding(SolidTexturing);
}
MaskedTexturingVertex::MaskedTexturingVertex(TPosition3d const & position, TNormal const & normal,
TTexCoord const & colorTexCoord, TTexCoord const & maskTexCoord)
: m_position(position)
, m_normal(normal)
, m_colorTexCoord(colorTexCoord)
, m_maskTexCoord(maskTexCoord)
{}
dp::BindingInfo const & MaskedTexturingVertex::GetBindingInfo()
{
return GetBinding(MaskedTexturing);
}
TextOutlinedStaticVertex::TextOutlinedStaticVertex(TTexCoord const & colorTexCoord, TTexCoord const & outlineTexCoord,
TTexCoord const & maskTexCoord)
: m_colorTexCoord(colorTexCoord)
, m_outlineTexCoord(outlineTexCoord)
, m_maskTexCoord(maskTexCoord)
{}
dp::BindingInfo const & TextOutlinedStaticVertex::GetBindingInfo()
{
return GetBinding(TextOutlinedStatic);
}
TextDynamicVertex::TextDynamicVertex(TPosition3d const & position, TNormal const & normal)
: m_position(position)
, m_normal(normal)
{}
dp::BindingInfo const & TextDynamicVertex::GetBindingInfo()
{
return GetBinding(TextDynamic);
}
uint32_t TextDynamicVertex::GetDynamicStreamID()
{
return 0x7F;
}
LineVertex::LineVertex(TPosition const & position, TNormal const & normal, TTexCoord const & color)
: m_position(position)
, m_normal(normal)
, m_colorTexCoord(color)
{}
dp::BindingInfo const & LineVertex::GetBindingInfo()
{
return GetBinding(Line);
}
DashedLineVertex::DashedLineVertex(TPosition const & position, TNormal const & normal, TTexCoord const & color,
TMaskTexCoord const & mask)
: m_position(position)
, m_normal(normal)
, m_colorTexCoord(color)
, m_maskTexCoord(mask)
{}
dp::BindingInfo const & DashedLineVertex::GetBindingInfo()
{
return GetBinding(DashedLine);
}
RouteVertex::RouteVertex(TPosition const & position, TNormal const & normal, TLength const & length,
TColor const & color)
: m_position(position)
, m_normal(normal)
, m_length(length)
, m_color(color)
{}
dp::BindingInfo const & RouteVertex::GetBindingInfo()
{
return GetBinding(Route);
}
RouteMarkerVertex::RouteMarkerVertex(TPosition const & position, TNormal const & normal, TColor const & color)
: m_position(position)
, m_normal(normal)
, m_color(color)
{}
dp::BindingInfo const & RouteMarkerVertex::GetBindingInfo()
{
return GetBinding(RouteMarker);
}
TextStaticVertex::TextStaticVertex(TTexCoord const & colorTexCoord, TTexCoord const & maskTexCoord)
: m_colorTexCoord(colorTexCoord)
, m_maskTexCoord(maskTexCoord)
{}
dp::BindingInfo const & TextStaticVertex::GetBindingInfo()
{
return GetBinding(TextStatic);
}
ColoredSymbolVertex::ColoredSymbolVertex(TPosition const & position, TNormal const & normal,
TTexCoord const & colorTexCoord)
: m_position(position)
, m_normal(normal)
, m_colorTexCoord(colorTexCoord)
{}
dp::BindingInfo const & ColoredSymbolVertex::GetBindingInfo()
{
return GetBinding(ColoredSymbol);
}
} // namespace gpu

View file

@ -0,0 +1,208 @@
#pragma once
#include "drape/binding_info.hpp"
#include "drape/glsl_types.hpp"
#include "base/buffer_vector.hpp"
namespace gpu
{
struct BaseVertex
{
using TPosition = glsl::vec3;
using TPosition3d = glsl::vec4;
using TNormal = glsl::vec2;
using TNormal3d = glsl::vec3;
using TTexCoord = glsl::vec2;
};
template <class T>
using VBUnknownSizeT = buffer_vector<T, 128>;
template <class T>
using VBReservedSizeT = std::vector<T>;
struct AreaVertex : BaseVertex
{
AreaVertex() = default;
AreaVertex(TPosition const & position, TTexCoord const & colorTexCoord);
TPosition m_position;
TTexCoord m_colorTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
struct Area3dVertex : BaseVertex
{
Area3dVertex() = default;
Area3dVertex(TPosition const & position, TPosition const & normal, TTexCoord const & colorTexCoord);
TPosition m_position;
TNormal3d m_normal;
TTexCoord m_colorTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
struct HatchingAreaVertex : BaseVertex
{
using TMaskTexCoord = glsl::vec2;
HatchingAreaVertex() = default;
HatchingAreaVertex(TPosition const & position, TTexCoord const & colorTexCoord, TMaskTexCoord const & maskTexCoord);
TPosition m_position;
TTexCoord m_colorTexCoord;
TMaskTexCoord m_maskTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
struct SolidTexturingVertex : BaseVertex
{
SolidTexturingVertex() = default;
SolidTexturingVertex(TPosition3d const & position, TNormal const & normal, TTexCoord const & colorTexCoord);
TPosition3d m_position;
TNormal m_normal;
TTexCoord m_colorTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
struct MaskedTexturingVertex : BaseVertex
{
MaskedTexturingVertex() = default;
MaskedTexturingVertex(TPosition3d const & position, TNormal const & normal, TTexCoord const & colorTexCoord,
TTexCoord const & maskTexCoord);
TPosition3d m_position;
TNormal m_normal;
TTexCoord m_colorTexCoord;
TTexCoord m_maskTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
struct TextStaticVertex : BaseVertex
{
TextStaticVertex() = default;
TextStaticVertex(TTexCoord const & colorTexCoord, TTexCoord const & maskTexCoord);
TTexCoord m_colorTexCoord;
TTexCoord m_maskTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
using TTextStaticVertexBuffer = VBReservedSizeT<TextStaticVertex>;
struct TextOutlinedStaticVertex : BaseVertex
{
public:
TextOutlinedStaticVertex() = default;
TextOutlinedStaticVertex(TTexCoord const & colorTexCoord, TTexCoord const & outlineTexCoord,
TTexCoord const & maskTexCoord);
TTexCoord m_colorTexCoord;
TTexCoord m_outlineTexCoord;
TTexCoord m_maskTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
using TTextOutlinedStaticVertexBuffer = VBReservedSizeT<TextOutlinedStaticVertex>;
struct TextDynamicVertex : BaseVertex
{
TextDynamicVertex() = default;
TextDynamicVertex(TPosition3d const & position, TNormal const & normal);
TPosition3d m_position;
TNormal m_normal;
static dp::BindingInfo const & GetBindingInfo();
static uint32_t GetDynamicStreamID();
};
using TTextDynamicVertexBuffer = VBReservedSizeT<TextDynamicVertex>;
struct LineVertex : BaseVertex
{
using TNormal = glsl::vec3;
LineVertex() = default;
LineVertex(TPosition const & position, TNormal const & normal, TTexCoord const & color);
TPosition m_position;
TNormal m_normal;
TTexCoord m_colorTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
struct DashedLineVertex : BaseVertex
{
using TNormal = glsl::vec3;
using TMaskTexCoord = glsl::vec4;
DashedLineVertex() = default;
DashedLineVertex(TPosition const & position, TNormal const & normal, TTexCoord const & color,
TMaskTexCoord const & mask);
TPosition m_position;
TNormal m_normal;
TTexCoord m_colorTexCoord;
TMaskTexCoord m_maskTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
struct RouteVertex : BaseVertex
{
using TLength = glsl::vec3;
using TColor = glsl::vec4;
RouteVertex() = default;
RouteVertex(TPosition const & position, TNormal const & normal, TLength const & length, TColor const & color);
TPosition m_position;
TNormal m_normal;
TLength m_length;
TColor m_color;
static dp::BindingInfo const & GetBindingInfo();
};
struct RouteMarkerVertex : BaseVertex
{
using TPosition = glsl::vec4;
using TNormal = glsl::vec3;
using TColor = glsl::vec4;
RouteMarkerVertex() = default;
RouteMarkerVertex(TPosition const & position, TNormal const & normal, TColor const & color);
TPosition m_position;
TNormal m_normal;
TColor m_color;
static dp::BindingInfo const & GetBindingInfo();
};
struct ColoredSymbolVertex : BaseVertex
{
using TNormal = glsl::vec4;
using TTexCoord = glsl::vec4;
ColoredSymbolVertex() = default;
ColoredSymbolVertex(TPosition const & position, TNormal const & normal, TTexCoord const & colorTexCoord);
TPosition m_position;
TNormal m_normal;
TTexCoord m_colorTexCoord;
static dp::BindingInfo const & GetBindingInfo();
};
} // namespace gpu