MCPcopy Create free account
hub / github.com/comaps/comaps / UpdateData

Method UpdateData

libs/drape/gpu_buffer.cpp:107–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void GPUBuffer::UpdateData(void * gpuPtr, void const * data, uint32_t elementOffset, uint32_t elementCount)
108{
109 uint32_t const elementSize = GetElementSize();
110 uint32_t const byteOffset = (elementOffset + m_mappingOffset) * elementSize;
111 uint32_t const byteCount = elementCount * elementSize;
112 uint32_t const byteCapacity = GetCapacity() * elementSize;
113 ASSERT(m_isMapped, ());
114
115#if defined(CHECK_VBO_BOUNDS)
116 int32_t size = GLFunctions::glGetBufferParameter(glTarget(m_t), gl_const::GLBufferSize);
117 ASSERT_EQUAL(size, byteCapacity, ());
118 ASSERT_LESS_OR_EQUAL(byteOffset + byteCount, size, ());
119#endif
120
121 if (IsMapBufferSupported())
122 {
123 ASSERT(gpuPtr != nullptr, ());
124 memcpy((uint8_t *)gpuPtr + byteOffset, data, byteCount);
125 }
126 else
127 {
128 ASSERT(gpuPtr == nullptr, ());
129 if (byteOffset == 0 && byteCount == byteCapacity)
130 GLFunctions::glBufferData(glTarget(m_t), byteCount, data, gl_const::GLDynamicDraw);
131 else
132 GLFunctions::glBufferSubData(glTarget(m_t), byteCount, data, byteOffset);
133 }
134}
135
136void GPUBuffer::Unmap()
137{

Callers 1

ApplyMutationMethod · 0.45

Calls 3

ASSERTFunction · 0.85
glTargetFunction · 0.85
IsMapBufferSupportedFunction · 0.85

Tested by

no test coverage detected