pub fn new<Name>(
        device: &Arc<Device>,
        name: Name,
        source: &'static [u8],
    ) -> Result<Self>
    where
        Name: Into<String>,
    {
        let source_u32 = ffi::copy_to_u32(source);
        let create_info = vk::ShaderModuleCreateInfo {
            p_code: source_u32.as_ptr(),
            code_size: source_u32.len() * std::mem::size_of::<u32>(),
            ..Default::default()
        };

        let shader_module = unsafe {
            device
                .logical_device
                .create_shader_module(&create_info, None)
                .context("unable to create shader module")?
        };

        device.name_vulkan_object(
            name,
            vk::ObjectType::SHADER_MODULE,
            &shader_module,
        )?;

        Ok(Self {
            shader_module,
            device: device.clone(),
        })
    }
/// Create a new shader module using the provided source.
///
/// Panics if the source array is not divisible evenly into u32 words.
Create a new shader module using the provided source.
Panics if the source array is not divisible evenly into u32 words.
Create a new shader module using the provided source . Panics if the source array is not divisible evenly into u32 words .
pub fn new<Name>(
        device: &Arc<Device>,
        name: Name,
        source: &'static [u8],
    ) -> Result<Self>
    where
        Name: Into<String>,
    {
        let source_u32 = ffi::copy_to_u32(source);
        let create_info = vk::ShaderModuleCreateInfo {
            p_code: source_u32.as_ptr(),
            code_size: source_u32.len() * std::mem::size_of::<u32>(),
            ..Default::default()
        };
        let shader_module = unsafe {
            device
                .logical_device
                .create_shader_module(&create_info, None)
                .context("unable to create shader module")?
        };
        device.name_vulkan_object(
            name,
            vk::ObjectType::SHADER_MODULE,
            &shader_module,
        )?;
        Ok(Self {
            shader_module,
            device: device.clone(),
        })
    }
pub fn new < Name > ( device : & Arc < Device > , name : Name , source : & ' static [ u8 ] , ) -> Result < Self > where Name : Into < String > , { let source_u32 = ffi :: copy_to_u32 ( source ) ; let create_info = vk :: ShaderModuleCreateInfo { p_code : source_u32 . as_ptr ( ) , code_size : source_u32 . len ( ) * std :: mem :: size_of :: < u32 > ( ) , .. Default :: default ( ) } ; let shader_module = unsafe { device . logical_device . create_shader_module ( & create_info , None ) . context ( " " ) ? } ; device . name_vulkan_object ( name , vk :: ObjectType :: SHADER_MODULE , & shader_module , ) ? ; Ok ( Self { shader_module , device : device . clone ( ) , } ) }
Create a new shader module using the provided source.
Create a new shader module using the provided source .
device
&Arc<Device>
name
Name
source
&'static [u8]