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.

40 lines
897B

  1. use crate::render::{Device, Uniforms};
  2. use ash::{version::DeviceV1_0, vk};
  3. use std::rc::Rc;
  4. pub struct DescriptorSetLayout {
  5. handle: vk::DescriptorSetLayout,
  6. pub device: Rc<Device>,
  7. }
  8. impl DescriptorSetLayout {
  9. pub fn create(device: Rc<Device>) -> Result<Rc<Self>, vk::Result> {
  10. let create_info = vk::DescriptorSetLayoutCreateInfo {
  11. binding_count: Uniforms::BIND_DESC.len() as u32,
  12. p_bindings: Uniforms::BIND_DESC.as_ptr(),
  13. ..Default::default()
  14. };
  15. let handle =
  16. unsafe { device.create_descriptor_set_layout(&create_info, None)? };
  17. Ok(Rc::new(Self { handle, device }))
  18. }
  19. }
  20. impl Drop for DescriptorSetLayout {
  21. fn drop(&mut self) {
  22. unsafe {
  23. self.device.destroy_descriptor_set_layout(self.handle, None);
  24. }
  25. }
  26. }
  27. impl std::ops::Deref for DescriptorSetLayout {
  28. type Target = vk::DescriptorSetLayout;
  29. fn deref(&self) -> &Self::Target {
  30. &self.handle
  31. }
  32. }
  33. // EOF