Guidance on displaying GPU-backed images from one surface to another

295 views
Skip to first unread message

William Candillon

unread,
Apr 17, 2023, 7:24:33 AM4/17/23
to skia-d...@googlegroups.com
Hello team,

I have been working with `image = surface->makeImageSnapshot()` where
the surface is GPU-backed, and I encountered some difficulties in
displaying the image on another GPU-backed surface. So far, I have
been able to do this using `image.makeNonTextureImage()`. However, my
concern is that this approach might involve an unnecessary GPU/CPU
roundtrip. Can you please confirm if this is indeed the case and if
there is a more efficient method?

Initially, I believed that the SkImage::MakeFromAdoptedTexture API
would be suitable for this task, but it didn't seem to help.

We have two use-cases for this, one of which being the ability of
providing an efficient backbuffering method to our users.

I attempted to create an example using Skia Fiddle, but whenever I
tried to create an offscreen GPU-backed surface, the process would
time out and result in the following error: "Failed to run, possibly
violated security container: 'Command exited with exit status 1:
HOME=/tmp /usr/local/bin/fiddle_secwrap
/tmp/skia/skia/out/Static/fiddle --duration 0.000000 --frame
0.000000\nSignal: 9\nWIFSIGNALED: Success\n\nFailed to decode JSON
output from fiddle.\nunexpected end of JSON input\nOutput was ""'"

In CanvasKit, the behaviour is identical which leads me to believe
that I might be overlooking some crucial information or understanding
regarding this matter. Any insights or guidance you can provide would
be amazing.

Kind regards,

William

William Candillon

unread,
Apr 18, 2023, 10:34:42 AM4/18/23
to skia-discuss
This fiddle appear to do exactly what we would like to achieve: https://fiddle.skia.org/c/d9e552a7754062e2d2f4030bb17f1c2d
We are using on older version of Skia and assume that SkImages::MakeBackendTextureFromImage was SkImage::MakeBackendTextureFromSkImage and SkImages::BorrowTextureFrom was SkImage::MakeFromTexture. But I was unsuccessful using these methods. Does the old image->makeTextureImage method achieves the same goal? In our case the method returns the same image reference and displaying it on the other surface doesn't show anything.

Is there a way to run fiddle.skia.org with the same version of Skia than the one we are using?

Kind regards,

William

Brian Osman

unread,
Apr 25, 2023, 9:32:04 AM4/25/23
to skia-d...@googlegroups.com
1. Yes - makeNonTextureImage is going to incur a CPU roundtrip of the data, so is definitely not ideal.
2. Are your two GPU surfaces created from the same GrContext (as is the case in the fiddle?). That's generally going to be necessary for this to work. (It's possible to get it to work in other situations - eg, if you have two GL contexts in a GL share group, there are ways to get resources to work across the boundary, but Skia itself has only minimal support for that, and it tends to be brittle due to driver issues).
3. The APIs you listed do match up (everything was recently renamed, but the functionality is identical).

--
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 on the web visit https://groups.google.com/d/msgid/skia-discuss/243e8930-c4f7-443a-8cd0-bc5e7b72a963n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages