api

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Overview

Package api exposes the shared behavior of all graphics api's.

Index

Constants

View Source
const (
	// ErrParameterNotFound is the error returned by GetParameter() and
	// SetParameter() when the command does not have the named parameter.
	ErrParameterNotFound = fault.Const("Parameter not found")
	// ErrResultNotFound is the error returned by GetResult() and SetResult()
	// when the command does not have a result value.
	ErrResultNotFound = fault.Const("Result not found")
)
View Source
const Break tyBreak = tyBreak(0)

Break can be returned from the callback passed to ForeachCmd to stop iteration of the loop.

View Source
const CmdNoID = CmdID(1<<63 - 1) // use max int64 for the benefit of java

CmdNoID is used when you have to pass an ID, but don't have one to use.

View Source
const NilRefID = RefID(0)

NilRefID identifies a nil reference in the API models.

Variables

View Source
var (
	// ErrMeshNotAvailable is an error returned by MeshProvider if a mesh is
	// requested on an object that does not have a mesh (e.g. non-draw call).
	ErrMeshNotAvailable = errors.New("Mesh not available at this command")
)
View Source
var (
	// ErrPipelineNotAvailable is an error returned by PipelineProvider if the
	// pipelines are requested on an object that does not have pipelines.
	ErrPipelineNotAvailable = errors.New("Pipelines not available at this command")
)

Functions

func CmdCallFor

func CmdCallFor(cmd Cmd) proto.Message

CmdCallFor returns the proto message type for the call result of cmd.

func ForeachCmd

func ForeachCmd(ctx context.Context, cmds []Cmd, onlyTerminated bool, cb func(context.Context, CmdID, Cmd) error) error

func GetParameter

func GetParameter(c Cmd, name string) (interface{}, error)

GetParameter returns the parameter value with the specified name.

func GetResult

func GetResult(c Cmd) (interface{}, error)

GetResult returns the command's result value.

func IsErrCmdAborted

func IsErrCmdAborted(err error) bool

IsErrCmdAborted returns true if the cause of the error err was due to an abort() in the command.

func MutateCmds

func MutateCmds(ctx context.Context, state *GlobalState, builder *builder.Builder,
	watcher StateWatcher, cmds ...Cmd) error

MutateCmds calls Mutate on each of cmds.

func Register

func Register(api API)

Register adds an api to the understood set. It is illegal to register the same name twice.

func ReverseSubCmdIDs

func ReverseSubCmdIDs(ids []SubCmdIdx)

ReverseSubCmdIDs reverses the slice of subcommand ids

func SetParameter

func SetParameter(c Cmd, name string, val interface{}) error

SetParameter sets the parameter with the specified name with val.

func SetResult

func SetResult(c Cmd, val interface{}) error

SetResult sets the commands result value to val.

func SortSubCmdIDs

func SortSubCmdIDs(ids []SubCmdIdx)

SortSubCmdIDs sorts the slice of subcommand ids

Types

type API

type API interface {
	// Name returns the official name of the api.
	Name() string

	// Index returns the API index.
	Index() uint8

	// ID returns the unique API identifier.
	ID() ID

	// ConstantSets returns the constant set pack for the API.
	ConstantSets() *constset.Pack

	// GetFramebufferAttachmentInfo returns the width, height, and format of the
	// specified framebuffer attachment.
	// It also returns an API specific index that maps the given attachment into
	// an API specific representation.
	GetFramebufferAttachmentInfos(
		ctx context.Context,
		state *GlobalState) (info []FramebufferAttachmentInfo, err error)

	// CreateCmd constructs and returns a new command with the specified name.
	CreateCmd(name string) Cmd

	// RebuildState returns a set of commands which, if executed on a new clean
	// state, will reproduce the API's state in s.
	// The segments of memory that were used to create these commands are
	// returned in the rangeList.
	RebuildState(ctx context.Context, s *GlobalState) ([]Cmd, interval.U64RangeList)

	// GetFramegraph returns the framegraph of the capture.
	GetFramegraph(ctx context.Context, p *path.Capture) (*Framegraph, error)
}

API is the common interface to a graphics programming api.

func All

func All() []API

All returns all the registered APIs.

func Find

func Find(id ID) API

Find looks up a graphics API by identifier. If the id has not been registered, it returns nil.

type APIObject

type APIObject interface {
	// API returns the API identifier that this type belongs to.
	API() API
}

APIObject is the interface implemented by types that belong to an API.

type AllocResult

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

AllocResult represents the result of allocating a range using a memory.Allocator, and potentially the database ID for data that's meant to be stored in the range.

func (AllocResult) Address

func (r AllocResult) Address() uint64

Address returns the beginning of the range.

func (AllocResult) Data

func (r AllocResult) Data() (memory.Range, id.ID)

Data can be used as a helper to Add(Read|Write) methods on commands.

func (AllocResult) Free

func (r AllocResult) Free()

Free frees the memory range through the originating allocator. This is not currently used.

func (AllocResult) Offset

func (r AllocResult) Offset(n uint64) memory.Pointer

Offset returns a pointer n bytes to the right of the associated range.

func (AllocResult) Ptr

func (r AllocResult) Ptr() memory.Pointer

Ptr returns a pointer to the beginning of the range.

func (AllocResult) Range

func (r AllocResult) Range() memory.Range

Range returns the associated memory.Range.

type ArrayIndexFragment

type ArrayIndexFragment struct {
	ArrayIndex int
}

ArrayIndexFragment is a Fragment identifying an array index. This corresponds to syntax such as `myArray[3]`.

func (ArrayIndexFragment) DenseIndex

func (f ArrayIndexFragment) DenseIndex() int

func (ArrayIndexFragment) Format

func (f ArrayIndexFragment) Format(s fmt.State, r rune)

type BoundPipeline

type BoundPipeline struct {
	Pipeline Resource
	Data     *ResourceData
}

BoundPipeline represents a pipeline resource and its data currently bound.

type CloneContext

type CloneContext map[interface{}]interface{}

CloneContext is used to keep track of references when cloning API objects.

type Cmd

