Implement vkCreateShaderModule and vkDestroyShaderModule

This commit is contained in:
msiglreith 2018-01-07 16:16:22 +01:00
parent a3a7f1f552
commit fb6d185e5f
2 changed files with 20 additions and 12 deletions

View file

@ -790,20 +790,33 @@ pub extern "C" fn gfxDestroyImageView(
} }
#[inline] #[inline]
pub extern "C" fn gfxCreateShaderModule( pub extern "C" fn gfxCreateShaderModule(
device: VkDevice, gpu: VkDevice,
pCreateInfo: *const VkShaderModuleCreateInfo, pCreateInfo: *const VkShaderModuleCreateInfo,
pAllocator: *const VkAllocationCallbacks, _pAllocator: *const VkAllocationCallbacks,
pShaderModule: *mut VkShaderModule, pShaderModule: *mut VkShaderModule,
) -> VkResult { ) -> 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] #[inline]
pub extern "C" fn gfxDestroyShaderModule( pub extern "C" fn gfxDestroyShaderModule(
device: VkDevice, gpu: VkDevice,
shaderModule: VkShaderModule, shaderModule: VkShaderModule,
pAllocator: *const VkAllocationCallbacks, _pAllocator: *const VkAllocationCallbacks,
) { ) {
unimplemented!() gpu.device.destroy_shader_module(*shaderModule.unwrap());
} }
#[inline] #[inline]
pub extern "C" fn gfxCreatePipelineCache( pub extern "C" fn gfxCreatePipelineCache(

View file

@ -35,6 +35,7 @@ pub type VkDescriptorPool = Handle<<B as hal::Backend>::DescriptorPool>;
pub type VkDescriptorSet = Handle<<B as hal::Backend>::DescriptorSet>; pub type VkDescriptorSet = Handle<<B as hal::Backend>::DescriptorSet>;
pub type VkSampler = Handle<<B as hal::Backend>::Sampler>; pub type VkSampler = Handle<<B as hal::Backend>::Sampler>;
pub type VkBufferView = Handle<<B as hal::Backend>::BufferView>; pub type VkBufferView = Handle<<B as hal::Backend>::BufferView>;
pub type VkShaderModule = Handle<<B as hal::Backend>::ShaderModule>;
pub enum Image<B: hal::Backend> { pub enum Image<B: hal::Backend> {
Image(B::Image), Image(B::Image),
@ -540,12 +541,6 @@ pub struct VkQueryPool_T {
pub type VkQueryPool = *mut VkQueryPool_T; pub type VkQueryPool = *mut VkQueryPool_T;
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone)] #[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 { pub struct VkPipelineCache_T {
_unused: [u8; 0], _unused: [u8; 0],
} }