use crate::error::SarektResult;
use ultraviolet as uv;
pub unsafe trait VertexBindings {
type BVA;
type BVB;
fn get_binding_description() -> Self::BVB;
fn get_attribute_descriptions() -> Vec<Self::BVA>;
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct DefaultForwardShaderVertex {
pub position: uv::Vec3,
pub color: uv::Vec3,
pub texture_coordinates: uv::Vec2,
}
impl DefaultForwardShaderVertex {
pub fn without_uv(pos: &[f32; 3], color: &[f32; 3]) -> Self {
Self::new(pos, color, &[0.0f32, 0.0f32])
}
pub fn new_with_texture(pos: &[f32; 3], texture_coordinates: &[f32; 2]) -> Self {
Self {
position: uv::Vec3::from(pos),
color: uv::Vec3::new(1f32, 1f32, 1f32),
texture_coordinates: uv::Vec2::from(texture_coordinates),
}
}
pub fn new(pos: &[f32; 3], color: &[f32; 3], texture_coordinates: &[f32; 2]) -> Self {
Self {
position: uv::Vec3::from(pos),
color: uv::Vec3::from(color),
texture_coordinates: uv::Vec2::from(texture_coordinates),
}
}
}
pub unsafe trait DescriptorLayoutInfo {
type BackendDescriptorSetLayoutBindings;
fn get_descriptor_set_layout_bindings() -> Self::BackendDescriptorSetLayoutBindings;
fn get_bind_uniform_info() -> SarektResult<BindUniformInfo>;
fn get_bind_texture_info() -> SarektResult<BindTextureInfo>;
}
#[derive(Clone, Debug)]
pub struct BindUniformInfo {
pub offset: u64,
pub range: u64,
pub bindings: Vec<u32>,
}
pub struct BindTextureInfo {
pub bindings: Vec<u32>,
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct DefaultForwardShaderLayout {
pub mvp: uv::Mat4,
pub enable_color_mixing: u32,
pub enable_texture_mixing: u32,
}
impl DefaultForwardShaderLayout {
pub fn new(mvp: uv::Mat4, enable_color_mixing: bool, enable_texture_mixing: bool) -> Self {
Self {
mvp,
enable_color_mixing: u32::from(enable_color_mixing),
enable_texture_mixing: u32::from(enable_texture_mixing),
}
}
}
impl Default for DefaultForwardShaderLayout {
fn default() -> Self {
DefaultForwardShaderLayout {
mvp: uv::Mat4::identity(),
enable_color_mixing: 0u32,
enable_texture_mixing: 1u32,
}
}
}