type Cmd interface {
	// All commands belong to an API
	APIObject

	// Thread returns the thread index this command was executed on.
	Thread() uint64

	// SetThread changes the thread index.
	SetThread(uint64)

	// CmdName returns the name of the command.
	CmdName() string

	// CmdParams returns the command's parameters.
	CmdParams() Properties

	// CmdResult returns the command's result value, or nil if there is no
	// result value.
	CmdResult() *Property

	// CmdFlags returns the flags of the command.
	CmdFlags() CmdFlags

	// Extras returns all the Extras associated with the command.
	Extras() *CmdExtras

	// Mutate mutates the State using the command. If the builder argument is
	// not nil then it will call the replay function on the builder.
	Mutate(context.Context, CmdID, *GlobalState, *builder.Builder, StateWatcher) error

	// Clone makes a shallow copy of this command.
	Clone() Cmd

	// Alive returns true if this command should be marked alive for DCE
	Alive() bool

	// Terminated returns true if this command did terminate during capture
	Terminated() bool

	// SetTerminated sets whether this command has terminated or not
	SetTerminated(terminated bool)
}

Cmd is the interface implemented by all graphics API commands.

func ServiceToCmd

func ServiceToCmd(c *Command) (Cmd, error)

ServiceToCmd returns the command built from c.

func WithExtras

func WithExtras(a Cmd, extras ...CmdExtra) Cmd

WithExtras adds the given extras to a command and returns it.

type CmdExtra

type CmdExtra interface{}

CmdExtra is the interface implemented by command 'extras' - additional information that can be placed inside a command.

type CmdExtras

type CmdExtras []CmdExtra

CmdExtras is a list of CmdExtra objects.

func (*CmdExtras) Aborted

func (e *CmdExtras) Aborted() *ErrCmdAborted

Aborted returns a pointer to the ErrCmdAborted structure in the CmdExtras, or nil if not found.

func (*CmdExtras) Add

func (e *CmdExtras) Add(es ...CmdExtra)

Add appends one or more CmdExtras to the list of CmdExtras.

func (*CmdExtras) All

func (e *CmdExtras) All() CmdExtras

func (*CmdExtras) CloneObservations

func (e *CmdExtras) CloneObservations()

CloneObservations makes a shallow clone of the extras, except for the observations, which are cloned.

func (*CmdExtras) GetOrAppendObservations

func (e *CmdExtras) GetOrAppendObservations() *CmdObservations

GetOrAppendObservations returns a pointer to the existing Observations structure in the CmdExtras, or appends and returns a pointer to a new observations structure if the CmdExtras does not already contain one.

func (*CmdExtras) MustClone

func (e *CmdExtras) MustClone(es ...CmdExtra)

MustClone clones all of es, adding them to e. if there was an error, a panic is raised

func (*CmdExtras) Observations

func (e *CmdExtras) Observations() *CmdObservations

Observations returns a pointer to the CmdObservations structure in the CmdExtras, or nil if there are no observations in the CmdExtras.

func (*CmdExtras) Replace

func (e *CmdExtras) Replace(old, new CmdExtra)

Replace replaces the `old` CmdExtra with the `new` CmdExtra. If `old` is not found, this does nothing.

type CmdFlags

type CmdFlags uint32

CmdFlags is a bitfield describing characteristics of a command.

const (
	DrawCall CmdFlags = 1 << iota
	TransformFeedback
	Clear
	EndOfFrame
	PushUserMarker
	PopUserMarker
	UserMarker
	ExecutedDraw
	ExecutedDispatch
	ExecutedCommandBuffer
	Submission
)

func (CmdFlags) IsClear

func (f CmdFlags) IsClear() bool

IsClear returns true if the command is a clear call.

func (CmdFlags) IsDrawCall

func (f CmdFlags) IsDrawCall() bool

IsDrawCall returns true if the command is a draw call.

func (CmdFlags) IsEndOfFrame

func (f CmdFlags) IsEndOfFrame() bool

IsEndOfFrame returns true if the command represents the end of a frame.

func (CmdFlags) IsExecutedCommandBuffer

func (f CmdFlags) IsExecutedCommandBuffer() bool

IsExecutedCommandBuffer returns true if the command executes a prerecorded command buffer.

func (CmdFlags) IsExecutedDispatch

func (f CmdFlags) IsExecutedDispatch() bool

IsExecutedDispatch returns true if the command is a dispatch that gets executed as a subcommand.

func (CmdFlags) IsExecutedDraw

func (f CmdFlags) IsExecutedDraw() bool

IsExecutedDraw returns true if the command is a draw call that gets executed as a subcommand.

func (CmdFlags) IsPopUserMarker

func (f CmdFlags) IsPopUserMarker() bool

IsPopUserMarker returns true if the command represents the end of the last pushed user marker.

func (CmdFlags) IsPushUserMarker

func (f CmdFlags) IsPushUserMarker() bool

IsPushUserMarker returns true if the command represents the start of a user marker group. The command may implement the Labeled interface to expose the marker name.

func (CmdFlags) IsSubmission

func (f CmdFlags) IsSubmission() bool

IsSubmission returns true if the command is a submission

func (CmdFlags) IsTransformFeedback

func (f CmdFlags) IsTransformFeedback() bool

IsTransformFeedback returns true if the command is a transform-feedback call.

func (CmdFlags) IsUserMarker

func (f CmdFlags) IsUserMarker() bool

IsUserMarker returns true if the command represents a non-grouping user marker. The command may implement the Labeled interface to expose the marker name.

type CmdGroupOrRoot

type CmdGroupOrRoot interface {
	SpanItem
	// Index returns the child at the given index. This can either be another
	// group, CmdId or root.
	Index(index uint64) SpanItem
}

CmdGroupOrRoot represents either a named group of commands, or a new SubCmdRoot under which new commands live.

type CmdID

type CmdID uint64

CmdID is the index of a command in a command stream.

func (CmdID) Derived

func (id CmdID) Derived() CmdID

Derived is used to create an ID which is used for generated extra commands. It is used purely for debugging (to print the related original command ID).

func (CmdID) IsReal

func (id CmdID) IsReal() bool

IsReal returns true if the id is not derived nor CmdNoID.

func (CmdID) Real

func (id CmdID) Real() CmdID

