librashader/librashader-runtime-gl/src/binding.rs

49 lines
1 KiB
Rust
Raw Normal View History

2022-11-20 10:48:54 +11:00
use gl::types::GLint;
2022-11-20 15:16:57 +11:00
use librashader_reflect::reflect::semantics::{
MemberOffset, SemanticMap, TextureSemantics, VariableSemantics,
};
use std::hash::Hash;
2022-11-20 10:48:54 +11:00
#[derive(Debug)]
pub enum VariableLocation {
Ubo(UniformLocation<GLint>),
Push(UniformLocation<GLint>),
}
impl VariableLocation {
pub fn location(&self) -> UniformLocation<GLint> {
match self {
2022-11-20 15:16:57 +11:00
VariableLocation::Ubo(l) | VariableLocation::Push(l) => *l,
2022-11-20 10:48:54 +11:00
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct UniformLocation<T> {
pub vertex: T,
pub fragment: T,
}
impl UniformLocation<GLint> {
pub fn is_fragment_valid(&self) -> bool {
self.fragment >= 0
}
pub fn is_vertex_valid(&self) -> bool {
self.vertex >= 0
}
pub fn is_valid(&self) -> bool {
self.is_fragment_valid() || self.is_vertex_valid()
}
}
#[derive(Debug, Copy, Clone)]
pub enum MemberLocation {
Offset(MemberOffset),
2022-11-20 15:16:57 +11:00
Uniform(UniformLocation<GLint>),
2022-11-20 10:48:54 +11:00
}
#[derive(Debug, Copy, Clone)]
pub struct TextureUnit<T>(T);