replay

package
v0.0.0-...-6c7272e Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package replay is used to issue replay requests to replay devices.

Index

Constants

This section is empty.

Variables

View Source
var Events struct {
	// OnReplay is called when a replay batch is sent to a device.
	OnReplay func(bind.Device, Intent, Config)
}

Events holds a number of callback functions that can be used to monitor replay activity.

Functions

func Execute

func Execute(
	ctx context.Context,
	dependent string,
	payload gapir.Payload,
	handlePost builder.PostDataHandler,
	handleNotification builder.NotificationHandler,
	fenceReadyCallback builder.FenceReadyRequestCallback,
	m Manager,
	conn *gapirClient.ConnectionKey,
	memoryLayout *device.MemoryLayout,
	os *device.OS) error

Execute sends the replay payload for execution on the target replay device communicating on connection. decoder will be used for decoding all postback reponses. Once a postback response is decoded, the corresponding handler in the handlers map will be called.

func GetDevice

func GetDevice(ctx context.Context) *path.Device

GetDevice retrieves the target replay device from a context previously annotated by PutDevice.

func GetTimestamps

func GetTimestamps(ctx context.Context, capturePath *path.Capture, device *path.Device, loopCount int32, handler service.TimeStampsHandler) error

GetTimestamps replays the trace and return the start and end timestamps for each commandbuffers

func GpuProfile

func GpuProfile(ctx context.Context, capturePath *path.Capture, device *path.Device) (*service.ProfilingData, error)

GpuProfile replays the trace and writes a Perfetto trace of the replay

func PutDevice

func PutDevice(ctx context.Context, m *path.Device) context.Context

PutDevice attaches a target replay device to a Context.

func PutManager

func PutManager(ctx context.Context, m Manager) context.Context

PutManager attaches a manager to a Context.

Types

type Config

type Config interface{}

Config is a user-defined type used to describe the type of replay being requested. Replay requests made with configs that have equality (==) will likely be batched into the same replay pass. Configs can be used to force requests into different replay passes. For example, by issuing requests with different configs we can prevent a profiling Request from being issued in the same pass as a Request to render all draw calls in wireframe.

type Custom

type Custom struct {
	T uint64 // The thread ID
	F func(ctx context.Context, s *api.GlobalState, b *builder.Builder) error
}

Custom is a command issuing custom replay operations to the replay builder b upon Replay().

func (Custom) API

func (Custom) API() api.API

func (Custom) Alive

func (Custom) Alive() bool

func (Custom) Caller

func (Custom) Caller() api.CmdID

api.Cmd compliance

func (Custom) Clone

func (cmd Custom) Clone(arena.Arena) api.Cmd

func (Custom) CmdFlags

func (Custom) CmdName

func (Custom) CmdName() string

func (Custom) CmdParams

func (Custom) CmdParams() api.Properties

func (Custom) CmdResult

func (Custom) CmdResult() *api.Property

func (Custom) Extras

func (Custom) Extras() *api.CmdExtras

func (Custom) Mutate

func (Custom) SetCaller

func (Custom) SetCaller(api.CmdID)

func (Custom) SetTerminated

func (Custom) SetTerminated(bool)

func (Custom) SetThread

func (cmd Custom) SetThread(t uint64)

func (Custom) Terminated

func (Custom) Terminated() bool

func (Custom) Thread

func (cmd Custom) Thread() uint64

type EndOfReplay

type EndOfReplay struct {
	// contains filtered or unexported fields
}

EndOfReplay is a transform that causes a post back at the end of the replay. It can be used to ensure that GAPIS waits for a replay to finish, if there are no postbacks, or no pending postbacks in the replay.

func (*EndOfReplay) AddNotifyInstruction

func (t *EndOfReplay) AddNotifyInstruction(ctx context.Context, out transform.Writer, result func() interface{})

AddNotifyInstruction adds the instruction to the replay stream that will notify GAPIS that the replay has finished. It should be the end (or very near the end) of the replay stream and thus be called from a transform Flush.

func (*EndOfReplay) AddResult

func (t *EndOfReplay) AddResult(r Result)

AddResult adds the given replay result listener to this transform.

func (*EndOfReplay) BuffersCommands

func (t *EndOfReplay) BuffersCommands() bool

func (*EndOfReplay) Flush

func (t *EndOfReplay) Flush(ctx context.Context, out transform.Writer) error

func (*EndOfReplay) PostLoop

func (t *EndOfReplay) PostLoop(ctx context.Context, out transform.Writer)

func (*EndOfReplay) PreLoop

func (t *EndOfReplay) PreLoop(ctx context.Context, out transform.Writer)

func (*EndOfReplay) Transform