Real create a real CmdID from a Derived CmdID.

func (CmdID) String

func (id CmdID) String() string

type CmdIDGroup

type CmdIDGroup struct {
	Name               string      // Name of this group.
	Range              CmdIDRange  // The range of commands this group (and items) represents.
	Spans              Spans       // All sub-groups and sub-ranges of this group.
	ExperimentableCmds []SubCmdIdx // Indices of commands under this group that can be disabled for experiments.
	UserData           interface{}
}

CmdIDGroup represents a named group of commands with support for sparse sub-groups and sub-command-ranges. Groups are ideal for expressing nested hierarchies of commands.

Groups have the concept of items. An item is either an immediate sub-group, or a command range that is within this group's span but outside of any sub-group.

func (*CmdIDGroup) AddCommand

func (g *CmdIDGroup) AddCommand(id CmdID) bool

AddCommand adds the command to the groups.

func (*CmdIDGroup) AddGroup

func (g *CmdIDGroup) AddGroup(start, end CmdID, name string, experimentableCmds []SubCmdIdx) (*CmdIDGroup, error)

If the new group does not overlap any existing groups in the list then it is inserted into the list, keeping ascending command-identifier order. If the new group sits completely within an existing group then this new group will be added to the existing group's sub-groups. If the new group completely wraps one or more existing groups in the list then these existing groups are added as sub-groups to the new group and then the new group is added to the list, keeping ascending command-identifier order. If the new group partially overlaps any existing group then the function will return an error.

*** Warning *** All groups must be added before commands. Attemping to call this function after commands have been added may result in panics!

func (*CmdIDGroup) AddRoot

func (g *CmdIDGroup) AddRoot(rootidx []uint64, nameLookUp *SubCmdIdxTrie) *SubCmdRoot

AddRoot adds a new Subcommand Root for the given index. It returns the span for this SubcommandGroup

func (*CmdIDGroup) Bounds

func (g *CmdIDGroup) Bounds() CmdIDRange

func (*CmdIDGroup) Cluster

func (g *CmdIDGroup) Cluster(maxChildren, maxNeighbours uint64)

Cluster groups together chains of command using the limits maxChildren and maxNeighbours.

If maxChildren is positive, the group, and any of it's decendent groups, which have more than maxChildren child elements, will have their children grouped into new synthetic groups of at most maxChildren children.

If maxNeighbours is positive, we will group long list of ungrouped commands, which are next to a group. This ensures the group is not lost in noise.

func (CmdIDGroup) Count

func (g CmdIDGroup) Count() uint64

Count returns the number of immediate items this group contains.

func (CmdIDGroup) DeepCount

func (g CmdIDGroup) DeepCount(pred func(g CmdIDGroup) bool) uint64

DeepCount returns the total (recursive) number of items this group contains. The given predicate determines wheter the tested group is counted as 1 or is recursed into.

func (CmdIDGroup) FindSubCommandRoot

func (g CmdIDGroup) FindSubCommandRoot(id CmdID) *SubCmdRoot

FindSubCommandRoot returns the SubCmdRoot that represents the given CmdID.

func (CmdIDGroup) Format

func (g CmdIDGroup) Format(f fmt.State, r rune)

Format writes a string representing the group's name, range and sub-groups.

func (CmdIDGroup) Index

func (g CmdIDGroup) Index(index uint64) SpanItem

Index returns the item at the specified index.

func (CmdIDGroup) IndexOf

func (g CmdIDGroup) IndexOf(id CmdID) uint64

IndexOf returns the item index that id refers directly to, or contains id.

func (CmdIDGroup) IterateBackwards

func (g CmdIDGroup) IterateBackwards(index uint64, cb func(childIdx uint64, item SpanItem) error) error

IterateBackwards calls cb with each contained command index or group starting with the item at index. If cb returns an error then traversal is stopped and the error is returned.

func (CmdIDGroup) IterateForwards

func (g CmdIDGroup) IterateForwards(index uint64, cb func(childIdx uint64, item SpanItem) error) error

IterateForwards calls cb with each contained command index or group starting with the item at index. If cb returns an error then traversal is stopped and the error is returned.

func (CmdIDGroup) Traverse

func (g CmdIDGroup) Traverse(backwards bool, start []uint64, cb TraverseCallback) error

Traverse traverses the command group starting with the specified index, calling cb for each encountered node.

type CmdIDRange

type CmdIDRange struct {
	Start CmdID // The first command within the range.
	End   CmdID // One past the last command within the range.
}

CmdIDRange describes an interval of commands.

func (*CmdIDRange) Bounds

func (r *CmdIDRange) Bounds() CmdIDRange

func (CmdIDRange) Clamp

func (i CmdIDRange) Clamp(id CmdID) CmdID

Clamp returns the nearest index in the range to id.

func (CmdIDRange) CmdIDRange

func (i CmdIDRange) CmdIDRange() (start, end CmdID)

CmdIDRange returns the start and end of the range.

func (CmdIDRange) Contains

func (i CmdIDRange) Contains(id CmdID) bool

Contains returns true if id is within the range, otherwise false.

func (CmdIDRange) First

func (i CmdIDRange) First() CmdID

First returns the first command index within the range.

func (CmdIDRange) Last

func (i CmdIDRange) Last() CmdID

Last returns the last command index within the range.

func (CmdIDRange) Length

func (i CmdIDRange) Length() uint64

Length returns the number of commands in the range.

func (*CmdIDRange) SetSpan

func (i *CmdIDRange) SetSpan(span interval.U64Span)

SetSpan sets the start and end range using a U64Span.

func (CmdIDRange) Span

func (i CmdIDRange) Span() interval.U64Span

Span returns the start and end of the range as a U64Span.

func (CmdIDRange) Split

func (r CmdIDRange) Split(i uint64) (*CmdIDRange, *CmdIDRange)

Split splits this range into two subranges where the first range will have a length no larger than the given value.

func (CmdIDRange) String

func (i CmdIDRange) String() string

String returns a string representing the range.

type CmdIDSet

type CmdIDSet map[CmdID]struct{}

CmdIDSet is a set of CmdIDs.

func (*CmdIDSet) Add

