pre double pipeline commit. The following will attempt to add another rendering stage for textured cuboids.

This commit is contained in:
zomseffen 2024-09-09 19:23:09 +02:00
parent 31d56ded3f
commit c5bcd148ca
22 changed files with 854 additions and 53 deletions

View file

@ -76,4 +76,75 @@ impl Hash for Vertex {
self.tex_coord[0].to_bits().hash(state);
self.tex_coord[1].to_bits().hash(state);
}
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct SizedVertex {
pub pos: Vec3,
pub color: Vec3,
pub tex_coord: Vec2,
pub size: Vec3,
}
impl SizedVertex {
pub const fn new(pos: Vec3, color: Vec3, tex_coord: Vec2, size: Vec3) -> Self {
Self { pos, color, tex_coord, size }
}
pub fn binding_description() -> vk::VertexInputBindingDescription {
vk::VertexInputBindingDescription::builder()
.binding(0)
.stride(size_of::<Vertex>() as u32)
.input_rate(vk::VertexInputRate::VERTEX)
.build()
}
pub fn attribute_descriptions() -> [vk::VertexInputAttributeDescription; 3] {
let pos = vk::VertexInputAttributeDescription::builder()
.binding(0)
.location(0)
.format(vk::Format::R32G32B32_SFLOAT)
.offset(0)
.build();
let color = vk::VertexInputAttributeDescription::builder()
.binding(0)
.location(1)
.format(vk::Format::R32G32B32_SFLOAT)
.offset(size_of::<Vec3>() as u32)
.build();
let tex_coord = vk::VertexInputAttributeDescription::builder()
.binding(0)
.location(2)
.format(vk::Format::R32G32_SFLOAT)
.offset((size_of::<Vec3>() + size_of::<Vec3>()) as u32)
.build();
[pos, color, tex_coord]
}
}
impl PartialEq for SizedVertex {
fn eq(&self, other: &Self) -> bool {
self.pos == other.pos
&& self.color == other.color
&& self.tex_coord == other.tex_coord
}
}
impl Eq for SizedVertex {}
impl Hash for SizedVertex {
fn hash<H: Hasher>(&self, state: &mut H) {
self.pos[0].to_bits().hash(state);
self.pos[1].to_bits().hash(state);
self.pos[2].to_bits().hash(state);
self.color[0].to_bits().hash(state);
self.color[1].to_bits().hash(state);
self.color[2].to_bits().hash(state);
self.tex_coord[0].to_bits().hash(state);
self.tex_coord[1].to_bits().hash(state);
}
}