use std::borrow::Borrow; use std::hash::{Hash, Hasher}; use gl::types::GLint; use librashader_reflect::reflect::semantics::{MemberOffset, SemanticMap, TextureSemantics, VariableSemantics}; #[derive(Debug)] pub enum VariableLocation { Ubo(UniformLocation), Push(UniformLocation), } impl VariableLocation { pub fn location(&self) -> UniformLocation { match self { VariableLocation::Ubo(l) | VariableLocation::Push(l) => *l } } } #[derive(Debug, Copy, Clone)] pub struct UniformLocation { pub vertex: T, pub fragment: T, } impl UniformLocation { 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), Uniform(UniformLocation) } #[derive(Debug, Copy, Clone)] pub struct TextureUnit(T); #[derive(Debug, Clone, Eq, Hash, PartialEq)] pub enum UniformBinding { Parameter(String), SemanticVariable(VariableSemantics), TextureSize(SemanticMap), } impl From for UniformBinding { fn from(value: VariableSemantics) -> Self { UniformBinding::SemanticVariable(value) } } impl From> for UniformBinding { fn from(value: SemanticMap) -> Self { UniformBinding::TextureSize(value) } }