func (s *CmdIDSet) Add(id CmdID)

Add adds id to the set. If the id was already in the set then the call does nothing.

func (CmdIDSet) Contains

func (s CmdIDSet) Contains(id CmdID) bool

Contains returns true if id is in the set, otherwise false.

func (*CmdIDSet) Remove

func (s *CmdIDSet) Remove(id CmdID)

Remove removes id from the set. If the id was not in the set then the call does nothing.

type CmdObservation

type CmdObservation struct {
	Pool  memory.PoolID // The pool in which the memory was observed.
	Range memory.Range  // Memory range that was observed.
	ID    id.ID         // The resource identifier of the observed data.
}

CmdObservation represents a single read or write observation made by an command.

func (CmdObservation) String

func (o CmdObservation) String() string

type CmdObservations

type CmdObservations struct {
	Reads  []CmdObservation
	Writes []CmdObservation
}

CmdObservations is a collection of reads and write observations performed by an command.

func (*CmdObservations) AddRead

func (o *CmdObservations) AddRead(rng memory.Range, id id.ID)

AddRead appends the read to the list of observations.

func (*CmdObservations) AddWrite

func (o *CmdObservations) AddWrite(rng memory.Range, id id.ID)

AddWrite appends the write to the list of observations.

func (*CmdObservations) ApplyReads

func (o *CmdObservations) ApplyReads(p *memory.Pool)

ApplyReads applies all the observed reads to memory pool p. This is a no-op when called when o is nil.

func (*CmdObservations) ApplyWrites

func (o *CmdObservations) ApplyWrites(p *memory.Pool)

ApplyWrites applies all the observed writes to the memory pool p. This is a no-op when called when o is nil.

func (*CmdObservations) DataString

func (o *CmdObservations) DataString(ctx context.Context) string

DataString returns a string describing all reads/writes and their raw data.

func (*CmdObservations) String

func (o *CmdObservations) String() string

type CmdSubmissionKey

type CmdSubmissionKey [4]uint64

TODO(apbodnar) find a more appropriate place for this

type CmdWithResult

type CmdWithResult interface {
	Cmd

	// CallResult returns the result value for this command.
	CallResult() proto.Message

	// SetCallResult changes the result value. Returns an error if the result
	// proto type does not match this command.
	SetCallResult(context.Context, proto.Message) error
}

CmdWithResult is the optional interface implemented by commands that have a result value.

type CompleteFragment

type CompleteFragment struct{}

CompleteFragment is a Fragment identifying the entire object (all fields), map (all key/value pairs) or array (all values).

func (CompleteFragment) DenseIndex

func (CompleteFragment) DenseIndex() int

func (CompleteFragment) Format

func (CompleteFragment) Format(s fmt.State, r rune)

type DenseFragment

type DenseFragment interface {
	DenseIndex() int
}

type DenseFragmentMap

type DenseFragmentMap struct {
	Values []denseFragmentMapEntry
}

func NewDenseFragmentMap

func NewDenseFragmentMap(cap int) *DenseFragmentMap

func (DenseFragmentMap) Clear

func (m DenseFragmentMap) Clear()

func (DenseFragmentMap) Delete

func (m DenseFragmentMap) Delete(f Fragment)

func (DenseFragmentMap) EmptyClone

func (m DenseFragmentMap) EmptyClone() FragmentMap

func (DenseFragmentMap) ForeachFrag

func (m DenseFragmentMap) ForeachFrag(f func(Fragment, interface{}) error) error

func (DenseFragmentMap) Get

func (m DenseFragmentMap) Get(f Fragment) (interface{}, bool)

func (*DenseFragmentMap) Set

func (m *DenseFragmentMap) Set(f Fragment, v interface{})

type Field

type Field interface {
	FieldName() string
	FieldIndex() int
	ClassName() string
}

Field identifies a field in an API object

type FieldFragment

type FieldFragment struct {
	Field
}

FieldFragment is a Fragment identifying a field member of an API object. This corresponds to API syntax such as `myObj.fieldName`.

func (FieldFragment) DenseIndex

func (f FieldFragment) DenseIndex() int

func (FieldFragment) Format

func (f FieldFragment) Format(s fmt.State, r rune)

type Fragment

type Fragment interface {
	// contains filtered or unexported methods
}

Fragment is an interface which marks types which identify pieces of API objects. All of the implementations appear below.

type FragmentMap

type FragmentMap interface {
	Get(Fragment) (interface{}, bool)
	Set(Fragment, interface{})
	Delete(Fragment)
	Clear()
	ForeachFrag(func(Fragment, interface{}) error) error
	EmptyClone() FragmentMap
}

type FramebufferAttachmentInfo

type FramebufferAttachmentInfo struct {
	// Width in texels of the framebuffer
	Width uint32
	// Height in texels of the framebuffer
	Height uint32
	// Framebuffer index
	Index uint32
	// Format of the image
	Format *image.Format
	// CanResize is true if this can be efficiently resized during replay.
	CanResize bool
	// Attachment type (Color, Depth, Input, Resolve)
	Type FramebufferAttachmentType
	// Error message when calling state.getFramebufferAttachmentInfo
	Err error
}

FramebufferAttachmentInfo describes a framebuffer at a given point in the trace

type GlobalState

type GlobalState struct {
	// MemoryLayout holds information about the device memory layout that was
	// used to create the capture.
	MemoryLayout *device.MemoryLayout

	// Memory holds the memory state of the application.
	Memory memory.Pools

	// APIs holds the per-API context states.
	APIs map[ID]State

	// Allocator keeps track of and reserves memory areas not used in the trace.
	Allocator memory.Allocator

	// OnResourceCreated is called when a new resource is created.
	OnResourceCreated func(Resource)

	// OnResourceAccessed is called when a resource is used.
	OnResourceAccessed func(Resource)

	// OnResourceDestroyed is called when a resource is destroyed.
	OnResourceDestroyed func(Resource)

	// OnError is called when the command does not conform to the API.
	OnError func(err interface{})

	// NewMessage is called when there is a message to be passed to a report.
	NewMessage func(level log.Severity, msg *stringtable.Msg) uint32

	// AddTag is called when we want to tag report item.
	AddTag func(msgID uint32, msg *stringtable.Msg)
}

