Struct u32
field is always 0
#206
Answered
by
Firestar99
Steveplays28
asked this question in
Q&A
-
Hi, I'm trying to move this struct from the CPU to the GPU, but the Why would this occur? #[derive(Debug, Clone, Copy, Default, Pod, Zeroable)]
#[repr(C)]
pub struct Voxel {
pub position: Vec3,
pub radius: Vec3,
pub material: u32,
_padding_0: u32,
_padding_1: u32,
_padding_2: u32,
} |
Beta Was this translation helpful? Give feedback.
Answered by
Firestar99
Apr 12, 2025
Replies: 1 comment 7 replies
-
Hello! Do you have a public repo I can look at to try to debug? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
Vec3
has a different representation between the CPU (12 bytes) and GPU (16 bytes). So for now, please just useVec4
for any structs that are communicated between host and device.@LegNeato maybe we should rebase this PR, which iirc makes Vec3 be 12 bytes on the GPU as well. (I've got a different workaround in my project, basically I convert all glam Vec's to
[f32; 3]
and then layout always matches)