Skip to content
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

Implement ShaderType for packed types #57

Open
daxpedda opened this issue Nov 17, 2023 · 2 comments
Open

Implement ShaderType for packed types #57

daxpedda opened this issue Nov 17, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@daxpedda
Copy link
Contributor

I'm hitting the issue where I want to implement ShaderType over a struct that has a [u16; 2] field, which isn't supported by Encase.

AFAIU seeing that WGSL doesn't, it makes sense. The way I make this currently work is by representing [u16; 2] as a u32 in WGSL and then unpack it into a vec2<u32>.

Is this in scope for Encase?

@daxpedda
Copy link
Contributor Author

daxpedda commented Nov 17, 2023

On that note: packed integers will probably receive more support in WGSL by things like gpuweb/gpuweb#2677.

@teoxoy
Copy link
Owner

teoxoy commented Nov 25, 2023

The problem I see with implementing ShaderType for [u16; 2] right now is that we might get an extension in the future which will enable the usage of u16 types. If that happens, the [u16; 2] could be interpreted as both a packed u32 or an array of 2 u16s.

I would recommend users create newtypes for packed scalars with their own ShaderType implementation.

encase could provide helper macros that derive those implementations and/or these newtypes directly, but the question then becomes how should those types look like/what is their API?

@teoxoy teoxoy added the enhancement New feature or request label Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants