-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async Shader Compilation (KHR_parallel_shader_compile) #1474
Comments
But it is a bit more involved, there is a setting for number of threads can be used. And then it is only beneficial when instead of querying This can't be just plugged in, and will require engine to take it in account. And some behaviour development.
|
Ah yeah, completion status needs updating. However, the implementation should select a sensible number of threads, as hinted by the comment in the spec sample code:
|
Status of this extension, been merged to latest ANGLE, so on Windows we will have it soon: gpuweb/gpuweb#144 (comment) |
Since this extension been promoted to Community Approved status, it has been implemented in some browsers. So my Chrome 76, can already show it supports that extension. ImplementationBased on previous discussions, here are some thoughts of implementation:
ConsiderationsCurrently I've tested different projects, where if shader is not compiled, I just skip drawcall, this leads to some popping. Additional issues related to this:
Behaviour changeDue to skip of rendering, there is blinking (popping) now of objects when their shaders compiling.
TestsThis will include time spent on blocked shader compilation. This will be preload time, and then time spent during application working.
Looks like great results. |
Seems pretty low cost to me. Another point: there's an internal function that is still internal (i.e. not in the public API ref). https://github.com/playcanvas/engine/blob/master/src/graphics/program-library.js#L95 If you call that from the console, it'll serialize all shader definitions to a JS file. Add that generated script to your project and all your shaders will precompile. Seems that that, combined with this implementation are a perfect match. |
It's a bit more complicated. In Editor it is even another story. When frame happens, it checks if shader is compiled, if not, it might compile by the next frame. But in Editor we do not call next frame. One easy solution, is to have an internal counter, of how many shaders were encountered that are not compiled. Editor simply checks if this counter is
Here is a scenario: you have a room, and want to render cubemap from middle of it. But you need to show/hide some objects just for that cubemap render. If you do this, with async shaders, then some objects will not render, and user don't have a control over it. With those 2 things sorted, I believe it will be ready for merge. |
I've added |
Nice, sounds sensible. |
Added public property I believe it is ready to be merged. |
There is a work going on for
KHR_parallel_shader_compile
extension:Specs: https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
Chrome Issue Tracker: https://bugs.chromium.org/p/chromium/issues/detail?id=849576
It allows to send shader to compiler without locking thread and check on compilation status later on.
That will speed up shader compilation on overall as well as open ability to compile shaders without thread lockup as it is now. From benchmarks even sync compilation path have already ~50% compilation time improvement.
Would be great to think about integrating it into the Engine once available.
The text was updated successfully, but these errors were encountered: