Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::GfxDevice Class Referenceabstract

Abstract graphics device interface. More...

#include <GfxDevice.hpp>

Inheritance diagram for esengine::GfxDevice:

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ ~GfxDevice()

virtual esengine::GfxDevice::~GfxDevice ( )
virtualdefault

Member Function Documentation

◆ adoptTextureContent()

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.

◆ armPassTimer()

virtual void esengine::GfxDevice::armPassTimer ( u32 query)
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.

◆ asyncComputeEnabled()

bool esengine::GfxDevice::asyncComputeEnabled ( ) const
inline

Definition at line 574 of file GfxDevice.hpp.

Referenced by esengine::WebGPUDevice::init().

◆ backendAcceptsVertexLayout()

virtual bool esengine::GfxDevice::backendAcceptsVertexLayout ( const VertexLayoutDesc & desc)
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().

◆ backendActiveUniforms()

virtual std::vector< GfxUniformInfo > esengine::GfxDevice::backendActiveUniforms ( u32 program)
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by getActiveUniforms().

◆ backendAdoptTexture()

virtual bool esengine::GfxDevice::backendAdoptTexture ( u32 id,
u32 nativeId,
const TextureDesc & desc )
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().

◆ backendAttribLocation()

virtual i32 esengine::GfxDevice::backendAttribLocation ( u32 program,
const char * name )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by getAttribLocation().

◆ backendBoundSamplerUnits()

virtual u32 esengine::GfxDevice::backendBoundSamplerUnits ( )
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().

◆ backendComputeScopeAvailable()

virtual bool esengine::GfxDevice::backendComputeScopeAvailable ( ) const
inlineprotectedvirtual

Definition at line 947 of file GfxDevice.hpp.

Referenced by beginAsyncComputeJob().

◆ backendCreateBuffer()

virtual bool esengine::GfxDevice::backendCreateBuffer ( u32 id,
const BufferDesc & desc,
const void * data )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by createBuffer().

◆ backendCreateCompressedTexture()

virtual bool esengine::GfxDevice::backendCreateCompressedTexture ( u32 id,
const TextureDesc & desc,
GfxCompressedFormat format,
const void * data,
u32 byteLength,
u32 mipLevels )
protectedpure virtual

◆ backendCreateCompute()

virtual bool esengine::GfxDevice::backendCreateCompute ( u32 id,
const GfxComputeSource & source,
std::string * outLog )
inlineprotectedvirtual

Reimplemented in esengine::WebGPUDevice.

Definition at line 939 of file GfxDevice.hpp.

Referenced by createCompute().

◆ backendCreateFramebuffer()

virtual bool esengine::GfxDevice::backendCreateFramebuffer ( u32 id,
const FramebufferDesc & desc )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by createFramebuffer().

◆ backendCreateProgram()

virtual bool esengine::GfxDevice::backendCreateProgram ( u32 id,
const GfxShaderSource & source,
const GfxAttribBinding * bindings,
u32 bindingCount,
std::string * outLog,
GfxShaderStage * outFailedStage )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by createProgram().

◆ backendCreateTexture()

virtual bool esengine::GfxDevice::backendCreateTexture ( u32 id,
const TextureDesc & desc,
const void * pixels )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by createTexture().

◆ backendCreateTimerQuery()

virtual bool esengine::GfxDevice::backendCreateTimerQuery ( u32 id)
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by createTimerQuery().

◆ backendDeleteBuffer()

virtual void esengine::GfxDevice::backendDeleteBuffer ( u32 id)
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by deleteBuffer().

◆ backendDeleteCompute()

virtual void esengine::GfxDevice::backendDeleteCompute ( u32 id)
inlineprotectedvirtual

Reimplemented in esengine::WebGPUDevice.

Definition at line 951 of file GfxDevice.hpp.

Referenced by deleteCompute().

◆ backendDeleteFramebuffer()

virtual void esengine::GfxDevice::backendDeleteFramebuffer ( u32 id)
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by deleteFramebuffer().

