-
Notifications
You must be signed in to change notification settings - Fork 27
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
Vertex buffers #1
Comments
Vertex buffers are a bit tricky to fit into the current design since they have a couple more limitations but also offer more flexibility at the same time. Only scalars and vectors should be allowed and there are also 8 bit and 16 bit variants that get mapped automatically to 32 bit ones in the shader. I experimented with adding support for them a while ago but don't have anything concrete yet. Do note that using the existing uniform/storage buffer warpers for this might not always work since vertex buffer items are tightly packed. |
I'd personally use bytemuck (for vertex buffers) for now since there is no extra padding needed for them. |
Thanks for the explanation, will do. |
Sorry for necrobump, but is there currently a solution for index buffers? As far as I know, if you have index buffer of u16 values for example, you need to pad them correctly. Casting arbitrarily sized index array through bytemuck can fail unlike vertex buffer. Edit: Well I scrapped something for this case and it seems to work: pub fn pad_index_buffer(buffer: &[u16]) -> Vec<u16> {
let s = buffer.len() % 4;
let mut gg = buffer.to_vec();
if s > 0 {
for _ in 0..s {
gg.push(0);
}
}
gg
} |
@kaphula |
I think a significant use case (at least one that I have) is generating/modifying vertex data in a compute shader, in which case the layout must be compatible with both structs in storage buffers and the vertex attribute layout. It would be useful to support the subset of vertex attribute formats that are representable in In my own use case, I just have my own derive macro that can generate I would use the new Would it be feasible/useful to go the same route as uniform/storage compatibility checks, i.e. something like |
I am currently trying to use
encase
withwgpu
, but got a bit confused when I tried to use it for vertex buffers.As far as I could tell, the only difference between
StorageBuffer
andUniformBuffer
is thatUniformBuffer
callsassert_uniform_compat
.So if I need to make a vertex buffer, am I supposed to just use
StorageBuffer
?(worked fine so far by the way)
The text was updated successfully, but these errors were encountered: