diff --git a/cmd/gapit/export_replay.go b/cmd/gapit/export_replay.go index 51bfdbe981..ab389f88b4 100644 --- a/cmd/gapit/export_replay.go +++ b/cmd/gapit/export_replay.go @@ -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") @@ -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 { diff --git a/cmd/gapit/flags.go b/cmd/gapit/flags.go index 338aaf0b0b..11e34b58d1 100644 --- a/cmd/gapit/flags.go +++ b/cmd/gapit/flags.go @@ -35,6 +35,13 @@ const ( SimpleList ) +const ( + ExportPlain ExportMode = iota + ExportDiagnostics + ExportFrames + ExportTimestamps +) + type VideoType uint8 var videoTypeNames = map[VideoType]string{ @@ -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"` @@ -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 .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 .apk (e.g. com.example.replay.apk)"` + SdkPath string `help:"Path to Android SDK directory (default: ANDROID_SDK_HOME environment variable)"` CommandFilterFlags CaptureFileFlags } diff --git a/gapis/server/export_replay.go b/gapis/server/export_replay.go index 2ba7184a2a..4d346e9c62 100644 --- a/gapis/server/export_replay.go +++ b/gapis/server/export_replay.go @@ -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) @@ -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. diff --git a/gapis/service/service.proto b/gapis/service/service.proto index 8002915025..714ca63a65 100644 --- a/gapis/service/service.proto +++ b/gapis/service/service.proto @@ -329,6 +329,7 @@ message ExportReplayOptions { path.Report report = 1; repeated GetFramebufferAttachmentRequest get_framebuffer_attachment_requests = 2; + GetTimestampsRequest get_timestamps_request = 3; } message ExportReplayRequest {