mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-31 21:39:03 +01:00
perf(sleepers): the instances of the sleepers and timbers of a track sent to the gpu once, as it's laid, and kept there in a buffer of their own; in each pass the runs of them in sight turned by the modelviews of their cells into the instance buffer of the frame by a compute pass, one dispatch and one barrier a pass, and drawn in one instanced draw for each model, part and level of detail, in place of the cpu turning every instance every frame
This commit is contained in:
@@ -141,6 +141,17 @@ void gl::frame_stream::next_frame()
|
||||
}
|
||||
|
||||
GLintptr gl::frame_stream::push(void const *Data, GLsizeiptr Size)
|
||||
{
|
||||
auto const offset{reserve(Size)};
|
||||
auto const ¤t{m_slots[m_slot]};
|
||||
if (current.data != nullptr)
|
||||
std::memcpy(current.data + offset, Data, static_cast<std::size_t>(Size));
|
||||
else
|
||||
glNamedBufferSubData(current.buffer, offset, Size, Data);
|
||||
return offset;
|
||||
}
|
||||
|
||||
GLintptr gl::frame_stream::reserve(GLsizeiptr Size)
|
||||
{
|
||||
auto *current{&m_slots[m_slot]};
|
||||
auto offset{align_up(m_fill, m_alignment)};
|
||||
@@ -167,13 +178,8 @@ GLintptr gl::frame_stream::push(void const *Data, GLsizeiptr Size)
|
||||
glFinish();
|
||||
++m_waits;
|
||||
}
|
||||
current = &m_slots[m_slot];
|
||||
offset = m_start;
|
||||
}
|
||||
if (current->data != nullptr)
|
||||
std::memcpy(current->data + offset, Data, static_cast<std::size_t>(Size));
|
||||
else
|
||||
glNamedBufferSubData(current->buffer, offset, Size, Data);
|
||||
m_fill = offset + Size;
|
||||
return offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user