◆ backendDeleteProgram()

virtual void esengine::GfxDevice::backendDeleteProgram ( u32 id)
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by deleteProgram().

◆ backendDeleteTexture()

virtual void esengine::GfxDevice::backendDeleteTexture ( u32 id)
protectedpure virtual

◆ backendDeleteVertexLayout()

virtual void esengine::GfxDevice::backendDeleteVertexLayout ( u32 id)
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().

◆ backendDispatchAsyncCompute()

virtual bool esengine::GfxDevice::backendDispatchAsyncCompute ( AsyncComputePriority ,
u32 ,
const GfxComputeBinding * ,
u32 ,
u32 ,
u32 ,
u32  )
inlineprotectedvirtual

Definition at line 948 of file GfxDevice.hpp.

Referenced by dispatchCompute().

◆ backendDispatchCompute()

virtual bool esengine::GfxDevice::backendDispatchCompute ( u32 id,
const GfxComputeBinding * bindings,
u32 bindingCount,
u32 groupsX,
u32 groupsY,
u32 groupsZ )
inlineprotectedvirtual

Reimplemented in esengine::WebGPUDevice.

Definition at line 952 of file GfxDevice.hpp.

Referenced by dispatchCompute().

◆ backendFinishProgram()

virtual bool esengine::GfxDevice::backendFinishProgram ( u32 id)
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().

◆ backendGenerateMipmaps()

virtual void esengine::GfxDevice::backendGenerateMipmaps ( u32 id)
protectedpure virtual

◆ backendIntUniformSet()

virtual void esengine::GfxDevice::backendIntUniformSet ( u32 program)
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.

◆ backendInvalidatePipelineCache()

virtual void esengine::GfxDevice::backendInvalidatePipelineCache ( )
protectedpure virtual

◆ backendMoveTexture()

virtual void esengine::GfxDevice::backendMoveTexture ( u32 into,
u32 from )
protectedpure virtual

Re-keys from's native texture under into; into holds none on entry.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by adoptTextureContent().

◆ backendPendingProgramCount()

virtual u32 esengine::GfxDevice::backendPendingProgramCount ( )
inlineprotectedvirtual

Reimplemented in esengine::GLDevice.

Definition at line 964 of file GfxDevice.hpp.

Referenced by pendingProgramCount().

◆ backendPendingProgramLabels()

virtual std::string esengine::GfxDevice::backendPendingProgramLabels ( )
inlineprotectedvirtual

Reimplemented in esengine::GLDevice.

Definition at line 965 of file GfxDevice.hpp.

Referenced by pendingProgramLabels().

◆ backendProgramPending()

virtual bool esengine::GfxDevice::backendProgramPending ( u32 id) const
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().

◆ backendProgramReady()

virtual bool esengine::GfxDevice::backendProgramReady ( u32 id)
inlineprotectedvirtual

Reimplemented in esengine::GLDevice.

Definition at line 963 of file GfxDevice.hpp.

Referenced by programReady().

◆ backendReadbackCount()

virtual u32 esengine::GfxDevice::backendReadbackCount ( ) const
protectedpure virtual

Readbacks in flight, the one live object the registry does not hold.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by liveObjects().

◆ backendResizeBuffer()

virtual void esengine::GfxDevice::backendResizeBuffer ( u32 id,
const BufferDesc & desc,
const void * data )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by resizeBuffer().

◆ backendSetAsyncComputeEnabled()

virtual void esengine::GfxDevice::backendSetAsyncComputeEnabled ( bool )
inlineprotectedvirtual

Definition at line 946 of file GfxDevice.hpp.

Referenced by esengine::WebGPUDevice::init(), and setAsyncComputeEnabled().

◆ backendSetPipeline()

virtual void esengine::GfxDevice::backendSetPipeline ( u32 id,
const PipelineDesc & desc )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by setPipeline().

◆ backendSetTextureParams()

virtual void esengine::GfxDevice::backendSetTextureParams ( u32 id,
const TextureDesc & desc )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by setTextureParams().

