Fix checking of power of 2 for scratch buffer caching.
A long time ago we use to make all scratch buffers be a power of 2
size. So when we went to add a scratch key to a buffer resource we
only added one if the size was a pow2 since otherwise we'd never
attempt to search for it. At some point to improve wasted space, we
added "midpoint" buckets between two pow2 values to the scratch
buffer creation. However, we did not update this scratch check. So a
client who was trying to upload a large cpu image every frame that
happened to need a transfer buffer of size that ended up at a
midpoint, would never get reuse of the xfer buffer and we would just
keep creating and deleting them every frame.
I don't think we need to do anything smarter in regards to checking
the size in this key call. Just not checking is fine because searching
the Ganesh code it looks like all dynamic buffers are always created
going through the resource cache which will make them one of our
"cachable" sizes. And Ganesh is pretty stable at this point. Even
still worst case if I missed a usage outside of the ResourceProvider
is that the buffer sits in our cache not being used until we're over
budget or gets purged for not being used in a long time.
Bug: b/298029730
Change-Id: Iaef70c620ace2fb6cc1ebeefe331056ae2453bd9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/771036
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
1 file changed