-
Notifications
You must be signed in to change notification settings - Fork 935
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
Add get_compilation_info #5410
Add get_compilation_info #5410
Conversation
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.
Looking great already! Left a few comments on things to improve / check upon.
Very nicely documented api on wgpu 👍
Regarding tests: Yes plz! :). You can put them under tests/test s, maybe even part of tests/tests/shader, haven't checked if that makes sense. Would be great to have simple test cases for success, warning and error.
Also, please add a changelog entry. This is a great addition that shouldn't be missed there :)
By the way, if I run
I get the following output. Am I doing something wrong?
|
uh yeah emscripten target seems to be broken again (much worse for me on trunk actually), ignore that for now. |
I added tests for this 🎉 They're very barebones, but should be decent enough to verify that this feature isn't completely broken. Out of curiosity, do those tests need to be gpu tests? Couldn't they theoretically run with a fake GPU backend? |
most of what ci runs is actually with software rasterizers by the respective apis. You're right that for these tests we don't actually need to go to a real backend but we're lacking the necessary mocking architecture to stub out wgpu_hal out of these. |
huh, sorry for the long delay - I missed the updates on this Thanks for the improvements, looking better already. But I'm still not happy about any of the "pick first" code in here. If any of these were to remain we need a good (documented) reason each, otherwise I have to assume that we have a bug where we're accidentally hiding errors. |
I think you mean code points here. Counting code units is encoding-dependent. But beyond that terminological nitpick: surely on basic principles this should be counting UTF-8 bytes (aka UTF-8 code units) instead? That's the only way a Rust string can be indexed/sliced efficiently. If the goal is to mark spans by counting "columns", then Unicode code points do not do that either — you need to execute the Don't count code points, because there are almost no use cases where it is the correct answer. |
@kpreid Yes, my bad, I meant code points. I would, for a brief moment, have argued that counting code points makes sense, since VSCode seems to do that. Except that that's not true, since VSCode has a special case for tabs So I'm realising that it's bonkers and you absolutely have a point. And that the best possible option is outputting something that a computer can reasonably convert to whatever is most appropriate for a given case. Though at that point, one would usually directly use the For what it's worth, I did copy it from the internal naga |
Okay, I fixed a few more issues. Importantly, I moved the
I wonder if there's a simpler variation of those |
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.
Looking really good now. A few cosmetic notes that would be nice to address.
Thanks @teoxoy for the input - now that this touched Naga stuff more directly I'll wait for your additional sign-off before merge.
Could you try to avoid rebasing on the next iteration? Rebasing may look nice on the history but makes it a lot harder to incrementally review - I can't tell github to show me the changes since last time and instead have to start from scratch
@kpreid @teoxoy I looked into the linePos (column number) a bit more. I also looked into the naga The So I looked at what some tools do
So my question: May I change the |
Sounds good to me. It makes things more consistent. |
And it's ready for a (hopefully) final review. I'm glad that I got to learn a ton about wgpu internals. Thank you for all the reviews and helping me get this PR into a decent shape. <3 |
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.
all good from my side 👍
Thanks again for taking this feature on working through all these iterations! :)
uhoh, this went into 0.20 changelog but didn't get release with it |
Connections
Fix #2130
Description
This adds an async
get_compilation_info
method to thewgpu
crate, which either uses the native compilation info as reported by naga, or the compilation info that the browser's WebGPU backend reported.The general idea is to note down all the relevant info when the compilation happens, and later extract them when the user calls
get_compilation_info
Relevant bits about API design are
GPUCompilationInfo
specification, which uses UTF-16 for reporting positions.Also moved the
ShaderError
struct fromwgpu_core
tonaga
, so that it can be used by bothAny suggestions on how to simplify the code, or improve it are very appreciated. There are a few bits that feel like I'm duplicating code, or feel suboptimal.
Testing
Basic unit tests have been added.
Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
I cannot get this to run locally without a million compile errors. I clearly missed some setup part.cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.