Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions gapis/api/sync/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ type Data struct {
SubcommandReferences map[api.CmdID][]SubcommandReference
// SubcommandGroups represents the last Subcommand in every command buffer.
SubcommandGroups map[api.CmdID][]api.SubCmdIdx
// Hidden contains all the commands that should be hidden from the regular
// command tree as they exist as a subcommand of another command.
Hidden api.CmdIDSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray, now we can hide our recreate- calls for Mid-Execution capture.

}

// NewData creates a new clean Data object
func NewData() *Data {
s := new(Data)
s.CommandRanges = make(map[api.CmdID]ExecutionRanges)
s.SubcommandReferences = make(map[api.CmdID][]SubcommandReference)
s.SubcommandGroups = make(map[api.CmdID][]api.SubCmdIdx)
return s
return &Data{
CommandRanges: map[api.CmdID]ExecutionRanges{},
SubcommandReferences: map[api.CmdID][]SubcommandReference{},
SubcommandGroups: map[api.CmdID][]api.SubCmdIdx{},
Hidden: api.CmdIDSet{},
}
}

// Len returns the length of subcommand indices
Expand Down
6 changes: 3 additions & 3 deletions gapis/resolve/command_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (r *CommandTreeResolvable) Resolve(ctx context.Context) (interface{}, error
return nil, log.Errf(ctx, nil, "Could not find valid Synchronization Data")
}

filter, err := buildFilter(ctx, p.Capture, p.Filter)
filter, err := buildFilter(ctx, p.Capture, p.Filter, snc)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -294,7 +294,7 @@ func (r *CommandTreeResolvable) Resolve(ctx context.Context) (interface{}, error
s := c.NewState()
api.ForeachCmd(ctx, c.Commands, func(ctx context.Context, id api.CmdID, cmd api.Cmd) error {
cmd.Mutate(ctx, s, nil)
if filter(cmd, s) {
if filter(id, cmd, s) {
for _, g := range groupers {
g.process(ctx, id, cmd, s)
}
Expand Down Expand Up @@ -345,7 +345,7 @@ func (r *CommandTreeResolvable) Resolve(ctx context.Context) (interface{}, error
api.ForeachCmd(ctx, c.Commands, func(ctx context.Context, id api.CmdID, cmd api.Cmd) error {
cmd.Mutate(ctx, s, nil)

if !filter(cmd, s) {
if !filter(id, cmd, s) {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions gapis/resolve/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Events(ctx context.Context, p *path.Events) (*service.Events, error) {
return nil, err
}

filter, err := buildFilter(ctx, p.Capture, p.Filter)
filter, err := buildFilter(ctx, p.Capture, p.Filter, nil)
if err != nil {
return nil, err
}
Expand All @@ -43,7 +43,7 @@ func Events(ctx context.Context, p *path.Events) (*service.Events, error) {
cmd.Mutate(ctx, s, nil)

// TODO: Add event generation to the API files.
if !filter(cmd, s) {
if !filter(id, cmd, s) {
return nil
}
f := cmd.CmdFlags()
Expand Down
18 changes: 12 additions & 6 deletions gapis/resolve/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ import (

"github.com/google/gapid/core/data/id"
"github.com/google/gapid/gapis/api"
"github.com/google/gapid/gapis/api/sync"
"github.com/google/gapid/gapis/service/path"
)

type filter func(api.Cmd, *api.State) bool
type filter func(api.CmdID, api.Cmd, *api.State) bool

func buildFilter(ctx context.Context, p *path.Capture, f *path.CommandFilter) (filter, error) {
func buildFilter(ctx context.Context, p *path.Capture, f *path.CommandFilter, sd *sync.Data) (filter, error) {
filters := []filter{}
if sd != nil {
filters = append(filters, func(id api.CmdID, cmd api.Cmd, s *api.State) bool {
return !sd.Hidden.Contains(id)
})
}
if c := f.GetContext(); c.IsValid() {
c, err := Context(ctx, p.Context(c))
if err != nil {
Expand All @@ -36,7 +42,7 @@ func buildFilter(ctx context.Context, p *path.Capture, f *path.CommandFilter) (f
return nil, err
}
ctxID := api.ContextID(id)
filters = append(filters, func(cmd api.Cmd, s *api.State) bool {
filters = append(filters, func(id api.CmdID, cmd api.Cmd, s *api.State) bool {
if api := cmd.API(); api != nil {
if ctx := api.Context(s, cmd.Thread()); ctx != nil {
return ctx.ID() == ctxID
Expand All @@ -46,7 +52,7 @@ func buildFilter(ctx context.Context, p *path.Capture, f *path.CommandFilter) (f
})
}
if len(f.GetThreads()) > 0 {
filters = append(filters, func(cmd api.Cmd, s *api.State) bool {
filters = append(filters, func(id api.CmdID, cmd api.Cmd, s *api.State) bool {
thread := cmd.Thread()
for _, t := range f.Threads {
if t == thread {
Expand All @@ -56,9 +62,9 @@ func buildFilter(ctx context.Context, p *path.Capture, f *path.CommandFilter) (f
return false
})
}
return func(cmd api.Cmd, s *api.State) bool {
return func(id api.CmdID, cmd api.Cmd, s *api.State) bool {
for _, f := range filters {
if !f(cmd, s) {
if !f(id, cmd, s) {
return false
}
}
Expand Down
4 changes: 2 additions & 2 deletions gapis/resolve/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r *ReportResolvable) Resolve(ctx context.Context) (interface{}, error) {
return nil, err
}

filter, err := buildFilter(ctx, r.Path.Capture, r.Path.Filter)
filter, err := buildFilter(ctx, r.Path.Capture, r.Path.Filter, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func (r *ReportResolvable) Resolve(ctx context.Context) (interface{}, error) {
}
}

if filter(cmd, state) {
if filter(id, cmd, state) {
for _, item := range items {
item.Tags = append(item.Tags, getAtomNameTag(cmd))
builder.Add(ctx, item)
Expand Down