GlobalState represents the graphics state across all contexts.

func NewStateWithAllocator

func NewStateWithAllocator(allocator memory.Allocator, memoryLayout *device.MemoryLayout) *GlobalState

NewStateWithAllocator returns a new, default-initialized State object, that uses the given memory.Allocator instance.

func NewStateWithEmptyAllocator

func NewStateWithEmptyAllocator(memoryLayout *device.MemoryLayout) *GlobalState

NewStateWithEmptyAllocator returns a new, default-initialized State object, that uses an allocator with no allocations.

func (*GlobalState) Alloc

func (s *GlobalState) Alloc(ctx context.Context, size uint64) (AllocResult, error)

Alloc allocates a memory range using the Allocator associated with the given State, and returns a AllocResult that can be used to access the pointer, and range.

func (*GlobalState) AllocData

func (s *GlobalState) AllocData(ctx context.Context, v ...interface{}) (AllocResult, error)

AllocData encodes and stores the value v to the database d, allocates a memory range big enough to store it using the Allocator associated with the given State, and returns a AllocResult that can be used to access the database ID, pointer, and range.

func (*GlobalState) AllocDataOrPanic

func (s *GlobalState) AllocDataOrPanic(ctx context.Context, v ...interface{}) AllocResult

AllocDataOrPanic is like AllocData, but panics if there's an error.

func (*GlobalState) AllocOrPanic

func (s *GlobalState) AllocOrPanic(ctx context.Context, size uint64) AllocResult

AllocOrPanic is like Alloc, but panics if there's an error.

func (GlobalState) MemoryDecoder

func (s GlobalState) MemoryDecoder(ctx context.Context, d memory.Data) *memory.Decoder

MemoryDecoder returns a memory decoder using the state's memory layout to decode data from d.

func (GlobalState) MemoryEncoder

func (s GlobalState) MemoryEncoder(p memory.PoolID, rng memory.Range) *memory.Encoder

MemoryEncoder returns a memory encoder using the state's memory layout to encode to the pool p, for the range rng.

func (GlobalState) MemoryReader

func (s GlobalState) MemoryReader(ctx context.Context, d memory.Data) binary.Reader

MemoryReader returns a binary reader using the state's memory endianness to read data from d.

func (GlobalState) MemoryWriter

func (s GlobalState) MemoryWriter(p memory.PoolID, rng memory.Range) binary.Writer

MemoryWriter returns a binary writer using the state's memory endianness to write data to the pool p, for the range rng.

func (*GlobalState) ReserveMemory

func (s *GlobalState) ReserveMemory(rngs interval.U64RangeList) *GlobalState

ReserveMemory reserves the specifed memory ranges from the state's allocator, preventing them from being allocated. ReserveMemory is a fluent helper function for calling s.Allocator.ReserveMemory(rngs).

func (GlobalState) String

func (s GlobalState) String() string

type GraphVisualizationAPI

type GraphVisualizationAPI interface {
	// GetGraphVisualizationBuilder returns a interface to GraphVisualizationBuilder
	GetGraphVisualizationBuilder() GraphVisualizationBuilder
}

GraphVisualizationAPI is the common interface for graph visualization.

type GraphVisualizationBuilder

type GraphVisualizationBuilder interface {
	// GetCommandLabel returns the Label for the command
	GetCommandLabel(command Cmd, cmdId uint64) *Label

	// GetSubCommandLabel returns the Label for the subcommand
	GetSubCommandLabel(index SubCmdIdx, commandName string, cmdId uint64, subCommandName string) *Label
}

GraphVisualizationBuilder is the common interface used to process commands from graphics API in order to get the Label for nodes in the graph visualization.

type Hierarchy

type Hierarchy struct {
	LevelsID []int
}

Hierarchy describes the levels ID of hierarchy for vulkan commands and vulkan subcommands.

func (*Hierarchy) GetID

func (h *Hierarchy) GetID(level int) int

GetID returns ID for a specific level, indexed from 1.

func (*Hierarchy) GetSize

func (h *Hierarchy) GetSize() int

GetSize returns the number of levels in Hierarchy.

func (*Hierarchy) IncreaseIDByOne

func (h *Hierarchy) IncreaseIDByOne(level int)

IncreaseIDByOne increases in one a level ID, indexed from 1.

func (*Hierarchy) PopBack

func (h *Hierarchy) PopBack()

PopBack removes the last level in Hierarchy.

func (*Hierarchy) PopBackToResize

func (h *Hierarchy) PopBackToResize(newSize int)

PopBackToResize keeps removing the back level until to get newSize levels in Hierarchy.

func (*Hierarchy) PushBackToResize

func (h *Hierarchy) PushBackToResize(newSize int)

PushBackToResize keeps adding a new level in the back until to get newSize levels in Hierarchy.

type HierarchyNames

type HierarchyNames struct {
	// BeginNameToLevel are the vulkan commands name that begin a new level.
	BeginNameToLevel map[string]int

	// EndNameToLevel are the vulkan commands name that end a new level.
	EndNameToLevel map[string]int

	// NameOfLevels are the names assigned to new levels.
	NameOfLevels []string
}

HierarchyNames describes the levels name of Hierarchy for vulkan commands and vulkan subcommands.

func (*HierarchyNames) GetName

func (hierarchyNames *HierarchyNames) GetName(level int) string

GetName returns name for a specific level, indexed from 1.

func (*HierarchyNames) PushBack

func (hierarchyNames *HierarchyNames) PushBack(beginName, endName, name string)

PushBack adds in the back a new level with beginName, endName and the name for this level.

type ID

type ID id.ID

ID is an API identifier

func (ID) CoreId

func (i ID) CoreId() id.ID

CoreId return id in gapid/core/data/id.ID type instead of api.ID type.

func (ID) IsValid

func (i ID) IsValid() bool

IsValid returns true if the id is not the default zero value.

func (ID) String

func (i ID) String() string

type Label

type Label struct {
	// LevelsName is the name for each level that node belongs
	// from top level to down level.
	LevelsName []string

	// LevelsID is the ID for each level that node belongs
	// from top level to down level.
	LevelsID []int
}