◆ backendSetUniform()

virtual void esengine::GfxDevice::backendSetUniform ( i32 nativeLocation,
const GfxUniformValue & value )
protectedpure virtual

◆ backendSetUniformBuffer()

virtual void esengine::GfxDevice::backendSetUniformBuffer ( u32 slot,
BufferHandle buffer,
u32 offsetBytes,
u32 sizeBytes )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by setUniformBuffer().

◆ backendUniformBlockBinding()

virtual void esengine::GfxDevice::backendUniformBlockBinding ( u32 program,
u32 nativeBlockIndex,
u32 bindingPoint )
protectedpure virtual

◆ backendUniformBlockIndex()

virtual u32 esengine::GfxDevice::backendUniformBlockIndex ( u32 program,
const char * name )
protectedpure virtual

◆ backendUniformLocation()

virtual i32 esengine::GfxDevice::backendUniformLocation ( u32 program,
const char * name )
protectedpure virtual

The backend's own location this generation, -1 when absent.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by getUniformLocation().

◆ backendUpdateBuffer()

virtual void esengine::GfxDevice::backendUpdateBuffer ( u32 id,
u32 offsetBytes,
const void * data,
u32 sizeBytes )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by updateBuffer().

◆ backendUpdateTexture()

virtual void esengine::GfxDevice::backendUpdateTexture ( u32 id,
i32 x,
i32 y,
u32 width,
u32 height,
const void * pixels,
bool flipY )
protectedpure virtual

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by updateTexture().

◆ backendUseProgram()

virtual void esengine::GfxDevice::backendUseProgram ( u32 id)
protectedpure virtual

◆ backendWaitAsyncCompute()

virtual void esengine::GfxDevice::backendWaitAsyncCompute ( )
inlineprotectedvirtual

Definition at line 950 of file GfxDevice.hpp.

Referenced by graphicsWaitOnAsyncComputeJob().

◆ beginAsyncComputeJob()

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().

◆ beginDeviceFrame()

bool esengine::GfxDevice::beginDeviceFrame ( )
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.

Returns
True when the frame may proceed (see isDeviceUsable).

Definition at line 260 of file GfxDevice.hpp.

References isDeviceUsable(), and pollDeviceLost().

◆ beginRenderPass()

virtual void esengine::GfxDevice::beginRenderPass ( const RenderPassDesc & desc)
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.

◆ beginTimerQuery()

virtual void esengine::GfxDevice::beginTimerQuery ( u32 query)
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().

◆ bindTexture()

virtual void esengine::GfxDevice::bindTexture ( u32 slot,
TextureHandle texture )
pure virtual

Activates a texture slot and binds a 2D texture.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by esengine::DrawList::execute().

◆ boundSamplerUnits()

u32 esengine::GfxDevice::boundSamplerUnits ( )
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().

◆ bufferDesc()

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.

◆ captureDeviceIdentity()

virtual void esengine::GfxDevice::captureDeviceIdentity ( )
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.

◆ captureNextFrame()

virtual ReadbackHandle esengine::GfxDevice::captureNextFrame ( u32 w,
u32 h )
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().

◆ clearStencil()

virtual void esengine::GfxDevice::clearStencil ( i32 value)
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.

◆ clipDepthRange()

virtual ClipDepthRange esengine::GfxDevice::clipDepthRange ( ) const
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.

◆ computeJobOpen()

bool esengine::GfxDevice::computeJobOpen ( ) const
inlineprotected

Definition at line 944 of file GfxDevice.hpp.

◆ copyFramebufferColor()

virtual bool esengine::GfxDevice::copyFramebufferColor ( FramebufferHandle source,
TextureHandle dst )
inlinevirtual

Reimplemented in esengine::GLDevice.

Definition at line 154 of file GfxDevice.hpp.

◆ countDraw()

void esengine::GfxDevice::countDraw ( )
inlineprotected

◆ createBuffer()

BufferHandle esengine::GfxDevice::createBuffer ( const BufferDesc & desc,
GfxContent content,
const void * initialData )

