1 // Copyright (c) 2021 The vulkano developers 2 // Licensed under the Apache License, Version 2.0 3 // <LICENSE-APACHE or 4 // https://www.apache.org/licenses/LICENSE-2.0> or the MIT 5 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, 6 // at your option. All files in the project carrying such 7 // notice may not be copied, modified, or distributed except 8 // according to those terms. 9 10 //! Subdivides primitives into smaller primitives. 11 12 use crate::pipeline::StateMode; 13 14 /// The state in a graphics pipeline describing the tessellation shader execution of a graphics 15 /// pipeline. 16 #[derive(Clone, Copy, Debug)] 17 pub struct TessellationState { 18 /// The number of patch control points to use. 19 /// 20 /// If set to `Dynamic`, the 21 /// [`extended_dynamic_state2_patch_control_points`](crate::device::Features::extended_dynamic_state2_patch_control_points) 22 /// feature must be enabled on the device. 23 pub patch_control_points: StateMode<u32>, 24 } 25 26 impl TessellationState { 27 /// Creates a new `TessellationState` with 3 patch control points. 28 #[inline] new() -> Self29 pub fn new() -> Self { 30 Self { 31 patch_control_points: StateMode::Fixed(3), 32 } 33 } 34 35 /// Sets the number of patch control points. 36 #[inline] patch_control_points(mut self, num: u32) -> Self37 pub fn patch_control_points(mut self, num: u32) -> Self { 38 self.patch_control_points = StateMode::Fixed(num); 39 self 40 } 41 42 /// Sets the number of patch control points to dynamic. 43 #[inline] patch_control_points_dynamic(mut self) -> Self44 pub fn patch_control_points_dynamic(mut self) -> Self { 45 self.patch_control_points = StateMode::Dynamic; 46 self 47 } 48 } 49 50 impl Default for TessellationState { 51 /// Returns [`TessellationState::new()`]. 52 #[inline] default() -> Self53 fn default() -> Self { 54 Self::new() 55 } 56 } 57