Skip to content

Commit

Permalink
Include query_timestamps in export_replay.
Browse files Browse the repository at this point in the history
  • Loading branch information
hysw committed May 17, 2019
1 parent 72d60f9 commit bdf7f6d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
10 changes: 9 additions & 1 deletion cmd/gapit/export_replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ func (verb *exportReplayVerb) Run(ctx context.Context, flags flag.FlagSet) error
}

var fbreqs []*service.GetFramebufferAttachmentRequest
if verb.OutputFrames {
var tsreq *service.GetTimestampsRequest
switch verb.Mode {
case ExportPlain, ExportDiagnostics:
// It's the default, do nothing.
case ExportFrames:
filter, err := verb.CommandFilterFlags.commandFilter(ctx, client, capturePath)
if err != nil {
return log.Err(ctx, err, "Couldn't get filter")
Expand Down Expand Up @@ -118,10 +122,14 @@ func (verb *exportReplayVerb) Run(ctx context.Context, flags flag.FlagSet) error
Hints: nil,
})
}
case ExportTimestamps:
// There are no useful field in GetTimestampsRequest as of now.
tsreq = &service.GetTimestampsRequest{}
}

opts := &service.ExportReplayOptions{
GetFramebufferAttachmentRequests: fbreqs,
GetTimestampsRequest: tsreq,
}

if err := client.ExportReplay(ctx, capturePath, device, verb.Out, opts); err != nil {
Expand Down
33 changes: 28 additions & 5 deletions cmd/gapit/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ const (
SimpleList
)

const (
ExportPlain ExportMode = iota
ExportDiagnostics
ExportFrames
ExportTimestamps
)

type VideoType uint8

var videoTypeNames = map[VideoType]string{
Expand Down Expand Up @@ -67,6 +74,22 @@ func (v PackagesOutput) String() string {
return packagesOutputNames[v]
}

type ExportMode uint8

var exportModeNames = map[ExportMode]string{
ExportPlain: "plain",
ExportDiagnostics: "diagnostics",
ExportFrames: "frames",
ExportTimestamps: "timestamps",
}

func (v *ExportMode) Choose(c interface{}) {
*v = c.(ExportMode)
}
func (v ExportMode) String() string {
return exportModeNames[v]
}

type (
CaptureFileFlags struct {
CaptureID bool `help:"if true then interpret the capture file argument as a capture ID that is already loaded in gapis"`
Expand Down Expand Up @@ -121,11 +144,11 @@ type (
ExportReplayFlags struct {
Gapis GapisFlags
Gapir GapirFlags
OriginalDevice bool `help:"export replay for the original device"`
Out string `help:"output directory for commands and assets"`
OutputFrames bool `help:"generate trace that output frames(disable diagnostics)"`
Apk string `help:"(experimental) name of the stand-alone APK created to perform the replay. This name must be <app_package>.apk (e.g. com.example.replay.apk)"`
SdkPath string `help:"Path to Android SDK directory (default: ANDROID_SDK_HOME environment variable)"`
OriginalDevice bool `help:"export replay for the original device"`
Out string `help:"output directory for commands and assets"`
Mode ExportMode `help:"generate special purposed trace"`
Apk string `help:"(experimental) name of the stand-alone APK created to perform the replay. This name must be <app_package>.apk (e.g. com.example.replay.apk)"`
SdkPath string `help:"Path to Android SDK directory (default: ANDROID_SDK_HOME environment variable)"`
CommandFilterFlags
CaptureFileFlags
}
Expand Down
15 changes: 13 additions & 2 deletions gapis/server/export_replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func exportReplay(ctx context.Context, c *path.Capture, d *path.Device, out stri

var queries []func(mgr replay.Manager) error
switch {
case opts.Report != nil && len(opts.GetFramebufferAttachmentRequests) > 0:
return log.Errf(ctx, nil, "Report and Framebuffer requests are not compatible.")
case opts.Report != nil && len(opts.GetFramebufferAttachmentRequests) > 0 && opts.GetTimestampsRequest != nil:
return log.Errf(ctx, nil, "at most one of the request should be specified")
case opts.GetFramebufferAttachmentRequests != nil:
r := &path.ResolveConfig{ReplayDevice: d}
changes, err := resolve.FramebufferChanges(ctx, c, r)
Expand Down Expand Up @@ -100,6 +100,17 @@ func exportReplay(ctx context.Context, c *path.Capture, d *path.Device, out stri
})
}
}
case opts.GetTimestampsRequest != nil:
for _, a := range cap.APIs {
a, ok := a.(replay.QueryTimestamps)
if !ok {
continue
}
queries = append(queries, func(mgr replay.Manager) error {
_, err := a.QueryTimestamps(ctx, intent, mgr, nil)
return err
})
}
case opts.Report != nil:
// TODO(hysw): Add a simple replay request that output commands as
// captured. For now, if there are no frame query, force an issue query.
Expand Down
1 change: 1 addition & 0 deletions gapis/service/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ message ExportReplayOptions {
path.Report report = 1;
repeated GetFramebufferAttachmentRequest get_framebuffer_attachment_requests =
2;
GetTimestampsRequest get_timestamps_request = 3;
}

message ExportReplayRequest {
Expand Down

0 comments on commit bdf7f6d

Please sign in to comment.