Creates a buffer with fixed capacity and optional initial contents.

Parameters
contentWho restores the contents after a loss.
initialDataWhen 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().

◆ createCompressedTexture()

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.

Parameters
dataAll mipLevels concatenated, level 0 (base) first, each block- aligned (gfxCompressedPyramidBytes). Level i has size max(1, width>>i) x max(1, height>>i).
mipLevelsNumber 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().

◆ createCompute()

ComputeHandle esengine::GfxDevice::createCompute ( const GfxComputeSource & source,
std::string * outLog = nullptr )

Compiles a compute program.

Returns
The program, or Invalid with 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.

◆ createFramebuffer()

FramebufferHandle esengine::GfxDevice::createFramebuffer ( const FramebufferDesc & desc)

Creates a framebuffer from its attachments and validates completeness.

Returns
The framebuffer handle, or Default (0) when incomplete — the default framebuffer can never be created, so 0 unambiguously means failure.

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.

◆ createPipeline()

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().

◆ createProgram()

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.

Parameters
vertexSrcVertex shader GLSL source (null-terminated).
fragmentSrcFragment shader GLSL source (null-terminated).
bindingsAttribute location bindings applied before link (may be null if count==0).
bindingCountNumber of entries in bindings.
outLogOptional; receives the driver info log on failure.
outFailedStageOptional; receives the stage that rejected the source.
Returns
The linked program handle, or Invalid on failure.

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.

◆ createTexture()

TextureHandle esengine::GfxDevice::createTexture ( const TextureDesc & desc,
GfxContent content,
const void * pixels )

◆ createTimerQuery()

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().

◆ createVertexLayout()

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().

◆ currentPipeline()

PipelineHandle esengine::GfxDevice::currentPipeline ( ) const
inlineprotected

The pipeline most recently bound, whose program uniforms are set on.

Definition at line 999 of file GfxDevice.hpp.

◆ deleteBuffer()

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().

◆ deleteCompute()

void esengine::GfxDevice::deleteCompute ( ComputeHandle program)

Deletes a compute program.

Definition at line 707 of file GfxDevice.cpp.

References backendDeleteCompute().

◆ deleteFramebuffer()

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.

◆ deleteProgram()

void esengine::GfxDevice::deleteProgram ( ShaderHandle program)

Deletes a shader program.

Definition at line 671 of file GfxDevice.cpp.

References backendDeleteProgram(), and esengine::Invalid.

◆ deleteTexture()

void esengine::GfxDevice::deleteTexture ( TextureHandle texture)

Deletes a texture.

Definition at line 545 of file GfxDevice.cpp.

References backendDeleteTexture().

◆ deleteVertexLayout()

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().

◆ deviceGeneration()

u64 esengine::GfxDevice::deviceGeneration ( ) const
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().

◆ deviceIdentity()

const GfxDeviceIdentity & esengine::GfxDevice::deviceIdentity ( ) const
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().

◆ deviceLostInfo()

const GfxDeviceLostInfo * esengine::GfxDevice::deviceLostInfo ( ) const
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().

◆ deviceStatus()

GfxDeviceStatus esengine::GfxDevice::deviceStatus ( ) const
inline

Whether the device can be drawn to (see GfxDeviceStatus).

Definition at line 98 of file GfxDevice.hpp.

Referenced by esengine::deviceStatus().

◆ discardReadback()

virtual void esengine::GfxDevice::discardReadback ( ReadbackHandle handle)
pure virtual

Abandons a readback (any state); its resources are released.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ dispatchCompute()

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.

Returns
false when nothing ran: the device does not compute, a resource named is gone, a render pass is open, or a count is zero or over the device's limit.

Definition at line 746 of file GfxDevice.cpp.

References backendDispatchAsyncCompute(), backendDispatchCompute(), isDeviceUsable(), manualComputeBarrier(), supportsAsyncCompute(), and supportsCompute().

◆ drawArrays()

virtual void esengine::GfxDevice::drawArrays ( u32 first,
u32 vertexCount )
pure virtual

Draws non-indexed triangles.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by esengine::drawGeometry().

◆ drawElements()

virtual void esengine::GfxDevice::drawElements ( u32 indexCount,
GfxDataType indexType,
u32 byteOffset )
pure virtual

Draws indexed triangles.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by esengine::drawGeometry(), and esengine::DrawList::execute().

◆ drawElementsInstanced()

virtual void esengine::GfxDevice::drawElementsInstanced ( u32 indexCount,
GfxDataType indexType,
u32 byteOffset,
u32 instanceCount )
pure virtual

Draws indexed triangles with instancing.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by drawElementsInstancedMulti(), and esengine::DrawList::execute().

◆ drawElementsInstancedMulti()

virtual void esengine::GfxDevice::drawElementsInstancedMulti ( GfxDataType indexType,
const u32 * counts,
const u32 * byteOffsets,
const u32 * instanceCounts,
u32 drawCount )
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().

◆ endAsyncComputeJob()

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.

◆ endFrame()

virtual void esengine::GfxDevice::endFrame ( )
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.

◆ endRenderPass()

virtual void esengine::GfxDevice::endRenderPass ( )
pure virtual

Ends the current pass, restoring the default framebuffer.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ endTimerQuery()

virtual void esengine::GfxDevice::endTimerQuery ( )
pure virtual

Stops the active timer query.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by esengine::GpuTimer::end().

◆ estimatedGpuBytes()

u64 esengine::GfxDevice::estimatedGpuBytes ( ) const
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().

◆ finishProgram()

bool esengine::GfxDevice::finishProgram ( ShaderHandle program)
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().

◆ forgoContent()

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().

◆ framebufferDesc()

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().

◆ frameCaptureIsBGRA()

virtual bool esengine::GfxDevice::frameCaptureIsBGRA ( ) const
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.

◆ framePending()

virtual bool esengine::GfxDevice::framePending ( )
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.

◆ generateMipmaps()

void esengine::GfxDevice::generateMipmaps ( TextureHandle texture)

Generates mipmaps for a texture.

Definition at line 596 of file GfxDevice.cpp.

References backendGenerateMipmaps(), and esengine::nextRevision().

◆ geometryWrites()

u64 esengine::GfxDevice::geometryWrites ( ) const
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.

◆ getActiveUniforms()

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.

◆ getAttribLocation()

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.

◆ getError()

virtual u32 esengine::GfxDevice::getError ( )
pure virtual

Queries the last error.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ getInt()

virtual i32 esengine::GfxDevice::getInt ( GfxIntParam name)
pure virtual

Queries a backend integer capability/limit.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ getString()

virtual std::string esengine::GfxDevice::getString ( GfxStringName name)
pure virtual

Queries a backend identification string (diagnostics).

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ getTimerQueryNs()

virtual bool esengine::GfxDevice::getTimerQueryNs ( u32 query,
u64 * outNanoseconds )
pure virtual

Fetches a completed query's elapsed nanoseconds; false while still pending.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by esengine::GpuTimer::poll().

◆ getUniformBlockIndex()

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.

◆ getUniformLocation()

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().

◆ graphicsWaitOnAsyncComputeJob()

void esengine::GfxDevice::graphicsWaitOnAsyncComputeJob ( AsyncComputeFence fence)

Definition at line 736 of file GfxDevice.cpp.

References backendWaitAsyncCompute(), and esengine::kNoAsyncComputeFence.

Referenced by manualComputeBarrier().

◆ importExternalTexture()

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().

◆ init()

virtual void esengine::GfxDevice::init ( )
pure virtual

Initializes the graphics device.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ invalidatePipelineCache()

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().

◆ isDeviceLive()

bool esengine::GfxDevice::isDeviceLive ( ) const
inline

Strictly Live: recovered but still-refilling counts as false.

Definition at line 101 of file GfxDevice.hpp.

References esengine::Live.

◆ isDeviceUsable()

◆ liveObjects()

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().

◆ manualComputeBarrier()

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().

◆ markDeviceDead()

void esengine::GfxDevice::markDeviceDead ( )
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.

◆ markDeviceLost()

bool esengine::GfxDevice::markDeviceLost ( GfxDeviceLostReason reason,
std::string message = {},
std::string context = {} )
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.

Returns
True when this call performed the transition.

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().

◆ maxSamples()

virtual u32 esengine::GfxDevice::maxSamples ( )
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.

◆ nativeTextureName()

virtual u32 esengine::GfxDevice::nativeTextureName ( TextureHandle texture) const
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.

◆ notifyDeviceLost()

void esengine::GfxDevice::notifyDeviceLost ( GfxDeviceLostReason reason,
std::string message = {},
std::string context = {} )
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.

◆ notifyProgramLinked()

void esengine::GfxDevice::notifyProgramLinked ( u32 id)
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().

◆ onDeviceLost()

virtual void esengine::GfxDevice::onDeviceLost ( )
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().

◆ onProgramLinked()

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().

◆ owedContent()

std::vector< GfxOwedContent > esengine::GfxDevice::owedContent ( ) const
inline

Sourced objects that have storage again and are waiting for their contents.

Definition at line 177 of file GfxDevice.hpp.

◆ pendingProgramCount()

u32 esengine::GfxDevice::pendingProgramCount ( )
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().

◆ pendingProgramLabels()

std::string esengine::GfxDevice::pendingProgramLabels ( )
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().

◆ pipelineDesc()

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.

◆ pollDeviceLost()

virtual bool esengine::GfxDevice::pollDeviceLost ( )
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.

Returns
True when THIS call is the one that observed the loss.

Reimplemented in esengine::GLDevice, and esengine::WebGPUDevice.

Definition at line 250 of file GfxDevice.hpp.

Referenced by beginDeviceFrame().

◆ pollReadback()

virtual GfxReadbackStatus esengine::GfxDevice::pollReadback ( ReadbackHandle handle)
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.

◆ programReady()

bool esengine::GfxDevice::programReady ( ShaderHandle program)
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().

◆ provideReplacementDevice()

virtual bool esengine::GfxDevice::provideReplacementDevice ( void * nativeDevice)
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().

◆ recoverDevice()

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.

Returns
True when the device is usable (Recovering or Live).

Definition at line 89 of file GfxDevice.cpp.

References esengine::Dead, isDeviceUsable(), esengine::Live, esengine::Lost, esengine::Recovering, and recreateDevice().

Referenced by esengine::recoverDevice().

◆ recreateDevice()

virtual bool esengine::GfxDevice::recreateDevice ( )
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().

◆ requestBufferReadback()

virtual ReadbackHandle esengine::GfxDevice::requestBufferReadback ( BufferHandle buffer,
u32 offsetBytes,
u32 sizeBytes )
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.

◆ requestReadback()

virtual ReadbackHandle esengine::GfxDevice::requestReadback ( FramebufferHandle target,
u32 w,
u32 h )
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.

Returns
A handle to poll, or Invalid when the request cannot be issued.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by captureNextFrame().

◆ requestTextureReadback()

virtual ReadbackHandle esengine::GfxDevice::requestTextureReadback ( TextureHandle texture)
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.

◆ resizeBackbuffer()

virtual void esengine::GfxDevice::resizeBackbuffer ( u32 width,
u32 height )
inlinevirtual

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.

◆ resizeBuffer()

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.

◆ resolvesDepth()

virtual bool esengine::GfxDevice::resolvesDepth ( ) const
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.

◆ resourceRecords()

const GfxResourceRegistry & esengine::GfxDevice::resourceRecords ( ) const
inlineprotected

Definition at line 945 of file GfxDevice.hpp.

◆ restoreCompressedTexture()

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.

◆ restoreContent()

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.

◆ restoreTextureFromNative()

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().

◆ retainedBytes()

usize esengine::GfxDevice::retainedBytes ( ) const
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.

