Add reset command pool

This commit is contained in:
Maik Klein 2017-04-22 15:07:07 +02:00
parent 7215777288
commit f5b04a888d
2 changed files with 153 additions and 109 deletions

View file

@ -3,3 +3,6 @@ members = [
"examples", "examples",
"ash" "ash"
] ]
[package.metadata.release]
no-dev-version = true

View file

@ -10,25 +10,29 @@ pub trait DeviceV1_0 {
fn handle(&self) -> vk::Device; fn handle(&self) -> vk::Device;
fn fp_v1_0(&self) -> &vk::DeviceFnV1_0; fn fp_v1_0(&self) -> &vk::DeviceFnV1_0;
unsafe fn destroy_device(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn destroy_sampler(&self,
sampler: vk::Sampler, sampler: vk::Sampler,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn free_memory(&self,
memory: vk::DeviceMemory, memory: vk::DeviceMemory,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn free_command_buffers(&self,
command_pool: vk::CommandPool, command_pool: vk::CommandPool,
command_buffers: &[vk::CommandBuffer]) { command_buffers: &[vk::CommandBuffer]) {
self.fp_v1_0().free_command_buffers(self.handle(), self.fp_v1_0()
.free_command_buffers(self.handle(),
command_pool, command_pool,
command_buffers.len() as vk::uint32_t, command_buffers.len() as vk::uint32_t,
command_buffers.as_ptr()); command_buffers.as_ptr());
@ -37,19 +41,22 @@ pub trait DeviceV1_0 {
unsafe fn destroy_fence(&self, unsafe fn destroy_fence(&self,
fence: vk::Fence, fence: vk::Fence,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn destroy_image(&self,
image: vk::Image, image: vk::Image,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn destroy_command_pool(&self,
pool: vk::CommandPool, pool: vk::CommandPool,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn destroy_image_view(&self,
@ -78,7 +85,8 @@ pub trait DeviceV1_0 {
unsafe fn destroy_pipeline_layout(&self, unsafe fn destroy_pipeline_layout(&self,
pipeline_layout: vk::PipelineLayout, pipeline_layout: vk::PipelineLayout,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.fp_v1_0().destroy_pipeline_layout(self.handle(), self.fp_v1_0()
.destroy_pipeline_layout(self.handle(),
pipeline_layout, pipeline_layout,
allocation_callbacks.as_raw_ptr()); allocation_callbacks.as_raw_ptr());
} }
@ -86,7 +94,8 @@ pub trait DeviceV1_0 {
unsafe fn destroy_buffer(&self, unsafe fn destroy_buffer(&self,
buffer: vk::Buffer, buffer: vk::Buffer,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn destroy_shader_module(&self,
@ -99,7 +108,8 @@ pub trait DeviceV1_0 {
unsafe fn destroy_pipeline(&self, unsafe fn destroy_pipeline(&self,
pipeline: vk::Pipeline, pipeline: vk::Pipeline,
allocation_callbacks: Option<&vk::AllocationCallbacks>) { 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, unsafe fn destroy_semaphore(&self,
@ -116,7 +126,9 @@ pub trait DeviceV1_0 {
.destroy_descriptor_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr()); .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() self.fp_v1_0()
.destroy_descriptor_set_layout(self.handle(), .destroy_descriptor_set_layout(self.handle(),
layout, layout,
@ -126,7 +138,8 @@ pub trait DeviceV1_0 {
unsafe fn free_descriptor_sets(&self, unsafe fn free_descriptor_sets(&self,
pool: vk::DescriptorPool, pool: vk::DescriptorPool,
descriptor_sets: &[vk::DescriptorSet]) { descriptor_sets: &[vk::DescriptorSet]) {
self.fp_v1_0().free_descriptor_sets(self.handle(), self.fp_v1_0()
.free_descriptor_sets(self.handle(),
pool, pool,
descriptor_sets.len() as u32, descriptor_sets.len() as u32,
descriptor_sets.as_ptr()); descriptor_sets.as_ptr());
@ -135,7 +148,8 @@ pub trait DeviceV1_0 {
unsafe fn update_descriptor_sets(&self, unsafe fn update_descriptor_sets(&self,
descriptor_writes: &[vk::WriteDescriptorSet], descriptor_writes: &[vk::WriteDescriptorSet],
descriptor_copies: &[vk::CopyDescriptorSet]) { descriptor_copies: &[vk::CopyDescriptorSet]) {
self.fp_v1_0().update_descriptor_sets(self.handle(), self.fp_v1_0()
.update_descriptor_sets(self.handle(),
descriptor_writes.len() as u32, descriptor_writes.len() as u32,
descriptor_writes.as_ptr(), descriptor_writes.as_ptr(),
descriptor_copies.len() as u32, descriptor_copies.len() as u32,
@ -164,7 +178,8 @@ pub trait DeviceV1_0 {
dst_buffer: vk::Buffer, dst_buffer: vk::Buffer,
regions: &[vk::BufferCopy]) { regions: &[vk::BufferCopy]) {
self.fp_v1_0().cmd_copy_buffer(command_buffer, self.fp_v1_0()
.cmd_copy_buffer(command_buffer,
src_buffer, src_buffer,
dst_buffer, dst_buffer,
regions.len() as u32, regions.len() as u32,
@ -177,7 +192,8 @@ pub trait DeviceV1_0 {
dst_image: vk::Image, dst_image: vk::Image,
dst_image_layout: vk::ImageLayout, dst_image_layout: vk::ImageLayout,
regions: &[vk::BufferImageCopy]) { regions: &[vk::BufferImageCopy]) {
self.fp_v1_0().cmd_copy_buffer_to_image(command_buffer, self.fp_v1_0()
.cmd_copy_buffer_to_image(command_buffer,
src_buffer, src_buffer,
dst_image, dst_image,
dst_image_layout, dst_image_layout,
@ -192,7 +208,8 @@ pub trait DeviceV1_0 {
dst_image: vk::Image, dst_image: vk::Image,
dst_image_layout: vk::ImageLayout, dst_image_layout: vk::ImageLayout,
regions: &[vk::ImageCopy]) { regions: &[vk::ImageCopy]) {
self.fp_v1_0().cmd_copy_image(command_buffer, self.fp_v1_0()
.cmd_copy_image(command_buffer,
src_image, src_image,
src_image_layout, src_image_layout,
dst_image, dst_image,
@ -205,7 +222,8 @@ pub trait DeviceV1_0 {
create_info: &vk::DescriptorSetAllocateInfo) create_info: &vk::DescriptorSetAllocateInfo)
-> VkResult<Vec<vk::DescriptorSet>> { -> VkResult<Vec<vk::DescriptorSet>> {
let mut desc_set = Vec::with_capacity(create_info.descriptor_set_count as usize); let mut desc_set = Vec::with_capacity(create_info.descriptor_set_count as usize);
let err_code = self.fp_v1_0() let err_code =
self.fp_v1_0()
.allocate_descriptor_sets(self.handle(), create_info, desc_set.as_mut_ptr()); .allocate_descriptor_sets(self.handle(), create_info, desc_set.as_mut_ptr());
desc_set.set_len(create_info.descriptor_set_count as usize); desc_set.set_len(create_info.descriptor_set_count as usize);
@ -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, unsafe fn reset_command_buffer(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
flags: vk::CommandBufferResetFlags) flags: vk::CommandBufferResetFlags)
@ -270,7 +301,8 @@ pub trait DeviceV1_0 {
} }
unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> { unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
let err_code = self.fp_v1_0() let err_code =
self.fp_v1_0()
.reset_fences(self.handle(), fences.len() as vk::uint32_t, fences.as_ptr()); .reset_fences(self.handle(), fences.len() as vk::uint32_t, fences.as_ptr());
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
@ -283,7 +315,8 @@ pub trait DeviceV1_0 {
buffer: vk::Buffer, buffer: vk::Buffer,
offset: vk::DeviceSize, offset: vk::DeviceSize,
index_type: vk::IndexType) { 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, unsafe fn cmd_clear_color_image(&self,
@ -292,7 +325,8 @@ pub trait DeviceV1_0 {
image_layout: vk::ImageLayout, image_layout: vk::ImageLayout,
clear_color_value: &vk::ClearColorValue, clear_color_value: &vk::ClearColorValue,
ranges: &[vk::ImageSubresourceRange]) { ranges: &[vk::ImageSubresourceRange]) {
self.fp_v1_0().cmd_clear_color_image(command_buffer, self.fp_v1_0()
.cmd_clear_color_image(command_buffer,
image, image,
image_layout, image_layout,
clear_color_value, clear_color_value,
@ -308,7 +342,8 @@ pub trait DeviceV1_0 {
vertex_offset: vk::int32_t, vertex_offset: vk::int32_t,
first_instance: vk::uint32_t) { first_instance: vk::uint32_t) {
self.fp_v1_0().cmd_draw_indexed(command_buffer, self.fp_v1_0()
.cmd_draw_indexed(command_buffer,
index_count, index_count,
instance_count, instance_count,
first_index, first_index,
@ -323,7 +358,8 @@ pub trait DeviceV1_0 {
first_set: vk::uint32_t, first_set: vk::uint32_t,
descriptor_sets: &[vk::DescriptorSet], descriptor_sets: &[vk::DescriptorSet],
dynamic_offsets: &[vk::uint32_t]) { dynamic_offsets: &[vk::uint32_t]) {
self.fp_v1_0().cmd_bind_descriptor_sets(command_buffer, self.fp_v1_0()
.cmd_bind_descriptor_sets(command_buffer,
pipeline_bind_point, pipeline_bind_point,
layout, layout,
first_set, first_set,
@ -337,14 +373,16 @@ pub trait DeviceV1_0 {
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
create_info: &vk::RenderPassBeginInfo, create_info: &vk::RenderPassBeginInfo,
contents: vk::SubpassContents) { 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, unsafe fn cmd_bind_pipeline(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
pipeline_bind_point: vk::PipelineBindPoint, pipeline_bind_point: vk::PipelineBindPoint,
pipeline: vk::Pipeline) { 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]) { unsafe fn cmd_set_scissor(&self, command_buffer: vk::CommandBuffer, scissors: &[vk::Rect2D]) {
@ -361,7 +399,8 @@ pub trait DeviceV1_0 {
buffers: &[vk::Buffer], buffers: &[vk::Buffer],
offsets: &[vk::DeviceSize]) { offsets: &[vk::DeviceSize]) {
debug_assert_eq!(buffers.len(), offsets.len()); debug_assert_eq!(buffers.len(), offsets.len());
self.fp_v1_0().cmd_bind_vertex_buffers(command_buffer, self.fp_v1_0()
.cmd_bind_vertex_buffers(command_buffer,
first_binding, first_binding,
buffers.len() as vk::uint32_t, buffers.len() as vk::uint32_t,
buffers.as_ptr(), buffers.as_ptr(),
@ -378,7 +417,8 @@ pub trait DeviceV1_0 {
instance_count: vk::uint32_t, instance_count: vk::uint32_t,
first_vertex: vk::uint32_t, first_vertex: vk::uint32_t,
first_instance: vk::uint32_t) { first_instance: vk::uint32_t) {
self.fp_v1_0().cmd_draw(command_buffer, self.fp_v1_0()
.cmd_draw(command_buffer,
vertex_count, vertex_count,
instance_count, instance_count,
first_vertex, first_vertex,
@ -390,16 +430,15 @@ pub trait DeviceV1_0 {
group_count_x: vk::uint32_t, group_count_x: vk::uint32_t,
group_count_y: vk::uint32_t, group_count_y: vk::uint32_t,
group_count_z: vk::uint32_t) { group_count_z: vk::uint32_t) {
self.fp_v1_0().cmd_dispatch(command_buffer, self.fp_v1_0()
group_count_x, .cmd_dispatch(command_buffer, group_count_x, group_count_y, group_count_z);
group_count_y,
group_count_z);
} }
unsafe fn cmd_set_viewport(&self, unsafe fn cmd_set_viewport(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
viewports: &[vk::Viewport]) { viewports: &[vk::Viewport]) {
self.fp_v1_0().cmd_set_viewport(command_buffer, self.fp_v1_0()
.cmd_set_viewport(command_buffer,
0, 0,
viewports.len() as vk::uint32_t, viewports.len() as vk::uint32_t,
viewports.as_ptr()); viewports.as_ptr());
@ -421,7 +460,8 @@ pub trait DeviceV1_0 {
} }
} }
unsafe fn create_graphics_pipelines(&self, unsafe fn create_graphics_pipelines
(&self,
pipeline_cache: vk::PipelineCache, pipeline_cache: vk::PipelineCache,
create_infos: &[vk::GraphicsPipelineCreateInfo], create_infos: &[vk::GraphicsPipelineCreateInfo],
allocation_callbacks: Option<&vk::AllocationCallbacks>) allocation_callbacks: Option<&vk::AllocationCallbacks>)
@ -530,7 +570,8 @@ pub trait DeviceV1_0 {
memory_barriers: &[vk::MemoryBarrier], memory_barriers: &[vk::MemoryBarrier],
buffer_memory_barriers: &[vk::BufferMemoryBarrier], buffer_memory_barriers: &[vk::BufferMemoryBarrier],
image_memory_barriers: &[vk::ImageMemoryBarrier]) { image_memory_barriers: &[vk::ImageMemoryBarrier]) {
self.fp_v1_0().cmd_pipeline_barrier(command_buffer, self.fp_v1_0()
.cmd_pipeline_barrier(command_buffer,
src_stage_mask, src_stage_mask,
dst_stage_mask, dst_stage_mask,
dependency_flags, dependency_flags,
@ -571,8 +612,7 @@ pub trait DeviceV1_0 {
} }
unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> { unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> {
let err_code = self.fp_v1_0() let err_code = self.fp_v1_0().end_command_buffer(command_buffer);
.end_command_buffer(command_buffer);
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
_ => Err(err_code), _ => Err(err_code),
@ -641,7 +681,8 @@ pub trait DeviceV1_0 {
create_info: &vk::CommandBufferAllocateInfo) create_info: &vk::CommandBufferAllocateInfo)
-> VkResult<Vec<vk::CommandBuffer>> { -> VkResult<Vec<vk::CommandBuffer>> {
let mut buffers = Vec::with_capacity(create_info.command_buffer_count as vk::size_t); let mut buffers = Vec::with_capacity(create_info.command_buffer_count as vk::size_t);
let err_code = self.fp_v1_0() let err_code =
self.fp_v1_0()
.allocate_command_buffers(self.handle(), create_info, buffers.as_mut_ptr()); .allocate_command_buffers(self.handle(), create_info, buffers.as_mut_ptr());
buffers.set_len(create_info.command_buffer_count as vk::size_t); buffers.set_len(create_info.command_buffer_count as vk::size_t);
match err_code { match err_code {