-
Notifications
You must be signed in to change notification settings - Fork 318
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
Eager shader compilation #5606
Eager shader compilation #5606
Conversation
A lot of shaders are missing the cache--putting this back in draft while I look into it. |
This may be connected with one thing - when we move a shape system to a layer which did not have earlier this shape system, we might submit the shader again. I do not think that we are re-using the shaders in this situation. If this is the case, it might be good to improve it in this PR as well. |
Keziah Wesley reports a new STANDUP for today (2023-02-09): Progress: Started working on eager shader compilation. Implemented support for persistent shaders, and compiling unpaired shaders. It should be finished by 2023-02-10. Next Day: Next day I will be working on the #5606 task. Debug shader compile errors. |
I can confirm, that indeed we don't do that. |
Keziah Wesley reports a new 🔴 DELAY for the last Friday (2023-02-10): Summary: There is 4 days delay in implementation of the Eager shader compilation (#5606) task. Delay Cause: In initial estimate, I thought we had ready-to-compile shader code. Constructing the input declarations at application start will require refactoring some functionality. |
Keziah Wesley reports a new STANDUP for the last Friday (2023-02-10): Progress: Using the Shape constructors to complete the shader programs, but constructing the shapes early is having some side effect that breaks rendering. It should be finished by 2023-02-14. Next Day: Next day I will be working on the #5606 task. Debug why constructing Shapes breaks rendering. |
Keziah Wesley reports a new STANDUP for yesterday (2023-02-13): Progress: Debugging the render problem when shape constructors are run. It should be finished by 2023-02-14. Next Day: Next day I will be working on the #5606 task. Finish the PR. |
Keziah Wesley reports a new STANDUP for today (2023-02-14): Progress: Finished eager shader compilation working. It should be finished by 2023-02-14. Next Day: Next day I will be working on the #5603 task. Profile and look for frontend optimization opportunities. |
I think this is handled by the caching layer in the shader compiler driver--the same shader code won't be compiled more than once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As always, beautiful and well written code ❤️
Few additional questions:
- Does this PR enable precompiled vertex shaders?
- Is there any callback when the shaders are ready? I want to use it for spinner hiding.
#[profile(Task)] | ||
pub fn instantiate_shaders() { | ||
SHAPES_DEFINITIONS.with_borrow(|shapes| { | ||
for shape in shapes { | ||
let path = &shape.definition_path; | ||
let preload = match path { | ||
_ if path.starts_with("app/gui/view/debug_scene/") => false, | ||
_ if path.starts_with("lib/rust/ensogl/example/") => false, | ||
_ => true, | ||
}; | ||
if preload { | ||
let _shape = (shape.cons)(); | ||
} | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks super hacky to me. What about this:
- Renaming
app/gui/view/debug_scene/
toapp/gui/view/examples/
- Renaming
lib/rust/ensogl/example/
tolib/rust/ensogl/examples/
- Excluding here anything that has folder
examples
in path. - Writing that in our docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit less hacky! Implemented.
I don't think QA is applicable to this--it is tested by profiling and looking at the graph, which I have posted in the PR description above; so I'll merge as soon as I pass code owner review. |
I haven't added support for offline vertex shader optimization; however I am eagerly linking the shader programs as well as compiling, so the shaders are ready to use when needed.
The shader compiler has an |
@kazcw can you add also vertex shader recompilation? It looks like it should just work with your changes now. Just test it out, if there would be problems, we will do it in separate PR (in such a case create a task for it pls). If its doable now, let's do it. |
It was almost working. The dummy input declarations we use for shader extraction needed to be stripped. Now using fully-optimized shaders! I've also added async completion notification--you can use |
This is amazing! |
Keziah Wesley reports a new 🔴 DELAY for yesterday (2023-02-20): Summary: There is 6 days delay in implementation of the Eager shader compilation (#5606) task. Delay Cause: Review latency. |
Keziah Wesley reports a new STANDUP for yesterday (2023-02-20): Progress: Addressed review on shader compilation--added a little more functionality. It should be finished by 2023-02-20. Next Day: Next day I will be working on the #5669 task. Look in to text rendering. |
Pull Request Description
Start shader compilation eagerly, rather than wait until they are needed. Implements #5604.
Before:
![image](https://user-images.githubusercontent.com/1047859/218881942-d3f87593-1d34-4da7-ade3-d1f41c6d3989.png)
We didn't compile shaders until we needed them, causing latency before new widgets can render.
After:
![image](https://user-images.githubusercontent.com/1047859/218881967-93875426-3ce5-407e-8b0f-bc42d7f5b77b.png)
Shaders are done compiling before
project_open
finishes.Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.