diff --git a/Cargo.toml b/Cargo.toml index 0707936..8419dc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,4 +2,7 @@ members = [ "examples", "ash" -] \ No newline at end of file +] + +[package.metadata.release] +no-dev-version = true \ No newline at end of file diff --git a/ash/src/device.rs b/ash/src/device.rs index 84fd5aa..c517a7a 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -10,46 +10,53 @@ pub trait DeviceV1_0 { fn handle(&self) -> vk::Device; fn fp_v1_0(&self) -> &vk::DeviceFnV1_0; unsafe fn destroy_device(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_device(self.handle(), allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_device(self.handle(), allocation_callbacks.as_raw_ptr()); } unsafe fn destroy_sampler(&self, sampler: vk::Sampler, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_sampler(self.handle(), sampler, allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_sampler(self.handle(), sampler, allocation_callbacks.as_raw_ptr()); } unsafe fn free_memory(&self, memory: vk::DeviceMemory, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().free_memory(self.handle(), memory, allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .free_memory(self.handle(), memory, allocation_callbacks.as_raw_ptr()); } unsafe fn free_command_buffers(&self, command_pool: vk::CommandPool, command_buffers: &[vk::CommandBuffer]) { - self.fp_v1_0().free_command_buffers(self.handle(), - command_pool, - command_buffers.len() as vk::uint32_t, - command_buffers.as_ptr()); + self.fp_v1_0() + .free_command_buffers(self.handle(), + command_pool, + command_buffers.len() as vk::uint32_t, + command_buffers.as_ptr()); } unsafe fn destroy_fence(&self, fence: vk::Fence, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_fence(self.handle(), fence, allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_fence(self.handle(), fence, allocation_callbacks.as_raw_ptr()); } unsafe fn destroy_image(&self, image: vk::Image, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_image(self.handle(), image, allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_image(self.handle(), image, allocation_callbacks.as_raw_ptr()); } unsafe fn destroy_command_pool(&self, pool: vk::CommandPool, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_command_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_command_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr()); } unsafe fn destroy_image_view(&self, @@ -78,15 +85,17 @@ pub trait DeviceV1_0 { unsafe fn destroy_pipeline_layout(&self, pipeline_layout: vk::PipelineLayout, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_pipeline_layout(self.handle(), - pipeline_layout, - allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_pipeline_layout(self.handle(), + pipeline_layout, + allocation_callbacks.as_raw_ptr()); } unsafe fn destroy_buffer(&self, buffer: vk::Buffer, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_buffer(self.handle(), buffer, allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_buffer(self.handle(), buffer, allocation_callbacks.as_raw_ptr()); } unsafe fn destroy_shader_module(&self, @@ -99,7 +108,8 @@ pub trait DeviceV1_0 { unsafe fn destroy_pipeline(&self, pipeline: vk::Pipeline, allocation_callbacks: Option<&vk::AllocationCallbacks>) { - self.fp_v1_0().destroy_pipeline(self.handle(), pipeline, allocation_callbacks.as_raw_ptr()); + self.fp_v1_0() + .destroy_pipeline(self.handle(), pipeline, allocation_callbacks.as_raw_ptr()); } unsafe fn destroy_semaphore(&self, @@ -116,7 +126,9 @@ pub trait DeviceV1_0 { .destroy_descriptor_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr()); } - unsafe fn destroy_descriptor_set_layout(&self, layout: vk::DescriptorSetLayout, allocation_callbacks: Option<&vk::AllocationCallbacks>) { + unsafe fn destroy_descriptor_set_layout(&self, layout: vk::DescriptorSetLayout, + allocation_callbacks: Option<&vk::AllocationCallbacks>) + { self.fp_v1_0() .destroy_descriptor_set_layout(self.handle(), layout, @@ -126,20 +138,22 @@ pub trait DeviceV1_0 { unsafe fn free_descriptor_sets(&self, pool: vk::DescriptorPool, descriptor_sets: &[vk::DescriptorSet]) { - self.fp_v1_0().free_descriptor_sets(self.handle(), - pool, - descriptor_sets.len() as u32, - descriptor_sets.as_ptr()); + self.fp_v1_0() + .free_descriptor_sets(self.handle(), + pool, + descriptor_sets.len() as u32, + descriptor_sets.as_ptr()); } unsafe fn update_descriptor_sets(&self, descriptor_writes: &[vk::WriteDescriptorSet], descriptor_copies: &[vk::CopyDescriptorSet]) { - self.fp_v1_0().update_descriptor_sets(self.handle(), - descriptor_writes.len() as u32, - descriptor_writes.as_ptr(), - descriptor_copies.len() as u32, - descriptor_copies.as_ptr()); + self.fp_v1_0() + .update_descriptor_sets(self.handle(), + descriptor_writes.len() as u32, + descriptor_writes.as_ptr(), + descriptor_copies.len() as u32, + descriptor_copies.as_ptr()); } unsafe fn create_sampler(&self, @@ -164,11 +178,12 @@ pub trait DeviceV1_0 { dst_buffer: vk::Buffer, regions: &[vk::BufferCopy]) { - self.fp_v1_0().cmd_copy_buffer(command_buffer, - src_buffer, - dst_buffer, - regions.len() as u32, - regions.as_ptr()); + self.fp_v1_0() + .cmd_copy_buffer(command_buffer, + src_buffer, + dst_buffer, + regions.len() as u32, + regions.as_ptr()); } unsafe fn cmd_copy_buffer_to_image(&self, @@ -177,12 +192,13 @@ pub trait DeviceV1_0 { dst_image: vk::Image, dst_image_layout: vk::ImageLayout, regions: &[vk::BufferImageCopy]) { - self.fp_v1_0().cmd_copy_buffer_to_image(command_buffer, - src_buffer, - dst_image, - dst_image_layout, - regions.len() as u32, - regions.as_ptr()); + self.fp_v1_0() + .cmd_copy_buffer_to_image(command_buffer, + src_buffer, + dst_image, + dst_image_layout, + regions.len() as u32, + regions.as_ptr()); } unsafe fn cmd_copy_image(&self, @@ -192,21 +208,23 @@ pub trait DeviceV1_0 { dst_image: vk::Image, dst_image_layout: vk::ImageLayout, regions: &[vk::ImageCopy]) { - self.fp_v1_0().cmd_copy_image(command_buffer, - src_image, - src_image_layout, - dst_image, - dst_image_layout, - regions.len() as u32, - regions.as_ptr()); + self.fp_v1_0() + .cmd_copy_image(command_buffer, + src_image, + src_image_layout, + dst_image, + dst_image_layout, + regions.len() as u32, + regions.as_ptr()); } unsafe fn allocate_descriptor_sets(&self, create_info: &vk::DescriptorSetAllocateInfo) -> VkResult> { let mut desc_set = Vec::with_capacity(create_info.descriptor_set_count as usize); - let err_code = self.fp_v1_0() - .allocate_descriptor_sets(self.handle(), create_info, desc_set.as_mut_ptr()); + let err_code = + self.fp_v1_0() + .allocate_descriptor_sets(self.handle(), create_info, desc_set.as_mut_ptr()); desc_set.set_len(create_info.descriptor_set_count as usize); match err_code { @@ -257,6 +275,19 @@ pub trait DeviceV1_0 { } } + unsafe fn reset_command_pool(&self, + command_pool: vk::CommandPool, + flags: vk::CommandPoolResetFlags) + -> VkResult<()> { + let err_code = self.fp_v1_0() + .reset_command_pool(self.handle(), command_pool, flags); + match err_code { + vk::Result::Success => Ok(()), + _ => Err(err_code), + } + + } + unsafe fn reset_command_buffer(&self, command_buffer: vk::CommandBuffer, flags: vk::CommandBufferResetFlags) @@ -270,8 +301,9 @@ pub trait DeviceV1_0 { } unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> { - let err_code = self.fp_v1_0() - .reset_fences(self.handle(), fences.len() as vk::uint32_t, fences.as_ptr()); + let err_code = + self.fp_v1_0() + .reset_fences(self.handle(), fences.len() as vk::uint32_t, fences.as_ptr()); match err_code { vk::Result::Success => Ok(()), _ => Err(err_code), @@ -283,7 +315,8 @@ pub trait DeviceV1_0 { buffer: vk::Buffer, offset: vk::DeviceSize, index_type: vk::IndexType) { - self.fp_v1_0().cmd_bind_index_buffer(command_buffer, buffer, offset, index_type); + self.fp_v1_0() + .cmd_bind_index_buffer(command_buffer, buffer, offset, index_type); } unsafe fn cmd_clear_color_image(&self, @@ -292,12 +325,13 @@ pub trait DeviceV1_0 { image_layout: vk::ImageLayout, clear_color_value: &vk::ClearColorValue, ranges: &[vk::ImageSubresourceRange]) { - self.fp_v1_0().cmd_clear_color_image(command_buffer, - image, - image_layout, - clear_color_value, - ranges.len() as vk::uint32_t, - ranges.as_ptr()); + self.fp_v1_0() + .cmd_clear_color_image(command_buffer, + image, + image_layout, + clear_color_value, + ranges.len() as vk::uint32_t, + ranges.as_ptr()); } unsafe fn cmd_draw_indexed(&self, @@ -308,12 +342,13 @@ pub trait DeviceV1_0 { vertex_offset: vk::int32_t, first_instance: vk::uint32_t) { - self.fp_v1_0().cmd_draw_indexed(command_buffer, - index_count, - instance_count, - first_index, - vertex_offset, - first_instance); + self.fp_v1_0() + .cmd_draw_indexed(command_buffer, + index_count, + instance_count, + first_index, + vertex_offset, + first_instance); } unsafe fn cmd_bind_descriptor_sets(&self, @@ -323,28 +358,31 @@ pub trait DeviceV1_0 { first_set: vk::uint32_t, descriptor_sets: &[vk::DescriptorSet], dynamic_offsets: &[vk::uint32_t]) { - self.fp_v1_0().cmd_bind_descriptor_sets(command_buffer, - pipeline_bind_point, - layout, - first_set, - descriptor_sets.len() as vk::uint32_t, - descriptor_sets.as_ptr(), - dynamic_offsets.len() as vk::uint32_t, - dynamic_offsets.as_ptr()) + self.fp_v1_0() + .cmd_bind_descriptor_sets(command_buffer, + pipeline_bind_point, + layout, + first_set, + descriptor_sets.len() as vk::uint32_t, + descriptor_sets.as_ptr(), + dynamic_offsets.len() as vk::uint32_t, + dynamic_offsets.as_ptr()) } unsafe fn cmd_begin_render_pass(&self, command_buffer: vk::CommandBuffer, create_info: &vk::RenderPassBeginInfo, contents: vk::SubpassContents) { - self.fp_v1_0().cmd_begin_render_pass(command_buffer, create_info, contents); + self.fp_v1_0() + .cmd_begin_render_pass(command_buffer, create_info, contents); } unsafe fn cmd_bind_pipeline(&self, command_buffer: vk::CommandBuffer, pipeline_bind_point: vk::PipelineBindPoint, pipeline: vk::Pipeline) { - self.fp_v1_0().cmd_bind_pipeline(command_buffer, pipeline_bind_point, pipeline); + self.fp_v1_0() + .cmd_bind_pipeline(command_buffer, pipeline_bind_point, pipeline); } unsafe fn cmd_set_scissor(&self, command_buffer: vk::CommandBuffer, scissors: &[vk::Rect2D]) { @@ -361,11 +399,12 @@ pub trait DeviceV1_0 { buffers: &[vk::Buffer], offsets: &[vk::DeviceSize]) { debug_assert_eq!(buffers.len(), offsets.len()); - self.fp_v1_0().cmd_bind_vertex_buffers(command_buffer, - first_binding, - buffers.len() as vk::uint32_t, - buffers.as_ptr(), - offsets.as_ptr()); + self.fp_v1_0() + .cmd_bind_vertex_buffers(command_buffer, + first_binding, + buffers.len() as vk::uint32_t, + buffers.as_ptr(), + offsets.as_ptr()); } unsafe fn cmd_end_render_pass(&self, command_buffer: vk::CommandBuffer) { @@ -378,11 +417,12 @@ pub trait DeviceV1_0 { instance_count: vk::uint32_t, first_vertex: vk::uint32_t, first_instance: vk::uint32_t) { - self.fp_v1_0().cmd_draw(command_buffer, - vertex_count, - instance_count, - first_vertex, - first_instance); + self.fp_v1_0() + .cmd_draw(command_buffer, + vertex_count, + instance_count, + first_vertex, + first_instance); } unsafe fn cmd_dispatch(&self, @@ -390,19 +430,18 @@ pub trait DeviceV1_0 { group_count_x: vk::uint32_t, group_count_y: vk::uint32_t, group_count_z: vk::uint32_t) { - self.fp_v1_0().cmd_dispatch(command_buffer, - group_count_x, - group_count_y, - group_count_z); + self.fp_v1_0() + .cmd_dispatch(command_buffer, group_count_x, group_count_y, group_count_z); } unsafe fn cmd_set_viewport(&self, command_buffer: vk::CommandBuffer, viewports: &[vk::Viewport]) { - self.fp_v1_0().cmd_set_viewport(command_buffer, - 0, - viewports.len() as vk::uint32_t, - viewports.as_ptr()); + self.fp_v1_0() + .cmd_set_viewport(command_buffer, + 0, + viewports.len() as vk::uint32_t, + viewports.as_ptr()); } unsafe fn create_semaphore(&self, @@ -421,11 +460,12 @@ pub trait DeviceV1_0 { } } - unsafe fn create_graphics_pipelines(&self, - pipeline_cache: vk::PipelineCache, - create_infos: &[vk::GraphicsPipelineCreateInfo], - allocation_callbacks: Option<&vk::AllocationCallbacks>) - -> Result, (Vec, vk::Result)>{ + unsafe fn create_graphics_pipelines + (&self, + pipeline_cache: vk::PipelineCache, + create_infos: &[vk::GraphicsPipelineCreateInfo], + allocation_callbacks: Option<&vk::AllocationCallbacks>) + -> Result, (Vec, vk::Result)> { let mut pipelines = Vec::with_capacity(create_infos.len()); let err_code = self.fp_v1_0() .create_graphics_pipelines(self.handle(), @@ -437,7 +477,7 @@ pub trait DeviceV1_0 { pipelines.set_len(create_infos.len()); match err_code { vk::Result::Success => Ok(pipelines), - _ => Err((pipelines,err_code)), + _ => Err((pipelines, err_code)), } } @@ -530,16 +570,17 @@ pub trait DeviceV1_0 { memory_barriers: &[vk::MemoryBarrier], buffer_memory_barriers: &[vk::BufferMemoryBarrier], image_memory_barriers: &[vk::ImageMemoryBarrier]) { - self.fp_v1_0().cmd_pipeline_barrier(command_buffer, - src_stage_mask, - dst_stage_mask, - dependency_flags, - memory_barriers.len() as vk::uint32_t, - memory_barriers.as_ptr(), - buffer_memory_barriers.len() as vk::uint32_t, - buffer_memory_barriers.as_ptr(), - image_memory_barriers.len() as vk::uint32_t, - image_memory_barriers.as_ptr()); + self.fp_v1_0() + .cmd_pipeline_barrier(command_buffer, + src_stage_mask, + dst_stage_mask, + dependency_flags, + memory_barriers.len() as vk::uint32_t, + memory_barriers.as_ptr(), + buffer_memory_barriers.len() as vk::uint32_t, + buffer_memory_barriers.as_ptr(), + image_memory_barriers.len() as vk::uint32_t, + image_memory_barriers.as_ptr()); } unsafe fn create_render_pass(&self, @@ -571,8 +612,7 @@ pub trait DeviceV1_0 { } unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> { - let err_code = self.fp_v1_0() - .end_command_buffer(command_buffer); + let err_code = self.fp_v1_0().end_command_buffer(command_buffer); match err_code { vk::Result::Success => Ok(()), _ => Err(err_code), @@ -641,8 +681,9 @@ pub trait DeviceV1_0 { create_info: &vk::CommandBufferAllocateInfo) -> VkResult> { let mut buffers = Vec::with_capacity(create_info.command_buffer_count as vk::size_t); - let err_code = self.fp_v1_0() - .allocate_command_buffers(self.handle(), create_info, buffers.as_mut_ptr()); + let err_code = + self.fp_v1_0() + .allocate_command_buffers(self.handle(), create_info, buffers.as_mut_ptr()); buffers.set_len(create_info.command_buffer_count as vk::size_t); match err_code { vk::Result::Success => Ok(buffers),