Questions on Skia GPU shaders

601 views
Skip to first unread message

Pavel Dey

unread,
Feb 19, 2021, 2:41:18 PM2/19/21
to skia-discuss
Hello Skia team,
I am an employee of Adobe India.
I am trying out Skia for creating effects on video. For that I am prototyping with images and exploring the capabilities of Skia. For the time being I have few generic question regarding Skia GPU shaders. Following your suggestion earlier I was able to implement a custom shader using SkRuntimeEffect. I would like to get your inputs on the following.
1. In Skia documentation it is mentioned that SkRuntimeEffect and SkRuntimeShaderBuilder API is experimental and subjected to change. So if the API changes, will it be backward compatible or will it break the existing code? What will be your plan for the Skia users?
2. Is there a way to debug Skia GPU shader code? I understand that putting breakpoint in GPU code does not make sense. But, in general what should be the debugging strategy if I want to debug a custom shader? Also, if Skia recommends some way to sniff GPU performance like utilisation etc., I would like to know that.
3. We have also explored RenderScript also, which provides similar APIs for an android platform. Though Skia is cross platform, considering performance, compatibility, stability and future support from Google, which one is recommended by Google?

Your valuable inputs will helpful for our product.

Thanks in advance
Pavel

Brian Osman

unread,
Feb 19, 2021, 3:09:09 PM2/19/21
to skia-d...@googlegroups.com
  1. At this point, some of Skia's largest clients are using SkRuntimeEffect and SkRuntimeShaderBuilder. Therefore, we have no plans to alter the API dramatically. It's still possible - all of Skia's API is subject to change. (For Google clients like Chrome and Android, we typically help migrate to newer API, and will include documentation in RELEASE_NOTES.txt). In any case, the C++ API is generally stable at this point. The same applies to the SkSL language that's accepted by SkRuntimeEffect, with some caveats:
    • To ensure that user shaders work on any device, we intentionally limit functionality to what can be supported on OpenGL ES2. At this point, that is enforced (almost) 100%. It's possible that we may need to prevent SkSL from being accepted in the future, if it's impossible to support on ES2. All major language features like this have already prevented, so I wouldn't expect anything drastic.
    • Similarly, we sometimes add new features to the SkSL language, as we find a need for them. When that happens, it's possible for new type names or identifiers to become keywords, making previously legal SkSL not parse correctly. Again - this isn't likely to be a problem unless you're using variable or function names that could collide with features from newer shading languages.
    • Whenever possible, we do strive to keep existing shaders working correctly.
  2. Skia itself doesn't have any GPU debugging facilities, but you may have good luck depending on your target platform. Various GPU debugging tools (RenderDoc, or many vendor tools from NVIDIA, Intel, Qualcomm, ARM, etc.) can be used to capture frames of an application, replay them, and sometimes step through shaders. The Skia draw calls will contain GLSL that maps very closely to the SkSL in your runtime effect (there may be other GLSL included for things like blending, other filters, etc...). For profiling, I haven't used it recently, but https://gpuinspector.dev/ should be a good Android solution. Many of the GPU vendor tools also function as GPU profilers, as well as debuggers.
  3. I can't really comment on RenderScript, and I'm probably biased, but I'd strongly recommend SkSL if your goal is to perform custom rendering in the context of an application that's already using Skia. It's well tested on a variety of devices and platforms, and ultimately compiles down to GLSL (or other language) shader code, so the final performance is only really limited by the complexity of your shader.

--
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/988dcdbd-b9ee-48af-9336-3110a1877c20n%40googlegroups.com.

--
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/988dcdbd-b9ee-48af-9336-3110a1877c20n%40googlegroups.com.

Mike Klein

unread,
Feb 19, 2021, 3:23:23 PM2/19/21
to skia-discuss
Important to note we don't speak for Google, on question 3 or really anything... these are our opinions as people who work almost entirely on Skia.  But I agree with Brian completely.

Pavel Dey

unread,
Feb 22, 2021, 10:54:10 AM2/22/21
to skia-discuss
Thank you again for the detailed response. Just to clarify little more on point 3. My goal is to prototype a standard video editor, where I should be able to apply different effects on video frames. Those can be anything from simple effects like increasing brightness to some complex effects where writing a custom shader is necessary. Right now I am dealing with custom shaders but other things will eventually come in future. However, from your inputs it looks like Skia will be a good fit for all such diverse requirements. I will explore more and seek your help if I face any issue.

Thanks and regards,
Pavel

Reply all
Reply to author
Forward
0 new messages