◆ setAsyncComputeEnabled()

void esengine::GfxDevice::setAsyncComputeEnabled ( bool enabled)

◆ setDeviceIdentity()

void esengine::GfxDevice::setDeviceIdentity ( std::string backend,
std::string vendor,
std::string renderer,
std::string version )
inlineprotected

Records the backend identity; see captureDeviceIdentity.

Definition at line 1021 of file GfxDevice.hpp.

Referenced by esengine::GLDevice::captureDeviceIdentity(), and esengine::WebGPUDevice::captureDeviceIdentity().

◆ setDeviceLostHandler()

void esengine::GfxDevice::setDeviceLostHandler ( std::function< void(const GfxDeviceLostInfo &)> handler)
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.

◆ setIndexBuffer()

virtual void esengine::GfxDevice::setIndexBuffer ( BufferHandle buffer)
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().

◆ setPipeline()

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().

◆ setRetainedBudget()

void esengine::GfxDevice::setRetainedBudget ( usize bytes)
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.

◆ setScissor()

virtual void esengine::GfxDevice::setScissor ( i32 x,
i32 y,
i32 w,
i32 h )
pure virtual

Sets the scissor rectangle.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by esengine::DrawList::execute().

◆ setScissorTest()

virtual void esengine::GfxDevice::setScissorTest ( bool enabled)
pure virtual

Enables or disables scissor test.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

Referenced by esengine::DrawList::execute().

◆ setSkipPendingPrograms()

void esengine::GfxDevice::setSkipPendingPrograms ( bool on)
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.

◆ setStencilReference()

virtual void esengine::GfxDevice::setStencilReference ( i32 ref)
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().

◆ setSurfaceSamples()

virtual void esengine::GfxDevice::setSurfaceSamples ( u32 samples)
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.

◆ setTextureParams()

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().

◆ setUniform1f()

void esengine::GfxDevice::setUniform1f ( i32 location,
f32 value )

Sets a float uniform.

Definition at line 822 of file GfxDevice.cpp.

References esengine::GfxUniformValue::f, esengine::GfxUniformValue::Float, and esengine::GfxUniformValue::type.

◆ setUniform1i()

void esengine::GfxDevice::setUniform1i ( i32 location,
i32 value )

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.

◆ setUniform2f()

void esengine::GfxDevice::setUniform2f ( i32 location,
f32 x,
f32 y )

Sets a vec2 uniform.

Definition at line 829 of file GfxDevice.cpp.

References esengine::GfxUniformValue::f, esengine::GfxUniformValue::type, and esengine::GfxUniformValue::Vec2.

◆ setUniform3f()

void esengine::GfxDevice::setUniform3f ( i32 location,
f32 x,
f32 y,
f32 z )

Sets a vec3 uniform.

Definition at line 837 of file GfxDevice.cpp.

References esengine::GfxUniformValue::f, esengine::GfxUniformValue::type, and esengine::GfxUniformValue::Vec3.

◆ setUniform4f()

void esengine::GfxDevice::setUniform4f ( i32 location,
f32 x,
f32 y,
f32 z,
f32 w )

Sets a vec4 uniform.

Definition at line 846 of file GfxDevice.cpp.

References esengine::GfxUniformValue::f, esengine::GfxUniformValue::type, and esengine::GfxUniformValue::Vec4.

◆ setUniformBuffer()

void esengine::GfxDevice::setUniformBuffer ( u32 slot,
BufferHandle buffer,
u32 offsetBytes = 0,
u32 sizeBytes = 0 )
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().

◆ setUniformMat3()

void esengine::GfxDevice::setUniformMat3 ( i32 location,
const f32 * data )

Sets a mat3 uniform.

Definition at line 856 of file GfxDevice.cpp.

References esengine::GfxUniformValue::f, esengine::GfxUniformValue::Mat3, and esengine::GfxUniformValue::type.

◆ setUniformMat4()

void esengine::GfxDevice::setUniformMat4 ( i32 location,
const f32 * data )

