|
Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
|
Abstract graphics device interface. More...
#include <GfxDevice.hpp>

Classes | |
| struct | Viewport |
| The viewport last set, so a pass that borrows the device can give it back. More... | |
Public Member Functions | |
| virtual | ~GfxDevice ()=default |
| virtual void | init ()=0 |
| Initializes the graphics device. | |
| virtual void | shutdown ()=0 |
| Shuts down the graphics device. | |
| 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. | |
| virtual ClipDepthRange | clipDepthRange () const =0 |
| The clip volume this device keeps along z. | |
| virtual bool | copyFramebufferColor (FramebufferHandle source, TextureHandle dst) |
| 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. | |
| virtual bool | pollDeviceLost () |
| Pumps backend-native loss detection. | |
| 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. | |
| virtual void | setViewport (i32 x, i32 y, u32 w, u32 h)=0 |
| Sets the rendering viewport. | |
| const Viewport & | viewport () const |
| virtual void | clearStencil (i32 value)=0 |
| Mid-pass stencil reset (the one clear that isn't a pass load-op). | |
| virtual void | setScissorTest (bool enabled)=0 |
| Enables or disables scissor test. | |
| virtual void | setScissor (i32 x, i32 y, i32 w, i32 h)=0 |
| Sets the scissor rectangle. | |
| 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. | |
| virtual void | setVertexBuffer (u32 slot, BufferHandle buffer, u32 offsetBytes)=0 |
| Binds a vertex buffer to a layout slot for subsequent draws. | |
| virtual void | setIndexBuffer (BufferHandle buffer)=0 |
| Binds the index buffer for subsequent indexed draws. | |
| 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 | bindTexture (u32 slot, TextureHandle texture)=0 |
| Activates a texture slot and binds a 2D texture. | |
| virtual bool | supportsCompressedFormat (GfxCompressedFormat format)=0 |
| Reports whether the backend can sample the given compressed format. | |
| virtual bool | supportsFloatTargets ()=0 |
| Whether RGBA16F color attachments are renderable. | |
| virtual bool | supportsUnblendedSurfaceTarget () const |
| Whether a blended draw can write the surface record's second attachment unblended. | |
| virtual u32 | maxSamples ()=0 |
| Most samples an offscreen colour attachment may carry; 1 = none. | |
| virtual bool | resolvesDepth () const |
| Whether this backend can resolve a multisampled DEPTH attachment. | |
| 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. | |
| virtual bool | supportsShaderLanguage (GfxShaderLanguage language) const =0 |
Whether this backend compiles language (GL: GLSL ES 300; WebGPU: WGSL). | |
| virtual bool | supportsDeferredLink () const |
| Whether createProgram honours GfxShaderSource::deferLink (GL: yes; a backend that links at once does not). | |
| 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. | |
| virtual void | setStencilReference (i32 ref)=0 |
| Sets the dynamic stencil reference for the bound pipeline's stencil mode (no-op if Off). | |
| void | invalidatePipelineCache () |
| Forces the next setPipeline to re-apply, dropping the cached current pipeline. | |
| virtual void | drawElements (u32 indexCount, GfxDataType indexType, u32 byteOffset)=0 |
| Draws indexed triangles. | |
| virtual void | drawArrays (u32 first, u32 vertexCount)=0 |
| Draws non-indexed triangles. | |
| virtual void | drawElementsInstanced (u32 indexCount, GfxDataType indexType, u32 byteOffset, u32 instanceCount)=0 |
| Draws indexed triangles with instancing. | |
| virtual bool | supportsMultiDraw () const |
| Whether drawElementsInstancedMulti is one call here, its draws told apart by gl_DrawID (WEBGL_multi_draw). | |
| virtual void | drawElementsInstancedMulti (GfxDataType indexType, const u32 *counts, const u32 *byteOffsets, const u32 *instanceCounts, u32 drawCount) |
drawCount indexed instanced draws through the bound pipeline and buffers, as one call where supportsMultiDraw(). | |
| 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 | beginRenderPass (const RenderPassDesc &desc)=0 |
| Targets a framebuffer for subsequent draws and applies the pass's clears. | |
| virtual void | endRenderPass ()=0 |
| Ends the current pass, restoring the default framebuffer. | |
| virtual void | endFrame () |
| The frame is over — everything drawn for it has been submitted. | |
| virtual bool | framePending () |
| Whether the GPU is still working on the frame last ended (see endFrame). | |
| virtual void | resizeBackbuffer (u32 width, u32 height) |
| Resizes the default backbuffer to the viewport size. | |
| virtual ReadbackHandle | requestReadback (FramebufferHandle target, u32 w, u32 h)=0 |
| Requests an RGBA8 readback of a framebuffer's color attachment. | |
| virtual GfxReadbackStatus | pollReadback (ReadbackHandle handle)=0 |
| The state of an in-flight readback; pumps backend completion events. A Failed readback is released by the poll that reported it. | |
| virtual bool | takeReadback (ReadbackHandle handle, void *dest, usize destSize)=0 |
Copies a Ready readback's pixels (w*h*4 bytes) into dest and releases it. | |
| virtual void | discardReadback (ReadbackHandle handle)=0 |
| Abandons a readback (any state); its resources are released. | |
| virtual ReadbackHandle | captureNextFrame (u32 w, u32 h) |
| Requests the next completed frame's on-screen image as a readback. | |
| 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 void | beginTimerQuery (u32 query)=0 |
| Starts timing GPU work into a query; one query may be active at a time. | |
| virtual void | endTimerQuery ()=0 |
| Stops the active timer query. | |
| virtual bool | timerDisjoint ()=0 |
| True when GPU timing was disturbed since the last check. | |
| virtual bool | getTimerQueryNs (u32 query, u64 *outNanoseconds)=0 |
| Fetches a completed query's elapsed nanoseconds; false while still pending. | |
| 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. | |
| virtual void | setWireframe (bool enabled)=0 |
| Enables or disables wireframe rendering (desktop only). | |
| virtual u32 | getError ()=0 |
| Queries the last error. | |
| virtual std::string | getString (GfxStringName name)=0 |
| Queries a backend identification string (diagnostics). | |
| virtual i32 | getInt (GfxIntParam name)=0 |
| Queries a backend integer capability/limit. | |
| GfxLiveObjects | liveObjects () const |
GPU objects alive right now (see GfxLiveObjects), read off the registry. | |
| virtual u64 | estimatedGpuBytes () const |
| virtual u32 | nativeTextureName (TextureHandle texture) const |
| The backend's own name for the object behind texture, or 0. | |
Protected Member Functions | |
| void | countDraw () |
| A backend has issued one draw (see takeDraws). | |
| virtual bool | backendCreateBuffer (u32 id, const BufferDesc &desc, const void *data)=0 |
| virtual void | backendDeleteBuffer (u32 id)=0 |
| virtual void | backendUpdateBuffer (u32 id, u32 offsetBytes, const void *data, u32 sizeBytes)=0 |
| virtual void | backendResizeBuffer (u32 id, const BufferDesc &desc, const void *data)=0 |
| virtual void | backendSetUniformBuffer (u32 slot, BufferHandle buffer, u32 offsetBytes, u32 sizeBytes)=0 |
| virtual bool | backendCreateTexture (u32 id, const TextureDesc &desc, const void *pixels)=0 |
| virtual bool | backendCreateCompressedTexture (u32 id, const TextureDesc &desc, GfxCompressedFormat format, const void *data, u32 byteLength, u32 mipLevels)=0 |
| virtual bool | backendAdoptTexture (u32 id, u32 nativeId, const TextureDesc &desc)=0 |
| Takes over a native texture the host created; false when this backend cannot. | |
| virtual void | backendDeleteTexture (u32 id)=0 |
| virtual void | backendMoveTexture (u32 into, u32 from)=0 |
Re-keys from's native texture under into; into holds none on entry. | |
| virtual void | backendUpdateTexture (u32 id, i32 x, i32 y, u32 width, u32 height, const void *pixels, bool flipY)=0 |
| virtual void | backendSetTextureParams (u32 id, const TextureDesc &desc)=0 |
| virtual void | backendGenerateMipmaps (u32 id)=0 |
| 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) |
| virtual bool | backendCreateProgram (u32 id, const GfxShaderSource &source, const GfxAttribBinding *bindings, u32 bindingCount, std::string *outLog, GfxShaderStage *outFailedStage)=0 |
| virtual void | backendDeleteProgram (u32 id)=0 |
| virtual bool | backendProgramPending (u32 id) const |
| True while a program created with deferLink has not been waited for. | |
| virtual bool | backendProgramReady (u32 id) |
| virtual u32 | backendPendingProgramCount () |
| virtual std::string | backendPendingProgramLabels () |
| virtual bool | backendFinishProgram (u32 id) |
| Waits for a deferred program, runs its onLinked callback; false when it failed to link. True for a program that was not deferred. | |
| void | notifyProgramLinked (u32 id) |
| For a backend finishing a deferred program: runs its onLinked callback, leaving the bound program as it was. | |
| virtual void | backendUseProgram (u32 id)=0 |
| virtual i32 | backendUniformLocation (u32 program, const char *name)=0 |
| The backend's own location this generation, -1 when absent. | |
| virtual i32 | backendAttribLocation (u32 program, const char *name)=0 |
| virtual void | backendSetUniform (i32 nativeLocation, const GfxUniformValue &value)=0 |
| virtual u32 | backendBoundSamplerUnits () |
| virtual void | backendIntUniformSet (u32 program) |
| virtual std::vector< GfxUniformInfo > | backendActiveUniforms (u32 program)=0 |
| virtual u32 | backendUniformBlockIndex (u32 program, const char *name)=0 |
| virtual void | backendUniformBlockBinding (u32 program, u32 nativeBlockIndex, u32 bindingPoint)=0 |
| virtual bool | backendAcceptsVertexLayout (const VertexLayoutDesc &desc) |
| False for a layout this backend has no way to express. | |
| virtual void | backendDeleteVertexLayout (u32 id)=0 |
| Drops what the backend derived from a layout (a GL VAO); the desc stays here. | |
| virtual void | backendSetPipeline (u32 id, const PipelineDesc &desc)=0 |
| virtual void | backendInvalidatePipelineCache ()=0 |
| virtual bool | backendCreateFramebuffer (u32 id, const FramebufferDesc &desc)=0 |
| virtual void | backendDeleteFramebuffer (u32 id)=0 |
| virtual bool | backendCreateTimerQuery (u32 id)=0 |
| virtual u32 | backendReadbackCount () const =0 |
| Readbacks in flight, the one live object the registry does not hold. | |
| PipelineHandle | currentPipeline () const |
| The pipeline most recently bound, whose program uniforms are set on. | |
| virtual void | captureDeviceIdentity () |
| Records who this backend is, so a later loss report can name it. | |
| virtual bool | recreateDevice () |
Backend half of recoverDevice: a working device again, with every id-to-native map and derived cache emptied. | |
| 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. | |
| virtual void | onDeviceLost () |
| Release what only this backend can name, while the dead device is still the current one. | |
Protected Attributes | |
| Viewport | viewport_ |
| Backends record what they were last handed; see viewport. | |
Abstract graphics device interface.
The device owns its state: setPipeline binds an immutable pipeline and skips re-applying it when unchanged, so the renderer no longer micro-manages GL state through an external tracker. Per-draw dynamic state (scissor, stencil ref, textures) is applied directly; sorted+merged draws already group it coarsely.
Definition at line 75 of file GfxDevice.hpp.
|
virtualdefault |
| bool esengine::GfxDevice::adoptTextureContent | ( | TextureHandle | into, |
| TextureHandle | from ) |
Moves from's storage and description behind into, and ends from.
How a provider pays an owed texture: it loads the content the way it always does, into a texture of its own, and hands that over. into keeps its handle and content policy; from names nothing afterwards.
Definition at line 506 of file GfxDevice.cpp.
References backendDeleteTexture(), backendMoveTexture(), ES_LOG_ERROR, esengine::nextRevision(), and esengine::Retained.
|
inlinevirtual |
Times the next render or compute pass into query (0 disarms), read back with getTimerQueryNs.
Only where timesPassesByArming(). A pass that is split in two by the device (a mid-pass copy) is timed up to the split.
Definition at line 878 of file GfxDevice.hpp.
|
inline |
Definition at line 574 of file GfxDevice.hpp.
Referenced by esengine::WebGPUDevice::init().
|
inlineprotectedvirtual |
False for a layout this backend has no way to express.
Reimplemented in esengine::WebGPUDevice.
Definition at line 984 of file GfxDevice.hpp.
Referenced by createVertexLayout().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by getActiveUniforms().
|
protectedpure virtual |
Takes over a native texture the host created; false when this backend cannot.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by importExternalTexture(), and restoreTextureFromNative().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by getAttribLocation().
|
inlineprotectedvirtual |
The units the bound program samples; a backend that cannot say answers every unit.
Reimplemented in esengine::GLDevice.
Definition at line 976 of file GfxDevice.hpp.
Referenced by boundSamplerUnits().
|
inlineprotectedvirtual |
Definition at line 947 of file GfxDevice.hpp.
Referenced by beginAsyncComputeJob().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by createBuffer().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by createCompressedTexture(), and restoreCompressedTexture().
|
inlineprotectedvirtual |
Reimplemented in esengine::WebGPUDevice.
Definition at line 939 of file GfxDevice.hpp.
Referenced by createCompute().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by createFramebuffer().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by createProgram().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by createTexture().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by createTimerQuery().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by deleteBuffer().
|
inlineprotectedvirtual |
Reimplemented in esengine::WebGPUDevice.
Definition at line 951 of file GfxDevice.hpp.
Referenced by deleteCompute().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by deleteFramebuffer().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by deleteProgram().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by adoptTextureContent(), deleteTexture(), restoreCompressedTexture(), and restoreTextureFromNative().
|
protectedpure virtual |
Drops what the backend derived from a layout (a GL VAO); the desc stays here.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by deleteVertexLayout().
|
inlineprotectedvirtual |
Definition at line 948 of file GfxDevice.hpp.
Referenced by dispatchCompute().
|
inlineprotectedvirtual |
Reimplemented in esengine::WebGPUDevice.
Definition at line 952 of file GfxDevice.hpp.
Referenced by dispatchCompute().
|
inlineprotectedvirtual |
Waits for a deferred program, runs its onLinked callback; false when it failed to link. True for a program that was not deferred.
Reimplemented in esengine::GLDevice.
Definition at line 967 of file GfxDevice.hpp.
Referenced by finishProgram().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by generateMipmaps(), and updateTexture().
|
inlineprotectedvirtual |
An integer uniform of program was set: a sampler may have moved to another unit.
Reimplemented in esengine::GLDevice.
Definition at line 978 of file GfxDevice.hpp.
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by invalidatePipelineCache().
Re-keys from's native texture under into; into holds none on entry.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by adoptTextureContent().
|
inlineprotectedvirtual |
Reimplemented in esengine::GLDevice.
Definition at line 964 of file GfxDevice.hpp.
Referenced by pendingProgramCount().
|
inlineprotectedvirtual |
Reimplemented in esengine::GLDevice.
Definition at line 965 of file GfxDevice.hpp.
Referenced by pendingProgramLabels().
|
inlineprotectedvirtual |
True while a program created with deferLink has not been waited for.
Reimplemented in esengine::GLDevice.
Definition at line 962 of file GfxDevice.hpp.
Referenced by onProgramLinked().
|
inlineprotectedvirtual |
Reimplemented in esengine::GLDevice.
Definition at line 963 of file GfxDevice.hpp.
Referenced by programReady().
|
protectedpure virtual |
Readbacks in flight, the one live object the registry does not hold.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by liveObjects().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by resizeBuffer().
|
inlineprotectedvirtual |
Definition at line 946 of file GfxDevice.hpp.
Referenced by esengine::WebGPUDevice::init(), and setAsyncComputeEnabled().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by setPipeline().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by setTextureParams().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by setUniformBuffer().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by uniformBlockBinding().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by getUniformBlockIndex(), and uniformBlockBinding().
|
protectedpure virtual |
The backend's own location this generation, -1 when absent.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by getUniformLocation().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by updateBuffer().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by updateTexture().
|
protectedpure virtual |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by notifyProgramLinked(), and useProgram().
|
inlineprotectedvirtual |
Definition at line 950 of file GfxDevice.hpp.
Referenced by graphicsWaitOnAsyncComputeJob().
| bool esengine::GfxDevice::beginAsyncComputeJob | ( | AsyncComputePriority | priority = AsyncComputePriority::Default | ) |
Opens a compute-only scope, including on single-queue devices. Scopes cannot nest.
Definition at line 721 of file GfxDevice.cpp.
References backendComputeScopeAvailable(), isDeviceUsable(), manualComputeBarrier(), and supportsCompute().
|
inline |
Opens a frame: polls for loss, and numbers the frame a report is stamped with.
The one place the renderer asks "may I draw at all". Everything a frame does afterwards — passes, post-process, readbacks — is predicated on this having returned true, which is why it is a single question at the top rather than a check per submission.
isDeviceUsable). Definition at line 260 of file GfxDevice.hpp.
References isDeviceUsable(), and pollDeviceLost().
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::GpuTimer::begin().
|
pure virtual |
Activates a texture slot and binds a 2D texture.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::DrawList::execute().
|
inline |
The texture units the bound program samples, one bit a unit; every unit where the backend cannot say.
A unit no active sampler reads can hold anything, so a draw binds only these: what a depth program, a shadow caster or a material that leaves maps unset never reads is never bound for it.
Definition at line 647 of file GfxDevice.hpp.
References backendBoundSamplerUnits().
Referenced by esengine::DrawList::execute().
| const BufferDesc * esengine::GfxDevice::bufferDesc | ( | BufferHandle | buffer | ) | const |
A buffer's description as it stands, or null for a handle that names none.
Definition at line 350 of file GfxDevice.cpp.
|
inlineprotectedvirtual |
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 in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 1010 of file GfxDevice.hpp.
|
inlinevirtual |
Requests the next completed frame's on-screen image as a readback.
One question, whichever backend answers it: a default framebuffer is read directly, a swapchain image only inside its own frame. Poll and take it like any other readback.
Reimplemented in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 832 of file GfxDevice.hpp.
References esengine::Default, and requestReadback().
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
inlineprotected |
Definition at line 944 of file GfxDevice.hpp.
|
inlinevirtual |
Reimplemented in esengine::GLDevice.
Definition at line 154 of file GfxDevice.hpp.
|
inlineprotected |
A backend has issued one draw (see takeDraws).
Definition at line 913 of file GfxDevice.hpp.
Referenced by esengine::GLDevice::drawArrays(), esengine::GLDevice::drawElements(), esengine::GLDevice::drawElementsInstanced(), and esengine::GLDevice::drawElementsInstancedMulti().
| BufferHandle esengine::GfxDevice::createBuffer | ( | const BufferDesc & | desc, |
| GfxContent | content, | ||
| const void * | initialData ) |
Creates a buffer with fixed capacity and optional initial contents.
| content | Who restores the contents after a loss. |
| initialData | When non-null, desc.size bytes uploaded at creation. |
Definition at line 280 of file GfxDevice.cpp.
References backendCreateBuffer(), esengine::GfxBufferRecord::bytes, esengine::Dead, esengine::Invalid, isDeviceUsable(), esengine::GfxContent::kind(), esengine::Retained, and esengine::BufferDesc::size.
Referenced by esengine::TilemapRenderPlugin::collect(), esengine::IndexBuffer::create(), esengine::IndexBuffer::create(), esengine::VertexBuffer::create(), esengine::VertexBuffer::createRaw(), and esengine::PerDrawBlocks::init().
| TextureHandle esengine::GfxDevice::createCompressedTexture | ( | const TextureDesc & | desc, |
| GfxContent | content, | ||
| GfxCompressedFormat | format, | ||
| const void * | data, | ||
| u32 | byteLength, | ||
| u32 | mipLevels ) |
Creates a texture from pre-compressed GPU block data.
The caller must first confirm the backend supports format (see supportsCompressedFormat) and fall back to an uncompressed createTexture otherwise. Data is uploaded as-is; no CPU-side decode.
| data | All mipLevels concatenated, level 0 (base) first, each block- aligned (gfxCompressedPyramidBytes). Level i has size max(1, width>>i) x max(1, height>>i). |
| mipLevels | Number of mip levels present (1 = base only). |
Definition at line 431 of file GfxDevice.cpp.
References backendCreateCompressedTexture(), esengine::GfxTextureRecord::bytes, esengine::GfxTextureRecord::compressed, esengine::GfxTextureRecord::compressedFormat, esengine::Dead, esengine::Invalid, isDeviceUsable(), esengine::GfxContent::kind(), esengine::GfxTextureRecord::mipLevels, and esengine::Retained.
Referenced by esengine::Texture::createCompressed().
| ComputeHandle esengine::GfxDevice::createCompute | ( | const GfxComputeSource & | source, |
| std::string * | outLog = nullptr ) |
Compiles a compute program.
outLog saying why (no compute, wrong language, a WGSL error). Definition at line 681 of file GfxDevice.cpp.
References backendCreateCompute(), esengine::Dead, esengine::GfxComputeRecord::entry, esengine::GfxComputeSource::entry, esengine::Invalid, isDeviceUsable(), esengine::GfxComputeSource::language, esengine::GfxComputeRecord::source, esengine::GfxComputeSource::source, supportsCompute(), and esengine::WGSL.
| FramebufferHandle esengine::GfxDevice::createFramebuffer | ( | const FramebufferDesc & | desc | ) |
Creates a framebuffer from its attachments and validates completeness.
Definition at line 917 of file GfxDevice.cpp.
References backendCreateFramebuffer(), esengine::FramebufferDesc::color0, esengine::FramebufferDesc::color1, esengine::FramebufferDesc::color2, esengine::Dead, esengine::Default, esengine::FramebufferDesc::depthStencil, isDeviceUsable(), esengine::FramebufferDesc::resolveColor0, esengine::FramebufferDesc::resolveColor1, esengine::FramebufferDesc::resolveColor2, and esengine::FramebufferDesc::resolveDepthStencil.
| PipelineHandle esengine::GfxDevice::createPipeline | ( | const PipelineDesc & | desc | ) |
Resolves a pipeline description to a cached handle (creating it on first use).
Definition at line 378 of file GfxDevice.cpp.
References esengine::Dead, and esengine::Invalid.
Referenced by esengine::applyMeshPipeline(), esengine::draw_meshWithMaterial(), and esengine::DrawList::execute().
| ShaderHandle esengine::GfxDevice::createProgram | ( | const GfxShaderSource & | source, |
| const GfxAttribBinding * | bindings, | ||
| u32 | bindingCount, | ||
| std::string * | outLog, | ||
| GfxShaderStage * | outFailedStage ) |
Compiles and links a GPU program from GLSL sources.
| vertexSrc | Vertex shader GLSL source (null-terminated). |
| fragmentSrc | Fragment shader GLSL source (null-terminated). |
| bindings | Attribute location bindings applied before link (may be null if count==0). |
| bindingCount | Number of entries in bindings. |
| outLog | Optional; receives the driver info log on failure. |
| outFailedStage | Optional; receives the stage that rejected the source. |
Definition at line 624 of file GfxDevice.cpp.
References esengine::GfxProgramRecord::attribBindings, backendCreateProgram(), esengine::Dead, esengine::GfxProgramRecord::fragment, esengine::GfxShaderSource::fragmentSrc, esengine::Invalid, isDeviceUsable(), esengine::GfxProgramRecord::language, esengine::GfxShaderSource::language, esengine::GfxProgramRecord::vertex, and esengine::GfxShaderSource::vertexSrc.
| TextureHandle esengine::GfxDevice::createTexture | ( | const TextureDesc & | desc, |
| GfxContent | content, | ||
| const void * | pixels ) |
Creates a 2D texture; uploads pixels (tightly packed, desc-sized) when non-null.
Storage is allocated either way. desc.mipmaps generates mipmaps after the initial upload.
Definition at line 406 of file GfxDevice.cpp.
References backendCreateTexture(), esengine::GfxTextureRecord::bytes, esengine::Dead, esengine::GfxTextureRecord::desc, ES_LOG_ERROR, esengine::TextureDesc::flipY, esengine::TextureDesc::format, esengine::Invalid, isDeviceUsable(), esengine::GfxContent::kind(), esengine::TextureDesc::layered(), esengine::TextureDesc::mipmaps, esengine::Retained, esengine::TextureDesc::samples, esengine::TextureDesc::storage, and esengine::TextureDesc::volume.
| u32 esengine::GfxDevice::createTimerQuery | ( | ) |
Creates a GPU elapsed-time query, or 0 when the backend cannot time GPU work.
Definition at line 946 of file GfxDevice.cpp.
References backendCreateTimerQuery(), and isDeviceUsable().
Referenced by esengine::GpuTimer::begin().
| VertexLayoutHandle esengine::GfxDevice::createVertexLayout | ( | const VertexLayoutDesc & | desc | ) |
Registers an immutable vertex layout; pipelines reference it by handle.
Definition at line 359 of file GfxDevice.cpp.
References backendAcceptsVertexLayout(), esengine::Dead, and esengine::Invalid.
Referenced by esengine::CustomGeometry::init().
|
inlineprotected |
The pipeline most recently bound, whose program uniforms are set on.
Definition at line 999 of file GfxDevice.hpp.
| void esengine::GfxDevice::deleteBuffer | ( | BufferHandle | buffer | ) |
Deletes a buffer.
Definition at line 299 of file GfxDevice.cpp.
References backendDeleteBuffer().
Referenced by esengine::MeshPlugin::collect(), and esengine::TilemapRenderPlugin::collect().
| void esengine::GfxDevice::deleteCompute | ( | ComputeHandle | program | ) |
Deletes a compute program.
Definition at line 707 of file GfxDevice.cpp.
References backendDeleteCompute().
| void esengine::GfxDevice::deleteFramebuffer | ( | FramebufferHandle | framebuffer | ) |
Deletes a framebuffer (its attachment textures are owned by the caller).
Definition at line 933 of file GfxDevice.cpp.
References backendDeleteFramebuffer(), and esengine::GfxProgramRecord::realized.
| void esengine::GfxDevice::deleteProgram | ( | ShaderHandle | program | ) |
Deletes a shader program.
Definition at line 671 of file GfxDevice.cpp.
References backendDeleteProgram(), and esengine::Invalid.
| void esengine::GfxDevice::deleteTexture | ( | TextureHandle | texture | ) |
| void esengine::GfxDevice::deleteVertexLayout | ( | VertexLayoutHandle | layout | ) |
Deletes a vertex layout (no pipeline may reference it afterwards).
Definition at line 366 of file GfxDevice.cpp.
References backendDeleteVertexLayout().
|
inline |
Which generation of the device the live GPU objects belong to.
Bumped by every successful rebuild. A resource can record the generation it was realized on, so a diagnostic can say whether it truly came back — a non-zero handle only looks like it did.
Definition at line 121 of file GfxDevice.hpp.
Referenced by esengine::TilemapRenderPlugin::collect().
|
inline |
Who this device is — available WHILE it is alive, unlike the loss report.
The identity was always captured at init; it was only reachable through a report that exists after a loss, so a healthy session could not say which GPU it was running on.
Definition at line 143 of file GfxDevice.hpp.
Referenced by esengine::deviceIdentity().
|
inline |
The loss report, or null while the device is Live.
Definition at line 133 of file GfxDevice.hpp.
References esengine::Live.
Referenced by esengine::deviceLostReport().
|
inline |
Whether the device can be drawn to (see GfxDeviceStatus).
Definition at line 98 of file GfxDevice.hpp.
Referenced by esengine::deviceStatus().
|
pure virtual |
Abandons a readback (any state); its resources are released.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
| bool esengine::GfxDevice::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.
Outside a render pass. Normally ordered on the graphics queue. Inside an async job the caller waits on its fence before consuming or overwriting its resources on graphics. A storage buffer or texture is bound for write only by the bindings listed; the rest of the device's state is untouched.
Definition at line 746 of file GfxDevice.cpp.
References backendDispatchAsyncCompute(), backendDispatchCompute(), isDeviceUsable(), manualComputeBarrier(), supportsAsyncCompute(), and supportsCompute().
Draws non-indexed triangles.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::drawGeometry().
|
pure virtual |
Draws indexed triangles.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::drawGeometry(), and esengine::DrawList::execute().
|
pure virtual |
Draws indexed triangles with instancing.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by drawElementsInstancedMulti(), and esengine::DrawList::execute().
|
inlinevirtual |
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 in esengine::GLDevice.
Definition at line 725 of file GfxDevice.hpp.
References drawElementsInstanced().
Referenced by esengine::GLDevice::drawElementsInstancedMulti(), and esengine::DrawList::execute().
| AsyncComputeFence esengine::GfxDevice::endAsyncComputeJob | ( | ) |
A fence for submitted work, or -1 when it is already ordered on the graphics queue.
Definition at line 730 of file GfxDevice.cpp.
References esengine::kNoAsyncComputeFence.
|
inlinevirtual |
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 in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 772 of file GfxDevice.hpp.
|
pure virtual |
Ends the current pass, restoring the default framebuffer.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
pure virtual |
Stops the active timer query.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::GpuTimer::end().
|
virtual |
Estimated live buffer/texture storage, including target attachments. Excludes driver overhead, shader binaries and host-owned swapchain images.
Reimplemented in esengine::WebGPUDevice.
Definition at line 957 of file GfxDevice.cpp.
References esengine::gfxBytesPerPixel(), esengine::gfxCompressedBlockInfo(), and isDeviceUsable().
|
inline |
Waits for program to link if it has not yet. False when it failed to.
Definition at line 533 of file GfxDevice.hpp.
References backendFinishProgram().
| void esengine::GfxDevice::forgoContent | ( | const GfxOwedContent & | owed | ) |
Gives up on one owed object's contents: it keeps its placeholder.
For a provider that no longer exists. Logged by the caller, never silent.
Definition at line 205 of file GfxDevice.cpp.
References esengine::GfxOwedContent::Buffer, esengine::GfxOwedContent::id, and esengine::GfxOwedContent::kind.
Referenced by restoreContent().
| const FramebufferDesc * esengine::GfxDevice::framebufferDesc | ( | FramebufferHandle | framebuffer | ) | const |
A framebuffer's description, or null for Default and unknown handles.
Definition at line 941 of file GfxDevice.cpp.
Referenced by esengine::GLDevice::beginRenderPass().
|
inlinevirtual |
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.
Reimplemented in esengine::WebGPUDevice.
Definition at line 838 of file GfxDevice.hpp.
|
inlinevirtual |
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 in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 780 of file GfxDevice.hpp.
| void esengine::GfxDevice::generateMipmaps | ( | TextureHandle | texture | ) |
Generates mipmaps for a texture.
Definition at line 596 of file GfxDevice.cpp.
References backendGenerateMipmaps(), and esengine::nextRevision().
|
inline |
How many times a static vertex or index buffer has been written or resized since the device was made.
What a picture kept from an earlier frame (a shadow map drawn again only when what it holds changed) asks to know that geometry it names by handle is still the geometry it drew: a handle is never reused, but a static buffer can still be rewritten in place. Dynamic buffers (a frame's own vertex pool) are not counted.
Definition at line 130 of file GfxDevice.hpp.
| std::vector< GfxUniformInfo > esengine::GfxDevice::getActiveUniforms | ( | ShaderHandle | program | ) |
Enumerates all active uniforms of a linked shader program.
Definition at line 872 of file GfxDevice.cpp.
References backendActiveUniforms(), getUniformLocation(), esengine::GfxProgramRecord::realized, and esengine::GfxProgramRecord::uniformNames.
| i32 esengine::GfxDevice::getAttribLocation | ( | ShaderHandle | program, |
| const char * | name ) |
Gets a vertex attribute location by name (-1 if not found).
Definition at line 798 of file GfxDevice.cpp.
References backendAttribLocation(), and esengine::GfxProgramRecord::realized.
|
pure virtual |
Queries the last error.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
pure virtual |
Queries a backend integer capability/limit.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
pure virtual |
Queries a backend identification string (diagnostics).
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Fetches a completed query's elapsed nanoseconds; false while still pending.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::GpuTimer::poll().
| u32 esengine::GfxDevice::getUniformBlockIndex | ( | ShaderHandle | program, |
| const char * | name ) |
Returns a program's uniform-block index by name, or GFX_INVALID_UNIFORM_BLOCK if absent.
Definition at line 889 of file GfxDevice.cpp.
References backendUniformBlockIndex(), esengine::GfxProgramRecord::blockBindings, esengine::GfxProgramRecord::blockNames, esengine::GFX_INVALID_UNIFORM_BLOCK, esengine::GFX_UNBOUND_BLOCK, and esengine::GfxProgramRecord::realized.
| i32 esengine::GfxDevice::getUniformLocation | ( | ShaderHandle | program, |
| const char * | name ) |
Gets a uniform location by name, -1 when the linked program has none.
The location belongs to the device, not the backend: it stays valid across a relink, and the value last set through it is set again.
Definition at line 784 of file GfxDevice.cpp.
References backendUniformLocation(), esengine::GfxProgramRecord::realized, esengine::GfxProgramRecord::uniformNames, and esengine::GfxProgramRecord::uniformValues.
Referenced by getActiveUniforms().
| void esengine::GfxDevice::graphicsWaitOnAsyncComputeJob | ( | AsyncComputeFence | fence | ) |
Definition at line 736 of file GfxDevice.cpp.
References backendWaitAsyncCompute(), and esengine::kNoAsyncComputeFence.
Referenced by manualComputeBarrier().
| TextureHandle esengine::GfxDevice::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).
The device owns it from here and, after a loss, recreates storage of desc behind the same handle for the provider in content to refill.
Definition at line 475 of file GfxDevice.cpp.
References backendAdoptTexture(), esengine::Dead, ES_LOG_ERROR, esengine::Invalid, isDeviceUsable(), esengine::GfxContent::kind(), and esengine::Retained.
Referenced by esengine::Texture::createFromExternalId().
|
pure virtual |
Initializes the graphics device.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
| void esengine::GfxDevice::invalidatePipelineCache | ( | ) |
Forces the next setPipeline to re-apply, dropping the cached current pipeline.
Call at the start of a render phase (frame flush, immediate-draw begin) so a pipeline left bound by a prior phase — or by a direct-state path like custom geometry — is not mistaken for the current one.
Definition at line 397 of file GfxDevice.cpp.
References backendInvalidatePipelineCache(), and esengine::Invalid.
Referenced by esengine::applyMeshPipeline(), and esengine::draw_meshWithMaterial().
|
inline |
Strictly Live: recovered but still-refilling counts as false.
Definition at line 101 of file GfxDevice.hpp.
References esengine::Live.
|
inline |
Whether work may be submitted — the one check the guards make.
True while Recovering as well as Live. A device that has been rebuilt but whose textures are still being re-uploaded must draw: refusing would leave the screen frozen for the whole reload instead of filling in as the content lands.
Definition at line 110 of file GfxDevice.hpp.
References esengine::Live, and esengine::Recovering.
Referenced by beginAsyncComputeJob(), beginDeviceFrame(), esengine::GLDevice::captureNextFrame(), esengine::GLDevice::copyFramebufferColor(), createBuffer(), createCompressedTexture(), createCompute(), createFramebuffer(), createProgram(), createTexture(), createTimerQuery(), esengine::GLDevice::discardReadback(), dispatchCompute(), esengine::GLDevice::drawArrays(), esengine::GLDevice::drawElements(), esengine::GLDevice::drawElementsInstanced(), esengine::GLDevice::drawElementsInstancedMulti(), esengine::GLDevice::endFrame(), estimatedGpuBytes(), esengine::WebGPUDevice::estimatedGpuBytes(), esengine::GLDevice::framePending(), importExternalTexture(), esengine::GLDevice::pollDeviceLost(), esengine::GLDevice::pollReadback(), recoverDevice(), esengine::GLDevice::requestReadback(), restoreCompressedTexture(), restoreTextureFromNative(), setAsyncComputeEnabled(), esengine::GLDevice::takeReadback(), and useProgram().
| GfxLiveObjects esengine::GfxDevice::liveObjects | ( | ) | const |
GPU objects alive right now (see GfxLiveObjects), read off the registry.
Definition at line 986 of file GfxDevice.cpp.
References backendReadbackCount().
| void esengine::GfxDevice::manualComputeBarrier | ( | ) |
Order dispatches across queues. Each inline dispatch is already a complete compute pass.
Definition at line 742 of file GfxDevice.cpp.
References graphicsWaitOnAsyncComputeJob().
Referenced by beginAsyncComputeJob(), dispatchCompute(), and setAsyncComputeEnabled().
|
inline |
Gives up on the device: no further recovery will be attempted.
The clean end of a loss that could not be recovered from. The report is kept; what changes is that the renderer stops waiting.
Definition at line 222 of file GfxDevice.hpp.
References esengine::Dead, esengine::Live, markDeviceLost(), and esengine::Unknown.
|
protected |
The single transition into Lost. Backends call this on detection.
Idempotent: a lost device usually produces a burst of secondary failures, and the first reason is the one that explains them.
Definition at line 60 of file GfxDevice.cpp.
References esengine::Invalid, esengine::kNoAsyncComputeFence, esengine::Live, esengine::Lost, onDeviceLost(), and esengine::Recovering.
Referenced by esengine::GLDevice::getError(), markDeviceDead(), esengine::GLDevice::pollDeviceLost(), and esengine::WebGPUDevice::reportUncapturedError().
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
inlinevirtual |
The backend's own name for the object behind texture, or 0.
For a host that writes the contents itself — a JS video frame or canvas going straight into the texture. It is only valid until the next device loss, which is why it is asked for at every write.
Reimplemented in esengine::GLDevice.
Definition at line 909 of file GfxDevice.hpp.
|
inline |
Declares the device lost from outside the backend.
The host observes losses the backend cannot: a browser firing webglcontextlost, a shell told by the OS that the adapter is gone. Idempotent — the FIRST reason wins, because it is the one that explains the rest.
Definition at line 163 of file GfxDevice.hpp.
|
protected |
For a backend finishing a deferred program: runs its onLinked callback, leaving the bound program as it was.
Definition at line 659 of file GfxDevice.cpp.
References backendUseProgram().
Referenced by esengine::GLDevice::backendFinishProgram().
|
inlineprotectedvirtual |
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 in esengine::GLDevice.
Definition at line 1045 of file GfxDevice.hpp.
Referenced by markDeviceLost().
| void esengine::GfxDevice::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.
For what has to be done to a program only after it links. Never runs for one that fails.
Definition at line 648 of file GfxDevice.cpp.
References backendProgramPending().
|
inline |
Sourced objects that have storage again and are waiting for their contents.
Definition at line 177 of file GfxDevice.hpp.
|
inline |
How many programs made with deferLink are still compiling.
Asking finishes the ones that are done (their shader objects are freed, what was owed to them is done), so a program nothing ever draws with does not stay on the list: a loading screen waits for this to be 0.
Definition at line 546 of file GfxDevice.hpp.
References backendPendingProgramCount().
|
inline |
What each program still compiling in the background is, one line each: what a "compiling shaders" readout names.
Definition at line 548 of file GfxDevice.hpp.
References backendPendingProgramLabels().
| const PipelineDesc * esengine::GfxDevice::pipelineDesc | ( | PipelineHandle | handle | ) | const |
A pipeline's description, or null for a handle that names none.
Definition at line 383 of file GfxDevice.cpp.
|
inlinevirtual |
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 in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 250 of file GfxDevice.hpp.
Referenced by beginDeviceFrame().
|
pure virtual |
The state of an in-flight readback; pumps backend completion events. A Failed readback is released by the poll that reported it.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
inline |
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.
Definition at line 539 of file GfxDevice.hpp.
References backendProgramReady().
Referenced by esengine::MeshPlugin::collect(), esengine::draw_meshWithMaterial(), and esengine::DrawList::execute().
|
inlinevirtual |
Takes a replacement device from the host, for backends that cannot make their own.
A WebGPU device is created by the page, so only the page can replace a lost one; GL rebuilds itself and has no use for this. The next recovery attempt picks up whatever was handed over.
Reimplemented in esengine::WebGPUDevice.
Definition at line 237 of file GfxDevice.hpp.
Referenced by esengine::provideReplacementDevice().
| bool esengine::GfxDevice::recoverDevice | ( | ) |
Rebuilds the device and every object it issued, behind the same handles.
Runs once per loss. Retained content is uploaded again and Sourced content becomes owed; the device turns Live when nothing is owed.
Definition at line 89 of file GfxDevice.cpp.
References esengine::Dead, isDeviceUsable(), esengine::Live, esengine::Lost, esengine::Recovering, and recreateDevice().
Referenced by esengine::recoverDevice().
|
inlineprotectedvirtual |
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 in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 1018 of file GfxDevice.hpp.
Referenced by recoverDevice().
|
inlinevirtual |
Copies bytes of a storage buffer out, to be taken with pollReadback / takeReadback.
takeReadback hands the bytes back as they are in the buffer; size and offsetBytes are multiples of 4. Invalid on a device that does not compute.
Reimplemented in esengine::WebGPUDevice.
Definition at line 610 of file GfxDevice.hpp.
References esengine::Invalid.
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by captureNextFrame().
|
inlinevirtual |
Copies a storage texture's pixels out, tightly packed in the texture's own format (rows top-down).
Unlike requestReadback it names the texture, not a framebuffer, since a compute target has none. RGBA8, RGBA16F and RGBA32F: four, eight and sixteen bytes a texel.
Reimplemented in esengine::WebGPUDevice.
Definition at line 620 of file GfxDevice.hpp.
References esengine::Invalid.
Resizes the default backbuffer to the viewport size.
GL tracks the canvas drawing buffer implicitly (default no-op); WebGPU swapchains are fixed-size, so its backend reconfigures the surface + companion depth-stencil when the size changes. Called once per frame with the current viewport (cheap when unchanged); must not be called inside a render pass.
Reimplemented in esengine::WebGPUDevice.
Definition at line 790 of file GfxDevice.hpp.
| void esengine::GfxDevice::resizeBuffer | ( | BufferHandle | buffer, |
| u32 | sizeBytes, | ||
| const void * | data ) |
Re-specifies a buffer's store with a new capacity, discarding prior contents.
The handle stays valid (streaming growth without re-wiring vertex layouts). data may be null to allocate uninitialized storage.
Definition at line 329 of file GfxDevice.cpp.
References backendResizeBuffer(), and esengine::Retained.
|
inlinevirtual |
Whether this backend can resolve a multisampled DEPTH attachment.
GL blits one; WebGPU has no depth resolve at all, so a pass that SAMPLES scene depth cannot run multisampled there. Colour resolves on both, which is what MSAA is usually asked for.
Reimplemented in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 492 of file GfxDevice.hpp.
|
inlineprotected |
Definition at line 945 of file GfxDevice.hpp.
| bool esengine::GfxDevice::restoreCompressedTexture | ( | TextureHandle | texture, |
| GfxCompressedFormat | format, | ||
| const void * | data, | ||
| u32 | byteLength, | ||
| u32 | mipLevels ) |
Puts compressed contents back behind an owed texture's handle.
Definition at line 455 of file GfxDevice.cpp.
References backendCreateCompressedTexture(), backendDeleteTexture(), isDeviceUsable(), esengine::nextRevision(), and esengine::Retained.
| void esengine::GfxDevice::restoreContent | ( | const GfxOwedContent & | owed | ) |
Settles one owed object whose provider wrote its contents itself.
For content the device cannot upload: a JS-side path that draws a canvas or a video frame straight into the native texture behind the handle. The provider says so, because the device never saw the write.
Definition at line 218 of file GfxDevice.cpp.
References forgoContent(), esengine::GfxOwedContent::id, esengine::GfxOwedContent::kind, and esengine::GfxOwedContent::Texture.
| bool esengine::GfxDevice::restoreTextureFromNative | ( | TextureHandle | texture, |
| u32 | nativeId ) |
Replaces the native texture behind texture with one the host created again.
Definition at line 493 of file GfxDevice.cpp.
References backendAdoptTexture(), backendDeleteTexture(), isDeviceUsable(), and esengine::nextRevision().
|
inline |
CPU bytes the device holds to put content back after a loss.
Retained content, plus the initial bytes of objects created while lost until the recovery uploads them. A cost the GPU figures never show.
Definition at line 198 of file GfxDevice.hpp.
| void esengine::GfxDevice::setAsyncComputeEnabled | ( | bool | enabled | ) |
Definition at line 715 of file GfxDevice.cpp.
References backendSetAsyncComputeEnabled(), isDeviceUsable(), and manualComputeBarrier().
|
inlineprotected |
Records the backend identity; see captureDeviceIdentity.
Definition at line 1021 of file GfxDevice.hpp.
Referenced by esengine::GLDevice::captureDeviceIdentity(), and esengine::WebGPUDevice::captureDeviceIdentity().
|
inline |
Called once per loss, with the completed report.
One observer, not a list: the renderer owns the device and fans the report out to whoever else needs it.
Definition at line 271 of file GfxDevice.hpp.
|
pure virtual |
Binds the index buffer for subsequent indexed draws.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::CustomGeometry::bind(), and esengine::DrawList::execute().
| void esengine::GfxDevice::setPipeline | ( | PipelineHandle | handle | ) |
Binds a pipeline: applies its program, blend, depth, stencil compare/op and culling.
Definition at line 388 of file GfxDevice.cpp.
References backendSetPipeline(), esengine::Invalid, and esengine::PipelineDesc::program.
Referenced by esengine::applyMeshPipeline(), esengine::draw_meshWithMaterial(), and esengine::DrawList::execute().
|
inline |
Warns once when retainedBytes() grows past bytes; 0 never warns.
Falling back under it re-arms the warning.
Definition at line 212 of file GfxDevice.hpp.
Sets the scissor rectangle.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::DrawList::execute().
|
pure virtual |
Enables or disables scissor test.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::DrawList::execute().
|
inline |
Whether a draw whose program is not ready is left out, instead of waited for.
Off: the first draw to need a program waits for it, and a frame that needs one the browser has not compiled yet stops (seconds, for a heavy lit shader on a driver that compiles slowly). On: the draw is skipped until the program is ready, and the frame goes on.
Definition at line 555 of file GfxDevice.hpp.
|
pure virtual |
Sets the dynamic stencil reference for the bound pipeline's stencil mode (no-op if Off).
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::DrawList::execute().
|
inlinevirtual |
Asks for the backbuffer to be drawn with this many samples.
Only a backend whose surface is NOT antialiased by the host has anything to do here: a WebGL canvas is created antialiased, a WebGPU surface texture never is. Ignored where it is free.
Reimplemented in esengine::WebGPUDevice.
Definition at line 500 of file GfxDevice.hpp.
| void esengine::GfxDevice::setTextureParams | ( | TextureHandle | texture, |
| TextureFilter | min, | ||
| TextureFilter | mag, | ||
| TextureWrap | wrapS, | ||
| TextureWrap | wrapT ) |
Sets texture filtering and wrap parameters.
Definition at line 583 of file GfxDevice.cpp.
References backendSetTextureParams(), and esengine::nextRevision().
Sets a float uniform.
Definition at line 822 of file GfxDevice.cpp.
References esengine::GfxUniformValue::f, esengine::GfxUniformValue::Float, and esengine::GfxUniformValue::type.
Sets an integer uniform of the bound program.
Definition at line 815 of file GfxDevice.cpp.
References esengine::GfxUniformValue::i, esengine::GfxUniformValue::Int, and esengine::GfxUniformValue::type.
Sets a vec2 uniform.
Definition at line 829 of file GfxDevice.cpp.
References esengine::GfxUniformValue::f, esengine::GfxUniformValue::type, and esengine::GfxUniformValue::Vec2.
Sets a vec3 uniform.
Definition at line 837 of file GfxDevice.cpp.
References esengine::GfxUniformValue::f, esengine::GfxUniformValue::type, and esengine::GfxUniformValue::Vec3.
Sets a vec4 uniform.
Definition at line 846 of file GfxDevice.cpp.
References esengine::GfxUniformValue::f, esengine::GfxUniformValue::type, and esengine::GfxUniformValue::Vec4.
|
inline |
Binds a buffer to a uniform binding slot (the block index shaders are linked to).
sizeBytes of it from offsetBytes, a multiple of GFX_UNIFORM_OFFSET_ALIGNMENT; a size of 0 is the whole buffer.
Definition at line 346 of file GfxDevice.hpp.
References backendSetUniformBuffer().
Sets a mat3 uniform.
Definition at line 856 of file GfxDevice.cpp.
References esengine::GfxUniformValue::f, esengine::GfxUniformValue::Mat3, and esengine::GfxUniformValue::type.
Sets a mat4 uniform.
Definition at line 864 of file GfxDevice.cpp.
References esengine::GfxUniformValue::f, esengine::GfxUniformValue::Mat4, and esengine::GfxUniformValue::type.
|
pure virtual |
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). |
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::CustomGeometry::bind(), and esengine::DrawList::execute().
Sets the rendering viewport.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
pure virtual |
Enables or disables wireframe rendering (desktop only).
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
pure virtual |
Shuts down the graphics device.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
inline |
Definition at line 556 of file GfxDevice.hpp.
Referenced by esengine::MeshPlugin::collect(), esengine::draw_meshWithMaterial(), and esengine::DrawList::execute().
|
inlinevirtual |
Hardware with an independent queue. Individual bindings can still require the graphics queue.
Definition at line 572 of file GfxDevice.hpp.
Referenced by dispatchCompute().
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::rm_supportsCompressedFormat().
|
inlinevirtual |
Whether this device runs compute shaders.
WebGPU does; WebGL2 has no compute stage, so a caller asks first and keeps a fallback. The calls below are harmless on a device that does not: they refuse (Invalid, false) and draw nothing.
Reimplemented in esengine::WebGPUDevice.
Definition at line 570 of file GfxDevice.hpp.
Referenced by beginAsyncComputeJob(), createCompute(), and dispatchCompute().
|
inlinevirtual |
Whether createProgram honours GfxShaderSource::deferLink (GL: yes; a backend that links at once does not).
Reimplemented in esengine::GLDevice.
Definition at line 524 of file GfxDevice.hpp.
|
pure virtual |
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.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::RenderTarget::init().
|
inlinevirtual |
Whether drawElementsInstancedMulti is one call here, its draws told apart by gl_DrawID (WEBGL_multi_draw).
Reimplemented in esengine::GLDevice.
Definition at line 717 of file GfxDevice.hpp.
Referenced by esengine::DrawList::execute().
|
pure virtual |
Whether this backend compiles language (GL: GLSL ES 300; WebGPU: WGSL).
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
|
inlinevirtual |
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 in esengine::GLDevice, and esengine::WebGPUDevice.
Definition at line 475 of file GfxDevice.hpp.
Referenced by esengine::DrawList::execute().
|
inline |
Every draw the GPU was asked for since the last call, and the tally started again.
Counted where the backends issue them, so it holds every pass a frame has: the scene and the overlay, and the shadow maps, depth prepass, reflections, motion vectors and post-processing that the draw lists' own count leaves out. An instanced draw is one.
Definition at line 206 of file GfxDevice.hpp.
|
pure virtual |
Copies a Ready readback's pixels (w*h*4 bytes) into dest and releases it.
destSize is short — a Pending readback stays alive. Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
| const TextureDesc * esengine::GfxDevice::textureDesc | ( | TextureHandle | texture | ) | const |
Definition at line 615 of file GfxDevice.cpp.
Referenced by esengine::GLDevice::backendCreateFramebuffer(), esengine::GLDevice::backendGenerateMipmaps(), esengine::GLDevice::backendUpdateTexture(), esengine::Texture::borrow(), and esengine::GLDevice::copyFramebufferColor().
| u64 esengine::GfxDevice::textureRevision | ( | TextureHandle | texture | ) | const |
A texture's description as it stands, or null for a handle that names none.
What texture's content is, as a number that changes whenever the device is given new content or sampling for it (see GfxTextureRecord::revision); 0 for none.
Definition at line 605 of file GfxDevice.cpp.
|
inline |
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.
Definition at line 445 of file GfxDevice.hpp.
|
pure virtual |
True when GPU timing was disturbed since the last check.
In-flight query results are then meaningless and must be discarded.
Implemented in esengine::GLDevice, and esengine::WebGPUDevice.
Referenced by esengine::GpuTimer::poll().
|
inlinevirtual |
True when a pass is timed by arming it, not by bracketing it with begin/endTimerQuery.
A GL query spans whatever is issued between its two calls; a WebGPU timestamp is written by the pass that carries it, so the pass has to be named before it opens. A per-pass timer picks its calls by this.
Definition at line 871 of file GfxDevice.hpp.
| u64 esengine::GfxDevice::trackedTextureRevision | ( | TextureHandle | texture | ) | const |
Zero for content that can change without an upload, including render targets and host textures.
Definition at line 610 of file GfxDevice.cpp.
| void esengine::GfxDevice::uniformBlockBinding | ( | ShaderHandle | program, |
| u32 | blockIndex, | ||
| u32 | bindingPoint ) |
Links a program's uniform block to an indexed binding slot.
Definition at line 903 of file GfxDevice.cpp.
References backendUniformBlockBinding(), backendUniformBlockIndex(), esengine::GfxProgramRecord::blockBindings, esengine::GfxProgramRecord::blockNames, esengine::GFX_INVALID_UNIFORM_BLOCK, and esengine::GfxProgramRecord::realized.
| void esengine::GfxDevice::updateBuffer | ( | BufferHandle | buffer, |
| u32 | offsetBytes, | ||
| const void * | data, | ||
| u32 | sizeBytes ) |
Updates a sub-range of a buffer; must fit within its capacity.
Definition at line 309 of file GfxDevice.cpp.
References backendUpdateBuffer().
| void esengine::GfxDevice::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).
| flipY | Vertical flip on upload (WebGL upload state; no-op on native backends). |
Definition at line 556 of file GfxDevice.cpp.
References backendGenerateMipmaps(), backendUpdateTexture(), ES_LOG_ERROR, esengine::TextureDesc::flipY, esengine::TextureDesc::format, esengine::gfxBytesPerPixel(), esengine::TextureDesc::height, esengine::TextureDesc::mipmaps, esengine::nextRevision(), and esengine::TextureDesc::width.
| void esengine::GfxDevice::useProgram | ( | ShaderHandle | program | ) |
Binds a program directly, for setup-time uniform seeding.
Per-frame rendering binds programs through setPipeline.
Definition at line 764 of file GfxDevice.cpp.
References backendUseProgram(), and isDeviceUsable().
| const VertexLayoutDesc * esengine::GfxDevice::vertexLayoutDesc | ( | VertexLayoutHandle | layout | ) | const |
A layout's description, or null for a handle that names none.
Definition at line 373 of file GfxDevice.cpp.
|
inline |
Definition at line 289 of file GfxDevice.hpp.
References viewport_.
|
protected |
Backends record what they were last handed; see viewport.
Definition at line 1001 of file GfxDevice.hpp.
Referenced by esengine::GLDevice::setViewport(), esengine::WebGPUDevice::setViewport(), and viewport().