diff --git a/gapis/api/vulkan/replay.go b/gapis/api/vulkan/replay.go index 3c488056e7..38ddea55ea 100644 --- a/gapis/api/vulkan/replay.go +++ b/gapis/api/vulkan/replay.go @@ -551,7 +551,7 @@ func (a API) Replay( if opt { // If we have not set up the dependency graph, do it now. if dceInfo.ft == nil { - ft, err := dependencygraph.GetFootprint(ctx, intent.Device) + ft, err := dependencygraph.GetFootprint(ctx, intent.Capture) if err != nil { return 0, err } diff --git a/gapis/replay/builder/builder.go b/gapis/replay/builder/builder.go index 90699cf1db..968f517e21 100644 --- a/gapis/replay/builder/builder.go +++ b/gapis/replay/builder/builder.go @@ -627,6 +627,9 @@ func (b *Builder) Build(ctx context.Context) (gapir.Payload, PostDataHandler, No log.I(ctx, "Resource count: %d", len(payload.Resources)) } + // Make a copy of the reference of the finished decoder list to cut off the + // connection between the builder and furture uses of the decoders so that + // the builder do not need to be kept alive when using these decoders. decoders := b.decoders handlePost := func(pd *gapir.PostData) { // TODO: should we skip it instead of return error? @@ -652,6 +655,9 @@ func (b *Builder) Build(ctx context.Context) (gapir.Payload, PostDataHandler, No }) } + // Make a copy of the reference of the finished notification reader list to + // cut off the connection between the builder and future uses of the readers + // so that the builder do not need to be kept alive when using these readers. readers := b.notificationReaders handleNotification := func(n *gapir.Notification) { ctx = log.Enter(ctx, "NotificationHandler") diff --git a/gapis/resolve/dependencygraph/footprint.go b/gapis/resolve/dependencygraph/footprint.go index b6829cfb92..c63bdf5260 100644 --- a/gapis/resolve/dependencygraph/footprint.go +++ b/gapis/resolve/dependencygraph/footprint.go @@ -23,7 +23,6 @@ import ( "github.com/google/gapid/gapis/api" "github.com/google/gapid/gapis/capture" "github.com/google/gapid/gapis/database" - "github.com/google/gapid/gapis/replay" "github.com/google/gapid/gapis/resolve/initialcmds" "github.com/google/gapid/gapis/service/path" ) @@ -163,10 +162,9 @@ type FootprintBuilder interface { } // GetFootprint returns a pointer to the resolved Footprint. -func GetFootprint(ctx context.Context, device *path.Device) (*Footprint, error) { +func GetFootprint(ctx context.Context, c *path.Capture) (*Footprint, error) { r, err := database.Build(ctx, &FootprintResolvable{ - Capture: capture.Get(ctx), - Device: device, + Capture: c, }) if err != nil { return nil, fmt.Errorf("Counld not get execution foot print: %v", err) @@ -176,18 +174,12 @@ func GetFootprint(ctx context.Context, device *path.Device) (*Footprint, error) // Resolve implements the database.Resolver interface. func (r *FootprintResolvable) Resolve(ctx context.Context) (interface{}, error) { - ctx = capture.Put(ctx, r.Capture) - if d := r.Device; d != nil { - ctx = replay.PutDevice(ctx, d) - } - - c, err := capture.Resolve(ctx) + c, err := capture.ResolveFromPath(ctx, r.Capture) if err != nil { return nil, err } cmds := c.Commands // If the capture contains initial state, prepend the commands to build the state. - initialCmds, ranges, err := initialcmds.InitialCommands(ctx, r.Capture) if err != nil { return nil, err diff --git a/gapis/server/BUILD.bazel b/gapis/server/BUILD.bazel index f5f2c69d17..0141412606 100644 --- a/gapis/server/BUILD.bazel +++ b/gapis/server/BUILD.bazel @@ -43,6 +43,7 @@ go_library( "//gapis/replay:go_default_library", "//gapis/replay/devices:go_default_library", "//gapis/resolve:go_default_library", + "//gapis/resolve/dependencygraph:go_default_library", "//gapis/service:go_default_library", "//gapis/service/path:go_default_library", "//gapis/stringtable:go_default_library", diff --git a/gapis/server/server.go b/gapis/server/server.go index cb6645fd60..7dc8a09dd3 100644 --- a/gapis/server/server.go +++ b/gapis/server/server.go @@ -27,7 +27,9 @@ import ( "sync/atomic" "time" + "github.com/google/gapid/core/app/crash" "github.com/google/gapid/core/app/crash/reporting" + "github.com/google/gapid/core/context/keys" "github.com/google/gapid/core/app" "github.com/google/gapid/core/app/analytics" @@ -43,6 +45,7 @@ import ( "github.com/google/gapid/gapis/replay" "github.com/google/gapid/gapis/replay/devices" "github.com/google/gapid/gapis/resolve" + "github.com/google/gapid/gapis/resolve/dependencygraph" "github.com/google/gapid/gapis/service" "github.com/google/gapid/gapis/service/path" "github.com/google/gapid/gapis/stringtable" @@ -239,6 +242,14 @@ func (s *server) LoadCapture(ctx context.Context, path string) (*path.Capture, e if _, err = capture.ResolveFromPath(ctx, p); err != nil { return nil, err } + // Pre-resolve the dependency graph. + crash.Go(func() { + newCtx := keys.Clone(context.Background(), ctx) + _, err = dependencygraph.GetFootprint(newCtx, p) + if err != nil { + log.E(newCtx, "Error resolve dependency graph: %v", err) + } + }) return p, nil }