Skip to content

Commit

Permalink
gvr: Don't put extra Draw groups inside the reprojection context.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-clayton committed Sep 14, 2017
1 parent 2338435 commit 447eead
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
23 changes: 19 additions & 4 deletions gapis/api/gvr/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,40 @@ func newReprojectionGroupers(ctx context.Context, p *path.CommandTree) []cmdgrou
}
}
return []cmdgrouper.Grouper{
cmdgrouper.Sequence("Left eye",
noSubFrameEventGrouper{cmdgrouper.Sequence("Left eye",
cmdgrouper.Rule{Pred: eglDestroySyncKHR()},
cmdgrouper.Rule{Pred: glClientWaitSync()},
cmdgrouper.Rule{Pred: glDeleteSync()},
cmdgrouper.Rule{Pred: notGlDrawElements(), Repeats: true},
cmdgrouper.Rule{Pred: glDrawElements()},
),
cmdgrouper.Sequence("Right eye",
)},
noSubFrameEventGrouper{cmdgrouper.Sequence("Right eye",
cmdgrouper.Rule{Pred: glFenceSync(gles.GLenum_GL_SYNC_GPU_COMMANDS_COMPLETE)},
cmdgrouper.Rule{Pred: glEndTilingQCOM(1), Optional: true},
cmdgrouper.Rule{Pred: glClientWaitSync()},
cmdgrouper.Rule{Pred: glDeleteSync()},
cmdgrouper.Rule{Pred: notGlDrawElements(), Repeats: true},
cmdgrouper.Rule{Pred: glDrawElements()},
cmdgrouper.Rule{Pred: notGlFlush(), Repeats: true},
),
)},
}
}

type noSubFrameEventGrouper struct {
cmdgrouper.Grouper
}

func (n noSubFrameEventGrouper) Build(end api.CmdID) []cmdgrouper.Group {
out := n.Grouper.Build(end)
for i := range out {
out[i].UserData = &resolve.CmdGroupData{
Thumbnail: api.CmdNoID,
NoFrameEventGroups: true,
}
}
return out
}

func newReprojectionEvents(ctx context.Context, p *path.Events) extensions.EventProvider {
if !isReprojectionContext(ctx, p.Capture.Context(p.GetFilter().GetContext().ID())) {
return nil
Expand Down
11 changes: 6 additions & 5 deletions gapis/resolve/cmdgrouper/cmdgrouper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (

// Group is the product of a Grouper.
type Group struct {
Start api.CmdID
End api.CmdID
Name string
Start api.CmdID
End api.CmdID
Name string
UserData interface{}
}

// Grouper is the interface implemented by types that build groups.
Expand Down Expand Up @@ -60,7 +61,7 @@ func (g *run) Process(ctx context.Context, id api.CmdID, cmd api.Cmd, s *api.Sta
val, name := g.f(cmd, s)
if val != g.current {
if g.current != nil {
g.out = append(g.out, Group{g.start, id, g.name})
g.out = append(g.out, Group{g.start, id, g.name, nil})
}
g.start = id
}
Expand All @@ -69,7 +70,7 @@ func (g *run) Process(ctx context.Context, id api.CmdID, cmd api.Cmd, s *api.Sta

func (g *run) Build(end api.CmdID) []Group {
if g.current != nil && g.start != end {
g.out = append(g.out, Group{g.start, end, g.name})
g.out = append(g.out, Group{g.start, end, g.name, nil})
}
out := g.out
g.out, g.start, g.current, g.name = nil, 0, nil, ""
Expand Down
23 changes: 16 additions & 7 deletions gapis/resolve/command_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ import (
"github.com/google/gapid/gapis/service/path"
)

type CommandTreeNodeUserData struct {
// CmdGroupData is the additional metadata assigned to api.CmdIDGroups UserData
// field.
type CmdGroupData struct {
Thumbnail api.CmdID
// If true, then children frame event groups should not be added to this group.
NoFrameEventGroups bool
}

// CommandTree resolves the specified command tree path.
Expand Down Expand Up @@ -245,7 +249,9 @@ func (r *CommandTreeResolvable) Resolve(ctx context.Context) (interface{}, error
}
for _, g := range groupers {
for _, l := range g.Build(api.CmdID(len(c.Commands))) {
out.root.AddGroup(l.Start, l.End, l.Name)
if group, err := out.root.AddGroup(l.Start, l.End, l.Name); err == nil {
group.UserData = l.UserData
}
}
}

Expand Down Expand Up @@ -298,7 +304,6 @@ func (r *CommandTreeResolvable) Resolve(ctx context.Context) (interface{}, error
markers := snc.SubCommandMarkerGroups.Value(append([]uint64{uint64(id)}, x[0:len(x)-1]...)).([]*api.CmdIDGroup)
r.AddSubCmdMarkerGroups(x[0:len(x)-1], markers)
}
// r.Insert([]uint64{uint64(id)}, append([]uint64{}, x...))
r.Insert(append([]uint64{}, x...))
}
return nil
Expand Down Expand Up @@ -349,6 +354,10 @@ func addFrameEventGroups(
break
}

if data, ok := group.UserData.(*CmdGroupData); ok && data.NoFrameEventGroups {
continue
}

// Start with group of size 1 and grow it backward as long as nothing gets in the way.
start := i
for start >= group.Bounds().Start+1 && group.Spans.IndexOf(start-1) == -1 {
Expand Down Expand Up @@ -400,7 +409,7 @@ func addFrameGroups(ctx context.Context, events *service.Events, p *path.Command

group, _ := t.root.AddGroup(frameStart, frameEnd+1, fmt.Sprintf("Frame %v", frameCount))
if group != nil {
group.UserData = &CommandTreeNodeUserData{Thumbnail: i}
group.UserData = &CmdGroupData{Thumbnail: i}
}
}
}
Expand All @@ -410,15 +419,15 @@ func addFrameGroups(ctx context.Context, events *service.Events, p *path.Command
}

func setThumbnails(ctx context.Context, g *api.CmdIDGroup, drawOrClearCmds api.Spans) {
data, _ := g.UserData.(*CommandTreeNodeUserData)
data, _ := g.UserData.(*CmdGroupData)
if data == nil {
data = &CommandTreeNodeUserData{Thumbnail: api.CmdNoID}
data = &CmdGroupData{Thumbnail: api.CmdNoID}
g.UserData = data
}
if data.Thumbnail == api.CmdNoID {
if s, c := interval.Intersect(drawOrClearCmds, g.Bounds().Span()); c > 0 {
thumbnail := drawOrClearCmds[s+c-1].Bounds().Start
g.UserData = &CommandTreeNodeUserData{Thumbnail: thumbnail}
data.Thumbnail = thumbnail
}
}

Expand Down
2 changes: 1 addition & 1 deletion gapis/resolve/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func CommandTreeNodeThumbnail(ctx context.Context, w, h uint32, f *image.Format,
switch item := cmdTree.index(p.Indices).(type) {
case api.CmdIDGroup:
thumbnail := item.Range.Last()
if userData, ok := item.UserData.(*CommandTreeNodeUserData); ok {
if userData, ok := item.UserData.(*CmdGroupData); ok {
if userData.Thumbnail != api.CmdNoID {
thumbnail = userData.Thumbnail
}
Expand Down

0 comments on commit 447eead

Please sign in to comment.