Initial pipeline abstraction

This commit is contained in:
Werner
2021-11-23 20:09:05 -03:00
parent b23bc27f55
commit f45d465c3f
23 changed files with 943 additions and 58 deletions

View File

@ -0,0 +1,37 @@
use super::StencilFaceState;
use serde::{Deserialize, Serialize};
/// State of the stencil operation (fixed-pipeline stage).
#[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub struct StencilState {
/// Front face mode.
pub front: StencilFaceState,
/// Back face mode.
pub back: StencilFaceState,
/// Stencil values are AND'd with this mask when reading and writing from the stencil buffer. Only low 8 bits are used.
pub read_mask: u32,
/// Stencil values are AND'd with this mask when writing to the stencil buffer. Only low 8 bits are used.
pub write_mask: u32,
}
impl StencilState {
/// Returns true if the stencil test is enabled.
pub fn IsEnabled(&self) -> bool {
(self.front != StencilFaceState::IGNORE || self.back != StencilFaceState::IGNORE)
&& (self.read_mask != 0 || self.write_mask != 0)
}
/// Returns true if the state doesn't mutate the target values.
pub fn IsReadOnly(&self) -> bool {
self.write_mask == 0
}
/// Returns true if the stencil state uses the reference value for testing.
pub fn NeedsReferenceValue(&self) -> bool {
self.front.NeedsReferenceValue() || self.back.NeedsReferenceValue()
}
}