[naga/wgsl-out]: polyfill inverse function#6385
Conversation
0cb32f3 to
ba0b5b3
Compare
ba0b5b3 to
0c93797
Compare
|
Fixed clippy errors and applied the suggestion from @teoxoy. Will await consensus from @jimblandy before moving forward with whether to keep the flag. I don't mind either way, but the idea to have the flag stemmed from concerns in #4330 where OP seemed to have reservations about the injected polyfill being "quite long". |
jimblandy
left a comment
There was a problem hiding this comment.
Unless I'm missing something, the polyfill names all need to start with __, a double underscore. A single underscore isn't a reserved prefix (see back::wgsl::Writer::reset's call to Namer::reset), so these injected polyfills could conflict with a definition supplied by the user for _naga_inverse_blah.
7a37872 to
c4b141c
Compare
|
@jimblandy Made the emitted polyfills start with a double underscore and further namespaced them as |
|
@chyyran No, you're right, double underscore isn't something that the code that we generate can define. We should be producing WGSL that other WGSL implementations would accept. Sorry for the bad advice. I think instead you should change the polyfill names back, so they start with |
c4b141c to
8309067
Compare
|
@jimblandy dropped the changes to add the double underscore and added |
|
@chyyran it looks like the snapshots need updating. |
|
Looks like its sensitive to insertion order. I’ll switch it to use an indexset. |
8309067 to
083d7e9
Compare
Connections
MathFunction::Inversefor matrices #4330inversein GLSL appears to cause an issue when parsing resulting WGSL (wgpu v0.8.1) naga#893Description
inverseis not currently supported by WGSL and might never be. However this leaves shaders that do need these functions fundamentally incompatible with WGSL unless they get polyfilled. This PR allowswgsl-outto emit polyfills for GLSLinversefunctions.The polyfills provided are ported from an old Mesa commit, and have been pre-validated with
naga-cli.outeris not included as part of this patch as it's much more rarer thaninverse, and another approach would probably be better. For example SPIRV-Cross just expands the calculation inline.Pre-emptive support for f16 is included as well. Note that the polyfill files are intentionally not templated to reduce large allocations during shader compilation. This allows
InversePolyfillto be 2’staticpointers and no larger.Testing
Added an
inverse-polyfill.fragtest to thein/glslfolder.This test is then run to validate the changes.
Checklist
cargo fmt.cargo clippy. If applicable, add:--target wasm32-unknown-unknown--target wasm32-unknown-emscriptencargo xtask testto run tests.CHANGELOG.md. See simple instructions inside file.