From 29ed96e540b727b5ab86d418f167e62183a068df Mon Sep 17 00:00:00 2001 From: Andrew Woloszyn Date: Tue, 2 Jan 2018 13:49:31 -0500 Subject: [PATCH] Let the vulkan early-terminator understand about MEC. 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. --- gapis/api/sync/sync.go | 2 +- gapis/api/transform/early_terminator.go | 2 +- gapis/api/transform/early_terminator_test.go | 6 +++--- gapis/api/transform/terminator.go | 2 +- gapis/api/vulkan/replay.go | 2 +- gapis/api/vulkan/vulkan_terminator.go | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gapis/api/sync/sync.go b/gapis/api/sync/sync.go index ebad4d1830..fa5667d021 100644 --- a/gapis/api/sync/sync.go +++ b/gapis/api/sync/sync.go @@ -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) diff --git a/gapis/api/transform/early_terminator.go b/gapis/api/transform/early_terminator.go index 4cc8074b01..4dd39b790a 100644 --- a/gapis/api/transform/early_terminator.go +++ b/gapis/api/transform/early_terminator.go @@ -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 } diff --git a/gapis/api/transform/early_terminator_test.go b/gapis/api/transform/early_terminator_test.go index b283e2df00..cf03aa0dc9 100644 --- a/gapis/api/transform/early_terminator_test.go +++ b/gapis/api/transform/early_terminator_test.go @@ -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) } diff --git a/gapis/api/transform/terminator.go b/gapis/api/transform/terminator.go index 14d4df4c2f..9d6b1fd1e6 100644 --- a/gapis/api/transform/terminator.go +++ b/gapis/api/transform/terminator.go @@ -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 } diff --git a/gapis/api/vulkan/replay.go b/gapis/api/vulkan/replay.go index 0570ac5aa8..d35a954e68 100644 --- a/gapis/api/vulkan/replay.go +++ b/gapis/api/vulkan/replay.go @@ -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 } diff --git a/gapis/api/vulkan/vulkan_terminator.go b/gapis/api/vulkan/vulkan_terminator.go index 4a4e6e0425..7c34417331 100644 --- a/gapis/api/vulkan/vulkan_terminator.go +++ b/gapis/api/vulkan/vulkan_terminator.go @@ -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") } @@ -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 }