Skip to content

Commit

Permalink
Group transform feedbacks into groups
Browse files Browse the repository at this point in the history
Fixes: google#906
  • Loading branch information
ben-clayton committed Aug 24, 2017
1 parent 1e862f2 commit 4a00976
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 43 deletions.
2 changes: 2 additions & 0 deletions gapic/src/main/com/google/gapid/models/ApiContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public Path.CommandTree.Builder commandTree(Path.CommandTree.Builder path) {
return path
.setGroupByFrame(true)
.setGroupByDrawCall(true)
.setGroupByTransformFeedback(true)
.setGroupByUserMarkers(true)
.setAllowIncompleteFrame(true);
}
Expand All @@ -199,6 +200,7 @@ public Path.CommandTree.Builder commandTree(Path.CommandTree.Builder path) {
return path
.setGroupByFrame(true)
.setGroupByDrawCall(true)
.setGroupByTransformFeedback(true)
.setGroupByUserMarkers(true)
.setAllowIncompleteFrame(true);
}
Expand Down
4 changes: 4 additions & 0 deletions gapis/api/cmd_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type CmdFlags uint32

const (
DrawCall CmdFlags = 1 << iota
TransformFeedback
Clear
StartOfFrame
EndOfFrame
Expand All @@ -30,6 +31,9 @@ const (
// IsDrawCall returns true if the command is a draw call.
func (f CmdFlags) IsDrawCall() bool { return (f & DrawCall) != 0 }

// IsTransformFeedback returns true if the command is a transform-feedback call.
func (f CmdFlags) IsTransformFeedback() bool { return (f & TransformFeedback) != 0 }

// IsClear returns true if the command is a clear call.
func (f CmdFlags) IsClear() bool { return (f & Clear) != 0 }

Expand Down
4 changes: 2 additions & 2 deletions gapis/api/templates/api.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,8 @@

func (ϟa *{{$name}}) API() api.API { return API{} }
func (ϟa *{{$name}}) CmdFlags(ϟctx context.Context, ϟs *api.State) api.CmdFlags {
{{$names := Strings "draw_call" "clear" "frame_start" "frame_end" "user_marker" "push_user_marker" "pop_user_marker"}}
{{$flags := Strings "DrawCall" "Clear" "StartOfFrame" "EndOfFrame" "UserMarker" "PushUserMarker" "PopUserMarker"}}
{{$names := Strings "draw_call" "transform_feedback" "clear" "frame_start" "frame_end" "user_marker" "push_user_marker" "pop_user_marker"}}
{{$flags := Strings "DrawCall" "TransformFeedback" "Clear" "StartOfFrame" "EndOfFrame" "UserMarker" "PushUserMarker" "PopUserMarker"}}

var out api.CmdFlags
{{range $i, $name := $names}}
Expand Down
50 changes: 32 additions & 18 deletions gapis/resolve/command_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,26 @@ func (r *CommandTreeResolvable) Resolve(ctx context.Context) (interface{}, error

if p.GroupByDrawCall || p.GroupByFrame {
events, err := Events(ctx, &path.Events{
Capture: p.Capture,
Filter: p.Filter,
DrawCalls: true,
FirstInFrame: true,
LastInFrame: true,
Capture: p.Capture,
Filter: p.Filter,
DrawCalls: true,
TransformFeedbacks: true,
FirstInFrame: true,
LastInFrame: true,
})
if err != nil {
return nil, log.Errf(ctx, err, "Couldn't get events")
}
if p.GroupByFrame {
addFrameEvents(ctx, events, p, out, api.CmdID(len(c.Commands)))
addFrameGroups(ctx, events, p, out, api.CmdID(len(c.Commands)))
}
if p.GroupByTransformFeedback {
addFrameEventGroups(ctx, events, p, out, api.CmdID(len(c.Commands)),
service.EventKind_TransformFeedback, "Transform Feedback")
}
if p.GroupByDrawCall {
addDrawEvents(ctx, events, p, out, api.CmdID(len(c.Commands)))
addFrameEventGroups(ctx, events, p, out, api.CmdID(len(c.Commands)),
service.EventKind_DrawCall, "Draw")
}
}

Expand Down Expand Up @@ -380,13 +386,21 @@ func (r *CommandTreeResolvable) Resolve(ctx context.Context) (interface{}, error
return out, nil
}

func addDrawEvents(ctx context.Context, events *service.Events, p *path.CommandTree, t *commandTree, last api.CmdID) {
drawCount := 0
func addFrameEventGroups(
ctx context.Context,
events *service.Events,
p *path.CommandTree,
t *commandTree,
last api.CmdID,
kind service.EventKind,
prefix string) {

count := 0
for _, e := range events.List {
i := api.CmdID(e.Command.Indices[0])
switch e.Kind {
case service.EventKind_DrawCall:
// Find group which contains this draw command
case kind:
// Find group which contains this event
group := &t.root
for true {
if idx := group.Spans.IndexOf(i); idx != -1 {
Expand All @@ -399,21 +413,21 @@ func addDrawEvents(ctx context.Context, events *service.Events, p *path.CommandT
}

// Start with group of size 1 and grow it backward as long as nothing gets in the way.
drawStart := i
for drawStart >= group.Bounds().Start+1 && group.Spans.IndexOf(drawStart-1) == -1 {
drawStart--
start := i
for start >= group.Bounds().Start+1 && group.Spans.IndexOf(start-1) == -1 {
start--
}

t.root.AddGroup(drawStart, i+1, fmt.Sprintf("Draw %v", drawCount+1))
drawCount++
t.root.AddGroup(start, i+1, fmt.Sprintf("%v %v", prefix, count+1))
count++

case service.EventKind_LastInFrame:
drawCount = 0
count = 0
}
}
}

func addFrameEvents(ctx context.Context, events *service.Events, p *path.CommandTree, t *commandTree, last api.CmdID) {
func addFrameGroups(ctx context.Context, events *service.Events, p *path.CommandTree, t *commandTree, last api.CmdID) {
frameCount, frameStart, frameEnd := 0, api.CmdID(0), api.CmdID(0)
for _, e := range events.List {
i := api.CmdID(e.Command.Indices[0])
Expand Down
8 changes: 7 additions & 1 deletion gapis/resolve/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ func Events(ctx context.Context, p *path.Events) (*service.Events, error) {
Command: p.Capture.Command(uint64(id)),
})
}
if p.DrawCalls && f.IsUserMarker() {
if p.TransformFeedbacks && f.IsTransformFeedback() {
events = append(events, &service.Event{
Kind: service.EventKind_TransformFeedback,
Command: p.Capture.Command(uint64(id)),
})
}
if p.UserMarkers && f.IsUserMarker() {
events = append(events, &service.Event{
Kind: service.EventKind_UserMarker,
Command: p.Capture.Command(uint64(id)),
Expand Down
31 changes: 17 additions & 14 deletions gapis/service/path/path.proto
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,15 @@ message Events {
Capture capture = 1;
CommandFilter filter = 2;
bool draw_calls = 3;
bool first_in_frame = 4;
bool last_in_frame = 5;
bool clears = 6;
bool user_markers = 7;
bool push_user_markers = 8;
bool pop_user_markers = 9;
bool framebuffer_observations = 10;
bool all_commands = 11;
bool transform_feedbacks = 4;
bool first_in_frame = 5;
bool last_in_frame = 6;
bool clears = 7;
bool user_markers = 8;
bool push_user_markers = 9;
bool pop_user_markers = 10;
bool framebuffer_observations = 11;
bool all_commands = 12;
}

// Parameter is the path to a single parameter on a command.
Expand Down Expand Up @@ -229,22 +230,24 @@ message CommandTree {
bool group_by_thread = 5;
// If true then commands will be grouped by draw calls.
bool group_by_draw_call = 6;
// If true then commands will be grouped by transform feedback calls.
bool group_by_transform_feedback = 7;
// If true then commands will be grouped by frame.
bool group_by_frame = 7;
bool group_by_frame = 8;
// If true then commands will be grouped by user markers.
bool group_by_user_markers = 8;
bool group_by_user_markers = 9;
// If true and grouping by context, 'no context' groups will be created.
bool include_no_context_groups = 9;
bool include_no_context_groups = 10;
// If true and grouping by frames, commands after the last frame will be
// grouped into an 'incomplete frame' group. Only if there is at least one
// complete frame.
bool allow_incomplete_frame = 10;
bool allow_incomplete_frame = 11;
// If positive, synthetic sub-nodes are created for nodes with more than
// this many children.
int32 max_children = 11;
int32 max_children = 12;
// If positive, synthetic sub-nodes are created for long spans of commands
// between groups. This ensures the groups do not get lost in the noise.
int32 max_neighbours = 12;
int32 max_neighbours = 13;
}

// CommandTreeNode is a path to a command tree node.
Expand Down
17 changes: 9 additions & 8 deletions gapis/service/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -652,16 +652,17 @@ message Event {
enum EventKind {
Unknown = 0;
DrawCall = 1;
FirstInFrame = 2;
LastInFrame = 3;
Clear = 4;
UserMarker = 5;
PushUserMarker = 6;
PopUserMarker = 7;
FramebufferObservation = 8;
TransformFeedback = 2;
FirstInFrame = 3;
LastInFrame = 4;
Clear = 5;
UserMarker = 6;
PushUserMarker = 7;
PopUserMarker = 8;
FramebufferObservation = 9;
// Note you probably only want to use AllCommands for debugging/testing
// purposes.
AllCommands = 9;
AllCommands = 10;
}

// StateTree represents a state tree hierarchy.
Expand Down

0 comments on commit 4a00976

Please sign in to comment.