Crates.io | glsl-layout2 |
lib.rs | glsl-layout2 |
version | 0.5.1 |
source | src |
created_at | 2023-04-23 20:33:26.165835 |
updated_at | 2023-04-23 20:33:26.165835 |
description | Provides data types and traits to build structures ready to upload into UBO. |
homepage | |
repository | https://github.com/nazariglez/glsl-layout2 |
max_upload_size | |
id | 846818 |
size | 52,593 |
This crates provides data types and traits to build structures ready to upload into UBO.
Deriving Uniform
with proc-macro will produce associated type Std140
with same data layout as uniform blocks declared with layout(std140)
.
All members of structure that derives Uniform
must implement Uniform
as well.
Implementing Uniform
should be done via deriving.
Implementing it manually is possible.
It requires to provide associated type Std140
which must implement Std140
trait.
But trait Std140
is marked unsafe so be careful.
Trait Uniform
also requires Copy
.
Typical usage scenario is:
#[derive(Copy, Clone, Uniform)]
struct FragmentArgs {
pos: vec3,
dir: vec3,
count: uint,
}
write_to_buffer(&FragmentArgs {
pos: [0.0, 1.0, 2.0].into(),
dir: [3.0, 4.0, 5.0].into(),
count: 42,
}.std140());
There are basic data types from glsl:
bool
is already occupied)Also more complex types:
glsl-layout
is free and open source software distributed under the terms of both
the MIT License and the Apache License 2.0.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
If uniform block contains array of structures and this array accessed with dynamic index (variable instead of literal)
it may load wrong bytes for members not aligned to size of vec4
(16 bytes). In this case manual padding can be the fix.