fakedevice

package
v1.9.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fakedevice is an explicit.Device that records every call, for the unit tests of the explicit renderer without a GPU. It checks the design limits of SPEC §9.3 as the real backends do, so a renderer that breaks one fails its test with GPULimitExceeded.

Flutter: no counterpart

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(b explicit.Buffer) []byte

Bytes returns what was written to the buffer, if b is a fake buffer.

Flutter: no counterpart

Types

type BufferWrite

type BufferWrite struct {
	// Offset is where the data went in the buffer.
	Offset int
	// Data is a copy of the bytes written.
	Data []byte
	// Usage is what the buffer was made for.
	Usage explicit.BufferUsage
}

BufferWrite is one call of WriteBuffer.

Flutter: no counterpart

type Call

type Call struct {
	// Op is the name of the method: "NewBuffer", "BeginPass", "Draw", ...
	Op string
	// Args are the arguments, as text.
	Args string
}

Call is one call the renderer made, in order. Op names the method and Args are its arguments in a readable form.

Flutter: no counterpart

func (Call) String

func (c Call) String() string

type Device

type Device struct {

	// Err, when set, is what the next call that can fail returns, once.
	Err error
	// AcquireErrs are the errors that the next calls of Swapchain.Acquire return, one
	// each, before it succeeds again.
	AcquireErrs []error
	// Rotation is the pre-rotation that the swapchains report after Configure, as Android's
	// currentTransform does: with a quarter turn their images have the width and height swapped.
	Rotation explicit.Rotation
	// StaleOnce makes the next Present leave its swapchain stale, as Android's surface turning
	// does: Stale is true until Configure, which then reports RotationAfter.
	StaleOnce     bool
	RotationAfter explicit.Rotation
	// CompleteReadsOnSubmit makes Submit run the done functions of the reads of the frame,
	// as a device that waits for the GPU does.
	CompleteReadsOnSubmit bool
	// Name is what Description says.
	Name string
	// Writes are the calls of WriteBuffer, with a copy of their data.
	Writes []BufferWrite
	// Quiet stops the device from keeping the log of its calls and the copies of the buffer
	// writes, so that a benchmark of the renderer counts what the renderer allocates and not
	// what the log does.
	Quiet bool
	// contains filtered or unexported fields
}

Device is the fake device. The zero value is not usable; use New.

Flutter: no counterpart

func New

func New() *Device

New returns a device with the design limits.

Flutter: no counterpart

func (*Device) Begin

func (d *Device) Begin() (explicit.Encoder, error)

Begin implements explicit.Device.

func (*Device) Calls

func (d *Device) Calls() []Call

Calls returns the calls made so far.

Flutter: no counterpart

func (*Device) Close

func (d *Device) Close() error

Close implements explicit.Device.

func (*Device) Closed

func (d *Device) Closed() bool

Closed is whether Close was called.

Flutter: no counterpart

func (*Device) CompleteReads

func (d *Device) CompleteReads()

CompleteReads runs the done function of every ReadTexture that is waiting, as the GPU finishing the frame would. The real backends never call it inside the frame that asked, and neither does this: the test calls it after Submit.

Flutter: no counterpart

func (*Device) Description

func (d *Device) Description() string

Description names the device, for the renderer's log.

Flutter: no counterpart

func (*Device) Limits

func (d *Device) Limits() explicit.Limits

Limits implements explicit.Device.

func (*Device) Live

func (d *Device) Live() Live

Live returns how many resources of each kind are alive.

Flutter: no counterpart

func (*Device) NewBindGroup

func (d *Device) NewBindGroup(p explicit.Pipeline, group int, entries []explicit.Binding) (explicit.BindGroup, error)

NewBindGroup implements explicit.Device.

func (*Device) NewBuffer

func (d *Device) NewBuffer(size int, usage explicit.BufferUsage) (explicit.Buffer, error)

NewBuffer implements explicit.Device.

func (*Device) NewPipeline

func (d *Device) NewPipeline(desc explicit.PipelineDesc) (explicit.Pipeline, error)

NewPipeline implements explicit.Device.

func (*Device) NewSampler

func (d *Device) NewSampler(desc explicit.SamplerDesc) (explicit.Sampler, error)

NewSampler implements explicit.Device.

func (*Device) NewSwapchain

func (d *Device) NewSwapchain(h gpu.SurfaceHandle) (explicit.Swapchain, error)

NewSwapchain implements explicit.Device.

func (*Device) NewTexture

func (d *Device) NewTexture(desc explicit.TextureDesc) (explicit.Texture, error)

NewTexture implements explicit.Device.

func (*Device) Ops

func (d *Device) Ops() []string

Ops returns the names of the calls made so far.

Flutter: no counterpart

func (*Device) Reset

func (d *Device) Reset()

Reset forgets the calls and the buffer writes made so far, for a benchmark that draws many frames.

Flutter: no counterpart

func (*Device) SetLimits

func (d *Device) SetLimits(l explicit.Limits)

SetLimits changes the limits the device checks, to test code that reads them.

Flutter: no counterpart

func (*Device) WriteBuffer

func (d *Device) WriteBuffer(b explicit.Buffer, offset int, data []byte)

WriteBuffer implements explicit.Device.

func (*Device) WriteTexture

func (d *Device) WriteTexture(t explicit.Texture, level int, r image.Rectangle, data []byte, stride int)

WriteTexture implements explicit.Device. It keeps the pixels of every level.

type Live

type Live struct {
	Buffers, Textures, Samplers, Pipelines int
}

Live is how many resources of each kind the device made that were not destroyed yet. A renderer that keeps making resources and never destroys them (a texture for each frame) shows here as a count that grows. Bind groups are not counted: the real devices take them from the pool of a frame, which is reset when the frame is done, and their Destroy does nothing.

Flutter: no counterpart

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL