您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

43 行
808B

  1. use crate::render::{Device, Spir};
  2. use ash::{version::DeviceV1_0, vk};
  3. use std::rc::Rc;
  4. pub struct ShaderModule {
  5. handle: vk::ShaderModule,
  6. pub device: Rc<Device>,
  7. }
  8. impl ShaderModule {
  9. pub fn create(
  10. device: Rc<Device>,
  11. spir: &Spir,
  12. ) -> Result<Rc<Self>, vk::Result> {
  13. let create_info = vk::ShaderModuleCreateInfo {
  14. code_size: spir.size,
  15. p_code: spir.code.as_ptr(),
  16. ..Default::default()
  17. };
  18. let handle = unsafe { device.create_shader_module(&create_info, None)? };
  19. Ok(Rc::new(Self { handle, device }))
  20. }
  21. }
  22. impl Drop for ShaderModule {
  23. fn drop(&mut self) {
  24. unsafe {
  25. self.device.destroy_shader_module(self.handle, None);
  26. }
  27. }
  28. }
  29. impl std::ops::Deref for ShaderModule {
  30. type Target = vk::ShaderModule;
  31. fn deref(&self) -> &Self::Target {
  32. &self.handle
  33. }
  34. }
  35. // EOF