m130 skia graphite/metal - bitmaps not showing

137 views
Skip to first unread message

Oliver Larkin

unread,
Nov 18, 2024, 6:11:15 PM11/18/24
to skia-discuss
Hello,

I've been experimenting with switching to the skia graphite backend, initially using metal. It's mostly working, and I am noticing that there is no longer.a pause on the first render which is great. Unfortunately images are no longer rendering, and I can't figure out why. 

Is there anything that changes w.r.t SkImage and graphite? I still get a valid SkImage but it doesn't get rendered.

Here is my W.I.P branch: https://github.com/iPlug2/iPlug2/tree/graphics/skia-graphite

Thanks for any tips

Oli

Greg Daniel

unread,
Nov 19, 2024, 9:19:02 AM11/19/24
to skia-d...@googlegroups.com
TextureFromImageYes, Graphite has a different model on handling of SkImages than Ganesh. Specifically, in Graphite the client has to specifically create SkImages that are GPU backed. Previously in Ganesh this was done behind the scenes if a client passed in a CPU/Bitmap/etc backed SkImage. In many ways this was convenient but it also led to hidden performance surprises to clients when they weren't expecting large uploads to happen (especially when things would move in and out of our internal cache). Now we require the client to explicitly make a graphite backend SkImage so they know there is work involved and they are responsible for keeping that SkImage alive as long as they want it.

To create a graphite backed SkImage you can simply call `SkImages::TextureFromImage` or any of the similar factory functions in `graphite/Image.h.` Additionally when making a Recorder in graphite you can pass in a RecorderOptions struct. On this struct there is a field for a ClientImageProvider. If this is provided, the Graphite backend will call a client provided callback anytime it encounters a non graphite backed SkImage. The callback will give the client an opportunity to return a new SkImage that is Graphite backend. You'll still need to use the factories mentioned above, but the ClientImageProvider callback is a way to catch cases you may have missed to make Graphite SkImages. Additionally it gives you extra information for e.g. should the SkImage be mipmapped or not based on the draw request.

One final side note, in Graphite all SkSurfaces and SkImages held by the client no longer count against Skia's internal GPU budget. Instead the client is responsible for caching them and managing the budget for them. Graphite now only considers memory it is using and allocating internally against its budget.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/skia-discuss/40b3ae3f-bd08-4a3a-b7f1-1a41292bd499n%40googlegroups.com.

Oliver Larkin

unread,
Nov 20, 2024, 5:10:43 PM11/20/24
to skia-discuss
Thanks for the advice - it was enough for me to get it working :-)

Oli



Reply all
Reply to author
Forward
0 new messages