Documentation
¶
Overview ¶
Package memback is an in-memory gpudev.Backend: resources are byte images, scanouts are framebuffers a flush composes into, and webgpu-batch contexts keep their objects in a table and check every replayed stream with go-gfx/webgpu's own reader (wire.Decode). It is the backend of the tests, the fuzz targets and the in-process end-to-end runs; it renders nothing.
Index ¶
- Constants
- Variables
- type Backend
- func (b *Backend) CreateResource(id uint32, f gpudev.Format, w, h uint32) error
- func (b *Backend) DestroyResource(id uint32)
- func (b *Backend) Flush(scanout, id uint32, r gpudev.Rect) error
- func (b *Backend) NewContext(ctx uint32) (gpudev.Context, error)
- func (b *Backend) SetScanout(scanout, id uint32, r gpudev.Rect) error
- func (b *Backend) Upload(id uint32, r gpudev.Rect, src []byte, stride uint64) error
- type Context
- type Image
- type Object
- type Shown
Constants ¶
const FirstID = 1 << 20
FirstID is the first host id a Context hands out.
Variables ¶
var ErrUnknown = errors.New("memback: unknown resource or object")
ErrUnknown: a call naming something the backend does not hold. The Device never makes one; tests that drive the backend directly can.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
sync.Mutex
Resources map[uint32]*Image
// Scanouts holds what each scanout shows: the image a flush last
// composed (nil until the first flush of an enabled scanout).
Scanouts map[uint32]*Image
Shown map[uint32]Shown // scanout -> resource and rect
Flushes int
Contexts map[uint32]*Context
// Fail, when set, makes every call that can fail return it.
Fail error
}
Backend is the in-memory backend. Its fields are for inspection; lock it (it is a sync.Locker) while reading them during device activity.
func (*Backend) CreateResource ¶
CreateResource implements gpudev.Backend.
func (*Backend) DestroyResource ¶
DestroyResource implements gpudev.Backend.
func (*Backend) Flush ¶
Flush implements gpudev.Backend: it copies r of the resource into the scanout image, at r's position relative to the scanout's rect.
func (*Backend) NewContext ¶
NewContext implements gpudev.Backend.
func (*Backend) SetScanout ¶
SetScanout implements gpudev.Backend.
type Context ¶
type Context struct {
ID uint32
Objects map[uint32]Object
Replays [][]wire.Cmd
Binds map[uint32]gpudev.Window
Closed bool
// contains filtered or unexported fields
}
Context is an in-memory webgpu-batch context. Host ids start at FirstID, far from the small ids guests use, so a stream the Device did not translate fails wire.Decode here.
type Image ¶
Image is a resource or scanout: Width×Height pixels, 4 bytes each, rows packed (stride Width*4), in the resource's byte order.