-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - use error scope to handle errors on shader module creation #3675
[Merged by Bors] - use error scope to handle errors on shader module creation #3675
Conversation
use futures_util::future::FutureExt; | ||
let error = render_device.wgpu_device().pop_error_scope(); | ||
if let Some(Some(wgpu::Error::Validation { description, .. })) = | ||
error.now_or_never() |
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.
now_or_never
will return Some
if the future is ready and None
otherwise.
On native wgpu will yield the error immediatly while on wasm it may take some time.
I used it here to not make the pipeline cache more complicated by storing and polling futures, which is IMO not worth it for this change.
7ba3a96
to
a156d1e
Compare
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.
Please update this on top of main and we can try to get it merged, unless @cart wants changes due to the additional dependency or otherwise. :)
a156d1e
to
8860540
Compare
Rebased it on main and inlined the futures-util dependency since it's just ~20 lines 8860540#diff-cc220cd7b30bdab53f07cc69085af49c438247ef41ebd0d0921d87013d74271cR544-R576 |
8860540
to
1389f05
Compare
Rebased on main again and added a comment explaining the usage of |
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 good to me. I appreciate that you removed the extra dependency!
bors r+ |
related: #3289 In addition to validating shaders early when debug assertions are enabled, use the new [error scopes](https://gpuweb.github.io/gpuweb/#error-scopes) API when creating a shader module. I chose to keep the early validation (and thereby parsing twice) when debug assertions are enabled in, because it lets as handle errors ourselves and display them with pretty colors, while the error scopes API just gives us a string we can display. This change pulls in `futures-util` as a new dependency for `future.now_or_never()`. I can inline that part of futures-lite into `bevy_render` to keep the compilation time lower if that's preferred.
…e#3675) related: bevyengine#3289 In addition to validating shaders early when debug assertions are enabled, use the new [error scopes](https://gpuweb.github.io/gpuweb/#error-scopes) API when creating a shader module. I chose to keep the early validation (and thereby parsing twice) when debug assertions are enabled in, because it lets as handle errors ourselves and display them with pretty colors, while the error scopes API just gives us a string we can display. This change pulls in `futures-util` as a new dependency for `future.now_or_never()`. I can inline that part of futures-lite into `bevy_render` to keep the compilation time lower if that's preferred.
…e#3675) related: bevyengine#3289 In addition to validating shaders early when debug assertions are enabled, use the new [error scopes](https://gpuweb.github.io/gpuweb/#error-scopes) API when creating a shader module. I chose to keep the early validation (and thereby parsing twice) when debug assertions are enabled in, because it lets as handle errors ourselves and display them with pretty colors, while the error scopes API just gives us a string we can display. This change pulls in `futures-util` as a new dependency for `future.now_or_never()`. I can inline that part of futures-lite into `bevy_render` to keep the compilation time lower if that's preferred.
related: #3289
In addition to validating shaders early when debug assertions are enabled, use the new error scopes API when creating a shader module.
I chose to keep the early validation (and thereby parsing twice) when debug assertions are enabled in, because it lets as handle errors ourselves and display them with pretty colors, while the error scopes API just gives us a string we can display.
This change pulls in
futures-util
as a new dependency forfuture.now_or_never()
. I can inline that part of futures-lite intobevy_render
to keep the compilation time lower if that's preferred.