Label describes the levels of hierarchy for nodes in the graph visualization using TensorBoard which reads pbtxt format.

func (*Label) GetCommandId

func (label *Label) GetCommandId() int

GetCommandId returns the ID of the last level corresponding to the node ID.

func (*Label) GetCommandName

func (label *Label) GetCommandName() string

GetCommandName returns the name of the last level corresponding to the node name.

func (*Label) GetLabelAsAString

func (label *Label) GetLabelAsAString() string

GetLabelAsAString returns the Label as a string concatenating names and ID for each level delimited by '/'.

func (*Label) GetSize

func (label *Label) GetSize() int

GetSize returns the number of levels.

func (*Label) GetTopLevelID

func (label *Label) GetTopLevelID() int

GetTopLevelID returns the ID of the first level corresponding to the top level in hierarchy.

func (*Label) GetTopLevelName

func (label *Label) GetTopLevelName() string

GetTopLevelName returns the name of the first level corresponding to the top level in hierarchy.

func (*Label) Insert

func (label *Label) Insert(level int, name string, id int)

Insert a new level in the current Label.

func (*Label) PushBack

func (label *Label) PushBack(name string, id int)

PushBack adds a level in the back of the current Label.

func (*Label) PushBackLabel

func (label *Label) PushBackLabel(labelToPush *Label)

PushBackLabel adds a Label in the back of the current Label.

func (*Label) PushFront

func (label *Label) PushFront(name string, id int)

PushFront adds a level in the front of the current Label..

type Labeled

type Labeled interface {
	// Label returns the commands's label.
	Label(ctx context.Context, s *GlobalState) string
}

Labeled is the interface implemented commands that have a label.

type MapIndexFragment

type MapIndexFragment struct {
	MapIndex interface{}
}

MapIndexFragment is a Fragment identifying a map index. This corresponds to syntax such as `myMap["foo"]`

func (MapIndexFragment) Format

func (f MapIndexFragment) Format(s fmt.State, r rune)

type MemoryBreakdownProvider

type MemoryBreakdownProvider interface {
	// MemoryBreakdown stores an overview of the state's memory layout into
	// a MemoryBreakdown object.  The layout includes data on memory types,
	// allocations, and which resources are bound to which locations in
	// memory.
	MemoryBreakdown(*GlobalState) (*MemoryBreakdown, error)
}

MemoryBreakdown is the type implemented by APIs that can report the memory layout of their state.

type MeshProvider

type MeshProvider interface {
	// Mesh returns the mesh representation of the object o.
	Mesh(ctx context.Context, o interface{}, p *path.Mesh, r *path.ResolveConfig) (*Mesh, error)
}

MeshProvider is the interface implemented by types that provide meshes.

type MutateInitialState

type MutateInitialState func(API API) State

MutateInitialState is called from SetResourceData to get a mutable instance of the initial state.

type NilReference

type NilReference struct{}

NilReference is a type representing a nil reference where an implementation of the `Reference` interface is expected.

func (NilReference) NewFragmentMap

func (NilReference) NewFragmentMap() FragmentMap

func (NilReference) RefID

func (NilReference) RefID() RefID

type PipelineProvider

type PipelineProvider interface {
	// BoundPipeline returns the pipeline bound at object o.
	BoundPipeline(ctx context.Context, o interface{}, p *path.Pipelines, r *path.ResolveConfig) (BoundPipeline, error)
}

PipelineProvider is the interface implemented by types that provide pipelines.

type Properties

type Properties []*Property

Properties is a list of property pointers.

func (Properties) Find

func (l Properties) Find(name string) *Property

Find returns the property with the given name, or nil if no matching property is found.

type Property

type Property struct {
	// Name of the property.
	Name string
	// Type of the value.
	Type reflect.Type
	// Get gets the property value from the given object.
	Get func() interface{}
	// Set assigns the value to the property on the given object.
	// For read-only properties Set may be nil.
	Set func(value interface{})
	// Constants is the optional index of the constant set used by the value.
	// -1 represents no constant set.
	Constants int
}

Property represents a single field on an object. A Property has a getter for reading the field value, and an optional setter for assigning to the field.

func NewProperty

func NewProperty(name string, get, set interface{}) *Property

NewProperty returns a new Property using the given getter and setter functions. set may be nil in the case of a read-only property.

func (*Property) SetConstants

func (p *Property) SetConstants(idx int) *Property

SetConstants is a helper method for setting the Constants field in a fluent expression.

type PropertyProvider

type PropertyProvider interface {
	Properties() Properties
}

PropertyProvider is the interface implemented by types that provide properties.

type RecordIdx

type RecordIdx []uint64

type RefID

type RefID uint64

RefID is a type used to identify instances of the reference types used in the API models.

func NewRefID

func NewRefID() RefID

NewRefID creates a new RefID. This RefID is unique within the process.

type RefObject

type RefObject interface {
	Reference
	NewFragmentMap() FragmentMap
}

type Reference

type Reference interface {
	RefID() RefID
}

Reference is an interface which exposes a unique identifier. Reference types in the API models should implement this interface.

type ReplaceCallback

type ReplaceCallback func(where uint64, with interface{})

ReplaceCallback is called from SetResourceData to propagate changes to current command stream.

type Resource

type Resource interface {
	// ResourceHandle returns the UI identity for the resource.
	// For GL this is the GLuint object name, for Vulkan the pointer.
	ResourceHandle() string

	// ResourceLabel returns the UI name for the resource.
	ResourceLabel() string

	// Order returns an integer used to sort the resources for presentation.
	Order() uint64

	// ResourceType returns the type of this resource.
	ResourceType(ctx context.Context) path.ResourceType

	// ResourceData returns the resource data given the current state.
	ResourceData(ctx context.Context, s *GlobalState, cmd *path.Command, r *path.ResolveConfig) (*ResourceData, error)

	// SetResourceData sets resource data in a new capture.
	SetResourceData(
		ctx context.Context,
		at *path.Command,
		data *ResourceData,
		resources ResourceMap,
		edits ReplaceCallback,
		mutate MutateInitialState,
		r *path.ResolveConfig) error
}

Resource represents an asset in a capture.

type ResourceMap

type ResourceMap map[string]id.ID

ResourceMap is a map from Resource handles to Resource IDs in the database. Note this map is not time-globally valid. It is only valid at a specific point in a trace, since handles may be re-used.

type Slice

type Slice interface {
	Reset(uint64, uint64, uint64, *GlobalState, memory.PoolID)
}

type Span

type Span interface {
	// Bounds returns the absolute range of command indices for the span.
	Bounds() CmdIDRange
	// contains filtered or unexported methods
}

Span is a child of a CmdIDGroup. It is implemented by CmdIDGroup and CmdIDRange and SubCmdRoot

type SpanItem

type SpanItem interface {
	// contains filtered or unexported methods
}

SpanItem is a placeholder interface exclusively implemented by CmdIDGroup, SubCmdIdx and SubCmdRoot

type Spans

type Spans []Span

Spans is a list of Span elements. Functions in this package expect the list to be in ascending command index order, and maintain that order on mutation.

func (Spans) GetSpan

func (l Spans) GetSpan(index int) interval.U64Span

GetSpan returns the command index span for the group at index in the list.

func (*Spans) IndexOf

func (l *Spans) IndexOf(id CmdID) int

IndexOf returns the index of the group that contains the command id or -1 if not found.

func (Spans) Length

func (l Spans) Length() int

Length returns the number of groups in the list.

func (Spans) Split

func (l Spans) Split(max uint64) Spans

Split returns a new list of spans where each new span will represent no more than the given number of items.

type SparseFragmentMap

type SparseFragmentMap struct {
	Map map[Fragment]interface{}
}

func NewSparseFragmentMap

func NewSparseFragmentMap() *SparseFragmentMap

func (SparseFragmentMap) Clear

func (m SparseFragmentMap) Clear()

func (SparseFragmentMap) Delete

func (m SparseFragmentMap) Delete(f Fragment)

func (SparseFragmentMap) EmptyClone

func (m SparseFragmentMap) EmptyClone() FragmentMap

func (SparseFragmentMap) ForeachFrag

func (m SparseFragmentMap) ForeachFrag(f func(Fragment, interface{}) error) error

func (SparseFragmentMap) Get

func (m SparseFragmentMap) Get(f Fragment) (interface{}, bool)

func (*SparseFragmentMap) Set

func (m *SparseFragmentMap) Set(f Fragment, v interface{})

type State

type State interface {
	// All states belong to an API
	APIObject

	// Clone returns a deep copy of the state object.
	Clone() State

	// Root returns the path to the root of the state to display. It can vary
	// based on filtering mode. Returning nil, nil indicates there is no state
	// to show at this point in the capture.
	Root(ctx context.Context, p *path.State, r *path.ResolveConfig) (path.Node, error)

	// SetupInitialState sanitizes deserialized state to make it valid.
	// It can fill in any derived data which we choose not to serialize,
	// or it can apply backward-compatibility fixes for older traces.
	SetupInitialState(ctx context.Context, state *GlobalState)

	// TrimInitialState removes some parts of the state that are
	// not used by the capture commands.
	TrimInitialState(ctx context.Context, p *path.Capture) error
}

State represents the graphics state for a single API.

type StateWatcher

type StateWatcher interface {
	// OnBeginCmd is called at the beginning of each API call
	OnBeginCmd(ctx context.Context, cmdID CmdID, cmd Cmd)

	// OnEndCmd is called at the end of each API call
	OnEndCmd(ctx context.Context, cmdID CmdID, cmd Cmd)

	// OnBeginSubCmd is called at the beginning of each subcommand execution
	OnBeginSubCmd(ctx context.Context, subCmdIdx SubCmdIdx, recordIdx RecordIdx)

	// OnEndSubCmd is called at the end of each subcommand execution
	OnEndSubCmd(ctx context.Context)

	// OnGet is called when a fragment of state (field, map key, array index) is read
	OnReadFrag(ctx context.Context, owner RefObject, f Fragment, v RefObject, track bool)

	// OnSet is called when a fragment of state (field, map key, array index) is written
	OnWriteFrag(ctx context.Context, owner RefObject, f Fragment, old RefObject, new RefObject, tracke bool)

	// OnWriteSlice is called when writing to a slice
	OnWriteSlice(ctx context.Context, s memory.Slice)

	// OnReadSlice is called when reading from a slice
	OnReadSlice(ctx context.Context, s memory.Slice)

	// OnWriteObs is called when a memory write observations become visible
	OnWriteObs(ctx context.Context, obs []CmdObservation)

	// OnReadObs is called when a memory read observations become visible
	OnReadObs(ctx context.Context, obs []CmdObservation)

	// OpenForwardDependency is called to begin a forward dependency.
	// When `CloseForwardDependency` is called later with the same `dependencyID`,
	// a dependency is added from the current command node during the
	// `OpenForwardDependency` to the current command node during the
	// `CloseForwardDependency` call.
	// Each `OpenForwardDependency` call should have at most one matching
	// `CloseForwardDependency` call; additional `CloseForwardDependency`
	// calls with the same `dependencyID` will **not** result in additional
	// forward dependencies.
	OpenForwardDependency(ctx context.Context, dependencyID interface{})

	// CloseForwardDependency is called to end a forward dependency.
	// See `OpenForwardDependency` for an explanation of forward dependencies.
	CloseForwardDependency(ctx context.Context, dependencyID interface{})

	// DropForwardDependency is called to abandon a previously opened
	// forward dependency, without actually adding the forward dependency.
	// See `OpenForwardDependency` for an explanation of forward dependencies.
	DropForwardDependency(ctx context.Context, dependencyID interface{})

	// OnRecordSubCmd is called when a subcommand is recorded.
	OnRecordSubCmd(ctx context.Context, recordIdx RecordIdx)
}

StateWatcher provides callbacks to track state effects

type SubCmdIdx

type SubCmdIdx []uint64

SubCmdIdx is a qualified path from a particular index to a given subcommand.

func (SubCmdIdx) Contains

func (s SubCmdIdx) Contains(s2 SubCmdIdx) bool

Contains returns true if s is one of the parent nodes of s2 or equals to s2.

func (*SubCmdIdx) Decrement

func (s *SubCmdIdx) Decrement()

Decrement returns the subcommand that preceded this subcommand. Decrement will decrement its way UP subcommand chains. Eg: {0, 1}.Decrement() == {0, 0}

{1, 0}.Decrement() == {0}
{0}.Decrement() == {}

func (SubCmdIdx) Equals

func (s SubCmdIdx) Equals(s2 SubCmdIdx) bool

Equals returns true if both sets of subcommand indices are the same.

func (SubCmdIdx) LEQ

func (s SubCmdIdx) LEQ(s2 SubCmdIdx) bool

LEQ returns true if s comes before s2.

func (SubCmdIdx) LessThan

func (s SubCmdIdx) LessThan(s2 SubCmdIdx) bool

LessThan returns true if s comes before s2.

type SubCmdIdxTrie

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

SubCmdIdxTrie is a map-based trie using SubCmdIdx for indexing the data stored inside.

func (*SubCmdIdxTrie) GetChildren

func (t *SubCmdIdxTrie) GetChildren(index uint64) *SubCmdIdxTrie

func (*SubCmdIdxTrie) PostOrderSortedKeys

func (t *SubCmdIdxTrie) PostOrderSortedKeys() []SubCmdIdx

PostOrderSortedKeys returns the keys of the value stored in the trie, the keys will be sorted in the post traversal order and lesser to greater. e.g.: [0, 1, 2], [0, 2], [1], [1, 2, 3], [0, 1] will be sorted as: [0, 1, 2], [0, 1], [0, 2], [1, 2, 3], [1]

func (*SubCmdIdxTrie) RemoveValue

func (t *SubCmdIdxTrie) RemoveValue(indices SubCmdIdx) bool

RemoveValue tries to remove a value indexed by the given SubCmdIdx in the trie. If a value is found, removes it and returns true. If a value with that SubCmdIdx is not found, returns false.

func (*SubCmdIdxTrie) SetValue

func (t *SubCmdIdxTrie) SetValue(indices SubCmdIdx, v interface{})

SetValue sets a value to the trie with the given SubCmdIdx as index.

func (*SubCmdIdxTrie) Value

func (t *SubCmdIdxTrie) Value(indices SubCmdIdx) interface{}

Value returns the value stored in the trie indexed by the given SubCmdIdx. if no value is found by the given SubCmdIdx, returns nil.

func (*SubCmdIdxTrie) Values

func (t *SubCmdIdxTrie) Values(indices SubCmdIdx) []interface{}

Values returns the values stored in the trie indexed by all prefixes of the SubCmdIdx, in increasing order of length; if no value is found for a prefix, the result contains `nil` for that prefix.

type SubCmdRoot

type SubCmdRoot struct {
	Id       SubCmdIdx  // The fully qualified index of the node
	SubGroup CmdIDGroup // The range of subcommands in this range
}

SubCmdRoot is a new namespace under which subcommands live.

func NewRoot

func NewRoot(idx []uint64, nameLookUp *SubCmdIdxTrie) *SubCmdRoot

NewRoot sets up a new root object.

func (*SubCmdRoot) AddSubCmdMarkerGroups

func (c *SubCmdRoot) AddSubCmdMarkerGroups(r []uint64, groups []*CmdIDGroup, nameLookUp *SubCmdIdxTrie) error

AddSubCmdMarkerGroups adds the given groups to the target SubCmdRoot with the relative hierarchy specified in r. If the groups are not added as immediate children of the target SubCmdRoot (r is not empty), child SubCmdRoots will be created under the target SubCmdRoot recursively until the immediate parent SubCmdRoot is created.

func (*SubCmdRoot) Bounds

func (c *SubCmdRoot) Bounds() CmdIDRange

func (SubCmdRoot) Index

func (c SubCmdRoot) Index(index uint64) SpanItem

func (*SubCmdRoot) Insert

func (c *SubCmdRoot) Insert(r []uint64, nameLookUp *SubCmdIdxTrie)

Insert adds a new subcommand into the SubCmdRoot. The subcommand is specified with its relative hierarchy to the target SubCmdRoot. If the subcommand is not an immediate child of the target SubCmdRoot (i.e. len(r) > 1) , new child SubCmdRoots will be created under the target SubCmdRoot, until the immediate parent of the subcommand is created.

func (*SubCmdRoot) InsertWithFilter

func (c *SubCmdRoot) InsertWithFilter(r []uint64, nameLookUp *SubCmdIdxTrie, filter func(CmdID) bool)

type TraverseCallback

type TraverseCallback func(indices []uint64, item SpanItem) error

TraverseCallback is the function that's called for each traversed item in a group.

Directories

Path Synopsis
Package all is used to import all known api APIs for their side effects.
Package all is used to import all known api APIs for their side effects.
Package commandGenerator includes the interface and the implementation for generating commands to process.
Package commandGenerator includes the interface and the implementation for generating commands to process.
Package controlFlowGenerator contains the interface and implementations to generate a control flow to create a replay.
Package controlFlowGenerator contains the interface and implementations to generate a control flow to create a replay.
Package sync provides interfaces for managing externally synchronized APIs.
Package sync provides interfaces for managing externally synchronized APIs.
Package terminator defines the Terminator interface, for special transforms that filter out the tail of a list of commands.
Package terminator defines the Terminator interface, for special transforms that filter out the tail of a list of commands.
Package test is the integration test suite for the api compiler and templates.
Package test is the integration test suite for the api compiler and templates.
test_pb
Package test_pb describes the serialization format for the test api.
Package test_pb describes the serialization format for the test api.
Package transform contains the elements to be able to transform commands which consist of interfaces for individual transform operations and a transform chain to run all of them.
Package transform contains the elements to be able to transform commands which consist of interfaces for individual transform operations and a transform chain to run all of them.
Package vulkan implements the API interface for the Vulkan graphics library.
Package vulkan implements the API interface for the Vulkan graphics library.
vulkan_pb
Package vulkan_pb describes the serialization format for the vulkan api.
Package vulkan_pb describes the serialization format for the vulkan api.

Jump to

Keyboard shortcuts

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