Convert PrimitiveState::cull_mode to Option<Face>

This commit is contained in:
Zsolt Bölöny 2021-02-10 11:59:38 +01:00
parent b1b44ca78c
commit 47a45bcaad
2 changed files with 10 additions and 18 deletions

View File

@ -808,9 +808,9 @@ pub fn map_primitive_state_to_rasterizer(
wgt::PolygonMode::Point => pso::PolygonMode::Point, wgt::PolygonMode::Point => pso::PolygonMode::Point,
}, },
cull_face: match desc.cull_mode { cull_face: match desc.cull_mode {
wgt::CullMode::None => pso::Face::empty(), None => pso::Face::empty(),
wgt::CullMode::Front => pso::Face::FRONT, Some(wgt::Face::Front) => pso::Face::FRONT,
wgt::CullMode::Back => pso::Face::BACK, Some(wgt::Face::Back) => pso::Face::BACK,
}, },
front_face: match desc.front_face { front_face: match desc.front_face {
wgt::FrontFace::Ccw => pso::FrontFace::CounterClockwise, wgt::FrontFace::Ccw => pso::FrontFace::CounterClockwise,

View File

@ -819,24 +819,16 @@ impl Default for FrontFace {
} }
} }
/// Type of faces to be culled. /// Face of a vertex.
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "trace", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))] #[cfg_attr(feature = "replay", derive(Deserialize))]
pub enum CullMode { pub enum Face {
/// No faces should be culled /// Front face
None = 0, Front = 0,
/// Front faces should be culled /// Back face
Front = 1, Back = 1,
/// Back faces should be culled
Back = 2,
}
impl Default for CullMode {
fn default() -> Self {
Self::None
}
} }
/// Type of drawing mode for polygons /// Type of drawing mode for polygons
@ -876,7 +868,7 @@ pub struct PrimitiveState {
pub front_face: FrontFace, pub front_face: FrontFace,
/// The face culling mode. /// The face culling mode.
#[cfg_attr(any(feature = "trace", feature = "replay"), serde(default))] #[cfg_attr(any(feature = "trace", feature = "replay"), serde(default))]
pub cull_mode: CullMode, pub cull_mode: Option<Face>,
/// Controls the way each polygon is rasterized. Can be either `Fill` (default), `Line` or `Point` /// Controls the way each polygon is rasterized. Can be either `Fill` (default), `Line` or `Point`
/// ///
/// Setting this to something other than `Fill` requires `Features::NON_FILL_POLYGON_MODE` to be enabled. /// Setting this to something other than `Fill` requires `Features::NON_FILL_POLYGON_MODE` to be enabled.