You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
950B

  1. use crate::render::DescriptorSetLayout;
  2. use ash::{version::DeviceV1_0, vk};
  3. use std::rc::Rc;
  4. pub struct PipelineLayout {
  5. handle: vk::PipelineLayout,
  6. pub descriptor: Rc<DescriptorSetLayout>,
  7. }
  8. impl PipelineLayout {
  9. pub fn create(
  10. descriptor: Rc<DescriptorSetLayout>,
  11. ) -> Result<Rc<Self>, vk::Result> {
  12. let set_layouts = [ **descriptor ];
  13. let create_info = vk::PipelineLayoutCreateInfo {
  14. set_layout_count: set_layouts.len() as u32,
  15. p_set_layouts: set_layouts.as_ptr(),
  16. ..Default::default()
  17. };
  18. let handle = unsafe {
  19. descriptor.device.create_pipeline_layout(&create_info, None)?
  20. };
  21. Ok(Rc::new(Self { handle, descriptor }))
  22. }
  23. }
  24. impl Drop for PipelineLayout {
  25. fn drop(&mut self) {
  26. unsafe {
  27. self.descriptor.device.destroy_pipeline_layout(self.handle, None);
  28. }
  29. }
  30. }
  31. impl std::ops::Deref for PipelineLayout {
  32. type Target = vk::PipelineLayout;
  33. fn deref(&self) -> &Self::Target {
  34. &self.handle
  35. }
  36. }
  37. // EOF