func (t *EndOfReplay) Transform(ctx context.Context, id api.CmdID, cmd api.Cmd, out transform.Writer) error

type Exporter

type Exporter interface {
	Manager
	// Export wait for waitRequests replay requests to be sent,
	// it then compiles the instructions for replay and triggers
	// all postback with builder.ErrReplayNotExecuted .
	Export(ctx context.Context, waitRequests int) (*gapir.Payload, error)
}

Exporter stores the input replays and export them as gapir instruction.

func NewExporter

func NewExporter() Exporter

NewExporter creates a new Exporter.

type Generator

type Generator interface {
	// Replay is called when a replay pass is ready to be sent to the replay
	// device. Replay may filter or transform the list of commands, satisfying
	// all the specified requests and config, before outputting the final
	// command stream to out.
	Replay(
		ctx context.Context,
		intent Intent,
		cfg Config,
		dependentPayload string,
		requests []RequestAndResult,
		device *device.Instance,
		capture *capture.GraphicsCapture,
		out transform.Writer) error
}

Generator is the interface for types that support replay generation.

type InitialPayloadResult

type InitialPayloadResult struct {
	// contains filtered or unexported fields
}

type Intent

type Intent struct {
	Device  *path.Device  // The path to the device being used for replay.
	Capture *path.Capture // The path to the capture that is being replayed.
}

Intent describes the source capture and replay target information used for issuing a replay request.

type Issue

type Issue struct {
	Command  api.CmdID        // The command that reported the issue.
	Severity service.Severity // The severity of the issue.
	Error    error            // The issue's error.
}

Issue represents a single replay issue reported by QueryIssues.

type Manager

type Manager interface {
	// Replay requests that req is to be performed on the device described by
	// intent, using the capture described by intent.
	Replay(
		ctx context.Context,
		intent Intent,
		cfg Config,
		req Request,
		generator Generator,
		hints *service.UsageHints,
		forceNonSplitReplay bool) (val interface{}, err error)
}

Manager executes replay requests.

func GetManager

func GetManager(ctx context.Context) Manager

GetManager retrieves the manager from a context previously annotated by PutManager.

func New

func New(ctx context.Context) Manager

New returns a new Manager instance using the database db.

func NewManagerForTest

func NewManagerForTest(client *gapir.Client) Manager

NewManagerForTest returns a new Manager for the test.

type MappingExporter

type MappingExporter struct {
	// contains filtered or unexported fields
}

func NewMappingExporter

func NewMappingExporter(ctx context.Context, mappings *map[uint64][]service.VulkanHandleMappingItem) *MappingExporter

func NewMappingExporterWithPrint

func NewMappingExporterWithPrint(ctx context.Context, path string) *MappingExporter

func (*MappingExporter) BuffersCommands

func (t *MappingExporter) BuffersCommands() bool

func (*MappingExporter) ExtractRemappings

func (m *MappingExporter) ExtractRemappings(ctx context.Context, s *api.GlobalState, b *builder.Builder) error

func (*MappingExporter) Flush

func (m *MappingExporter) Flush(ctx context.Context, out transform.Writer) error

func (*MappingExporter) PostLoop

func (m *MappingExporter) PostLoop(ctx context.Context, out transform.Writer)

func (*MappingExporter) PreLoop

func (m *MappingExporter) PreLoop(ctx context.Context, out transform.Writer)

func (*MappingExporter) Transform

func (m *MappingExporter) Transform(ctx context.Context, id api.CmdID, cmd api.Cmd, out transform.Writer) error

type Profiler

type Profiler interface {
	// Profile execute a profilable replay.
	Profile(
		ctx context.Context,
		intent Intent,
		mgr Manager,
		hints *service.UsageHints,
		traceOptions *service.TraceOptions) (*service.ProfilingData, error)
}

Profiler is the interface implemented by replays that can be performed in a profiling mode while capturing profiling data.

type QueryFramebufferAttachment

type QueryFramebufferAttachment interface {
	QueryFramebufferAttachment(
		ctx context.Context,
		intent Intent,
		mgr Manager,
		after []uint64,
		width, height uint32,
		attachment api.FramebufferAttachment,
		framebufferIndex uint32,
		drawMode service.DrawMode,
		disableReplayOptimization bool,
		displayToSurface bool,
		hints *service.UsageHints) (*image.Data, error)
}

QueryFramebufferAttachment is the interface implemented by types that can return the content of a framebuffer attachment at a particular point in a capture.

type QueryIssues

type QueryIssues interface {
	QueryIssues(
		ctx context.Context,
		intent Intent,
		mgr Manager,
		loopCount int32,
		displayToSurface bool,
		hints *service.UsageHints) ([]Issue, error)
}

