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.
 
 
 

42 lines
808 B

use crate::render::{Device, Spir};
use ash::{version::DeviceV1_0, vk};
use std::rc::Rc;
pub struct ShaderModule {
handle: vk::ShaderModule,
pub device: Rc<Device>,
}
impl ShaderModule {
pub fn create(
device: Rc<Device>,
spir: &Spir,
) -> Result<Rc<Self>, vk::Result> {
let create_info = vk::ShaderModuleCreateInfo {
code_size: spir.size,
p_code: spir.code.as_ptr(),
..Default::default()
};
let handle = unsafe { device.create_shader_module(&create_info, None)? };
Ok(Rc::new(Self { handle, device }))
}
}
impl Drop for ShaderModule {
fn drop(&mut self) {
unsafe {
self.device.destroy_shader_module(self.handle, None);
}
}
}
impl std::ops::Deref for ShaderModule {
type Target = vk::ShaderModule;
fn deref(&self) -> &Self::Target {
&self.handle
}
}
// EOF