skia /
skia /
ea5d3fe55baa6ae402ecab11e27d78d8426b4467 [graphite] Use true scratch resources in ScratchResourceManager
With this CL, there will be near ideal reuse of scratch resources
between Recordings from the same Recorder. Once we switch to a single
ResourceCache, all Recorders will automatically start sharing scratch
resources.
To deal with the corner case of a scratch Device's tasks getting added
to a Recorder's root task list before it's been sampled (e.g. if all
tracked devices have to be flushed for an atlas), the Device gets
instantiated by its RenderPassTask but does not have any pending read
counts. Later on, a subsequent Recording will include the draws
that actually sample from the scratch Device's target.
When there are no pending reads, the DrawTask does not attempt to
monitor and return the texture to the scratch resource manager.
Previously, it would still be instantiated via the
ScratchResourceManager even with a 0 pending read count, and the
manager would just have some textures that were marked as unavailable
when it'd be destructed.
Now that the ScratchResourceManager requests textures with the
kScratch sharing type, textures that leak between Recordings cannot
be kScratch lest some other Recording uses the same Texture and
overwrites the contents that should have been preserved.
To address this issue, RenderPassTask now detects when the scratch
device has no pending reads and explicitly requests a non-shareable
resource. In these cases the instantiation now happens entirely
outside of the ScratchResourceManager, so now there are asserts in
ScratchResourceManager that all of the textures its aware of have
been returned by the end of the snap().
Once the flushTrackedDevices() blockers are resolved, we can
consolidate back to using all scratch textures as leaks shouldn't
be possible.
Bug: b/387504956
Bug: b/389909946
Change-Id: I6082b63c5c7b69d6f3299b5227cabc07049a29d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/934956
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Nicolette Prevost <nicolettep@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
3 files changed