Skip to content

Commit

Permalink
Let the vulkan early-terminator understand about MEC.
Browse files Browse the repository at this point in the history
Now that we serialize state, we have to let the early-terminator
know that is it running with extra commands. This is so that the
sync data matches the actual command list.
  • Loading branch information
AWoloszyn committed Jan 3, 2018
1 parent f5d04ae commit 29ed96e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gapis/api/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func MutationCmdsFor(ctx context.Context, c *path.Capture, data *Data, cmds []ap
terminators = append(terminators, transform.NewEarlyTerminator(api.ID()))
}
for _, t := range terminators {
if err := t.Add(ctx, id, subindex); err != nil {
if err := t.Add(ctx, 0, id, subindex); err != nil {
return nil, err
}
transforms.Add(t)
Expand Down
2 changes: 1 addition & 1 deletion gapis/api/transform/early_terminator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewEarlyTerminator(api api.ID) Terminator {
return &earlyTerminator{api: api}
}

func (t *earlyTerminator) Add(ctx context.Context, id api.CmdID, idx api.SubCmdIdx) error {
func (t *earlyTerminator) Add(ctx context.Context, extraCommands int, id api.CmdID, idx api.SubCmdIdx) error {
if id > t.lastID {
t.lastID = id
}
Expand Down
6 changes: 3 additions & 3 deletions gapis/api/transform/early_terminator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func TestEarlyTerminator(t *testing.T) {
)

transform := NewEarlyTerminator(api.ID{})
transform.Add(ctx, 20, []uint64{0})
transform.Add(ctx, 50, []uint64{})
transform.Add(ctx, 70, []uint64{1})
transform.Add(ctx, 0, 20, []uint64{0})
transform.Add(ctx, 0, 50, []uint64{})
transform.Add(ctx, 0, 70, []uint64{1})

CheckTransform(ctx, t, transform, inputs, expected)
}
2 changes: 1 addition & 1 deletion gapis/api/transform/terminator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ type Terminator interface {

// Add relaxes the termination limit to pass-through all commands before and
// including the command or subcommand.
Add(context.Context, api.CmdID, api.SubCmdIdx) error
Add(context.Context, int, api.CmdID, api.SubCmdIdx) error
}
2 changes: 1 addition & 1 deletion gapis/api/vulkan/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (a API) Replay(
}
cmdid := req.after[0] + uint64(extraCommands)
// TODO(subcommands): Add subcommand support here
if err := earlyTerminator.Add(ctx, api.CmdID(cmdid), req.after[1:]); err != nil {
if err := earlyTerminator.Add(ctx, extraCommands, api.CmdID(cmdid), req.after[1:]); err != nil {
return err
}

Expand Down
6 changes: 3 additions & 3 deletions gapis/api/vulkan/vulkan_terminator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewVulkanTerminator(ctx context.Context, capture *path.Capture) (*VulkanTer
// Add adds the command with identifier id to the set of commands that must be
// seen before the VulkanTerminator will consume all commands (excluding the EOS
// command).
func (t *VulkanTerminator) Add(ctx context.Context, id api.CmdID, subcommand api.SubCmdIdx) error {
func (t *VulkanTerminator) Add(ctx context.Context, extraCommands int, id api.CmdID, subcommand api.SubCmdIdx) error {
if len(t.requestSubIndex) != 0 {
return log.Errf(ctx, nil, "Cannot handle multiple requests when requesting a subcommand")
}
Expand All @@ -75,10 +75,10 @@ func (t *VulkanTerminator) Add(ctx context.Context, id api.CmdID, subcommand api
t.requestSubIndex = append([]uint64{uint64(id)}, subcommand...)
sc := api.SubCmdIdx(t.requestSubIndex[1:])
handled := false
if rng, ok := t.syncData.CommandRanges[id]; ok {
if rng, ok := t.syncData.CommandRanges[api.CmdID(uint64(id)-uint64(extraCommands))]; ok {
for _, k := range rng.SortedKeys() {
if !rng.Ranges[k].LessThan(sc) {
t.lastRequest = api.CmdID(k)
t.lastRequest = k + api.CmdID(extraCommands)
handled = true
break
}
Expand Down

0 comments on commit 29ed96e

Please sign in to comment.