mirror of
https://github.com/guilhermewerner/wgpu-renderer
synced 2025-06-16 13:54:21 +00:00
Initial pipeline abstraction
This commit is contained in:
37
Source/Render/Pipeline/StencilState.rs
Normal file
37
Source/Render/Pipeline/StencilState.rs
Normal 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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user