QueryIssues is the interface implemented by types that can verify the replay performs as expected and without errors. If the capture includes FramebufferObservation commands, this also includes checking the replayed framebuffer matches (within reasonable error) the framebuffer observed at capture time.

type QueryTimestamps

type QueryTimestamps interface {
	QueryTimestamps(
		ctx context.Context,
		intent Intent,
		mgr Manager,
		loopCount int32,
		handler service.TimeStampsHandler,
		hints *service.UsageHints) error
}

QueryTimestamps is the interface implemented by types that can return the timestamps of the execution of commands

type Request

type Request interface{}

Request is a user-defined type that holds information relevant to a single replay request. An example Request would be one that informs ReplayTransforms to insert a postback of the currently bound render-target content at a specific command.

type RequestAndResult

type RequestAndResult struct {
	Request Request
	Result  Result
}

RequestAndResult is a pair of Request and Result.

type Result

type Result func(val interface{}, err error)

Result is the function called for the result of a request. One of val and err must be nil.

func (Result) Do

func (r Result) Do(f func() (val interface{}, err error)) error

Do calls f and passes the return value-error pair to Result.

func (Result) Transform

func (r Result) Transform(f func(in interface{}) (out interface{}, err error)) Result

Transform returns a new Result that passes the non-error value through f before calling the original r.

type SignalHandler

type SignalHandler struct {
	StartSignal task.Signal
	StartFunc   task.Task
	ReadySignal task.Signal
	ReadyFunc   task.Task
	StopSignal  task.Signal
	StopFunc    task.Task
	DoneSignal  task.Signal
	DoneFunc    task.Task
	Written     int64
	Err         error
}

TODO(apbodnar) move this into whatever eventually calls Profile()

func NewSignalHandler

func NewSignalHandler() *SignalHandler

type SplitGenerator

type SplitGenerator interface {
	Generator
	// GetInitialPayload returns a set of instructions
	// that can be used to set up the replay.
	GetInitialPayload(ctx context.Context,
		capture *path.Capture,
		device *device.Instance,
		out transform.Writer) error
	// CleanupResources returns a set of instructions
	// that can be used to clean up from the Initial payload.
	CleanupResources(ctx context.Context,
		device *device.Instance,
		out transform.Writer) error
}

SplitGenerator is the interface for types that support split-replay generation.

type Support

type Support interface {
	// GetReplayPriority returns a uint32 representing the preference for
	// replaying this trace on the given device.
	// A lower number represents a higher priority, and Zero represents
	// an inability for the trace to be replayed on the given device.
	GetReplayPriority(context.Context, *device.Instance, *capture.Header) uint32
}

Support is the optional interface implemented by APIs that can describe replay support for particular devices and device types.

type WaitForFence

type WaitForFence struct {
	TransformCallback func(ctx context.Context, p *gapir.FenceReadyRequest)
	FlushCallback     func(ctx context.Context, p *gapir.FenceReadyRequest)
	ShouldWait        func(ctx context.Context, id api.CmdID, cmd api.Cmd) bool
}

func (*WaitForFence) AddFlushWait

func (t *WaitForFence) AddFlushWait(ctx context.Context, out transform.Writer) error

func (*WaitForFence) AddTransformWait

func (t *WaitForFence) AddTransformWait(ctx context.Context, id api.CmdID, out transform.Writer)

func (*WaitForFence) BuffersCommands

func (t *WaitForFence) BuffersCommands() bool

func (*WaitForFence) Flush

func (t *WaitForFence) Flush(ctx context.Context, out transform.Writer) error

func (*WaitForFence) PostLoop

func (t *WaitForFence) PostLoop(ctx context.Context, out transform.Writer)

func (*WaitForFence) PreLoop

func (t *WaitForFence) PreLoop(ctx context.Context, out transform.Writer)

func (*WaitForFence) Transform

func (t *WaitForFence) Transform(ctx context.Context, id api.CmdID, cmd api.Cmd, out transform.Writer) error

Directories

Path Synopsis
Package asm contains high-level instructions to control the replay virtual machine.
Package asm contains high-level instructions to control the replay virtual machine.
Package builder contains the Builder type to build replay payloads.
Package builder contains the Builder type to build replay payloads.
Package devices contains functions for gathering devices that can replay a capture.
Package devices contains functions for gathering devices that can replay a capture.
Package opcode holds all the opcodes that are to be interpreted by the replay virtual machine.
Package opcode holds all the opcodes that are to be interpreted by the replay virtual machine.
Package protocol contains the constants and types used to communicate with the replay system and its virtual-machine interpreter.
Package protocol contains the constants and types used to communicate with the replay system and its virtual-machine interpreter.
Package value contains the value types used by the replay virtual machine.
Package value contains the value types used by the replay virtual machine.

Jump to

Keyboard shortcuts

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