Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
GLDevice.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
16#pragma once
17
18// =============================================================================
19// Includes
20// =============================================================================
21
22#include "./GfxDevice.hpp"
23#include "../../core/Hash.hpp"
24
25#include <initializer_list>
26#include <string>
27#include <unordered_map>
28#include <unordered_set>
29#include <vector>
30
31namespace esengine {
32
33// =============================================================================
34// GLDevice Class
35// =============================================================================
36
40class GLDevice final : public GfxDevice {
41public:
42 GLDevice() = default;
43 ~GLDevice() override = default;
44
46
47 void init() override;
48 void shutdown() override;
49
50 bool pollDeviceLost() override;
51
52 void setViewport(i32 x, i32 y, u32 w, u32 h) override;
53 void clearStencil(i32 value) override;
54
55 void setScissorTest(bool enabled) override;
56 void setScissor(i32 x, i32 y, i32 w, i32 h) override;
57
58 void setVertexBuffer(u32 slot, BufferHandle buffer, u32 offsetBytes) override;
59 void setIndexBuffer(BufferHandle buffer) override;
60
61 void bindTexture(u32 slot, TextureHandle texture) override;
63 bool supportsFloatTargets() override;
64 bool supportsUnblendedSurfaceTarget() const override { return indexed_blend_ == 1; }
65 u32 maxSamples() override;
67 bool resolvesDepth() const override { return true; }
68
69 bool supportsShaderLanguage(GfxShaderLanguage language) const override {
70 return language == GfxShaderLanguage::GLSL_ES300;
71 }
72
74
75 void setStencilReference(i32 ref) override;
76
77 void drawElements(u32 indexCount, GfxDataType indexType, u32 byteOffset) override;
78 void drawArrays(u32 first, u32 vertexCount) override;
79 void drawElementsInstanced(u32 indexCount, GfxDataType indexType, u32 byteOffset, u32 instanceCount) override;
80 bool supportsMultiDraw() const override { return multi_draw_; }
81 void drawElementsInstancedMulti(GfxDataType indexType, const u32* counts, const u32* byteOffsets,
82 const u32* instanceCounts, u32 drawCount) override;
83
84 void beginRenderPass(const RenderPassDesc& desc) override;
85 void endRenderPass() override;
86
88 bool copyFramebufferColor(FramebufferHandle source, TextureHandle dst) override;
93 bool takeReadback(ReadbackHandle handle, void* dest, usize destSize) override;
94 void discardReadback(ReadbackHandle handle) override;
95
96 void beginTimerQuery(u32 query) override;
97 void endTimerQuery() override;
98 bool timerDisjoint() override;
99 bool getTimerQueryNs(u32 query, u64* outNanoseconds) override;
100
101 void setWireframe(bool enabled) override;
102 u32 getError() override;
103 std::string getString(GfxStringName name) override;
104 i32 getInt(GfxIntParam name) override;
105
107 u32 nativeTextureName(TextureHandle texture) const override { return nameOf(texture_names_, static_cast<u32>(texture)); }
108
109protected:
110 void captureDeviceIdentity() override;
111 bool recreateDevice() override;
112 void onDeviceLost() override;
113
114 bool backendCreateBuffer(u32 id, const BufferDesc& desc, const void* data) override;
115 void backendDeleteBuffer(u32 id) override;
116 void backendUpdateBuffer(u32 id, u32 offsetBytes, const void* data, u32 sizeBytes) override;
117 void backendResizeBuffer(u32 id, const BufferDesc& desc, const void* data) override;
118 void backendSetUniformBuffer(u32 slot, BufferHandle buffer, u32 offsetBytes, u32 sizeBytes) override;
119
120 bool backendCreateTexture(u32 id, const TextureDesc& desc, const void* pixels) override;
122 const void* data, u32 byteLength, u32 mipLevels) override;
123 bool backendAdoptTexture(u32 id, u32 nativeId, const TextureDesc& desc) override;
124 void backendDeleteTexture(u32 id) override;
125 void backendMoveTexture(u32 into, u32 from) override;
126 void backendUpdateTexture(u32 id, i32 x, i32 y, u32 width, u32 height,
127 const void* pixels, bool flipY) override;
128 void backendSetTextureParams(u32 id, const TextureDesc& desc) override;
129 void backendGenerateMipmaps(u32 id) override;
130
131 bool backendCreateProgram(u32 id, const GfxShaderSource& source,
132 const GfxAttribBinding* bindings, u32 bindingCount,
133 std::string* outLog, GfxShaderStage* outFailedStage) override;
134 void backendDeleteProgram(u32 id) override;
135 void backendUseProgram(u32 id) override;
136 i32 backendUniformLocation(u32 program, const char* name) override;
137 i32 backendAttribLocation(u32 program, const char* name) override;
138 void backendSetUniform(i32 nativeLocation, const GfxUniformValue& value) override;
139 u32 backendBoundSamplerUnits() override;
140 void backendIntUniformSet(u32 program) override;
141 std::vector<GfxUniformInfo> backendActiveUniforms(u32 program) override;
142 u32 backendUniformBlockIndex(u32 program, const char* name) override;
143 void backendUniformBlockBinding(u32 program, u32 nativeBlockIndex, u32 bindingPoint) override;
144
145 void backendDeleteVertexLayout(u32 id) override;
146 void backendSetPipeline(u32 id, const PipelineDesc& desc) override;
148 u32 primitiveMode() const;
149 void backendInvalidatePipelineCache() override;
150
151 bool supportsDeferredLink() const override { return true; }
152 bool backendProgramPending(u32 id) const override { return pending_programs_.count(id) != 0; }
153 bool backendFinishProgram(u32 id) override;
154 void endFrame() override;
155 bool framePending() override;
156 bool backendProgramReady(u32 id) override;
158 std::string backendPendingProgramLabels() override;
159
160 bool backendCreateFramebuffer(u32 id, const FramebufferDesc& desc) override;
161 void backendDeleteFramebuffer(u32 id) override;
162
163 bool backendCreateTimerQuery(u32 id) override;
164 u32 backendReadbackCount() const override { return static_cast<u32>(readbacks_.size()); }
165
166private:
167 static u32 nameOf(const std::vector<u32>& names, u32 id) {
168 return id < names.size() ? names[id] : 0u;
169 }
170 static void setName(std::vector<u32>& names, u32 id, u32 name) {
171 if (id >= names.size()) names.resize(static_cast<usize>(id) + 1, 0u);
172 names[id] = name;
173 }
175 bool isRenderbuffer(u32 textureId) const;
181 bool boundFramebufferComplete(std::initializer_list<TextureHandle> attachments);
183 std::unordered_map<std::string, bool> framebuffer_complete_;
184
185 // Clear machinery: backend-internal since RenderPassDesc became the only way
186 // to request clears (it carries the values; beginRenderPass applies them).
187 void setClearColor(f32 r, f32 g, f32 b, f32 a);
188 void setClearStencil(i32 value);
189 void clear(bool color, bool depth, bool stencil);
190
191 // The loose state setters a pipeline bundles (blend/depth/stencil/cull/masks):
192 // backend-internal since the pipeline became the only way to set them.
193 void setBlendEnabled(bool enabled);
194 void setBlendMode(BlendMode mode, bool layerAlpha = false);
195 void setDepthTest(bool enabled);
196 void setDepthWrite(bool enabled);
197 void setStencilTest(bool enabled);
198 void setStencilFunc(GfxStencilFunc func, i32 ref, u32 mask);
199 void setStencilOp(GfxStencilOp sfail, GfxStencilOp dpfail, GfxStencilOp dppass);
200 void setStencilMask(u32 mask);
201 void setColorMask(bool r, bool g, bool b, bool a);
202 void setCulling(bool enabled);
203 void setCullFace(bool front);
204 void setDepthBias(i16 bias);
205
206 void applyStencilMode(GfxStencilMode mode);
207
208 void uploadBufferStore(u32 id, u32 offsetBytes, const void* data, u32 sizeBytes, bool respec);
209
210 // Drops every "what is currently bound" cache. Those answers are only valid
211 // for the context that was asked; after a restore they would suppress the
212 // very binds that re-establish state.
213 void resetStateCache();
214
215 // Applies the current pipeline's vertex layout to the pending buffer bindings:
216 // the layout's lazily-created VAO is bound, and any slot whose buffer/offset
217 // differs from what the VAO has baked is re-pointed. WebGL2 has no explicit
218 // vertex-input object, so the VAO is purely a backend cache here.
219 void prepareVertexState();
220
221 // Binds a texture on the active unit for a create/update/mipmap edit while
222 // keeping the sampler-binding cache coherent, so bindTexture() can skip
223 // redundant per-draw binds (every gl* call is a WASM→JS FFI crossing).
224 void bindTextureForEdit(u32 name);
225
226 // Detach a texture from every sampler slot it lingers in, keeping the sampler
227 // cache coherent. Used by beginRenderPass to break feedback loops: a render
228 // target's own attachment must not stay bound to a sampler while it is drawn to.
229 void evictSamplerBinding(u32 name);
230
232 u32 textureTarget(u32 name) const;
234 std::unordered_set<u32> array_names_;
236 std::unordered_set<u32> volume_names_;
237
239 std::vector<u32> buffer_names_;
240 std::vector<u32> texture_names_;
241 std::vector<u32> program_names_;
243 struct PendingProgram { u32 vertex = 0; u32 fragment = 0; std::string label; };
244 std::unordered_map<u32, PendingProgram> pending_programs_;
246 u32 programName(u32 id);
248 bool pass_discard_msaa_ = false;
249 bool pass_discard_depth_ = false;
251 i8 default_depth_bits_ = -1;
252 i8 default_stencil_bits_ = -1;
254 void discardLeftDepth();
256 std::unordered_set<u32> failed_programs_;
258 i8 completion_status_ = 0;
259 std::vector<u32> framebuffer_names_;
260 std::vector<u32> query_names_;
262 std::vector<u32> uniform_slots_;
264 struct UniformRange { u32 offset = 0; u32 size = 0; };
265 std::vector<UniformRange> uniform_ranges_;
266 void bindUniformSlot(u32 slot, u32 name);
267
271 enum Cap : u32 { kCapDepthTest, kCapStencilTest, kCapCull, kCapBlend, kCapCount };
272 i8 cap_state_[kCapCount] = {-1, -1, -1, -1};
273 i8 depth_mask_ = -1;
274 i16 color_mask_ = -1;
275 i64 stencil_mask_ = -1;
277 struct UniformBound { u32 name = 0; u32 offset = 0; u32 size = 0; bool known = false; };
278 std::vector<UniformBound> uniform_bound_;
279 void setCap(Cap cap, u32 glCap, bool enabled);
280 void resetDrawStateCaches();
281
282 u32 current_pipeline_id_ = 0;
283 GfxTopology current_topology_ = GfxTopology::Triangles;
284 GfxStencilMode current_stencil_mode_ = GfxStencilMode::Off;
285 // Redundant-state caches: a pipeline switch sharing the program or blend func
286 // skips the FFI-crossing GL call. 0xFF is an out-of-range BlendMode, so the
287 // first real set always issues.
288 u32 current_program_name_ = 0;
291 std::unordered_map<u32, u32> sampler_units_;
292 BlendMode current_blend_ = static_cast<BlendMode>(0xFF);
293 bool current_blend_adds_only_ = false;
294
295 // Redundant-state caches for the two per-draw hot paths. glActiveTexture is
296 // the only site that moves the active unit, so active_texture_unit_ is
297 // authoritative; bound_texture_[unit] mirrors the sampler bindings by GL name.
298 static constexpr u32 kTextureSlots = 17;
299 u32 active_texture_unit_ = 0;
300 u32 bound_texture_[kTextureSlots] = {};
301 i16 current_depth_bias_ = 0;
302 i8 depth_equal_ = -1;
303 i8 alpha_to_coverage_ = -1;
304 i8 cull_front_ = -1;
308 bool current_fbo_has_gbuffer_ = false;
309 bool current_fbo_has_albedo_ = false;
310 i8 draw_buffers_ = -1;
311 void applyDrawBuffers(bool gbuffer, bool albedo);
313 i8 indexed_blend_ = 0;
315 bool surface_blend_off_ = false;
316 void applySurfaceBlend(bool off);
317 int scissor_test_ = -1; // tri-state: -1 unknown, 0 disabled, 1 enabled
318 int float_targets_ = -1; // supportsFloatTargets(), answered once per context: -1 not asked yet
319
320 struct VaoCache {
321 u32 vao = 0;
322 bool configured = false;
323 u32 bakedVbo[MAX_VERTEX_BUFFER_SLOTS] = {};
324 u32 bakedOffset[MAX_VERTEX_BUFFER_SLOTS] = {};
325 u32 bakedIbo = 0;
326 };
327 // A vertex array object per (layout, the buffers it reads from): it holds the attribute pointers, which name their buffer, so one VAO shared by
328 // every buffer of a layout re-pointed all of them at each draw that changed buffer (a tilemap's strips, a mesh's own vertices). Slots the
329 // layout does not read are 0 in the key, so a stale handle left in one does not make a second VAO. Offsets are not in the key: a draw that
330 // moves along a buffer (instance records) re-points just that slot, as before.
331 struct VaoKey {
332 u32 layout = 0;
334 u32 ibo = 0;
335 bool operator==(const VaoKey&) const = default;
336 };
337 struct VaoKeyHash {
338 usize operator()(const VaoKey& key) const {
339 u64 h = hash::fnv1aWord(hash::kFnv64Offset, key.layout);
340 for (u32 slot = 0; slot < MAX_VERTEX_BUFFER_SLOTS; ++slot) h = hash::fnv1aWord(h, key.vbo[slot]);
341 return static_cast<usize>(hash::fnv1aWord(h, key.ibo));
342 }
343 };
344 std::unordered_map<VaoKey, VaoCache, VaoKeyHash> vaos_;
347 VaoKey last_vao_key_{};
348 VaoCache* last_vao_ = nullptr;
350 void releaseVaosUsing(u32 bufferName);
351 u32 current_layout_ = 0;
352 u32 pending_vbo_[MAX_VERTEX_BUFFER_SLOTS] = {};
353 u32 pending_vbo_offset_[MAX_VERTEX_BUFFER_SLOTS] = {};
354 u32 pending_ibo_ = 0;
355 u32 bound_vao_ = 0;
357 bool multi_draw_ = false;
358 bool loop_floor_ = false;
359 std::vector<i32> multi_counts_, multi_instances_;
360 std::vector<const void*> multi_offsets_;
361
362 // Where a multisampled framebuffer resolves to, and how big, by framebuffer id.
363 // The blit runs whenever the target is left, which is the only reason anything
364 // above the RHI can sample a target it drew into multisampled.
365 struct ResolvePair {
366 u32 destFbo = 0;
367 u32 width = 0;
368 u32 height = 0;
369 bool depth = false;
370 bool gbuffer = false;
371 bool albedo = false;
372 };
373 std::unordered_map<u32, ResolvePair> framebuffer_resolve_;
376 void resolveFramebuffer(u32 framebufferId);
378 u32 current_framebuffer_ = 0;
380 u32 max_samples_ = 0;
381
382 // A readback until it is taken. On WebGL2 the read goes into a pixel-pack buffer behind a fence, so asking for it does not wait for
383 // the GPU to finish the frame (glReadPixels into memory waited for the whole scene: seconds a camera preview on a heavy one) and it
384 // is Ready once the fence has passed; elsewhere the pixels are read at once and Ready at the first poll.
385 struct Readback {
386 std::vector<u8> pixels;
387 u32 buffer = 0;
388 void* fence = nullptr; // GLsync
389 usize size = 0;
390 };
391 std::unordered_map<u32, Readback> readbacks_;
393 void releaseReadback(Readback& readback, bool live);
394 u32 next_readback_id_ = 1;
395
396 // 0 = unprobed, 1 = timer queries available, 2 = unavailable.
397 int timer_query_state_ = 0;
398 bool timer_disjoint_pending_ = false;
400 void* frame_fence_ = nullptr;
401};
402
403} // namespace esengine
Abstract graphics device interface.
void init() override
Initializes the graphics device.
Definition GLDevice.cpp:318
bool backendCreateBuffer(u32 id, const BufferDesc &desc, const void *data) override
bool supportsUnblendedSurfaceTarget() const override
Whether a blended draw can write the surface record's second attachment unblended.
Definition GLDevice.hpp:64
void backendDeleteFramebuffer(u32 id) override
~GLDevice() override=default
void setViewport(i32 x, i32 y, u32 w, u32 h) override
Sets the rendering viewport.
Definition GLDevice.cpp:528
bool framePending() override
Whether the GPU is still working on the frame last ended (see endFrame).
void backendUniformBlockBinding(u32 program, u32 nativeBlockIndex, u32 bindingPoint) override
u32 backendReadbackCount() const override
Readbacks in flight, the one live object the registry does not hold.
Definition GLDevice.hpp:164
void backendSetUniform(i32 nativeLocation, const GfxUniformValue &value) override
Definition GLDevice.cpp:944
void beginTimerQuery(u32 query) override
Starts timing GPU work into a query; one query may be active at a time.
void discardReadback(ReadbackHandle handle) override
Abandons a readback (any state); its resources are released.
ClipDepthRange clipDepthRange() const override
The clip volume this device keeps along z.
Definition GLDevice.hpp:45
void backendDeleteBuffer(u32 id) override
void backendUseProgram(u32 id) override
Definition GLDevice.cpp:927
std::vector< GfxUniformInfo > backendActiveUniforms(u32 program) override
bool resolvesDepth() const override
Definition GLDevice.hpp:67
bool recreateDevice() override
Backend half of recoverDevice: a working device again, with every id-to-native map and derived cache ...
Definition GLDevice.cpp:413
void backendInvalidatePipelineCache() override
void backendIntUniformSet(u32 program) override
void onDeviceLost() override
Release what only this backend can name, while the dead device is still the current one.
Definition GLDevice.cpp:371
void endRenderPass() override
Ends the current pass, restoring the default framebuffer.
void backendDeleteProgram(u32 id) override
Definition GLDevice.cpp:913
void setIndexBuffer(BufferHandle buffer) override
Binds the index buffer for subsequent indexed draws.
void backendResizeBuffer(u32 id, const BufferDesc &desc, const void *data) override
void backendDeleteTexture(u32 id) override
i32 getInt(GfxIntParam name) override
Queries a backend integer capability/limit.
u32 maxSamples() override
Most samples an offscreen colour attachment may carry; 1 = none.
void backendUpdateBuffer(u32 id, u32 offsetBytes, const void *data, u32 sizeBytes) override
bool backendProgramPending(u32 id) const override
True while a program created with deferLink has not been waited for.
Definition GLDevice.hpp:152
bool backendCreateTexture(u32 id, const TextureDesc &desc, const void *pixels) override
u32 nativeTextureName(TextureHandle texture) const override
This generation's GL name behind a texture, for a host uploading into it.
Definition GLDevice.hpp:107
bool supportsCompressedFormat(GfxCompressedFormat format) override
Reports whether the backend can sample the given compressed format.
bool backendCreateTimerQuery(u32 id) override
bool timerDisjoint() override
True when GPU timing was disturbed since the last check.
void setStencilReference(i32 ref) override
GL reads a framebuffer from the bottom up.
void drawElementsInstanced(u32 indexCount, GfxDataType indexType, u32 byteOffset, u32 instanceCount) override
Draws indexed triangles with instancing.
void backendGenerateMipmaps(u32 id) override
bool supportsShaderLanguage(GfxShaderLanguage language) const override
Whether this backend compiles language (GL: GLSL ES 300; WebGPU: WGSL).
Definition GLDevice.hpp:69
void drawElements(u32 indexCount, GfxDataType indexType, u32 byteOffset) override
Draws indexed triangles.
void captureDeviceIdentity() override
Records who this backend is, so a later loss report can name it.
Definition GLDevice.cpp:342
bool takeReadback(ReadbackHandle handle, void *dest, usize destSize) override
Copies a Ready readback's pixels (w*h*4 bytes) into dest and releases it.
void clearStencil(i32 value) override
Mid-pass stencil reset (the one clear that isn't a pass load-op).
u32 primitiveMode() const
bool backendCreateProgram(u32 id, const GfxShaderSource &source, const GfxAttribBinding *bindings, u32 bindingCount, std::string *outLog, GfxShaderStage *outFailedStage) override
Definition GLDevice.cpp:739
void endTimerQuery() override
Stops the active timer query.
bool supportsDeferredLink() const override
Whether createProgram honours GfxShaderSource::deferLink (GL: yes; a backend that links at once does ...
Definition GLDevice.hpp:151
ReadbackHandle requestReadback(FramebufferHandle target, u32 w, u32 h) override
Requests an RGBA8 readback of a framebuffer's color attachment.
u32 backendUniformBlockIndex(u32 program, const char *name) override
void shutdown() override
Shuts down the graphics device.
Definition GLDevice.cpp:487
void backendSetTextureParams(u32 id, const TextureDesc &desc) override
void setWireframe(bool enabled) override
Enables or disables wireframe rendering (desktop only).
bool backendCreateFramebuffer(u32 id, const FramebufferDesc &desc) override
bool backendAdoptTexture(u32 id, u32 nativeId, const TextureDesc &desc) override
Takes over a native texture the host created; false when this backend cannot.
void drawElementsInstancedMulti(GfxDataType indexType, const u32 *counts, const u32 *byteOffsets, const u32 *instanceCounts, u32 drawCount) override
drawCount indexed instanced draws through the bound pipeline and buffers, as one call where supportsM...
bool backendFinishProgram(u32 id) override
Waits for a deferred program, runs its onLinked callback; false when it failed to link....
Definition GLDevice.cpp:836
GfxReadbackStatus pollReadback(ReadbackHandle handle) override
The state of an in-flight readback; pumps backend completion events. A Failed readback is released by...
void backendUpdateTexture(u32 id, i32 x, i32 y, u32 width, u32 height, const void *pixels, bool flipY) override
bool supportsMultiDraw() const override
Whether drawElementsInstancedMulti is one call here, its draws told apart by gl_DrawID (WEBGL_multi_d...
Definition GLDevice.hpp:80
std::string backendPendingProgramLabels() override
Definition GLDevice.cpp:884
bool getTimerQueryNs(u32 query, u64 *outNanoseconds) override
Fetches a completed query's elapsed nanoseconds; false while still pending.
void backendMoveTexture(u32 into, u32 from) override
Re-keys from's native texture under into; into holds none on entry.
void backendDeleteVertexLayout(u32 id) override
Drops what the backend derived from a layout (a GL VAO); the desc stays here.
bool supportsFloatTargets() override
Whether RGBA16F color attachments are renderable.
u32 backendPendingProgramCount() override
Definition GLDevice.cpp:871
u32 backendBoundSamplerUnits() override
Definition GLDevice.cpp:977
void bindTexture(u32 slot, TextureHandle texture) override
Activates a texture slot and binds a 2D texture.
void beginRenderPass(const RenderPassDesc &desc) override
Targets a framebuffer for subsequent draws and applies the pass's clears.
void drawArrays(u32 first, u32 vertexCount) override
Draws non-indexed triangles.
std::string getString(GfxStringName name) override
Queries a backend identification string (diagnostics).
ReadbackHandle captureNextFrame(u32 w, u32 h) override
void backendSetUniformBuffer(u32 slot, BufferHandle buffer, u32 offsetBytes, u32 sizeBytes) override
void backendSetPipeline(u32 id, const PipelineDesc &desc) override
bool backendCreateCompressedTexture(u32 id, const TextureDesc &desc, GfxCompressedFormat format, const void *data, u32 byteLength, u32 mipLevels) override
void setScissor(i32 x, i32 y, i32 w, i32 h) override
Sets the scissor rectangle.
Definition GLDevice.cpp:683
bool backendProgramReady(u32 id) override
Definition GLDevice.cpp:893
void endFrame() override
The frame is over — everything drawn for it has been submitted.
bool pollDeviceLost() override
Pumps backend-native loss detection.
Definition GLDevice.cpp:499
bool copyFramebufferColor(FramebufferHandle source, TextureHandle dst) override
i32 backendAttribLocation(u32 program, const char *name) override
Definition GLDevice.cpp:939
void setVertexBuffer(u32 slot, BufferHandle buffer, u32 offsetBytes) override
Binds a vertex buffer to a layout slot for subsequent draws.
u32 getError() override
Queries the last error.
i32 backendUniformLocation(u32 program, const char *name) override
The backend's own location this generation, -1 when absent.
Definition GLDevice.cpp:934
void setScissorTest(bool enabled) override
Enables or disables scissor test.
Definition GLDevice.cpp:676
Abstract graphics device interface.
Definition GfxDevice.hpp:75
constexpr u64 fnv1aWord(u64 h, u64 word)
Definition Hash.hpp:17
constexpr u64 kFnv64Offset
Definition Hash.hpp:12
FramebufferHandle
Handle 0 is the default framebuffer (backbuffer); it cannot be created or deleted.
Definition GfxEnums.hpp:41
std::int32_t i32
Signed 32-bit integer.
Definition Types.hpp:54
GfxStringName
Backend identification strings.
Definition GfxEnums.hpp:509
std::uint64_t u64
Unsigned 64-bit integer.
Definition Types.hpp:47
ClipDepthRange
What a device's clip volume does with depth.
Definition GfxEnums.hpp:562
@ MinusOneToOne
OpenGL / OpenGL ES / WebGL.
Definition GfxEnums.hpp:563
GfxStencilMode
Stencil behaviour baked into a pipeline. The reference value is dynamic (GfxDevice::setStencilReferen...
@ Off
No stencil test; full color write.
std::size_t usize
Size type for indexing and sizes.
Definition Types.hpp:64
std::int16_t i16
Signed 16-bit integer.
Definition Types.hpp:52
GfxShaderLanguage
Shader source language a backend consumes.
Definition GfxEnums.hpp:654
GfxShaderStage
Which pipeline stage rejected a program during createProgram().
Definition GfxEnums.hpp:736
GfxCompressedFormat
GPU-compressed texture internal formats for createCompressedTexture.
Definition GfxEnums.hpp:326
std::int8_t i8
Signed 8-bit integer.
Definition Types.hpp:50
GfxReadbackStatus
State of an in-flight readback. GL completes at request time (first poll reports Ready); WebGPU resol...
Definition GfxEnums.hpp:47
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
BlendMode
Predefined blend modes for rendering.
Definition BlendMode.hpp:22
std::int64_t i64
Signed 64-bit integer.
Definition Types.hpp:56
static constexpr u32 MAX_VERTEX_BUFFER_SLOTS
Definition GfxEnums.hpp:218
GfxIntParam
Backend integer capabilities/limits.
Definition GfxEnums.hpp:517
GfxTopology
How a pipeline's indices assemble into primitives. Baked into the pipeline, as WebGPU bakes it,...
@ Triangles
Every three indices a triangle: all geometry the engine draws.
ReadbackHandle
An in-flight framebuffer readback (GfxDevice::requestReadback).
Definition GfxEnums.hpp:43
float f32
32-bit floating point
Definition Types.hpp:59
Immutable creation parameters of a GPU buffer.
Definition GfxEnums.hpp:403
Attachments of an offscreen render target. The attach point of depthStencil follows its texture's pix...
Definition GfxEnums.hpp:451
Vertex attribute location binding applied before a program is linked.
Definition GfxEnums.hpp:730
A program's source pair, tagged with the language it is written in.
Definition GfxEnums.hpp:660
The last value a program was given for one uniform, replayed after a relink.
Immutable description of a draw pipeline. Equality keys the pipeline cache, so two draws with the sam...
One render pass: a target, which attachments to clear on entry, and the clear values — full load-op s...
Definition GfxEnums.hpp:485
Immutable creation parameters of a 2D texture or 2D texture array.
Definition GfxEnums.hpp:414