Skip to content

Commit cb82762

Browse files
committed
Added a command-line option to disable replay optimization.
For gapit video and gapit screenshot, added an option that can disable replay optimization.
1 parent fe901a2 commit cb82762

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

cmd/gapit/flags.go

+2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ type (
117117
Count int `help:"number of frames after Start to capture: -1 for all frames"`
118118
Minimum int `help:"_return error when less than this number of frames is found"`
119119
}
120+
NoOpt bool `help:"disables optimization of the replay stream"`
120121
CommandFilterFlags
121122
}
122123
DumpShadersFlags struct {
@@ -228,6 +229,7 @@ type (
228229
Gapis GapisFlags
229230
Gapir GapirFlags
230231
At flags.U64Slice `help:"command/subcommand index for the screenshot. Empty for last"`
232+
NoOpt bool `help:"disables optimization of the replay stream"`
231233
}
232234
UnpackFlags struct {
233235
Verbose bool `help:"if true, then output will not be truncated"`

cmd/gapit/screenshot.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ type screenshotVerb struct{ ScreenshotFlags }
3737
func init() {
3838
verb := &screenshotVerb{
3939
ScreenshotFlags{
40-
At: flags.U64Slice{},
40+
At: flags.U64Slice{},
41+
NoOpt: false,
4142
},
4243
}
4344

@@ -77,7 +78,7 @@ func (verb *screenshotVerb) Run(ctx context.Context, flags flag.FlagSet) error {
7778

7879
command := capture.Command(verb.At[0], verb.At[1:]...)
7980

80-
if frame, err := getSingleFrame(ctx, command, device, client); err == nil {
81+
if frame, err := getSingleFrame(ctx, command, device, client, verb.NoOpt); err == nil {
8182
return verb.writeSingleFrame(flipImg(frame), "screenshot.png")
8283
} else {
8384
return err
@@ -94,12 +95,13 @@ func (verb *screenshotVerb) writeSingleFrame(frame image.Image, fn string) error
9495
return png.Encode(out, frame)
9596
}
9697

97-
func getSingleFrame(ctx context.Context, cmd *path.Command, device *path.Device, client service.Service) (*image.NRGBA, error) {
98+
func getSingleFrame(ctx context.Context, cmd *path.Command, device *path.Device, client service.Service, noOpt bool) (*image.NRGBA, error) {
9899
ctx = log.V{"cmd": cmd.Indices}.Bind(ctx)
99100
settings := &service.RenderSettings{MaxWidth: uint32(0xFFFFFFFF), MaxHeight: uint32(0xFFFFFFFF)}
100101
iip, err := client.GetFramebufferAttachment(ctx,
101102
&service.ReplaySettings{
102103
Device: device,
104+
DisableReplayOptimization: noOpt,
103105
},
104106
cmd, api.FramebufferAttachment_Color0, settings, nil)
105107
if err != nil {

cmd/gapit/sxs_video.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (verb *videoVerb) sxsVideoSource(
171171
Stride: int(v.fbo.Width) * 4,
172172
Rect: image.Rect(0, 0, int(v.fbo.Width), int(v.fbo.Height)),
173173
}
174-
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, v.command, device, client); err == nil {
174+
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, v.command, device, client, verb.NoOpt); err == nil {
175175
v.rendered = frame
176176
} else {
177177
v.renderError = err

cmd/gapit/video.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func init() {
5959
verb.FPS = 5
6060
verb.Frames.Count = allTheWay
6161
verb.Frames.Minimum = 1
62+
verb.NoOpt = false
6263
app.AddVerb(&app.Verb{
6364
Name: "video",
6465
ShortHelp: "Produce a video or sequence of frames from a .gfxtrace file",
@@ -128,7 +129,7 @@ func (verb *videoVerb) regularVideoSource(
128129
for i, e := range eofEvents {
129130
i, e := i, e
130131
executor(ctx, func(ctx context.Context) error {
131-
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, e.Command, device, client); err == nil {
132+
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, e.Command, device, client, verb.NoOpt); err == nil {
132133
rendered[i] = flipImg(frame)
133134
} else {
134135
errors[i] = err
@@ -326,11 +327,12 @@ func (verb *videoVerb) encodeVideo(ctx context.Context, filepath string, vidFun
326327
return nil
327328
}
328329

329-
func getFrame(ctx context.Context, maxWidth, maxHeight int, cmd *path.Command, device *path.Device, client service.Service) (*image.NRGBA, error) {
330+
func getFrame(ctx context.Context, maxWidth, maxHeight int, cmd *path.Command, device *path.Device, client service.Service, noOpt bool) (*image.NRGBA, error) {
330331
ctx = log.V{"cmd": cmd.Indices}.Bind(ctx)
331332
settings := &service.RenderSettings{MaxWidth: uint32(maxWidth), MaxHeight: uint32(maxHeight)}
332333
iip, err := client.GetFramebufferAttachment(ctx, &service.ReplaySettings{
333334
Device: device,
335+
DisableReplayOptimization: noOpt,
334336
}, cmd, api.FramebufferAttachment_Color0, settings, nil)
335337
if err != nil {
336338
return nil, log.Errf(ctx, err, "GetFramebufferAttachment failed at %v", cmd)

0 commit comments

Comments
 (0)