FakeBackend class final
A device that records rather than draws.
- Implemented types
Constructors
-
FakeBackend({Set<
String> missingShaders = const <String>{}, bool supportsWireframe = true, bool supportsStencil = true, bool supportsRenderToMip = true, Set<TextureFormat> unsupportedFormats = const <TextureFormat>{}, int maxAnisotropy = 16, int maxColorAttachments = 2, Map<String, StageBindings> ? stageBindings, FramebufferOrigin framebufferOrigin = FramebufferOrigin.topLeft})
Properties
- answerReadback ↔ ByteData Function(TextureHandle texture, ScreenRect region)?
-
What a readback answers, or null for a region of zeros.
getter/setter pair
-
bindingViolations
→ List<
String> -
Declared slots left unbound at a draw, across every pass. See
stageBindings.
final
- completesImmediately ↔ bool
-
Whether onFrameComplete runs its callback at once.
getter/setter pair
-
createdCubeRenderTargets
→ List<
({TextureFormat format, int mipLevels, int size})> -
Every cube a pass may draw into, with the level count it was asked for,
so a test can see that a probe allocated what it meant to.
final
-
createdTextures
→ List<
RenderTargetSpec> -
final
- defaultColorFormat → TextureFormat
-
The colour format this device prefers.
no setteroverride
- defaultDepthStencilFormat → TextureFormat
-
The depth/stencil format this device prefers. Legitimately
TextureFormat.unknown on a context that has none.
no setteroverride
- depthRange → DepthRange
-
What this backend's clip space maps depth onto.
no setteroverride
- disposed ↔ bool
-
Whether dispose has been called, for a test that wants to assert a
device was actually torn down rather than merely dropped.
getter/setter pair
- framebufferOrigin → FramebufferOrigin
-
The engine's own convention by default, so a fake never exercises the
remap. The backends that need the other one are covered by running
them; a test that pins what the engine hands such a backend asks for
FramebufferOrigin.bottomLeft.
final
- frames ↔ int
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- hdrColorFormat → TextureFormat
-
The format to render high dynamic range colour into.
no setteroverride
-
hdrOutputFormats
→ List<
TextureFormat> -
The formats this device can present an extended-range frame in, empty
when it can only present standard range.
no setteroverride
-
linkedPipelines
→ List<
String> -
Every pair linked so far, by name and in order, so a test can tell
whether a frame linked anything — a renderer that relinked drops every
pipeline it held and links each one again, and one it forgot to drop
shows up here as a link that did not happen.
final
-
loadedLibraries
→ List<
FakeLoadedShaderLibrary> -
Every library loadShaders has handed out, in order, so a test can
reach the one an application holds and count its refreshes.
final
- maxAnisotropy → int
-
Sixteen, which is what most hardware answers, and settable so a test
can be the device that answers one and see what a caller clamps to.
final
- maxColorAttachments → int
-
Two, and settable so a test can be the device that answers one —
gfx-50n.final -
overwrites
→ List<
({Object backend, int lengthInBytes, int offsetInBytes})> -
Every call overwriteGeometry has recorded, in order — a test asks this
rather than the bytes themselves, because this backend keeps none: it
records wiring, not content, the same promise uploads already makes.
final
-
overwrittenTextures
→ List<
({TextureFormat format, int mipLevel, ScreenRect region})> -
Every call overwriteTexture has recorded, in order — wiring, not
content, the same promise uploadedPixels already makes for a whole
upload.
final
-
passes
→ List<
FakePass> -
Every pass ever opened, in the order it was opened.
final
-
pendingFrames
→ List<
void Function()> -
Frames whose work the GPU has not "finished".
final
- preferredSampleCount → int
-
Samples to use for multisampled targets, or 1 for none.
no setteroverride
-
readbacks
→ List<
({ScreenRect region, TextureHandle texture})> -
Every readback asked for, in order: which texture and which region.
final
-
releasedGeometry
→ List<
GeometryBuffer> -
final
-
releasedTextures
→ List<
TextureHandle> -
What was handed back one at a time, in the order it was handed back.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shaders → FakeShaderLibrary
-
The compiled bundle this device was built with.
final
-
stageBindings
→ Map<
String, StageBindings> ? -
What each stage declares, by name, or null to accept every bind.
final
- supportsBlendColor → bool
-
Whether
PassEncoder.setBlendColorreaches the hardware.no setteroverride - supportsCompute → bool
-
Whether compute pipelines can be created and dispatched —
H6. The members below it throw an UnsupportedError where this is false.no setteroverride - supportsCubeTextures → bool
-
Whether a cube texture can be created and sampled.
no setteroverride
- supportsFloat32Filtering → bool
-
Whether a 32-bit float texture can be drawn into and sampled with
linear filtering.
no setteroverride
- supportsGpuTimestamps → bool
-
Whether this device measures how long the GPU spends in each labelled
pass —
H2. When true, onGpuTimings is called with them.no setteroverride - supportsIndependentBlend → bool
-
Whether a pass with several colour targets can blend each differently.
no setteroverride
- supportsMipmaps → bool
-
True, because a fake has nothing to be incapable with. The real answer is
a device property, and the two backends that have one disagree.
no setteroverride
- supportsOffscreenMsaa ↔ bool
-
True, and settable so a test can be the device that answers no —
gfx-20n.getter/setter pairoverride-getter - supportsRenderToMip → bool
-
Settable for the same reason supportsWireframe is: the interesting
case is the backend that says no — flutter_gpu on OpenGL ES — and the
renderer is supposed to build a probe without a chain there rather than
name a level the device will refuse.
final
- supportsStencil → bool
-
Settable for the same reason supportsWireframe is: the case worth a
test is the device that says no, where the x-ray stage has to draw
nothing rather than configure a test against an attachment with no
stencil in it.
final
- supportsWireframe → bool
-
Settable, because the interesting case is the backend that says no —
OpenGL ES has no
glPolygonMode, and the engine is supposed to decline its own wireframe setting rather than let the request reach a backend that would refuse it mid-frame.final -
unsupportedFormats
→ Set<
TextureFormat> -
The formats this fake says it cannot sample, so a test can be the
device that has no BC7 and see what a loader does about it.
final
-
uploadedMipLevels
→ List<
List< ByteData> ?> -
The chain each of those came with — null for an upload that brought
none — so a test can tell a base level from a base level and its mips.
final
-
uploadedPixels
→ List<
ByteData> -
The bytes of each of those, for a test that cares what colour it was.
final
-
uploadedTextures
→ List<
RenderTargetSpec> -
Pixel uploads, in order, so a test can assert what reached the device.
final
-
uploads
→ List<
GeometryUsage> -
Recorded with its usage, because a backend exists that cannot change its
mind about one later.
final
Methods
-
beginComputePass(
{String? label}) → ComputeEncoder -
Opens a compute pass;
labelnames it to a debugger and to onGpuTimings.override -
beginFrame(
) → void -
Tells the backend a new frame is starting.
override
-
beginRenderPass(
RenderPassDescriptor descriptor) → CommandEncoder -
Opens a pass and returns the encoder that records into it.
override
-
createComputePipeline(
ShaderHandle shader) → ComputePipelineHandle -
A pipeline from a compute stage of this device's shader library.
override
-
createCubeRenderTarget(
{required int size, required TextureFormat format, int mipLevels = 1}) → TextureHandle? -
Allocates a cube texture a pass can draw into, face by face and level by
level, with nothing in it yet.
override
-
createCubeTextureFromPixels(
{required int size, required TextureFormat format, required List< ByteData> faces, List<List< ? mipLevels}) → TextureHandle?ByteData> > -
Uploads six square images as one cube texture.
override
-
createPipeline(
ShaderHandle vertex, ShaderHandle fragment, {VertexLayoutSpec? layout}) → PipelineHandle -
Links two stages into something that can be bound.
override
-
createStorageBuffer(
ByteData bytes, {bool hostReadable = false}) → StorageBuffer -
A storage buffer holding
bytes.hostReadableallows readBuffer.override -
createTexture(
RenderTargetSpec spec) → TextureHandle -
A brand-new texture matching
spec, with the single TextureHandle that will ever stand for it.override -
createTextureFromPixels(
{required int width, required int height, required TextureFormat format, required ByteData pixels, List< ByteData> ? mipLevels}) → TextureHandle? -
Creates a texture already holding
pixels.override -
dispose(
) → void -
Releases every persistent resource this device holds — the textures and
geometry buffers handed out by createTexture, createTextureFromPixels,
createCubeTextureFromPixels, createCubeRenderTarget and
uploadGeometry.
override
-
finishOldestFrame(
) → void - Lets the oldest unfinished frame complete.
-
loadShaders(
ByteData bytes) → Future< LoadedShaderLibrary> -
Decodes the bundle — so bytes that are not one are refused the way every
real backend refuses them — and answers its names. No section is read:
a fake compiles nothing, which is also the software rasteriser's answer.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFrameComplete(
void whenDone()) → void -
Runs
whenDoneonce the GPU has finished with the frame being encoded now.override -
onGpuTimings(
void listener(GpuFrameTimings timings)?) → void -
Sets where each frame's GPU timings go, a frame or two after it was
encoded; null stops them. Never called on a device whose
supportsGpuTimestamps is false.
override
-
overwriteGeometry(
GeometryBuffer target, int offsetInBytes, ByteData bytes) → void -
Writes
bytesintotargetstartingoffsetInBytesinto it, in place.override -
overwriteTexture(
TextureHandle target, ByteData rgba, {ScreenRect? region, int mipLevel = 0}) → Future< void> -
Overwrites
region(the whole texture by default) oftarget's base level withrgba— raw RGBA8 bytes,region.width * region.height * 4of them, row-major from the top the same way readback answers them.override -
readback(
TextureHandle texture, {ScreenRect? region}) → Future< ByteData> -
Refuses what the contract refuses, records the rest, and answers zeros
unless answerReadback says otherwise.
override
-
readBuffer(
StorageBuffer buffer) → Future< ByteData> -
The contents of
buffer, once every pass submitted before this call has finished writing it.buffermust behostReadable.override -
readPixels(
TextureHandle texture) → Future< ByteData?> -
Null, which is a legitimate answer rather than a refusal: it is what a
real device says about a texture whose pixels cannot be read.
override
-
releaseGeometry(
GeometryBuffer geometry) → void -
Releases one geometry buffer, rather than waiting for the whole device to
go.
override
-
releaseStorageBuffer(
StorageBuffer buffer) → void -
Releases one storage buffer, as releaseGeometry releases geometry.
override
-
releaseTexture(
TextureHandle texture) → void -
Gives one back, rather than waiting for the whole device to go.
override
-
supportsTextureFormat(
TextureFormat format) → bool -
Whether a texture uploaded in
formatcan be created and sampled here.override -
toString(
) → String -
A string representation of this object.
inherited
-
uploadGeometry(
ByteData bytes, GeometryUsage usage) → GeometryBuffer -
Uploads geometry that will outlive the frame.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited