feat(render): Renderer with LOD selection, 3.3 and 4.3+ upload paths, headless smoke test

This commit is contained in:
Martino Ferrari committed 2026-09-27 23:03:08 +02:00
1 parent e0cdd95a3b
commit 3555ab63d7
20 files changed
+1544 -25

No files matched your search

+26 -4
View File
@@ -14,11 +14,11 @@ constexpr gl::GLuint kPerInstance = 1;
} // namespace
bool LineVertexArray::create(Status* st) noexcept {
bool LineVertexArray::create(Status* st, UploadMode mode) noexcept {
if (!vao_.create(st)) {
return false;
}
if (!buffer_.create(st)) {
if (!buffer_.create(st, mode)) {
vao_.reset(); // do not leave a vertex array behind on the failure path
return false;
}
@@ -32,6 +32,7 @@ bool LineVertexArray::create(Status* st) noexcept {
gl::glVertexAttribDivisor(0u, kPerInstance);
gl::glVertexAttribDivisor(1u, kPerInstance);
gl::glBindVertexArray(0); // leave the binding as we found it
epoch_ = buffer_.epoch();
return true;
}
@@ -43,14 +44,26 @@ void LineVertexArray::upload(const f32* interleaved, u32 segments) noexcept {
return;
}
buffer_.upload(interleaved, segments);
// Only the mapped transfer moves the instances between slots, and the
// attribute offsets have to follow them. The generation changes for a new slot
// or a re-created buffer, never otherwise, so the baseline path re-points at
// most once.
if (buffer_.epoch() != epoch_) {
const usize base = buffer_.slot_offset();
vao_.bind();
buffer_.bind();
vao_.attrib(0u, 2, sizeof(LineInstance), base + offsetof(LineInstance, x0));
vao_.attrib(1u, 2, sizeof(LineInstance), base + offsetof(LineInstance, x1));
epoch_ = buffer_.epoch();
}
instances_ = segments;
}
bool TextVertexArray::create(Status* st) noexcept {
bool TextVertexArray::create(Status* st, UploadMode mode) noexcept {
if (!vao_.create(st)) {
return false;
}
if (!buffer_.create(st)) {
if (!buffer_.create(st, mode)) {
vao_.reset();
return false;
}
@@ -61,6 +74,7 @@ bool TextVertexArray::create(Status* st) noexcept {
gl::glVertexAttribDivisor(0u, kPerInstance);
gl::glVertexAttribDivisor(1u, kPerInstance);
gl::glBindVertexArray(0);
epoch_ = buffer_.epoch();
return true;
}
@@ -70,6 +84,14 @@ void TextVertexArray::upload(const f32* interleaved, u32 glyphs) noexcept {
return;
}
buffer_.upload(interleaved, glyphs);
if (buffer_.epoch() != epoch_) {
const usize base = buffer_.slot_offset();
vao_.bind();
buffer_.bind();
vao_.attrib(0u, 2, sizeof(TextInstance), base + offsetof(TextInstance, x));
vao_.attrib(1u, 2, sizeof(TextInstance), base + offsetof(TextInstance, u));
epoch_ = buffer_.epoch();
}
instances_ = glyphs;
}