Skip to content

Conversation

@superdump
Copy link
Contributor

For interoperability with wgsl.

This seems to work for #29 but I am not certain.

ElectronicRU and others added 4 commits May 27, 2021 07:23
Quite a bit of black magic with newtypes and additional traits,
but overall I quite like the final design.
For interoperability with wgsl.
Copy link

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this change actually isn't right. Structs must always be rounded up to their alignment, not just in a specific situation.

@superdump superdump changed the title Add *_padded_size_static rounding up to alignment Add *_padded_size_static rounding up to alignment and as_padded_* with recursive padding Jul 4, 2021
@superdump
Copy link
Contributor Author

This is now based on top of #27 as it uses its Padded infrastructure. I have added as_padded_std140() and as_padded_std430() which recursively build using the padded types. I'll continue the discussion in #29 as most of the information is over there.

What I think remains to be done:, aside from verifying that this produces correct results for AsStd140/AsStd430 derivation and whatnot, is:

  • verify this is correct
  • add tests
  • As this is no longer just std140 and std430, perhaps it should have another name than 'padded std140' etc? The motivation for me doing this is for WGSL usage.
  • add Writer support that calls .as_padded_std140() instead of .as_std140() to ensure padding is added at the end of structs and arrays before the next member

@cwfitzgerald
Copy link

There shouldn't be a need to have a separate kind of thing. The rules I explained in #29 apply to both std140 and std430, so this should just be the default.

@superdump
Copy link
Contributor Author

Making this the default in a clean way seems to be quite challenging... :/

@LPGhatguy
Copy link
Owner

Hey, I ended up reworking a big chunk of the library to solve this same issue. It should now be compatible with WebGPU/WGSL layout as well as GLSL.

Take a look, if you're still using Crevice!

I'm going to close this PR as it's fallen pretty far behind. We can revisit this idea if it's something that's important on top of the main branch.

@LPGhatguy LPGhatguy closed this Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants