2022-11-20 10:48:54 +11:00
|
|
|
use gl::types::GLint;
|
2022-11-28 15:27:21 +11:00
|
|
|
use librashader_reflect::reflect::semantics::{BindingStage, MemberOffset};
|
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> {
|
2022-11-28 15:27:21 +11:00
|
|
|
// 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, 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
|
|
|
}
|
|
|
|
}
|