1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use vk;

/// Builder for a multisample state
///
/// Default initialized with
///
/// - sample shading: disabled
/// - rasterization samples: `vk::SAMPLE_COUNT_1_BIT`
/// - min sample shading: `1
/// - sample mask: `null`
/// - alpha to coverage: disabled
/// - alpha to one: disabled
pub struct Builder {
  pub info: vk::PipelineMultisampleStateCreateInfo,
}

impl Builder {
  pub fn raw(info: vk::PipelineMultisampleStateCreateInfo) -> Self {
    Self { info }
  }

  pub fn sample_shading_enable(mut self, enable: vk::Bool32) -> Self {
    self.info.sampleShadingEnable = enable;
    self
  }
  pub fn rasterization_samples(mut self, samples: vk::SampleCountFlagBits) -> Self {
    self.info.rasterizationSamples = samples;
    self
  }
  pub fn min_sample_shading(mut self, samples: f32) -> Self {
    self.info.minSampleShading = samples;
    self
  }
  pub fn sample_mask(mut self, mask: *const vk::SampleMask) -> Self {
    self.info.pSampleMask = mask;
    self
  }
  pub fn alpha_to_coverage_enable(mut self, enable: vk::Bool32) -> Self {
    self.info.alphaToCoverageEnable = enable;
    self
  }
  pub fn alpha_to_one_enable(mut self, enable: vk::Bool32) -> Self {
    self.info.alphaToOneEnable = enable;
    self
  }
}

impl Default for Builder {
  fn default() -> Builder {
    Builder {
      info: vk::PipelineMultisampleStateCreateInfo {
        sType: vk::STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
        pNext: std::ptr::null(),
        flags: 0,
        sampleShadingEnable: vk::FALSE,
        rasterizationSamples: vk::SAMPLE_COUNT_1_BIT,
        minSampleShading: 1.0f32,
        pSampleMask: std::ptr::null(),
        alphaToCoverageEnable: vk::FALSE,
        alphaToOneEnable: vk::FALSE,
      },
    }
  }
}