-
Notifications
You must be signed in to change notification settings - Fork 43
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
Import under ifdef unexpected behavior #90
Comments
This is more a bevy issue than a naga oil issue. I think building the module would work in raw naga oil without ever importing A. But in bevy for asset loading to be complete we need all possible dependents loaded, and your dependent doesn’t load successfully. The obvious workaround is to put all of A behind the same directive. |
Sorry, I don't think I understand :( |
Ah sorry I misunderstood. And you’re right, it looks like we iterate and pull used items from all possible imports (which isn’t necessary in this case since there are none). it would be a trivial fix to not try and load modules with no used items, but that would break virtual functions (no imported items would appear to be used so the module would be ignored). These might be broken anyway but I’d like to revive them if they are. So we’d instead need to get preprocessor data with defines context … which is also a bit messy because modules can add shaderdefs themselves, and we can end up in an inconsistent state. There is maybe a clean fix, but I wonder why you’re in this situation? Cant you remove the module import if it’s not valid, or fix it so it is? |
Thank you for fast responses! :) For my situation it's a little more complicated. My module is valid when correct shader defs are provided. It uses them for binding indices.
There is more information regarding my scenario in the description. And you can also check PR where I encountered this behavior bevyengine/bevy#13262 Also, right now it's not really an issue for me, I managed to bypass it by moving bindings into nested module like this https://github.com/bevyengine/bevy/pull/13262/files#diff-49ec0e7e6216fe88b72aa04b3ef5684978a425f9afbd8f09c5b1c025440c163f |
Ok that makes sense. Then you could wrap the binding declaration itself in an ifdef on the def for the binding index? I don’t think nesting achieves anything that you can’t do with a flatter structure. The other alternative is to use a consistent binding across all the bevy use points, like 99 or something. Binding indexes don’t need to be sequential. |
You are right, wrapping bindings in ifdef's should work, but it has it's own issues related to some specifics. Right now I feel like nesting is the cleanest solution. |
imported module is being validated even though it should never be imported
results in
I have a branch with this test here: https://github.com/arcashka/naga_oil/blob/failing_import_test/src/compose/test.rs#L1098
This example is silly looking because I tried to make it as minimal as possible. I found this issue when I used shader defs as an index for tonemapping lut bindings.
Conditional import
in
tonemapping_shared.wgsl
i hadwhich resulted in
when
TONEMAP_IN_SHADER
is undefinedThe text was updated successfully, but these errors were encountered: