|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
OpenGL ES 3.0 / WebGL 2.0 implementation of GfxDevice. More...
#include <GLDevice.hpp>

Public Member Functions | |
| GLDevice ()=default | |
| ~GLDevice () override=default | |
| ClipDepthRange | clipDepthRange () const override |
| The clip volume this device keeps along z. | |
| void | init () override |
| Initializes the graphics device. | |
| void | shutdown () override |
| Shuts down the graphics device. | |
| bool | pollDeviceLost () override |
| Pumps backend-native loss detection. | |
| void | setViewport (i32 x, i32 y, u32 w, u32 h) override |
| Sets the rendering viewport. | |
| void | clearStencil (i32 value) override |
| Mid-pass stencil reset (the one clear that isn't a pass load-op). | |
| void | setScissorTest (bool enabled) override |
| Enables or disables scissor test. | |
| void | setScissor (i32 x, i32 y, i32 w, i32 h) override |
| Sets the scissor rectangle. | |
| void | setVertexBuffer (u32 slot, BufferHandle buffer, u32 offsetBytes) override |
| Binds a vertex buffer to a layout slot for subsequent draws. | |
| void | setIndexBuffer (BufferHandle buffer) override |
| Binds the index buffer for subsequent indexed draws. | |
| void | bindTexture (u32 slot, TextureHandle texture) override |
| Activates a texture slot and binds a 2D texture. | |
| bool | supportsCompressedFormat (GfxCompressedFormat format) override |
| Reports whether the backend can sample the given compressed format. | |
| bool | supportsFloatTargets () override |
| Whether RGBA16F color attachments are renderable. | |
| bool | supportsUnblendedSurfaceTarget () const override |
| Whether a blended draw can write the surface record's second attachment unblended. | |
| u32 | maxSamples () override |
| Most samples an offscreen colour attachment may carry; 1 = none. | |
| bool | resolvesDepth () const override |
| bool | supportsShaderLanguage (GfxShaderLanguage language) const override |
Whether this backend compiles language (GL: GLSL ES 300; WebGPU: WGSL). | |
| void | setStencilReference (i32 ref) override |
| GL reads a framebuffer from the bottom up. | |
| void | drawElements (u32 indexCount, GfxDataType indexType, u32 byteOffset) override |
| Draws indexed triangles. | |
| void | drawArrays (u32 first, u32 vertexCount) override |
| Draws non-indexed triangles. | |
| void | drawElementsInstanced (u32 indexCount, GfxDataType indexType, u32 byteOffset, u32 instanceCount) override |
| Draws indexed triangles with instancing. | |
| bool | supportsMultiDraw () const override |
| Whether drawElementsInstancedMulti is one call here, its draws told apart by gl_DrawID (WEBGL_multi_draw). | |
| 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 supportsMultiDraw(). | |
| void | beginRenderPass (const RenderPassDesc &desc) override |
| Targets a framebuffer for subsequent draws and applies the pass's clears. | |
| void | endRenderPass () override |
| Ends the current pass, restoring the default framebuffer. | |
| ReadbackHandle | requestReadback (FramebufferHandle target, u32 w, u32 h) override |
| Requests an RGBA8 readback of a framebuffer's color attachment. | |
| bool | copyFramebufferColor (FramebufferHandle source, TextureHandle dst) override |
| ReadbackHandle | captureNextFrame (u32 w, u32 h) override |
| GfxReadbackStatus | pollReadback (ReadbackHandle handle) override |
| The state of an in-flight readback; pumps backend completion events. A Failed readback is released by the poll that reported it. | |
| 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 | discardReadback (ReadbackHandle handle) override |
| Abandons a readback (any state); its resources are released. | |
| void | beginTimerQuery (u32 query) override |
| Starts timing GPU work into a query; one query may be active at a time. | |
| void | endTimerQuery () override |
| Stops the active timer query. | |
| bool | timerDisjoint () override |
| True when GPU timing was disturbed since the last check. | |
| bool | getTimerQueryNs (u32 query, u64 *outNanoseconds) override |
| Fetches a completed query's elapsed nanoseconds; false while still pending. | |
| void | setWireframe (bool enabled) override |
| Enables or disables wireframe rendering (desktop only). | |
| u32 | getError () override |
| Queries the last error. | |
| std::string | getString (GfxStringName name) override |
| Queries a backend identification string (diagnostics). | |
| i32 | getInt (GfxIntParam name) override |
| Queries a backend integer capability/limit. | |
| u32 | nativeTextureName (TextureHandle texture) const override |
| This generation's GL name behind a texture, for a host uploading into it. | |
| Public Member Functions inherited from esengine::GfxDevice | |
| virtual | ~GfxDevice ()=default |
| GfxDeviceStatus | deviceStatus () const |
Whether the device can be drawn to (see GfxDeviceStatus). | |
| bool | isDeviceLive () const |
| Strictly Live: recovered but still-refilling counts as false. | |
| bool | isDeviceUsable () const |
| Whether work may be submitted — the one check the guards make. | |
| u64 | deviceGeneration () const |
| Which generation of the device the live GPU objects belong to. | |
| u64 | geometryWrites () const |
| How many times a static vertex or index buffer has been written or resized since the device was made. | |
| const GfxDeviceLostInfo * | deviceLostInfo () const |
| The loss report, or null while the device is Live. | |
| const GfxDeviceIdentity & | deviceIdentity () const |
| Who this device is — available WHILE it is alive, unlike the loss report. | |
| void | notifyDeviceLost (GfxDeviceLostReason reason, std::string message={}, std::string context={}) |
| Declares the device lost from outside the backend. | |
| bool | recoverDevice () |
| Rebuilds the device and every object it issued, behind the same handles. | |
| std::vector< GfxOwedContent > | owedContent () const |
| Sourced objects that have storage again and are waiting for their contents. | |
| void | forgoContent (const GfxOwedContent &owed) |
| Gives up on one owed object's contents: it keeps its placeholder. | |
| void | restoreContent (const GfxOwedContent &owed) |
| Settles one owed object whose provider wrote its contents itself. | |
| usize | retainedBytes () const |
| CPU bytes the device holds to put content back after a loss. | |
| u32 | takeDraws () |
| Every draw the GPU was asked for since the last call, and the tally started again. | |
| void | setRetainedBudget (usize bytes) |
| Warns once when retainedBytes() grows past bytes; 0 never warns. | |
| void | markDeviceDead () |
| Gives up on the device: no further recovery will be attempted. | |
| virtual bool | provideReplacementDevice (void *nativeDevice) |
| Takes a replacement device from the host, for backends that cannot make their own. | |
| bool | beginDeviceFrame () |
| Opens a frame: polls for loss, and numbers the frame a report is stamped with. | |
| void | setDeviceLostHandler (std::function< void(const GfxDeviceLostInfo &)> handler) |
| Called once per loss, with the completed report. | |
| const Viewport & | viewport () const |
| BufferHandle | createBuffer (const BufferDesc &desc, GfxContent content, const void *initialData) |
| Creates a buffer with fixed capacity and optional initial contents. | |
| void | deleteBuffer (BufferHandle buffer) |
| Deletes a buffer. | |
| void | updateBuffer (BufferHandle buffer, u32 offsetBytes, const void *data, u32 sizeBytes) |
| Updates a sub-range of a buffer; must fit within its capacity. | |
| void | resizeBuffer (BufferHandle buffer, u32 sizeBytes, const void *data) |
| Re-specifies a buffer's store with a new capacity, discarding prior contents. | |
| const BufferDesc * | bufferDesc (BufferHandle buffer) const |
| A buffer's description as it stands, or null for a handle that names none. | |
| void | setUniformBuffer (u32 slot, BufferHandle buffer, u32 offsetBytes=0, u32 sizeBytes=0) |
| Binds a buffer to a uniform binding slot (the block index shaders are linked to). | |
| VertexLayoutHandle | createVertexLayout (const VertexLayoutDesc &desc) |
| Registers an immutable vertex layout; pipelines reference it by handle. | |
| void | deleteVertexLayout (VertexLayoutHandle layout) |
| Deletes a vertex layout (no pipeline may reference it afterwards). | |
| const VertexLayoutDesc * | vertexLayoutDesc (VertexLayoutHandle layout) const |
| A layout's description, or null for a handle that names none. | |
| TextureHandle | createTexture (const TextureDesc &desc, GfxContent content, const void *pixels) |
| Creates a 2D texture; uploads pixels (tightly packed, desc-sized) when non-null. | |
| TextureHandle | createCompressedTexture (const TextureDesc &desc, GfxContent content, GfxCompressedFormat format, const void *data, u32 byteLength, u32 mipLevels) |
| Creates a texture from pre-compressed GPU block data. | |
| bool | restoreCompressedTexture (TextureHandle texture, GfxCompressedFormat format, const void *data, u32 byteLength, u32 mipLevels) |
| Puts compressed contents back behind an owed texture's handle. | |
| TextureHandle | importExternalTexture (u32 nativeId, const TextureDesc &desc, GfxContent content) |
| Adopts a texture a host created with the device's own API (a JS-side WebGL upload). | |
| bool | restoreTextureFromNative (TextureHandle texture, u32 nativeId) |
Replaces the native texture behind texture with one the host created again. | |
| bool | adoptTextureContent (TextureHandle into, TextureHandle from) |
Moves from's storage and description behind into, and ends from. | |
| void | deleteTexture (TextureHandle texture) |
| Deletes a texture. | |
| void | updateTexture (TextureHandle texture, i32 x, i32 y, u32 width, u32 height, const void *pixels, bool flipY) |
| Uploads pixels to a sub-rectangle of a texture (transfer format from its desc). | |
| void | setTextureParams (TextureHandle texture, TextureFilter min, TextureFilter mag, TextureWrap wrapS, TextureWrap wrapT) |
| Sets texture filtering and wrap parameters. | |
| void | generateMipmaps (TextureHandle texture) |
| Generates mipmaps for a texture. | |
| u64 | textureRevision (TextureHandle texture) const |
| A texture's description as it stands, or null for a handle that names none. | |
| u64 | trackedTextureRevision (TextureHandle texture) const |
| Zero for content that can change without an upload, including render targets and host textures. | |
| u64 | textureShapes () const |
| Counts every texture made, deleted, or given new storage under its handle (a restore, an adopt): what changes the size a handle answers, never what its pixels hold. | |
| const TextureDesc * | textureDesc (TextureHandle texture) const |
| virtual void | setSurfaceSamples (u32 samples) |
| Asks for the backbuffer to be drawn with this many samples. | |
| ShaderHandle | createProgram (const GfxShaderSource &source, const GfxAttribBinding *bindings, u32 bindingCount, std::string *outLog, GfxShaderStage *outFailedStage) |
| Compiles and links a GPU program from GLSL sources. | |
| void | onProgramLinked (ShaderHandle program, std::function< void()> callback) |
Runs callback when program has linked, once: now if it already has, at the first thing that needs it otherwise. | |
| bool | finishProgram (ShaderHandle program) |
Waits for program to link if it has not yet. False when it failed to. | |
| bool | programReady (ShaderHandle program) |
Whether program can be drawn with now, without waiting: linked, or finished linking in the background (and then finished here, which is quick). False while it is still compiling, and for one that failed. Always true for a program that was not deferred. | |
| u32 | pendingProgramCount () |
| How many programs made with deferLink are still compiling. | |
| std::string | pendingProgramLabels () |
| What each program still compiling in the background is, one line each: what a "compiling shaders" readout names. | |
| void | setSkipPendingPrograms (bool on) |
| Whether a draw whose program is not ready is left out, instead of waited for. | |
| bool | skipPendingPrograms () const |
| void | deleteProgram (ShaderHandle program) |
| Deletes a shader program. | |
| virtual bool | supportsCompute () const |
| Whether this device runs compute shaders. | |
| virtual bool | supportsAsyncCompute () const |
| Hardware with an independent queue. Individual bindings can still require the graphics queue. | |
| void | setAsyncComputeEnabled (bool enabled) |
| bool | asyncComputeEnabled () const |
| bool | beginAsyncComputeJob (AsyncComputePriority priority=AsyncComputePriority::Default) |
| Opens a compute-only scope, including on single-queue devices. Scopes cannot nest. | |
| AsyncComputeFence | endAsyncComputeJob () |
| A fence for submitted work, or -1 when it is already ordered on the graphics queue. | |
| void | graphicsWaitOnAsyncComputeJob (AsyncComputeFence fence) |
| void | manualComputeBarrier () |
| Order dispatches across queues. Each inline dispatch is already a complete compute pass. | |
| ComputeHandle | createCompute (const GfxComputeSource &source, std::string *outLog=nullptr) |
| Compiles a compute program. | |
| void | deleteCompute (ComputeHandle program) |
| Deletes a compute program. | |
| bool | dispatchCompute (ComputeHandle program, const GfxComputeBinding *bindings, u32 bindingCount, u32 groupsX, u32 groupsY=1, u32 groupsZ=1) |
Runs program over groupsX x groupsY x groupsZ workgroups, with these resources bound. | |
| virtual ReadbackHandle | requestBufferReadback (BufferHandle buffer, u32 offsetBytes, u32 sizeBytes) |
| Copies bytes of a storage buffer out, to be taken with pollReadback / takeReadback. | |
| virtual ReadbackHandle | requestTextureReadback (TextureHandle texture) |
| Copies a storage texture's pixels out, tightly packed in the texture's own format (rows top-down). | |
| void | useProgram (ShaderHandle program) |
| Binds a program directly, for setup-time uniform seeding. | |
| i32 | getUniformLocation (ShaderHandle program, const char *name) |
| Gets a uniform location by name, -1 when the linked program has none. | |
| i32 | getAttribLocation (ShaderHandle program, const char *name) |
| Gets a vertex attribute location by name (-1 if not found). | |
| u32 | boundSamplerUnits () |
| The texture units the bound program samples, one bit a unit; every unit where the backend cannot say. | |
| void | setUniform1i (i32 location, i32 value) |
| Sets an integer uniform of the bound program. | |
| void | setUniform1f (i32 location, f32 value) |
| Sets a float uniform. | |
| void | setUniform2f (i32 location, f32 x, f32 y) |
| Sets a vec2 uniform. | |
| void | setUniform3f (i32 location, f32 x, f32 y, f32 z) |
| Sets a vec3 uniform. | |
| void | setUniform4f (i32 location, f32 x, f32 y, f32 z, f32 w) |
| Sets a vec4 uniform. | |
| void | setUniformMat3 (i32 location, const f32 *data) |
| Sets a mat3 uniform. | |
| void | setUniformMat4 (i32 location, const f32 *data) |
| Sets a mat4 uniform. | |
| std::vector< GfxUniformInfo > | getActiveUniforms (ShaderHandle program) |
| Enumerates all active uniforms of a linked shader program. | |
| u32 | getUniformBlockIndex (ShaderHandle program, const char *name) |
| Returns a program's uniform-block index by name, or GFX_INVALID_UNIFORM_BLOCK if absent. | |
| void | uniformBlockBinding (ShaderHandle program, u32 blockIndex, u32 bindingPoint) |
| Links a program's uniform block to an indexed binding slot. | |
| PipelineHandle | createPipeline (const PipelineDesc &desc) |
| Resolves a pipeline description to a cached handle (creating it on first use). | |
| const PipelineDesc * | pipelineDesc (PipelineHandle handle) const |
| A pipeline's description, or null for a handle that names none. | |
| void | setPipeline (PipelineHandle handle) |
| Binds a pipeline: applies its program, blend, depth, stencil compare/op and culling. | |
| void | invalidatePipelineCache () |
| Forces the next setPipeline to re-apply, dropping the cached current pipeline. | |
| FramebufferHandle | createFramebuffer (const FramebufferDesc &desc) |
| Creates a framebuffer from its attachments and validates completeness. | |
| void | deleteFramebuffer (FramebufferHandle framebuffer) |
| Deletes a framebuffer (its attachment textures are owned by the caller). | |
| const FramebufferDesc * | framebufferDesc (FramebufferHandle framebuffer) const |
| A framebuffer's description, or null for Default and unknown handles. | |
| virtual void | resizeBackbuffer (u32 width, u32 height) |
| Resizes the default backbuffer to the viewport size. | |
| virtual bool | frameCaptureIsBGRA () const |
| Whether a captured frame's bytes are BGRA rather than RGBA — the surface's choice on a backend that has one, and never GL's. | |
| u32 | createTimerQuery () |
| Creates a GPU elapsed-time query, or 0 when the backend cannot time GPU work. | |
| virtual bool | timesPassesByArming () const |
| True when a pass is timed by arming it, not by bracketing it with begin/endTimerQuery. | |
| virtual void | armPassTimer (u32 query) |
Times the next render or compute pass into query (0 disarms), read back with getTimerQueryNs. | |
| GfxLiveObjects | liveObjects () const |
GPU objects alive right now (see GfxLiveObjects), read off the registry. | |
| virtual u64 | estimatedGpuBytes () const |
Protected Member Functions | |
| void | captureDeviceIdentity () override |
| Records who this backend is, so a later loss report can name it. | |
| bool | recreateDevice () override |
Backend half of recoverDevice: a working device again, with every id-to-native map and derived cache emptied. | |
| void | onDeviceLost () override |
| Release what only this backend can name, while the dead device is still the current one. | |
| bool | backendCreateBuffer (u32 id, const BufferDesc &desc, const void *data) override |
| void | backendDeleteBuffer (u32 id) override |
| void | backendUpdateBuffer (u32 id, u32 offsetBytes, const void *data, u32 sizeBytes) override |
| void | backendResizeBuffer (u32 id, const BufferDesc &desc, const void *data) override |
| void | backendSetUniformBuffer (u32 slot, BufferHandle buffer, u32 offsetBytes, u32 sizeBytes) override |
| bool | backendCreateTexture (u32 id, const TextureDesc &desc, const void *pixels) override |
| bool | backendCreateCompressedTexture (u32 id, const TextureDesc &desc, GfxCompressedFormat format, const void *data, u32 byteLength, u32 mipLevels) 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 | backendDeleteTexture (u32 id) override |
| void | backendMoveTexture (u32 into, u32 from) override |
Re-keys from's native texture under into; into holds none on entry. | |
| void | backendUpdateTexture (u32 id, i32 x, i32 y, u32 width, u32 height, const void *pixels, bool flipY) override |
| void | backendSetTextureParams (u32 id, const TextureDesc &desc) override |
| void | backendGenerateMipmaps (u32 id) override |
| bool | backendCreateProgram (u32 id, const GfxShaderSource &source, const GfxAttribBinding *bindings, u32 bindingCount, std::string *outLog, GfxShaderStage *outFailedStage) override |
| void | backendDeleteProgram (u32 id) override |
| void | backendUseProgram (u32 id) override |
| i32 | backendUniformLocation (u32 program, const char *name) override |
| The backend's own location this generation, -1 when absent. | |
| i32 | backendAttribLocation (u32 program, const char *name) override |
| void | backendSetUniform (i32 nativeLocation, const GfxUniformValue &value) override |
| u32 | backendBoundSamplerUnits () override |
| void | backendIntUniformSet (u32 program) override |
| std::vector< GfxUniformInfo > | backendActiveUniforms (u32 program) override |
| u32 | backendUniformBlockIndex (u32 program, const char *name) override |
| void | backendUniformBlockBinding (u32 program, u32 nativeBlockIndex, u32 bindingPoint) override |
| void | backendDeleteVertexLayout (u32 id) override |
| Drops what the backend derived from a layout (a GL VAO); the desc stays here. | |
| void | backendSetPipeline (u32 id, const PipelineDesc &desc) override |
| u32 | primitiveMode () const |
| void | backendInvalidatePipelineCache () override |
| bool | supportsDeferredLink () const override |
| Whether createProgram honours GfxShaderSource::deferLink (GL: yes; a backend that links at once does not). | |
| bool | backendProgramPending (u32 id) const override |
| True while a program created with deferLink has not been waited for. | |
| bool | backendFinishProgram (u32 id) override |
| Waits for a deferred program, runs its onLinked callback; false when it failed to link. True for a program that was not deferred. | |
| void | endFrame () override |
| The frame is over — everything drawn for it has been submitted. | |
| bool | framePending () override |
| Whether the GPU is still working on the frame last ended (see endFrame). | |
| bool | backendProgramReady (u32 id) override |
| u32 | backendPendingProgramCount () override |
| std::string | backendPendingProgramLabels () override |
| bool | backendCreateFramebuffer (u32 id, const FramebufferDesc &desc) override |
| void | backendDeleteFramebuffer (u32 id) override |
| bool | backendCreateTimerQuery (u32 id) override |
| u32 | backendReadbackCount () const override |
| Readbacks in flight, the one live object the registry does not hold. | |
| Protected Member Functions inherited from esengine::GfxDevice | |
| void | countDraw () |
| A backend has issued one draw (see takeDraws). | |
| virtual bool | backendCreateCompute (u32 id, const GfxComputeSource &source, std::string *outLog) |
| bool | computeJobOpen () const |
| const GfxResourceRegistry & | resourceRecords () const |
| virtual void | backendSetAsyncComputeEnabled (bool) |
| virtual bool | backendComputeScopeAvailable () const |
| virtual bool | backendDispatchAsyncCompute (AsyncComputePriority, u32, const GfxComputeBinding *, u32, u32, u32, u32) |
| virtual void | backendWaitAsyncCompute () |
| virtual void | backendDeleteCompute (u32 id) |
| virtual bool | backendDispatchCompute (u32 id, const GfxComputeBinding *bindings, u32 bindingCount, u32 groupsX, u32 groupsY, u32 groupsZ) |
| void | notifyProgramLinked (u32 id) |
| For a backend finishing a deferred program: runs its onLinked callback, leaving the bound program as it was. | |
| virtual bool | backendAcceptsVertexLayout (const VertexLayoutDesc &desc) |
| False for a layout this backend has no way to express. | |
| PipelineHandle | currentPipeline () const |
| The pipeline most recently bound, whose program uniforms are set on. | |
| void | setDeviceIdentity (std::string backend, std::string vendor, std::string renderer, std::string version) |
Records the backend identity; see captureDeviceIdentity. | |
| bool | markDeviceLost (GfxDeviceLostReason reason, std::string message={}, std::string context={}) |
| The single transition into Lost. Backends call this on detection. | |
Additional Inherited Members | |
| Protected Attributes inherited from esengine::GfxDevice | |
| Viewport | viewport_ |
| Backends record what they were last handed; see viewport. | |
OpenGL ES 3.0 / WebGL 2.0 implementation of GfxDevice.
Definition at line 40 of file GLDevice.hpp.
|
default |
|
overridedefault |
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1041 of file GLDevice.cpp.
References esengine::GfxUniformInfo::arraySize, esengine::gfx::kLoopFloorUniform, esengine::GfxUniformInfo::location, esengine::GfxUniformInfo::name, and esengine::GfxUniformInfo::type.
|
overrideprotectedvirtual |
Takes over a native texture the host created; false when this backend cannot.
Implements esengine::GfxDevice.
Definition at line 1631 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 939 of file GLDevice.cpp.
|
overrideprotectedvirtual |
The units the bound program samples; a backend that cannot say answers every unit.
Reimplemented from esengine::GfxDevice.
Definition at line 977 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1119 of file GLDevice.cpp.
References esengine::BufferDesc::size.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1594 of file GLDevice.cpp.
References esengine::GfxBlockInfo::blockHeight, esengine::GfxBlockInfo::blockWidth, esengine::GfxBlockInfo::bytesPerBlock, esengine::gfxCompressedBlockInfo(), esengine::TextureDesc::height, esengine::TextureDesc::magFilter, esengine::TextureDesc::minFilter, esengine::TextureDesc::width, esengine::TextureDesc::wrapS, and esengine::TextureDesc::wrapT.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1719 of file GLDevice.cpp.
References esengine::FramebufferDesc::color0, esengine::FramebufferDesc::color1, esengine::FramebufferDesc::color2, esengine::DepthComponent24, esengine::FramebufferDesc::depthStencil, ES_LOG_ERROR, esengine::TextureDesc::format, GL_DEPTH_STENCIL_ATTACHMENT, esengine::FramebufferDesc::height, esengine::Invalid, esengine::FramebufferDesc::resolveColor0, esengine::FramebufferDesc::resolveColor1, esengine::FramebufferDesc::resolveColor2, esengine::FramebufferDesc::resolveDepthStencil, esengine::GfxDevice::textureDesc(), and esengine::FramebufferDesc::width.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 739 of file GLDevice.cpp.
References esengine::GfxShaderSource::deferLink, ES_LOG_ERROR, ES_LOG_WARN, esengine::gfx::floorConstantLoops(), esengine::Fragment, esengine::GfxShaderSource::fragmentSrc, esengine::GLSL_ES300, esengine::GfxShaderSource::language, esengine::Link, esengine::None, esengine::Vertex, and esengine::GfxShaderSource::vertexSrc.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1519 of file GLDevice.cpp.
References esengine::TextureDesc::flipY, esengine::TextureDesc::format, GL_UNPACK_FLIP_Y_WEBGL, esengine::TextureDesc::height, esengine::TextureDesc::layers, esengine::TextureDesc::magFilter, esengine::TextureDesc::minFilter, esengine::TextureDesc::mipmaps, esengine::TextureDesc::samples, esengine::TextureDesc::volume, esengine::TextureDesc::width, esengine::TextureDesc::wrapS, and esengine::TextureDesc::wrapT.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 2128 of file GLDevice.cpp.
References esengine::ctx().
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1132 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1884 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 913 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1637 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Drops what the backend derived from a layout (a GL VAO); the desc stays here.
Implements esengine::GfxDevice.
Definition at line 1180 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Waits for a deferred program, runs its onLinked callback; false when it failed to link. True for a program that was not deferred.
Reimplemented from esengine::GfxDevice.
Definition at line 836 of file GLDevice.cpp.
References ES_LOG_ERROR, ES_LOG_WARN, and esengine::GfxDevice::notifyProgramLinked().
Referenced by backendProgramReady().
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1681 of file GLDevice.cpp.
References esengine::GfxDevice::textureDesc().
|
overrideprotectedvirtual |
An integer uniform of program was set: a sampler may have moved to another unit.
Reimplemented from esengine::GfxDevice.
Definition at line 1010 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1408 of file GLDevice.cpp.
References esengine::Off.
Re-keys from's native texture under into; into holds none on entry.
Implements esengine::GfxDevice.
Definition at line 1651 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Reimplemented from esengine::GfxDevice.
Definition at line 871 of file GLDevice.cpp.
References backendProgramReady().
|
overrideprotectedvirtual |
Reimplemented from esengine::GfxDevice.
Definition at line 884 of file GLDevice.cpp.
|
inlineoverrideprotectedvirtual |
True while a program created with deferLink has not been waited for.
Reimplemented from esengine::GfxDevice.
Definition at line 152 of file GLDevice.hpp.
|
overrideprotectedvirtual |
Reimplemented from esengine::GfxDevice.
Definition at line 893 of file GLDevice.cpp.
References backendFinishProgram(), and esengine::ctx().
Referenced by backendPendingProgramCount().
|
inlineoverrideprotectedvirtual |
Readbacks in flight, the one live object the registry does not hold.
Implements esengine::GfxDevice.
Definition at line 164 of file GLDevice.hpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1149 of file GLDevice.cpp.
References esengine::BufferDesc::size.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1337 of file GLDevice.cpp.
References esengine::PipelineDesc::albedo, esengine::PipelineDesc::alphaToCoverage, backendUseProgram(), esengine::PipelineDesc::blend, esengine::PipelineDesc::blendEnabled, esengine::PipelineDesc::colorWrite, esengine::PipelineDesc::cullEnabled, esengine::PipelineDesc::cullFront, esengine::PipelineDesc::depthBias, esengine::PipelineDesc::depthEqual, esengine::PipelineDesc::depthTest, esengine::PipelineDesc::depthWrite, esengine::PipelineDesc::gbuffer, esengine::PipelineDesc::layerAlpha, esengine::PipelineDesc::program, esengine::PipelineDesc::stencil, esengine::PipelineDesc::topology, and esengine::PipelineDesc::vertexLayout.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1670 of file GLDevice.cpp.
References esengine::TextureDesc::magFilter, esengine::TextureDesc::mipmaps, esengine::TextureDesc::wrapS, and esengine::TextureDesc::wrapT.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 944 of file GLDevice.cpp.
References esengine::GfxUniformValue::f, esengine::GfxUniformValue::Float, esengine::GfxUniformValue::i, esengine::GfxUniformValue::Int, esengine::GfxUniformValue::Mat3, esengine::GfxUniformValue::Mat4, esengine::GfxUniformValue::None, esengine::GfxUniformValue::type, esengine::GfxUniformValue::Vec2, esengine::GfxUniformValue::Vec3, and esengine::GfxUniformValue::Vec4.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1153 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1089 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1083 of file GLDevice.cpp.
References esengine::GFX_INVALID_UNIFORM_BLOCK.
|
overrideprotectedvirtual |
The backend's own location this generation, -1 when absent.
Implements esengine::GfxDevice.
Definition at line 934 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1145 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 1656 of file GLDevice.cpp.
References esengine::TextureDesc::format, GL_UNPACK_FLIP_Y_WEBGL, esengine::RGBA8, and esengine::GfxDevice::textureDesc().
|
overrideprotectedvirtual |
Implements esengine::GfxDevice.
Definition at line 927 of file GLDevice.cpp.
Referenced by backendSetPipeline().
|
overridevirtual |
Targets a framebuffer for subsequent draws and applies the pass's clears.
Beginning a pass while another is open retargets directly (the GL model has no explicit pass object); endRenderPass returns to the backbuffer. A WebGPU backend maps this to real pass boundaries.
Implements esengine::GfxDevice.
Definition at line 1899 of file GLDevice.cpp.
References esengine::RenderPassDesc::clearColor, esengine::RenderPassDesc::clearColorValue, esengine::RenderPassDesc::clearDepth, esengine::RenderPassDesc::clearH, esengine::RenderPassDesc::clearStencil, esengine::RenderPassDesc::clearStencilValue, esengine::RenderPassDesc::clearW, esengine::RenderPassDesc::clearX, esengine::RenderPassDesc::clearY, esengine::FramebufferDesc::color1, esengine::FramebufferDesc::color2, esengine::RenderPassDesc::discardDepth, esengine::RenderPassDesc::discardMultisampled, esengine::GfxDevice::framebufferDesc(), esengine::Invalid, setScissor(), setScissorTest(), and esengine::RenderPassDesc::target.
|
overridevirtual |
Starts timing GPU work into a query; one query may be active at a time.
The same span on every backend: the GPU's time for everything issued until endTimerQuery, every pass included. A render pass still open at the end belongs to the span up to where the pass ends.
Implements esengine::GfxDevice.
Definition at line 2148 of file GLDevice.cpp.
References GL_TIME_ELAPSED_EXT.
|
overridevirtual |
Activates a texture slot and binds a 2D texture.
Implements esengine::GfxDevice.
Definition at line 1485 of file GLDevice.cpp.
|
overrideprotectedvirtual |
Records who this backend is, so a later loss report can name it.
Called from init() while the backend still answers, and again after a recovery: a rebuilt device can be a DIFFERENT GPU, and a report naming the one that is gone sends the reader hunting the wrong hardware. Implementations call setDeviceIdentity.
Reimplemented from esengine::GfxDevice.
Definition at line 342 of file GLDevice.cpp.
References getString(), esengine::Renderer, esengine::GfxDevice::setDeviceIdentity(), esengine::Vendor, and esengine::Version.
Referenced by init().
|
overridevirtual |
What is on the canvas now, read at once: a capture asks for the frame it is looking at and waits for it anyway, and a fence polled across tasks took a headless CPU rasterizer half as long again per capture as the read it replaced.
Reimplemented from esengine::GfxDevice.
Definition at line 2018 of file GLDevice.cpp.
References esengine::Invalid, esengine::GfxDevice::isDeviceUsable(), and esengine::RGBA8.
|
overridevirtual |
Mid-pass stencil reset (the one clear that isn't a pass load-op).
The mask pass wipes the stencil attachment of the CURRENT target before rebuilding mask refs — it must not restart the pass (the scene may be rendering into a post-process capture). GL clears the attachment; a WebGPU backend emulates with a stencil-write quad.
Implements esengine::GfxDevice.
Definition at line 1894 of file GLDevice.cpp.
|
inlineoverridevirtual |
The clip volume this device keeps along z.
Pure: a backend that does not state this is a backend whose projections silently mean something else, which is the bug this exists to make impossible. It is not read off deviceIdentity, whose backend name is a label rather than a capability.
Implements esengine::GfxDevice.
Definition at line 45 of file GLDevice.hpp.
References esengine::MinusOneToOne.
|
overridevirtual |
Reimplemented from esengine::GfxDevice.
Definition at line 2063 of file GLDevice.cpp.
References esengine::TextureDesc::height, esengine::GfxDevice::isDeviceUsable(), esengine::TextureDesc::layered(), esengine::TextureDesc::samples, esengine::GfxDevice::textureDesc(), and esengine::TextureDesc::width.
|
overridevirtual |
Abandons a readback (any state); its resources are released.
Implements esengine::GfxDevice.
Definition at line 2110 of file GLDevice.cpp.
References esengine::GfxDevice::isDeviceUsable().
Draws non-indexed triangles.
Implements esengine::GfxDevice.
Definition at line 1432 of file GLDevice.cpp.
References esengine::GfxDevice::countDraw(), esengine::GfxDevice::isDeviceUsable(), and primitiveMode().
|
overridevirtual |
Draws indexed triangles.
Implements esengine::GfxDevice.
Definition at line 1424 of file GLDevice.cpp.
References esengine::GfxDevice::countDraw(), esengine::GfxDevice::isDeviceUsable(), and primitiveMode().
|
overridevirtual |
Draws indexed triangles with instancing.
Implements esengine::GfxDevice.
Definition at line 1465 of file GLDevice.cpp.
References esengine::GfxDevice::countDraw(), esengine::GfxDevice::isDeviceUsable(), and primitiveMode().
|
overridevirtual |
drawCount indexed instanced draws through the bound pipeline and buffers, as one call where supportsMultiDraw().
Draw k reads counts[k] indices from byteOffsets[k], instanceCounts[k] times, and its vertex stage sees gl_DrawID = k. Elsewhere it is the draws one after another, which is the same picture only for a program that does not read gl_DrawID; the draw list asks for runs only where the device has said it draws them.
Reimplemented from esengine::GfxDevice.
Definition at line 1439 of file GLDevice.cpp.
References esengine::GfxDevice::countDraw(), esengine::GfxDevice::drawElementsInstancedMulti(), esengine::GfxDevice::isDeviceUsable(), and primitiveMode().
|
overrideprotectedvirtual |
The frame is over — everything drawn for it has been submitted.
A backend that borrows the swapchain image for the duration of a frame gives it back here (WebGPU hands one out per frame and takes it back at present), which is why the boundary has to be stated rather than inferred from the last pass: a frame may open several passes on the swapchain — a post-process blit over the captured scene, a second camera — and each of those is NOT the end. Default: nothing to do (GL presents through the platform).
Reimplemented from esengine::GfxDevice.
Definition at line 1856 of file GLDevice.cpp.
References esengine::GfxDevice::isDeviceUsable().
|
overridevirtual |
Ends the current pass, restoring the default framebuffer.
Implements esengine::GfxDevice.
Definition at line 1995 of file GLDevice.cpp.
|
overridevirtual |
Stops the active timer query.
Implements esengine::GfxDevice.
Definition at line 2152 of file GLDevice.cpp.
References GL_TIME_ELAPSED_EXT.
|
overrideprotectedvirtual |
Whether the GPU is still working on the frame last ended (see endFrame).
A frame loop that asks before starting the next keeps one frame in flight, so what is drawn shows input at most a frame late; a browser left to itself queues two or three behind a GPU-bound frame, and a camera let go of goes on moving for those frames. Asks without waiting. Default: never (a device that cannot tell).
Reimplemented from esengine::GfxDevice.
Definition at line 1845 of file GLDevice.cpp.
References esengine::GfxDevice::isDeviceUsable().
|
overridevirtual |
Queries the last error.
Implements esengine::GfxDevice.
Definition at line 2187 of file GLDevice.cpp.
References esengine::ContextLost, GL_CONTEXT_LOST, GL_CONTEXT_LOST_WEBGL, and esengine::GfxDevice::markDeviceLost().
|
overridevirtual |
Queries a backend integer capability/limit.
Implements esengine::GfxDevice.
Definition at line 2211 of file GLDevice.cpp.
References esengine::MaxTextureImageUnits, esengine::MaxTextureSize, and esengine::MaxVertexAttribs.
|
overridevirtual |
Queries a backend identification string (diagnostics).
Implements esengine::GfxDevice.
Definition at line 2199 of file GLDevice.cpp.
References esengine::Renderer, esengine::ShadingLanguageVersion, esengine::Vendor, and esengine::Version.
Referenced by captureDeviceIdentity().
Fetches a completed query's elapsed nanoseconds; false while still pending.
Implements esengine::GfxDevice.
Definition at line 2166 of file GLDevice.cpp.
|
overridevirtual |
Initializes the graphics device.
Implements esengine::GfxDevice.
Definition at line 318 of file GLDevice.cpp.
References captureDeviceIdentity(), esengine::ctx(), ES_LOG_DEBUG, and esengine::glslMultiDraw().
Referenced by recreateDevice().
|
overridevirtual |
Most samples an offscreen colour attachment may carry; 1 = none.
The engine owns its own multisampling: a target the scene draws into is created with this many samples and resolves itself. Ask before requesting samples — a backend answering 1 has no MSAA to give, and a target that asks anyway would resolve from nothing.
Implements esengine::GfxDevice.
Definition at line 2006 of file GLDevice.cpp.
|
inlineoverridevirtual |
This generation's GL name behind a texture, for a host uploading into it.
Reimplemented from esengine::GfxDevice.
Definition at line 107 of file GLDevice.hpp.
|
overrideprotectedvirtual |
Release what only this backend can name, while the dead device is still the current one.
The window matters: on a lost device these releases are silent no-ops, whereas after the rebuild the same calls hand a NEW device objects belonging to the old one.
Reimplemented from esengine::GfxDevice.
Definition at line 371 of file GLDevice.cpp.
References esengine::ctx().
|
overridevirtual |
Pumps backend-native loss detection.
Backends whose loss arrives as a callback (WebGPU) or a status query (GL robustness) surface it here. Default: the backend cannot detect loss itself and depends entirely on notifyDeviceLost.
Reimplemented from esengine::GfxDevice.
Definition at line 499 of file GLDevice.cpp.
References esengine::ContextLost, esengine::ctx(), esengine::GfxDevice::isDeviceUsable(), and esengine::GfxDevice::markDeviceLost().
|
overridevirtual |
The state of an in-flight readback; pumps backend completion events. A Failed readback is released by the poll that reported it.
Implements esengine::GfxDevice.
Definition at line 2075 of file GLDevice.cpp.
References esengine::Failed, esengine::GfxDevice::isDeviceUsable(), esengine::Pending, and esengine::Ready.
Referenced by takeReadback().
|
protected |
The GL primitive mode of the bound pipeline's topology.
The mode the bound pipeline's topology means.
Definition at line 1420 of file GLDevice.cpp.
References esengine::Lines.
Referenced by drawArrays(), drawElements(), drawElementsInstanced(), and drawElementsInstancedMulti().
|
overrideprotectedvirtual |
Backend half of recoverDevice: a working device again, with every id-to-native map and derived cache emptied.
The registry then rebuilds each object through the primitives above. Default: this backend cannot rebuild itself, so a loss is final.
Reimplemented from esengine::GfxDevice.
Definition at line 413 of file GLDevice.cpp.
References esengine::ctx(), and init().
|
overridevirtual |
Requests an RGBA8 readback of a framebuffer's color attachment.
Backend-neutral contract: GL reads synchronously (the first poll reports Ready); WebGPU records a texture→staging copy and resolves when the buffer map lands, so callers must poll across event-loop turns. Must be called OUTSIDE a render pass. Rows land bottom-up (the GL convention every capture consumer assumes). The WebGPU backend reads offscreen targets only — the surface texture is not copyable — so a Default-target request returns Invalid there.
Implements esengine::GfxDevice.
Definition at line 2032 of file GLDevice.cpp.
References esengine::Invalid, esengine::GfxDevice::isDeviceUsable(), and esengine::RGBA8.
|
inlineoverridevirtual |
A GL blit resolves depth as well as colour.
Reimplemented from esengine::GfxDevice.
Definition at line 67 of file GLDevice.hpp.
|
overridevirtual |
Binds the index buffer for subsequent indexed draws.
Implements esengine::GfxDevice.
Definition at line 1225 of file GLDevice.cpp.
Sets the scissor rectangle.
Implements esengine::GfxDevice.
Definition at line 683 of file GLDevice.cpp.
Referenced by beginRenderPass().
|
overridevirtual |
Enables or disables scissor test.
Implements esengine::GfxDevice.
Definition at line 676 of file GLDevice.cpp.
Referenced by beginRenderPass().
|
overridevirtual |
GL reads a framebuffer from the bottom up.
Implements esengine::GfxDevice.
Definition at line 1387 of file GLDevice.cpp.
References esengine::Always, esengine::Decrement, esengine::Equal, esengine::Increment, esengine::NotEqual, esengine::Off, esengine::Test, esengine::TestOutside, esengine::Write, and esengine::Zero.
|
overridevirtual |
Binds a vertex buffer to a layout slot for subsequent draws.
| offsetBytes | Byte offset of element 0 — how an instanced draw rebases its per-instance stream (GLES3 has no baseInstance). |
Implements esengine::GfxDevice.
Definition at line 1219 of file GLDevice.cpp.
References esengine::MAX_VERTEX_BUFFER_SLOTS.
Sets the rendering viewport.
Implements esengine::GfxDevice.
Definition at line 528 of file GLDevice.cpp.
References esengine::GfxDevice::viewport_.
|
overridevirtual |
Enables or disables wireframe rendering (desktop only).
Implements esengine::GfxDevice.
Definition at line 2182 of file GLDevice.cpp.
|
overridevirtual |
Shuts down the graphics device.
Implements esengine::GfxDevice.
Definition at line 487 of file GLDevice.cpp.
References ES_LOG_INFO.
|
overridevirtual |
Reports whether the backend can sample the given compressed format.
ETC2/EAC is always true on a WebGL2/GLES3 backend (core spec); ASTC and S3TC depend on driver extensions. Probe this before calling createCompressedTexture with a non-core format.
Implements esengine::GfxDevice.
Definition at line 2223 of file GLDevice.cpp.
References esengine::ASTC_4x4, esengine::ASTC_4x4_SRGB, esengine::ASTC_8x8, esengine::ETC2_RGB8, esengine::ETC2_RGBA8, esengine::ETC2_RGBA8_SRGB, esengine::S3TC_DXT1, esengine::S3TC_DXT5, and esengine::S3TC_DXT5_SRGB.
|
inlineoverrideprotectedvirtual |
Whether createProgram honours GfxShaderSource::deferLink (GL: yes; a backend that links at once does not).
Reimplemented from esengine::GfxDevice.
Definition at line 151 of file GLDevice.hpp.
|
overridevirtual |
Whether RGBA16F color attachments are renderable.
WebGL2 gates float-target rendering behind EXT_color_buffer_float (sampling half-float textures is core); WebGPU always supports it. Probe this before creating an HDR framebuffer and fall back to SRGB8_ALPHA8/RGBA8.
Implements esengine::GfxDevice.
Definition at line 2249 of file GLDevice.cpp.
|
inlineoverridevirtual |
Whether drawElementsInstancedMulti is one call here, its draws told apart by gl_DrawID (WEBGL_multi_draw).
Reimplemented from esengine::GfxDevice.
Definition at line 80 of file GLDevice.hpp.
|
inlineoverridevirtual |
Whether this backend compiles language (GL: GLSL ES 300; WebGPU: WGSL).
Implements esengine::GfxDevice.
Definition at line 69 of file GLDevice.hpp.
References esengine::GLSL_ES300.
|
inlineoverridevirtual |
Whether a blended draw can write the surface record's second attachment unblended.
The surface record is never blended: a normal averaged with the one under it is neither's. A draw that composes the scene behind itself (water, glass reading the scene's colour) is still blended into the first attachment, and owns the pixel's record all the same. WebGPU sets blend per target; WebGL2 needs OES_draw_buffers_indexed. Where this is false such a draw leaves the record as the opaque scene wrote it.
Reimplemented from esengine::GfxDevice.
Definition at line 64 of file GLDevice.hpp.
|
overridevirtual |
Copies a Ready readback's pixels (w*h*4 bytes) into dest and releases it.
destSize is short — a Pending readback stays alive. Implements esengine::GfxDevice.
Definition at line 2090 of file GLDevice.cpp.
References esengine::GfxDevice::isDeviceUsable(), pollReadback(), and esengine::Ready.
|
overridevirtual |
True when GPU timing was disturbed since the last check.
In-flight query results are then meaningless and must be discarded.
Implements esengine::GfxDevice.
Definition at line 2156 of file GLDevice.cpp.
References GL_GPU_DISJOINT_EXT.