trace library

Recording what a device was asked, keeping it as a .f3dtrace file, and asking it again of any backend — H3.

final recording = RecordingDevice(device);
final renderer = Renderer.create(device: recording);
final frame = renderer.render(...);
await recording.readback(frame.frame);
final bytes = Trace(recording.events).encode();

final replay = await replayTrace(Trace.decode(bytes), otherDevice);
replay.pixels.single; // the same frame, drawn by the other backend

A library of its own rather than part of flutter3d_hardware.dart: an application draws without it, and a tool or a test that wants it asks.

Classes

RecordingDevice
A GraphicsDevice that passes every call to inner and keeps it as a TraceEvent in events; see the library comment.
Trace
Calls made of a device, in order, with every resource named by an id.
TraceBeginComputePass
GraphicsDevice.beginComputePass: a compute pass opened.
TraceBeginFrame
GraphicsDevice.beginFrame: the start of a frame. Carries nothing.
TraceBeginRenderPass
GraphicsDevice.beginRenderPass: a render pass opened on textures the trace made.
TraceBindIndexBuffer
PassEncoder.bindIndexBuffer: indices the device already holds.
TraceBindIndexData
PassEncoder.bindIndexData: indices built this frame, bound as bytes.
TraceBindPipeline
PassEncoder.bindPipeline: the render pipeline the following draws use.
TraceBindTexture
PassEncoder.bindTexture: a texture and sampler bound to a stage's slot.
TraceBindUniformBlock
PassEncoder.bindUniformBlock: a uniform block's members, by name.
TraceBindVertexBuffer
PassEncoder.bindVertexBuffer: vertices the device already holds.
TraceBindVertexData
PassEncoder.bindVertexData: vertices built this frame, bound as bytes.
TraceBlobReader
Reads payloads back out of a trace's blob.
TraceBlobWriter
Collects the byte payloads of a trace into one buffer, handing back where each landed.
TraceClearBindings
PassEncoder.clearBindings: every binding of the pass forgotten.
TraceColorTarget
One colour attachment, with its textures named by id: a ColorTarget as a trace writes it.
TraceComputeBindPipeline
ComputeEncoder.bindPipeline: the pipeline the following dispatches run.
TraceComputeBindStorageBuffer
ComputeEncoder.bindStorageBuffer: a storage buffer bound to a stage's binding, whole.
TraceComputeBindUniformBlock
ComputeEncoder.bindUniformBlock: a compute stage's uniform block, by member name.
TraceComputeSubmit
ComputeEncoder.submit: a compute pass closed and queued.
TraceCreateComputePipeline
GraphicsDevice.createComputePipeline: a pipeline from a compute stage.
TraceCreateCubeRenderTarget
GraphicsDevice.createCubeRenderTarget: an empty cube a pass can draw into.
TraceCreateCubeTextureFromPixels
GraphicsDevice.createCubeTextureFromPixels: a cube texture made from six square faces.
TraceCreatePipeline
GraphicsDevice.createPipeline: a render pipeline from two stages and an optional vertex layout.
TraceCreateStorageBuffer
GraphicsDevice.createBuffer for a storage buffer, or the older createStorageBuffer: a buffer compute passes read and write.
TraceCreateTexture
GraphicsDevice.createTexture, or a render target a pool made: an empty texture.
TraceCreateTextureFromPixels
GraphicsDevice.createTextureFromPixels: a 2D texture made holding pixels.
TraceDepthTarget
The depth attachment, with its texture named by id: a DepthTarget as a trace writes it. A class for TraceColorTarget's reason, with DepthTarget's defaults.
TraceDispatch
ComputeEncoder.dispatch: the bound pipeline run over a grid of workgroups.
TraceDraw
PassEncoder.draw: a draw with what is bound.
TraceEvent
The base of every recorded call; see the library comment for why it is open and what a switch over it owes.
TraceGeometryRange
A slice of a geometry buffer: which buffer, and which bytes of it.
TraceInsertDebugMarker
PassEncoder.insertDebugMarker.
TraceLabeled
What kind of resource a TraceSetLabel names, which says whose ids its number is among.
TraceLoadShaders
GraphicsDevice.loadShaders: a shader bundle loaded. Pipelines name their stages by name, looked up in the libraries loaded so far.
TraceOverwriteGeometry
GraphicsDevice.overwriteGeometry: bytes written into a buffer the trace uploaded.
TraceOverwriteTexture
GraphicsDevice.overwriteTexture: a region of a texture written from RGBA8 bytes.
TracePassEvent
An event recorded into an open render pass.
TracePopDebugGroup
PassEncoder.popDebugGroup.
TracePushDebugGroup
PassEncoder.pushDebugGroup: a named group opened in pass pass.
TraceReadback
GraphicsDevice.readback: a texture's pixels read back at this point in the queue.
TraceReadBuffer
GraphicsDevice.readBuffer: a host-readable storage buffer read back.
TraceReadPixels
A read of a whole texture written by a trace from before 1.0, when readPixels was its own call. Nothing records it now; a replay answers it with GraphicsDevice.readback.
TraceReleaseGeometry
GraphicsDevice.releaseGeometry: a geometry buffer given back.
TraceReleaseStorageBuffer
GraphicsDevice.releaseStorageBuffer: a storage buffer given back.
TraceReleaseTexture
TextureHandle.dispose or GraphicsDevice.releaseTexture: a texture given back.
TraceReplay
What a replay read back, in the order the trace asked.
TraceSetAlphaToCoverage
PassEncoder.setAlphaToCoverage — P7. A trace recorded before it had none, which replays as it was recorded: off.
TraceSetBlend
PassEncoder.setBlend: the blend state of one colour attachment.
TraceSetBlendColor
PassEncoder.setBlendColor: the constant the blend-constant factors read.
TraceSetCullMode
PassEncoder.setCullMode: which faces the following draws discard.
TraceSetDepthCompare
PassEncoder.setDepthCompare: the depth test of the following draws.
TraceSetDepthWrite
PassEncoder.setDepthWrite: whether the following draws write depth.
TraceSetLabel
GraphicsDevice.setLabel: label given to a resource the trace made.
TraceSetPolygonMode
PassEncoder.setPolygonMode: whether triangles fill or draw as lines.
TraceSetPrimitiveType
PassEncoder.setPrimitiveType: how the following draws assemble vertices.
TraceSetScissor
PassEncoder.setScissor: the rectangle draws are clipped to.
TraceSetStencil
PassEncoder.setStencil: the stencil test of the following draws.
TraceSetStencilReference
PassEncoder.setStencilReference: the value the stencil test compares against.
TraceSetViewport
PassEncoder.setViewport: a PassViewport since 1.0.0-rc.1, written as the four whole numbers a ScreenRect was whenever it covers whole pixels and the whole depth range, so older traces read and newer ones of such a pass are byte for byte what they were.
TraceSetWindingOrder
PassEncoder.setWindingOrder: which winding counts as front-facing.
TraceSubmit
CommandEncoder.submit: a render pass closed and queued.
TraceUploadGeometry
GraphicsDevice.uploadGeometry: a geometry buffer made from bytes.

Functions

replayTrace(Trace trace, GraphicsDevice device) → Future<TraceReplay>
Issues every call of trace against device and collects what it reads.

Exceptions / Errors

TraceFormatException
A .f3dtrace that is not one, is newer than this build reads, or names something this build has no value for.