diff --git a/gapis/api/transform/dce.go b/gapis/api/transform/dce.go index d8e2fc346c..de77c5da92 100644 --- a/gapis/api/transform/dce.go +++ b/gapis/api/transform/dce.go @@ -68,6 +68,7 @@ func (s *commandIndicesSet) contains(fci api.SubCmdIdx) bool { type DCE struct { footprint *dependencygraph.Footprint endBehaviorIndex uint64 + endCmdIndex api.CmdID requests *commandIndicesSet requestCount uint64 } @@ -90,6 +91,9 @@ func (t *DCE) Request(ctx context.Context, fci api.SubCmdIdx) { if bi > t.endBehaviorIndex { t.endBehaviorIndex = bi } + if api.CmdID(fci[0]) > t.endCmdIndex { + t.endCmdIndex = api.CmdID(fci[0]) + } } // Transform is to comform the interface of Transformer, but does not accept @@ -106,6 +110,15 @@ func (t *DCE) Transform(ctx context.Context, id api.CmdID, c api.Cmd, // the alive commands to the following transforms to mutate them and write them // to build instructions for replay. func (t *DCE) Flush(ctx context.Context, out Writer) { + if t.endBehaviorIndex >= uint64(len(t.footprint.Behaviors)) { + log.E(ctx, "DCE: Cannot backpropagate through def-use chain from behavior index: %v, "+ + "with length of behavior list: %v.", t.endBehaviorIndex, len(t.footprint.Behaviors)) + log.W(ctx, "DCE: Fallback to disable DCE.") + for i := api.CmdID(0); i <= t.endCmdIndex; i++ { + out.MutateAndWrite(ctx, i, t.footprint.Commands[int(i)]) + } + return + } t0 := dCECounter.Start() livenessBoard, aliveCmds := t.backPropagate(ctx) dCECounter.Stop(t0) diff --git a/gapis/api/vulkan/footprint_builder.go b/gapis/api/vulkan/footprint_builder.go index d112686ddf..2ce2c5f673 100644 --- a/gapis/api/vulkan/footprint_builder.go +++ b/gapis/api/vulkan/footprint_builder.go @@ -1279,7 +1279,8 @@ func (vb *FootprintBuilder) BuildFootprint(ctx context.Context, // Mutate if err := cmd.Mutate(ctx, id, s, nil); err != nil { - log.E(ctx, "Command %v %v: %v", id, cmd, err) + // Continue the footprint building without emitting errors here. It is the + // following mutate() calls' responsibility to catch the error. return } diff --git a/gapis/resolve/dependencygraph/footprint.go b/gapis/resolve/dependencygraph/footprint.go index ca1506fee4..395a67a2d9 100644 --- a/gapis/resolve/dependencygraph/footprint.go +++ b/gapis/resolve/dependencygraph/footprint.go @@ -161,7 +161,7 @@ func (f *Footprint) BehaviorIndex(ctx context.Context, if u, ok := v.(uint64); ok { return u } - log.E(ctx, "Invalid behavior index: %v is not a uint64", v) + log.E(ctx, "Invalid behavior index: %v is not a uint64. Request command index: %v", v, fci) return uint64(0) } log.E(ctx, "Cannot get behavior index for command indexed with: %v", fci) @@ -229,8 +229,10 @@ func (r *FootprintResolvable) Resolve(ctx context.Context) (interface{}, error) // side effect of the this command. if err := cmd.Mutate(ctx, id, s, nil); err != nil { bh.Aborted = true + // Continue the footprint building even if errors are found. It is + // following mutate calls, which are to build the replay + // instructions, that are responsible to catch the error. // TODO: This error should be moved to report view. - return fmt.Errorf("Command %v %v: %v", id, cmd, err) } ft.AddBehavior(ctx, bh) return nil