Skip to content

Fields of Vertex struct being reordered on new rust version results in incorrect render #616

Open
@nbvdkamp

Description

@nbvdkamp

After updating my nightly rust install my luminance application started rendering my models completely incorrectly, as if the attribute data is being garbled. On the 2022-11-11 nightly build it still works as expected so I'm quite sure rust-lang/rust#102750 being merged is what caused things to break, though I haven't bisected yet.

This is my vertex struct:

#[derive(Copy, Clone, Debug, Semantics)]
pub enum VertexSemantics {
    #[sem(name = "position", repr = "[f32; 3]", wrapper = "VertexPosition")]
    Position,
    #[sem(name = "normal", repr = "[f32; 3]", wrapper = "VertexNormal")]
    Normal,
    #[sem(name = "uv", repr = "[f32; 2]", wrapper = "VertexUV")]
    TextureCoords,
}

#[derive(Copy, Clone, Vertex)]
#[vertex(sem = "VertexSemantics")]
pub struct Vertex {
    pub position: VertexPosition,
    pub normal: VertexNormal,
    pub uv: VertexUV,
}

Adding #[repr(C)] to Vertex fixes the issue so presumably luminance makes a bad assumption somewhere about vertex struct layout being not being reordered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions