diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 6f7ed6d..51975ed 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -790,20 +790,33 @@ pub extern "C" fn gfxDestroyImageView( } #[inline] pub extern "C" fn gfxCreateShaderModule( - device: VkDevice, + gpu: VkDevice, pCreateInfo: *const VkShaderModuleCreateInfo, - pAllocator: *const VkAllocationCallbacks, + _pAllocator: *const VkAllocationCallbacks, pShaderModule: *mut VkShaderModule, ) -> VkResult { - unimplemented!() + let info = unsafe { &*pCreateInfo }; + let code = unsafe { + slice::from_raw_parts(info.pCode as *const u8, info.codeSize as usize) + }; + + let shader_module = gpu + .device + .create_shader_module(code) + .expect("Error creating shader module"); // TODO + + unsafe { + *pShaderModule = Handle::new(shader_module); + } + VkResult::VK_SUCCESS } #[inline] pub extern "C" fn gfxDestroyShaderModule( - device: VkDevice, + gpu: VkDevice, shaderModule: VkShaderModule, - pAllocator: *const VkAllocationCallbacks, + _pAllocator: *const VkAllocationCallbacks, ) { - unimplemented!() + gpu.device.destroy_shader_module(*shaderModule.unwrap()); } #[inline] pub extern "C" fn gfxCreatePipelineCache( diff --git a/libportability-gfx/src/lib.rs b/libportability-gfx/src/lib.rs index e0c787b..a39d42d 100644 --- a/libportability-gfx/src/lib.rs +++ b/libportability-gfx/src/lib.rs @@ -35,6 +35,7 @@ pub type VkDescriptorPool = Handle<::DescriptorPool>; pub type VkDescriptorSet = Handle<::DescriptorSet>; pub type VkSampler = Handle<::Sampler>; pub type VkBufferView = Handle<::BufferView>; +pub type VkShaderModule = Handle<::ShaderModule>; pub enum Image { Image(B::Image), @@ -540,12 +541,6 @@ pub struct VkQueryPool_T { pub type VkQueryPool = *mut VkQueryPool_T; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct VkShaderModule_T { - _unused: [u8; 0], -} -pub type VkShaderModule = *mut VkShaderModule_T; -#[repr(C)] -#[derive(Debug, Copy, Clone)] pub struct VkPipelineCache_T { _unused: [u8; 0], }