feat(render): Renderer with LOD selection, 3.3 and 4.3+ upload paths, headless smoke test
This commit is contained in:
1 parent
e0cdd95a3b
commit
3555ab63d7
20 files changed
+1544
-25
No files matched your search
@@ -59,6 +59,7 @@ enum : GLenum {
|
||||
|
||||
// Pixel store state.
|
||||
GL_UNPACK_ALIGNMENT = 0x0CF5,
|
||||
GL_PACK_ALIGNMENT = 0x0D05,
|
||||
|
||||
// Shaders and programs.
|
||||
GL_FRAGMENT_SHADER = 0x8B30,
|
||||
@@ -76,6 +77,9 @@ enum : GLenum {
|
||||
GL_MAP_PERSISTENT_BIT = 0x0040 /* 4.4 */,
|
||||
GL_MAP_COHERENT_BIT = 0x0080 /* 4.4 */,
|
||||
|
||||
// Rasterisation state (1.0).
|
||||
GL_SCISSOR_TEST = 0x0C11,
|
||||
|
||||
// Textures.
|
||||
GL_TEXTURE_2D = 0x0DE1,
|
||||
GL_TEXTURE0 = 0x84C0,
|
||||
@@ -120,6 +124,8 @@ enum : GLenum {
|
||||
X(void, glEnable, (GLenum)) \
|
||||
X(void, glBlendFunc, (GLenum, GLenum)) \
|
||||
X(void, glPixelStorei, (GLenum, GLint)) \
|
||||
X(void, glDisable, (GLenum)) \
|
||||
X(void, glScissor, (GLint, GLint, GLsizei, GLsizei)) \
|
||||
/* shaders and programs */ \
|
||||
X(GLuint, glCreateShader, (GLenum)) \
|
||||
X(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint*)) \
|
||||
@@ -148,6 +154,8 @@ enum : GLenum {
|
||||
X(void, glBindBuffer, (GLenum, GLuint)) \
|
||||
X(void, glBufferData, (GLenum, GLsizeiptr, const void*, GLenum)) \
|
||||
X(void, glBufferSubData, (GLenum, GLintptr, GLsizeiptr, const void*)) \
|
||||
X(void*, glMapBufferRange, (GLenum, GLintptr, GLsizeiptr, GLbitfield)) \
|
||||
X(GLboolean, glUnmapBuffer, (GLenum)) \
|
||||
/* vertex arrays */ \
|
||||
X(void, glGenVertexArrays, (GLsizei, GLuint*)) \
|
||||
X(void, glDeleteVertexArrays, (GLsizei, const GLuint*)) \
|
||||
@@ -182,8 +190,17 @@ enum : GLenum {
|
||||
X(GLenum, glClientWaitSync, (GLsync, GLbitfield, GLuint64)) \
|
||||
X(void, glDeleteSync, (GLsync))
|
||||
|
||||
// Entry points above the 3.3 baseline, resolved best-effort: a driver that lacks
|
||||
// one leaves it null and `load()` still succeeds, so the library keeps working on
|
||||
// a 3.3-only context. Every one of these is reached only after `caps()` -- or an
|
||||
// explicit null check -- says the context can do it (see caps.hpp).
|
||||
#define PLOT_GL_OPTIONAL_FUNCS(X) \
|
||||
/* persistent buffer mapping, GL 4.4 / ARB_buffer_storage */ \
|
||||
X(void, glBufferStorage, (GLenum, GLsizeiptr, const void*, GLbitfield))
|
||||
|
||||
#define PLOT_GL_DECL(ret, name, args) extern ret (*name) args;
|
||||
PLOT_GL_FUNCS(PLOT_GL_DECL)
|
||||
PLOT_GL_OPTIONAL_FUNCS(PLOT_GL_DECL)
|
||||
#undef PLOT_GL_DECL
|
||||
|
||||
} // namespace plot::gl
|
||||
@@ -66,6 +66,21 @@ class Buffer final : public Handle<Buffer> {
|
||||
/// Overwrites `bytes` bytes starting at `offset`; the store must already be
|
||||
/// at least `offset + bytes` large.
|
||||
void upload_sub(const void* data, usize bytes, usize offset) const noexcept;
|
||||
/// Replaces the store with `bytes` bytes of immutable storage carrying `flags`
|
||||
/// (`GL_MAP_WRITE_BIT` and friends). GL 4.4 / ARB_buffer_storage: only legal on
|
||||
/// a context whose caps() report `buffer_storage`, and the entry point may be
|
||||
/// null even on such a context (it is resolved best-effort, see api.hpp), so a
|
||||
/// caller checks `glBufferStorage != nullptr` first. The contents start
|
||||
/// undefined.
|
||||
void storage(usize bytes, GLbitfield flags) const noexcept;
|
||||
|
||||
/// Maps `bytes` bytes from `offset` with `access`, returning the pointer or
|
||||
/// null. GL 3.0 core, but a `GL_MAP_PERSISTENT_BIT` map needs the same
|
||||
/// capability as `storage()` above.
|
||||
void* map_range(usize offset, usize bytes, GLbitfield access) const noexcept;
|
||||
|
||||
/// Unmaps the store's data; the pointer from map_range() is invalid after this.
|
||||
bool unmap() const noexcept;
|
||||
|
||||
/// Exposed for the CRTP base. Deleting an unknown name is a GL no-op.
|
||||
static void destroy(GLuint id) noexcept;
|
||||
|
||||
@@ -10,6 +10,9 @@ using ProcLoader = void* (*)(const char*);
|
||||
|
||||
/// Resolves every entry point of `PLOT_GL_FUNCS` (see api.hpp) into the global
|
||||
/// table declared there, so the rest of the library can call `gl*` directly.
|
||||
/// The above-baseline entries of `PLOT_GL_OPTIONAL_FUNCS` are resolved the same
|
||||
/// way but never fail the load: a driver without them leaves those pointers
|
||||
/// null, and callers reach them only behind `caps()`.
|
||||
///
|
||||
/// Returns false when any required name cannot be found; entries that did
|
||||
/// resolve keep their pointers, so a failed load() never breaks a table that
|
||||
|
||||
Reference in new issue
Block a user