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

36 lines
870 B
Rust
Raw Normal View History

2022-11-20 10:48:54 +11:00
use gl::types::GLint;
use librashader_reflect::reflect::semantics::BindingStage;
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_valid(&self, stage: BindingStage) -> bool {
let mut validity = false;
if stage.contains(BindingStage::FRAGMENT) {
validity = validity || self.fragment >= 0;
}
if stage.contains(BindingStage::VERTEX) {
validity = validity || self.vertex >= 0;
}
validity
2022-11-20 10:48:54 +11:00
}
}