remove From<vk::Result> for VkResult

this is a breaking change

see https://github.com/MaikKlein/ash/pull/493
This commit is contained in:
Philippe Renon 2021-11-12 16:35:36 +01:00 committed by Benjamin Saunders
parent 675f91e9cd
commit 2f51478d54
8 changed files with 43 additions and 45 deletions

View file

@ -166,14 +166,14 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_2 self.device_fn_1_2
.wait_semaphores(self.handle(), wait_info, timeout) .wait_semaphores(self.handle(), wait_info, timeout)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"]
pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> { pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> {
self.device_fn_1_2 self.device_fn_1_2
.signal_semaphore(self.handle(), signal_info) .signal_semaphore(self.handle(), signal_info)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddress.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferDeviceAddress.html>"]
@ -218,7 +218,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_1 self.device_fn_1_1
.bind_buffer_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr()) .bind_buffer_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr())
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindImageMemory2.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindImageMemory2.html>"]
@ -228,7 +228,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_1 self.device_fn_1_1
.bind_image_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr()) .bind_image_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr())
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceGroupPeerMemoryFeatures.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceGroupPeerMemoryFeatures.html>"]
@ -507,12 +507,14 @@ impl Device {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetEvent.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetEvent.html>"]
pub unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> { pub unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> {
self.device_fn_1_0.set_event(self.handle(), event).into() self.device_fn_1_0.set_event(self.handle(), event).result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetEvent.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetEvent.html>"]
pub unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> { pub unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> {
self.device_fn_1_0.reset_event(self.handle(), event).into() self.device_fn_1_0
.reset_event(self.handle(), event)
.result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetEvent.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetEvent.html>"]
pub unsafe fn cmd_set_event( pub unsafe fn cmd_set_event(
@ -770,7 +772,7 @@ impl Device {
descriptor_sets.len() as u32, descriptor_sets.len() as u32,
descriptor_sets.as_ptr(), descriptor_sets.as_ptr(),
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkUpdateDescriptorSets.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkUpdateDescriptorSets.html>"]
@ -990,7 +992,7 @@ impl Device {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDeviceWaitIdle.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDeviceWaitIdle.html>"]
pub unsafe fn device_wait_idle(&self) -> VkResult<()> { pub unsafe fn device_wait_idle(&self) -> VkResult<()> {
self.device_fn_1_0.device_wait_idle(self.handle()).into() self.device_fn_1_0.device_wait_idle(self.handle()).result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDescriptorPool.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDescriptorPool.html>"]
@ -1018,7 +1020,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.reset_descriptor_pool(self.handle(), pool, flags) .reset_descriptor_pool(self.handle(), pool, flags)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetCommandPool.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetCommandPool.html>"]
@ -1029,7 +1031,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.reset_command_pool(self.handle(), command_pool, flags) .reset_command_pool(self.handle(), command_pool, flags)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetCommandBuffer.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetCommandBuffer.html>"]
@ -1040,14 +1042,14 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.reset_command_buffer(command_buffer, flags) .reset_command_buffer(command_buffer, flags)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetFences.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetFences.html>"]
pub unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> { pub unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.reset_fences(self.handle(), fences.len() as u32, fences.as_ptr()) .reset_fences(self.handle(), fences.len() as u32, fences.as_ptr())
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBindIndexBuffer.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBindIndexBuffer.html>"]
@ -1473,7 +1475,7 @@ impl Device {
mem::size_of::<T>() as _, mem::size_of::<T>() as _,
flags, flags,
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginQuery.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginQuery.html>"]
@ -1665,7 +1667,7 @@ impl Device {
src_caches.len() as u32, src_caches.len() as u32,
src_caches.as_ptr(), src_caches.as_ptr(),
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkMapMemory.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkMapMemory.html>"]
@ -1694,7 +1696,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.invalidate_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr()) .invalidate_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr())
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkFlushMappedMemoryRanges.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkFlushMappedMemoryRanges.html>"]
@ -1704,7 +1706,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.flush_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr()) .flush_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr())
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateFramebuffer.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateFramebuffer.html>"]
@ -1786,12 +1788,14 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.begin_command_buffer(command_buffer, begin_info) .begin_command_buffer(command_buffer, begin_info)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEndCommandBuffer.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEndCommandBuffer.html>"]
pub unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> { pub unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> {
self.device_fn_1_0.end_command_buffer(command_buffer).into() self.device_fn_1_0
.end_command_buffer(command_buffer)
.result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitForFences.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitForFences.html>"]
@ -1809,7 +1813,7 @@ impl Device {
wait_all as u32, wait_all as u32,
timeout, timeout,
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetFenceStatus.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetFenceStatus.html>"]
@ -1824,7 +1828,7 @@ impl Device {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueWaitIdle.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueWaitIdle.html>"]
pub unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> { pub unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
self.device_fn_1_0.queue_wait_idle(queue).into() self.device_fn_1_0.queue_wait_idle(queue).result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueSubmit.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueSubmit.html>"]
@ -1836,7 +1840,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.queue_submit(queue, submits.len() as u32, submits.as_ptr(), fence) .queue_submit(queue, submits.len() as u32, submits.as_ptr(), fence)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueBindSparse.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueBindSparse.html>"]
@ -1848,7 +1852,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.queue_bind_sparse(queue, bind_info.len() as u32, bind_info.as_ptr(), fence) .queue_bind_sparse(queue, bind_info.len() as u32, bind_info.as_ptr(), fence)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateBufferView.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateBufferView.html>"]
@ -2059,7 +2063,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.bind_buffer_memory(self.handle(), buffer, device_memory, offset) .bind_buffer_memory(self.handle(), buffer, device_memory, offset)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindImageMemory.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindImageMemory.html>"]
@ -2071,7 +2075,7 @@ impl Device {
) -> VkResult<()> { ) -> VkResult<()> {
self.device_fn_1_0 self.device_fn_1_0
.bind_image_memory(self.handle(), image, device_memory, offset) .bind_image_memory(self.handle(), image, device_memory, offset)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRenderAreaGranularity.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRenderAreaGranularity.html>"]

View file

@ -29,7 +29,7 @@ impl DebugMarker {
) -> VkResult<()> { ) -> VkResult<()> {
self.debug_marker_fn self.debug_marker_fn
.debug_marker_set_object_name_ext(device, name_info) .debug_marker_set_object_name_ext(device, name_info)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerBeginEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerBeginEXT.html>"]

View file

@ -33,7 +33,7 @@ impl DebugUtils {
) -> VkResult<()> { ) -> VkResult<()> {
self.debug_utils_fn self.debug_utils_fn
.set_debug_utils_object_name_ext(device, name_info) .set_debug_utils_object_name_ext(device, name_info)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html>"]
@ -44,7 +44,7 @@ impl DebugUtils {
) -> VkResult<()> { ) -> VkResult<()> {
self.debug_utils_fn self.debug_utils_fn
.set_debug_utils_object_tag_ext(device, tag_info) .set_debug_utils_object_tag_ext(device, tag_info)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginDebugUtilsLabelEXT.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginDebugUtilsLabelEXT.html>"]

View file

@ -151,7 +151,7 @@ impl AccelerationStructure {
infos.as_ptr(), infos.as_ptr(),
build_range_infos.as_ptr(), build_range_infos.as_ptr(),
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyAccelerationStructureKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyAccelerationStructureKHR.html>"]
@ -162,7 +162,7 @@ impl AccelerationStructure {
) -> VkResult<()> { ) -> VkResult<()> {
self.acceleration_structure_fn self.acceleration_structure_fn
.copy_acceleration_structure_khr(self.handle, deferred_operation, info as *const _) .copy_acceleration_structure_khr(self.handle, deferred_operation, info as *const _)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyAccelerationStructureToMemoryKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyAccelerationStructureToMemoryKHR.html>"]
@ -177,7 +177,7 @@ impl AccelerationStructure {
deferred_operation, deferred_operation,
info as *const _, info as *const _,
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyMemoryToAccelerationStructureKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCopyMemoryToAccelerationStructureKHR.html>"]
@ -192,7 +192,7 @@ impl AccelerationStructure {
deferred_operation, deferred_operation,
info as *const _, info as *const _,
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWriteAccelerationStructuresPropertiesKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWriteAccelerationStructuresPropertiesKHR.html>"]
@ -213,7 +213,7 @@ impl AccelerationStructure {
data.as_mut_ptr() as *mut std::ffi::c_void, data.as_mut_ptr() as *mut std::ffi::c_void,
stride, stride,
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html>"]

View file

@ -46,7 +46,7 @@ impl TimelineSemaphore {
) -> VkResult<()> { ) -> VkResult<()> {
self.timeline_semaphore_fn self.timeline_semaphore_fn
.wait_semaphores_khr(device, wait_info, timeout) .wait_semaphores_khr(device, wait_info, timeout)
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"]
@ -57,7 +57,7 @@ impl TimelineSemaphore {
) -> VkResult<()> { ) -> VkResult<()> {
self.timeline_semaphore_fn self.timeline_semaphore_fn
.signal_semaphore_khr(device, signal_info) .signal_semaphore_khr(device, signal_info)
.into() .result()
} }
pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn { pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn {

View file

@ -90,7 +90,7 @@ impl RayTracing {
bind_info.len() as u32, bind_info.len() as u32,
bind_info.as_ptr(), bind_info.as_ptr(),
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureNV.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureNV.html>"]
@ -206,7 +206,7 @@ impl RayTracing {
data.len(), data.len(),
data.as_mut_ptr() as *mut std::ffi::c_void, data.as_mut_ptr() as *mut std::ffi::c_void,
) )
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleNV.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleNV.html>"]
@ -250,7 +250,7 @@ impl RayTracing {
pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> { pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
self.ray_tracing_fn self.ray_tracing_fn
.compile_deferred_nv(self.handle, pipeline, shader) .compile_deferred_nv(self.handle, pipeline, shader)
.into() .result()
} }
pub fn name() -> &'static CStr { pub fn name() -> &'static CStr {

View file

@ -70,7 +70,7 @@ impl Instance {
let mut group_count = out.len() as u32; let mut group_count = out.len() as u32;
self.instance_fn_1_1 self.instance_fn_1_1
.enumerate_physical_device_groups(self.handle(), &mut group_count, out.as_mut_ptr()) .enumerate_physical_device_groups(self.handle(), &mut group_count, out.as_mut_ptr())
.into() .result()
} }
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures2.html>"] #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceFeatures2.html>"]
@ -117,7 +117,7 @@ impl Instance {
format_info, format_info,
image_format_prop, image_format_prop,
) )
.into() .result()
} }
/// Retrieve the number of elements to pass to [`Self::get_physical_device_queue_family_properties2()`] /// Retrieve the number of elements to pass to [`Self::get_physical_device_queue_family_properties2()`]

View file

@ -3,12 +3,6 @@ use std::convert::TryInto;
use crate::vk; use crate::vk;
pub type VkResult<T> = Result<T, vk::Result>; pub type VkResult<T> = Result<T, vk::Result>;
impl From<vk::Result> for VkResult<()> {
fn from(err_code: vk::Result) -> Self {
err_code.result()
}
}
impl vk::Result { impl vk::Result {
pub fn result(self) -> VkResult<()> { pub fn result(self) -> VkResult<()> {
self.result_with_success(()) self.result_with_success(())