Sets a mat4 uniform.

Definition at line 864 of file GfxDevice.cpp.

References esengine::GfxUniformValue::f, esengine::GfxUniformValue::Mat4, and esengine::GfxUniformValue::type.

◆ setVertexBuffer()

virtual void esengine::GfxDevice::setVertexBuffer ( u32 slot,
BufferHandle buffer,
u32 offsetBytes )
pure virtual

Binds a vertex buffer to a layout slot for subsequent draws.

Parameters
offsetBytesByte 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().

◆ setViewport()

virtual void esengine::GfxDevice::setViewport ( i32 x,
i32 y,
u32 w,
u32 h )
pure virtual

Sets the rendering viewport.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ setWireframe()

virtual void esengine::GfxDevice::setWireframe ( bool enabled)
pure virtual

Enables or disables wireframe rendering (desktop only).

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ shutdown()

virtual void esengine::GfxDevice::shutdown ( )
pure virtual

Shuts down the graphics device.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ skipPendingPrograms()

bool esengine::GfxDevice::skipPendingPrograms ( ) const
inline

◆ supportsAsyncCompute()

virtual bool esengine::GfxDevice::supportsAsyncCompute ( ) const
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().

◆ supportsCompressedFormat()

virtual bool esengine::GfxDevice::supportsCompressedFormat ( GfxCompressedFormat format)
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().

◆ supportsCompute()

virtual bool esengine::GfxDevice::supportsCompute ( ) const
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().

◆ supportsDeferredLink()

virtual bool esengine::GfxDevice::supportsDeferredLink ( ) const
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.

◆ supportsFloatTargets()

virtual bool esengine::GfxDevice::supportsFloatTargets ( )
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().

◆ supportsMultiDraw()

virtual bool esengine::GfxDevice::supportsMultiDraw ( ) const
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().

◆ supportsShaderLanguage()

virtual bool esengine::GfxDevice::supportsShaderLanguage ( GfxShaderLanguage language) const
pure virtual

Whether this backend compiles language (GL: GLSL ES 300; WebGPU: WGSL).

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ supportsUnblendedSurfaceTarget()

virtual bool esengine::GfxDevice::supportsUnblendedSurfaceTarget ( ) const
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().

◆ takeDraws()

u32 esengine::GfxDevice::takeDraws ( )
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.

◆ takeReadback()

virtual bool esengine::GfxDevice::takeReadback ( ReadbackHandle handle,
void * dest,
usize destSize )
pure virtual

Copies a Ready readback's pixels (w*h*4 bytes) into dest and releases it.

Returns
False when the handle is unknown, still Pending, or destSize is short — a Pending readback stays alive.

Implemented in esengine::GLDevice, and esengine::WebGPUDevice.

◆ textureDesc()

◆ textureRevision()

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.

◆ textureShapes()

u64 esengine::GfxDevice::textureShapes ( ) const
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.

◆ timerDisjoint()

virtual bool esengine::GfxDevice::timerDisjoint ( )
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().

◆ timesPassesByArming()

virtual bool esengine::GfxDevice::timesPassesByArming ( ) const
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.

◆ trackedTextureRevision()

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.

◆ uniformBlockBinding()

void esengine::GfxDevice::uniformBlockBinding ( ShaderHandle program,
u32 blockIndex,
u32 bindingPoint )

◆ updateBuffer()

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().

◆ updateTexture()

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).

Parameters
flipYVertical 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.

◆ useProgram()

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().

◆ vertexLayoutDesc()

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.

◆ viewport()

const Viewport & esengine::GfxDevice::viewport ( ) const
inline

Definition at line 289 of file GfxDevice.hpp.

References viewport_.

Member Data Documentation

◆ viewport_

Viewport esengine::GfxDevice::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().


The documentation for this class was generated from the following files:
  • /home/runner/work/estella/estella/src/esengine/renderer/rhi/GfxDevice.hpp
  • /home/runner/work/estella/estella/src/esengine/renderer/rhi/GfxDevice.cpp