194: Add Khronos doc links and other ergonomic cleanup r=MaikKlein a=aloucks

* Khronos doc links are now automatically generated in vk.rs
* Added doc links to all other non-generated functions
* Implemented std::error::Error for LoadingError
* Made EntryCustom public in addition to the Entry typedef so that
  rustdoc no longer ignores it
* Moved Entry::new into EntryCustom (non-breaking)
* Added EntryCustom::try_enumerate_instance_version. The EntryV1_1 trait
  is not implemented for any type. Even if it were, the function would
  panic for Vulkan 1.0 implementations
* Added entry and instance creation example to lib docs
* Updated the Display impl for vk::Result so that it matches
  other bitmask and enum conventions
* Removed lazy_static dependency because it was no longer being
  referenced

Co-authored-by: Aaron Loucks <aloucks@cofront.net>
This commit is contained in:
bors[bot] 2019-03-22 09:47:08 +00:00
commit 6015cdc820
23 changed files with 1426 additions and 78 deletions

View file

@ -11,7 +11,6 @@ documentation = "https://docs.rs/ash"
[dependencies]
shared_library = "0.1.9"
lazy_static = "1"
[features]
default = []

View file

@ -117,4 +117,4 @@ impl VkAllocation for DefaultAllocatorCallback {
fn create_allocation_callback() -> Option<vk::AllocationCallbacks> {
None
}
}
}

View file

@ -10,6 +10,7 @@ use RawPtr;
pub trait DeviceV1_1: DeviceV1_0 {
fn fp_v1_1(&self) -> &vk::DeviceFnV1_1;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBindBufferMemory2.html>"]
unsafe fn bind_buffer_memory2(&self, bind_infos: &[vk::BindBufferMemoryInfo]) -> VkResult<()> {
let err_code = self.fp_v1_1().bind_buffer_memory2(
self.handle(),
@ -22,6 +23,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBindImageMemory2.html>"]
unsafe fn bind_image_memory2(&self, bind_infos: &[vk::BindImageMemoryInfo]) -> VkResult<()> {
let err_code = self.fp_v1_1().bind_image_memory2(
self.handle(),
@ -34,6 +36,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDeviceGroupPeerMemoryFeatures.html>"]
unsafe fn get_device_group_peer_memory_features(
&self,
heap_index: u32,
@ -51,11 +54,13 @@ pub trait DeviceV1_1: DeviceV1_0 {
peer_memory_features
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetDeviceMask.html>"]
unsafe fn cmd_set_device_mask(&self, command_buffer: vk::CommandBuffer, device_mask: u32) {
self.fp_v1_1()
.cmd_set_device_mask(command_buffer, device_mask);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDispatchBase.html>"]
unsafe fn cmd_dispatch_base(
&self,
command_buffer: vk::CommandBuffer,
@ -77,6 +82,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetImageMemoryRequirements2.html>"]
unsafe fn get_image_memory_requirements2(
&self,
info: &vk::ImageMemoryRequirementsInfo2,
@ -86,6 +92,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
.get_image_memory_requirements2(self.handle(), info, out);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetBufferMemoryRequirements2.html>"]
unsafe fn get_buffer_memory_requirements2(
&self,
info: &vk::BufferMemoryRequirementsInfo2,
@ -109,6 +116,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
count as usize
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetImageSparseMemoryRequirements2.html>"]
unsafe fn get_image_sparse_memory_requirements2(
&self,
info: &vk::ImageSparseMemoryRequirementsInfo2,
@ -123,6 +131,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkTrimCommandPool.html>"]
unsafe fn trim_command_pool(
&self,
command_pool: vk::CommandPool,
@ -132,6 +141,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
.trim_command_pool(self.handle(), command_pool, flags);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateSamplerYcbcrConversion.html>"]
unsafe fn create_sampler_ycbcr_conversion(
&self,
create_info: &vk::SamplerYcbcrConversionCreateInfo,
@ -150,6 +160,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroySamplerYcbcrConversion.html>"]
unsafe fn destroy_sampler_ycbcr_conversion(
&self,
ycbcr_conversion: vk::SamplerYcbcrConversion,
@ -162,6 +173,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDescriptorUpdateTemplate.html>"]
unsafe fn create_descriptor_update_template(
&self,
create_info: &vk::DescriptorUpdateTemplateCreateInfo,
@ -180,6 +192,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDescriptorUpdateTemplate.html>"]
unsafe fn destroy_descriptor_update_template(
&self,
descriptor_update_template: vk::DescriptorUpdateTemplate,
@ -192,6 +205,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkUpdateDescriptorSetWithTemplate.html>"]
unsafe fn update_descriptor_set_with_template(
&self,
descriptor_set: vk::DescriptorSet,
@ -206,6 +220,7 @@ pub trait DeviceV1_1: DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDescriptorSetLayoutSupport.html>"]
unsafe fn get_descriptor_set_layout_support(
&self,
create_info: &vk::DescriptorSetLayoutCreateInfo,
@ -220,11 +235,13 @@ pub trait DeviceV1_1: DeviceV1_0 {
pub trait DeviceV1_0 {
fn handle(&self) -> vk::Device;
fn fp_v1_0(&self) -> &vk::DeviceFnV1_0;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDevice.html>"]
unsafe fn destroy_device(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.fp_v1_0()
.destroy_device(self.handle(), allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroySampler.html>"]
unsafe fn destroy_sampler(
&self,
sampler: vk::Sampler,
@ -234,6 +251,7 @@ pub trait DeviceV1_0 {
.destroy_sampler(self.handle(), sampler, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkFreeMemory.html>"]
unsafe fn free_memory(
&self,
memory: vk::DeviceMemory,
@ -243,6 +261,7 @@ pub trait DeviceV1_0 {
.free_memory(self.handle(), memory, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkFreeCommandBuffers.html>"]
unsafe fn free_command_buffers(
&self,
command_pool: vk::CommandPool,
@ -256,6 +275,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateEvent.html>"]
unsafe fn create_event(
&self,
create_info: &vk::EventCreateInfo,
@ -276,6 +296,7 @@ pub trait DeviceV1_0 {
/// Returns true if the event was set, and false if the event was reset, otherwise it will
/// return the error code.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetEventStatus.html>"]
unsafe fn get_event_status(&self, event: vk::Event) -> VkResult<bool> {
let err_code = self.fp_v1_0().get_event_status(self.handle(), event);
match err_code {
@ -285,6 +306,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkSetEvent.html>"]
unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> {
let err_code = self.fp_v1_0().set_event(self.handle(), event);
match err_code {
@ -293,6 +315,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetEvent.html>"]
unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> {
let err_code = self.fp_v1_0().reset_event(self.handle(), event);
match err_code {
@ -300,6 +323,7 @@ pub trait DeviceV1_0 {
_ => Err(err_code),
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetEvent.html>"]
unsafe fn cmd_set_event(
&self,
command_buffer: vk::CommandBuffer,
@ -309,6 +333,7 @@ pub trait DeviceV1_0 {
self.fp_v1_0()
.cmd_set_event(command_buffer, event, stage_mask);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdResetEvent.html>"]
unsafe fn cmd_reset_event(
&self,
command_buffer: vk::CommandBuffer,
@ -319,6 +344,7 @@ pub trait DeviceV1_0 {
.cmd_reset_event(command_buffer, event, stage_mask);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdWaitEvents.html>"]
unsafe fn cmd_wait_events(
&self,
command_buffer: vk::CommandBuffer,
@ -344,6 +370,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyFence.html>"]
unsafe fn destroy_fence(
&self,
fence: vk::Fence,
@ -353,6 +380,7 @@ pub trait DeviceV1_0 {
.destroy_fence(self.handle(), fence, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyEvent.html>"]
unsafe fn destroy_event(
&self,
event: vk::Event,
@ -362,6 +390,7 @@ pub trait DeviceV1_0 {
.destroy_event(self.handle(), event, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyImage.html>"]
unsafe fn destroy_image(
&self,
image: vk::Image,
@ -371,6 +400,7 @@ pub trait DeviceV1_0 {
.destroy_image(self.handle(), image, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyCommandPool.html>"]
unsafe fn destroy_command_pool(
&self,
pool: vk::CommandPool,
@ -380,6 +410,7 @@ pub trait DeviceV1_0 {
.destroy_command_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyImageView.html>"]
unsafe fn destroy_image_view(
&self,
image_view: vk::ImageView,
@ -392,6 +423,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyRenderPass.html>"]
unsafe fn destroy_render_pass(
&self,
renderpass: vk::RenderPass,
@ -404,6 +436,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyFramebuffer.html>"]
unsafe fn destroy_framebuffer(
&self,
framebuffer: vk::Framebuffer,
@ -416,6 +449,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyPipelineLayout.html>"]
unsafe fn destroy_pipeline_layout(
&self,
pipeline_layout: vk::PipelineLayout,
@ -428,6 +462,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyPipelineCache.html>"]
unsafe fn destroy_pipeline_cache(
&self,
pipeline_cache: vk::PipelineCache,
@ -440,6 +475,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyBuffer.html>"]
unsafe fn destroy_buffer(
&self,
buffer: vk::Buffer,
@ -449,6 +485,7 @@ pub trait DeviceV1_0 {
.destroy_buffer(self.handle(), buffer, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyShaderModule.html>"]
unsafe fn destroy_shader_module(
&self,
shader: vk::ShaderModule,
@ -461,6 +498,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyPipeline.html>"]
unsafe fn destroy_pipeline(
&self,
pipeline: vk::Pipeline,
@ -470,6 +508,7 @@ pub trait DeviceV1_0 {
.destroy_pipeline(self.handle(), pipeline, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroySemaphore.html>"]
unsafe fn destroy_semaphore(
&self,
semaphore: vk::Semaphore,
@ -482,6 +521,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDescriptorPool.html>"]
unsafe fn destroy_descriptor_pool(
&self,
pool: vk::DescriptorPool,
@ -494,6 +534,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyQueryPool.html>"]
unsafe fn destroy_query_pool(
&self,
pool: vk::QueryPool,
@ -503,6 +544,7 @@ pub trait DeviceV1_0 {
.destroy_query_pool(self.handle(), pool, allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDescriptorSetLayout.html>"]
unsafe fn destroy_descriptor_set_layout(
&self,
layout: vk::DescriptorSetLayout,
@ -515,6 +557,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkFreeDescriptorSets.html>"]
unsafe fn free_descriptor_sets(
&self,
pool: vk::DescriptorPool,
@ -528,6 +571,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkUpdateDescriptorSets.html>"]
unsafe fn update_descriptor_sets(
&self,
descriptor_writes: &[vk::WriteDescriptorSet],
@ -542,6 +586,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateSampler.html>"]
unsafe fn create_sampler(
&self,
create_info: &vk::SamplerCreateInfo,
@ -560,6 +605,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBlitImage.html>"]
unsafe fn cmd_blit_image(
&self,
command_buffer: vk::CommandBuffer,
@ -582,6 +628,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdResolveImage.html>"]
unsafe fn cmd_resolve_image(
&self,
command_buffer: vk::CommandBuffer,
@ -602,6 +649,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdFillBuffer.html>"]
unsafe fn cmd_fill_buffer(
&self,
command_buffer: vk::CommandBuffer,
@ -614,6 +662,7 @@ pub trait DeviceV1_0 {
.cmd_fill_buffer(command_buffer, buffer, offset, size, data);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdUpdateBuffer.html>"]
unsafe fn cmd_update_buffer(
&self,
command_buffer: vk::CommandBuffer,
@ -630,6 +679,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyBuffer.html>"]
unsafe fn cmd_copy_buffer(
&self,
command_buffer: vk::CommandBuffer,
@ -646,6 +696,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyImageToBuffer.html>"]
unsafe fn cmd_copy_image_to_buffer(
&self,
command_buffer: vk::CommandBuffer,
@ -664,6 +715,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyBufferToImage.html>"]
unsafe fn cmd_copy_buffer_to_image(
&self,
command_buffer: vk::CommandBuffer,
@ -682,6 +734,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyImage.html>"]
unsafe fn cmd_copy_image(
&self,
command_buffer: vk::CommandBuffer,
@ -702,6 +755,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkAllocateDescriptorSets.html>"]
unsafe fn allocate_descriptor_sets(
&self,
create_info: &vk::DescriptorSetAllocateInfo,
@ -720,6 +774,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDescriptorSetLayout.html>"]
unsafe fn create_descriptor_set_layout(
&self,
create_info: &vk::DescriptorSetLayoutCreateInfo,
@ -738,6 +793,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDeviceWaitIdle.html>"]
unsafe fn device_wait_idle(&self) -> VkResult<()> {
let err_code = self.fp_v1_0().device_wait_idle(self.handle());
match err_code {
@ -746,6 +802,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDescriptorPool.html>"]
unsafe fn create_descriptor_pool(
&self,
create_info: &vk::DescriptorPoolCreateInfo,
@ -764,6 +821,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetDescriptorPool.html>"]
unsafe fn reset_descriptor_pool(
&self,
pool: vk::DescriptorPool,
@ -778,6 +836,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandPool.html>"]
unsafe fn reset_command_pool(
&self,
command_pool: vk::CommandPool,
@ -792,6 +851,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetCommandBuffer.html>"]
unsafe fn reset_command_buffer(
&self,
command_buffer: vk::CommandBuffer,
@ -804,6 +864,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkResetFences.html>"]
unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
let err_code =
self.fp_v1_0()
@ -814,6 +875,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBindIndexBuffer.html>"]
unsafe fn cmd_bind_index_buffer(
&self,
command_buffer: vk::CommandBuffer,
@ -825,6 +887,7 @@ pub trait DeviceV1_0 {
.cmd_bind_index_buffer(command_buffer, buffer, offset, index_type);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdClearColorImage.html>"]
unsafe fn cmd_clear_color_image(
&self,
command_buffer: vk::CommandBuffer,
@ -843,6 +906,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdClearDepthStencilImage.html>"]
unsafe fn cmd_clear_depth_stencil_image(
&self,
command_buffer: vk::CommandBuffer,
@ -861,6 +925,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdClearAttachments.html>"]
unsafe fn cmd_clear_attachments(
&self,
command_buffer: vk::CommandBuffer,
@ -876,6 +941,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndexed.html>"]
unsafe fn cmd_draw_indexed(
&self,
command_buffer: vk::CommandBuffer,
@ -895,6 +961,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndexedIndirect.html>"]
unsafe fn cmd_draw_indexed_indirect(
&self,
command_buffer: vk::CommandBuffer,
@ -912,6 +979,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdExecuteCommands.html>"]
unsafe fn cmd_execute_commands(
&self,
primary_command_buffer: vk::CommandBuffer,
@ -924,6 +992,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBindDescriptorSets.html>"]
unsafe fn cmd_bind_descriptor_sets(
&self,
command_buffer: vk::CommandBuffer,
@ -945,6 +1014,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyQueryPoolResults.html>"]
unsafe fn cmd_copy_query_pool_results(
&self,
command_buffer: vk::CommandBuffer,
@ -968,6 +1038,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdPushConstants.html>"]
unsafe fn cmd_push_constants(
&self,
command_buffer: vk::CommandBuffer,
@ -986,6 +1057,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBeginRenderPass.html>"]
unsafe fn cmd_begin_render_pass(
&self,
command_buffer: vk::CommandBuffer,
@ -996,6 +1068,7 @@ pub trait DeviceV1_0 {
.cmd_begin_render_pass(command_buffer, create_info, contents);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdNextSubpass.html>"]
unsafe fn cmd_next_subpass(
&self,
command_buffer: vk::CommandBuffer,
@ -1004,6 +1077,7 @@ pub trait DeviceV1_0 {
self.fp_v1_0().cmd_next_subpass(command_buffer, contents);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBindPipeline.html>"]
unsafe fn cmd_bind_pipeline(
&self,
command_buffer: vk::CommandBuffer,
@ -1014,6 +1088,7 @@ pub trait DeviceV1_0 {
.cmd_bind_pipeline(command_buffer, pipeline_bind_point, pipeline);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetScissor.html>"]
unsafe fn cmd_set_scissor(
&self,
command_buffer: vk::CommandBuffer,
@ -1028,11 +1103,13 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetLineWidth.html>"]
unsafe fn cmd_set_line_width(&self, command_buffer: vk::CommandBuffer, line_width: f32) {
self.fp_v1_0()
.cmd_set_line_width(command_buffer, line_width);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBindVertexBuffers.html>"]
unsafe fn cmd_bind_vertex_buffers(
&self,
command_buffer: vk::CommandBuffer,
@ -1050,10 +1127,12 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdEndRenderPass.html>"]
unsafe fn cmd_end_render_pass(&self, command_buffer: vk::CommandBuffer) {
self.fp_v1_0().cmd_end_render_pass(command_buffer);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDraw.html>"]
unsafe fn cmd_draw(
&self,
command_buffer: vk::CommandBuffer,
@ -1071,6 +1150,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndirect.html>"]
unsafe fn cmd_draw_indirect(
&self,
command_buffer: vk::CommandBuffer,
@ -1083,6 +1163,7 @@ pub trait DeviceV1_0 {
.cmd_draw_indirect(command_buffer, buffer, offset, draw_count, stride);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDispatch.html>"]
unsafe fn cmd_dispatch(
&self,
command_buffer: vk::CommandBuffer,
@ -1094,6 +1175,7 @@ pub trait DeviceV1_0 {
.cmd_dispatch(command_buffer, group_count_x, group_count_y, group_count_z);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDispatchIndirect.html>"]
unsafe fn cmd_dispatch_indirect(
&self,
command_buffer: vk::CommandBuffer,
@ -1104,6 +1186,7 @@ pub trait DeviceV1_0 {
.cmd_dispatch_indirect(command_buffer, buffer, offset);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetViewport.html>"]
unsafe fn cmd_set_viewport(
&self,
command_buffer: vk::CommandBuffer,
@ -1118,6 +1201,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetDepthBias.html>"]
unsafe fn cmd_set_depth_bias(
&self,
command_buffer: vk::CommandBuffer,
@ -1129,6 +1213,7 @@ pub trait DeviceV1_0 {
.cmd_set_depth_bias(command_buffer, constant_factor, clamp, slope_factor);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetBlendConstants.html>"]
unsafe fn cmd_set_blend_constants(
&self,
command_buffer: vk::CommandBuffer,
@ -1138,6 +1223,7 @@ pub trait DeviceV1_0 {
.cmd_set_blend_constants(command_buffer, blend_constants);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetDepthBounds.html>"]
unsafe fn cmd_set_depth_bounds(
&self,
command_buffer: vk::CommandBuffer,
@ -1148,6 +1234,7 @@ pub trait DeviceV1_0 {
.cmd_set_depth_bounds(command_buffer, min_depth_bounds, max_depth_bounds);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetStencilCompareMask.html>"]
unsafe fn cmd_set_stencil_compare_mask(
&self,
command_buffer: vk::CommandBuffer,
@ -1158,6 +1245,7 @@ pub trait DeviceV1_0 {
.cmd_set_stencil_compare_mask(command_buffer, face_mask, compare_mask);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetStencilWriteMask.html>"]
unsafe fn cmd_set_stencil_write_mask(
&self,
command_buffer: vk::CommandBuffer,
@ -1168,6 +1256,7 @@ pub trait DeviceV1_0 {
.cmd_set_stencil_write_mask(command_buffer, face_mask, write_mask);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetStencilReference.html>"]
unsafe fn cmd_set_stencil_reference(
&self,
command_buffer: vk::CommandBuffer,
@ -1178,6 +1267,7 @@ pub trait DeviceV1_0 {
.cmd_set_stencil_reference(command_buffer, face_mask, reference);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetQueryPoolResults.html>"]
unsafe fn get_query_pool_results<T>(
&self,
query_pool: vk::QueryPool,
@ -1213,6 +1303,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBeginQuery.html>"]
unsafe fn cmd_begin_query(
&self,
command_buffer: vk::CommandBuffer,
@ -1224,6 +1315,7 @@ pub trait DeviceV1_0 {
.cmd_begin_query(command_buffer, query_pool, query, flags);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdEndQuery.html>"]
unsafe fn cmd_end_query(
&self,
command_buffer: vk::CommandBuffer,
@ -1234,6 +1326,7 @@ pub trait DeviceV1_0 {
.cmd_end_query(command_buffer, query_pool, query);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdResetQueryPool.html>"]
unsafe fn cmd_reset_query_pool(
&self,
command_buffer: vk::CommandBuffer,
@ -1245,6 +1338,7 @@ pub trait DeviceV1_0 {
.cmd_reset_query_pool(command_buffer, pool, first_query, query_count);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdWriteTimestamp.html>"]
unsafe fn cmd_write_timestamp(
&self,
command_buffer: vk::CommandBuffer,
@ -1256,6 +1350,7 @@ pub trait DeviceV1_0 {
.cmd_write_timestamp(command_buffer, pipeline_stage, query_pool, query);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateSemaphore.html>"]
unsafe fn create_semaphore(
&self,
create_info: &vk::SemaphoreCreateInfo,
@ -1274,6 +1369,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateGraphicsPipelines.html>"]
unsafe fn create_graphics_pipelines(
&self,
pipeline_cache: vk::PipelineCache,
@ -1296,6 +1392,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateComputePipelines.html>"]
unsafe fn create_compute_pipelines(
&self,
pipeline_cache: vk::PipelineCache,
@ -1318,6 +1415,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateBuffer.html>"]
unsafe fn create_buffer(
&self,
create_info: &vk::BufferCreateInfo,
@ -1336,6 +1434,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreatePipelineLayout.html>"]
unsafe fn create_pipeline_layout(
&self,
create_info: &vk::PipelineLayoutCreateInfo,
@ -1354,6 +1453,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreatePipelineCache.html>"]
unsafe fn create_pipeline_cache(
&self,
create_info: &vk::PipelineCacheCreateInfo,
@ -1373,6 +1473,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPipelineCacheData.html>"]
unsafe fn get_pipeline_cache_data(
&self,
pipeline_cache: vk::PipelineCache,
@ -1401,6 +1502,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkMapMemory.html>"]
unsafe fn map_memory(
&self,
memory: vk::DeviceMemory,
@ -1418,10 +1520,12 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkUnmapMemory.html>"]
unsafe fn unmap_memory(&self, memory: vk::DeviceMemory) {
self.fp_v1_0().unmap_memory(self.handle(), memory);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkInvalidateMappedMemoryRanges.html>"]
unsafe fn invalidate_mapped_memory_ranges(
&self,
ranges: &[vk::MappedMemoryRange],
@ -1437,6 +1541,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkFlushMappedMemoryRanges.html>"]
unsafe fn flush_mapped_memory_ranges(&self, ranges: &[vk::MappedMemoryRange]) -> VkResult<()> {
let err_code = self.fp_v1_0().flush_mapped_memory_ranges(
self.handle(),
@ -1449,6 +1554,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateFramebuffer.html>"]
unsafe fn create_framebuffer(
&self,
create_info: &vk::FramebufferCreateInfo,
@ -1467,6 +1573,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDeviceQueue.html>"]
unsafe fn get_device_queue(&self, queue_family_index: u32, queue_index: u32) -> vk::Queue {
let mut queue = mem::uninitialized();
self.fp_v1_0()
@ -1474,6 +1581,7 @@ pub trait DeviceV1_0 {
queue
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdPipelineBarrier.html>"]
unsafe fn cmd_pipeline_barrier(
&self,
command_buffer: vk::CommandBuffer,
@ -1498,6 +1606,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateRenderPass.html>"]
unsafe fn create_render_pass(
&self,
create_info: &vk::RenderPassCreateInfo,
@ -1516,6 +1625,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBeginCommandBuffer.html>"]
unsafe fn begin_command_buffer(
&self,
command_buffer: vk::CommandBuffer,
@ -1530,6 +1640,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEndCommandBuffer.html>"]
unsafe fn end_command_buffer(&self, command_buffer: vk::CommandBuffer) -> VkResult<()> {
let err_code = self.fp_v1_0().end_command_buffer(command_buffer);
match err_code {
@ -1538,6 +1649,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkWaitForFences.html>"]
unsafe fn wait_for_fences(
&self,
fences: &[vk::Fence],
@ -1557,6 +1669,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetFenceStatus.html>"]
unsafe fn get_fence_status(&self, fence: vk::Fence) -> VkResult<()> {
let err_code = self.fp_v1_0().get_fence_status(self.handle(), fence);
match err_code {
@ -1565,6 +1678,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueWaitIdle.html>"]
unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
let err_code = self.fp_v1_0().queue_wait_idle(queue);
match err_code {
@ -1573,6 +1687,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueSubmit.html>"]
unsafe fn queue_submit(
&self,
queue: vk::Queue,
@ -1588,6 +1703,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateBufferView.html>"]
unsafe fn create_buffer_view(
&self,
create_info: &vk::BufferViewCreateInfo,
@ -1606,6 +1722,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyBufferView.html>"]
unsafe fn destroy_buffer_view(
&self,
buffer_view: vk::BufferView,
@ -1618,6 +1735,7 @@ pub trait DeviceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateImageView.html>"]
unsafe fn create_image_view(
&self,
create_info: &vk::ImageViewCreateInfo,
@ -1636,6 +1754,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkAllocateCommandBuffers.html>"]
unsafe fn allocate_command_buffers(
&self,
create_info: &vk::CommandBufferAllocateInfo,
@ -1653,6 +1772,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateCommandPool.html>"]
unsafe fn create_command_pool(
&self,
create_info: &vk::CommandPoolCreateInfo,
@ -1671,6 +1791,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateQueryPool.html>"]
unsafe fn create_query_pool(
&self,
create_info: &vk::QueryPoolCreateInfo,
@ -1689,6 +1810,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateImage.html>"]
unsafe fn create_image(
&self,
create_info: &vk::ImageCreateInfo,
@ -1707,6 +1829,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetImageSubresourceLayout.html>"]
unsafe fn get_image_subresource_layout(
&self,
image: vk::Image,
@ -1722,6 +1845,7 @@ pub trait DeviceV1_0 {
layout
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetImageMemoryRequirements.html>"]
unsafe fn get_image_memory_requirements(&self, image: vk::Image) -> vk::MemoryRequirements {
let mut mem_req = mem::uninitialized();
self.fp_v1_0()
@ -1729,6 +1853,7 @@ pub trait DeviceV1_0 {
mem_req
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetBufferMemoryRequirements.html>"]
unsafe fn get_buffer_memory_requirements(&self, buffer: vk::Buffer) -> vk::MemoryRequirements {
let mut mem_req = mem::uninitialized();
self.fp_v1_0()
@ -1736,6 +1861,7 @@ pub trait DeviceV1_0 {
mem_req
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkAllocateMemory.html>"]
unsafe fn allocate_memory(
&self,
create_info: &vk::MemoryAllocateInfo,
@ -1754,6 +1880,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateShaderModule.html>"]
unsafe fn create_shader_module(
&self,
create_info: &vk::ShaderModuleCreateInfo,
@ -1772,6 +1899,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateFence.html>"]
unsafe fn create_fence(
&self,
create_info: &vk::FenceCreateInfo,
@ -1790,6 +1918,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBindBufferMemory.html>"]
unsafe fn bind_buffer_memory(
&self,
buffer: vk::Buffer,
@ -1805,6 +1934,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBindImageMemory.html>"]
unsafe fn bind_image_memory(
&self,
image: vk::Image,
@ -1821,6 +1951,7 @@ pub trait DeviceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkDevice.html>"]
#[derive(Clone)]
pub struct Device {
handle: vk::Device,

View file

@ -27,12 +27,10 @@ const LIB_PATH: &'static str = "libvulkan.so";
#[cfg(any(target_os = "macos", target_os = "ios"))]
const LIB_PATH: &'static str = "libvulkan.dylib";
lazy_static! {
static ref VK_LIB: Result<DynamicLibrary, String> =
DynamicLibrary::open(Some(&Path::new(LIB_PATH)));
}
/// Function loader
pub type Entry = EntryCustom<Arc<DynamicLibrary>>;
/// Function loader
#[derive(Clone)]
pub struct EntryCustom<L> {
static_fn: vk::StaticFn,
@ -46,6 +44,16 @@ pub enum LoadingError {
LibraryLoadError(String),
}
impl fmt::Display for LoadingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
LoadingError::LibraryLoadError(e) => write!(f, "{}", e),
}
}
}
impl Error for LoadingError {}
#[derive(Debug)]
pub enum InstanceError {
LoadError(Vec<&'static str>),
@ -54,33 +62,28 @@ pub enum InstanceError {
impl fmt::Display for InstanceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "InstanceError::{:?}", self)
}
}
impl Error for InstanceError {
fn description(&self) -> &str {
"InstanceError"
}
fn cause(&self) -> Option<&Error> {
if let &InstanceError::VkError(ref err) = self {
return err.source();
match self {
InstanceError::LoadError(e) => write!(f, "{}", e.join("; ")),
InstanceError::VkError(e) => write!(f, "{}", e),
}
None
}
}
impl Error for InstanceError {}
#[allow(non_camel_case_types)]
pub trait EntryV1_0 {
type Instance;
fn fp_v1_0(&self) -> &vk::EntryFnV1_0;
fn static_fn(&self) -> &vk::StaticFn;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateInstance.html>"]
unsafe fn create_instance(
&self,
create_info: &vk::InstanceCreateInfo,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Instance, InstanceError>;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceLayerProperties.html>"]
fn enumerate_instance_layer_properties(&self) -> VkResult<Vec<vk::LayerProperties>> {
unsafe {
let mut num = 0;
@ -98,6 +101,8 @@ pub trait EntryV1_0 {
}
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceExtensionProperties.html>"]
fn enumerate_instance_extension_properties(&self) -> VkResult<Vec<vk::ExtensionProperties>> {
unsafe {
let mut num = 0;
@ -120,6 +125,7 @@ pub trait EntryV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetInstanceProcAddr.html>"]
fn get_instance_proc_addr(
&self,
instance: vk::Instance,
@ -131,6 +137,7 @@ pub trait EntryV1_0 {
impl<L> EntryV1_0 for EntryCustom<L> {
type Instance = Instance;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateInstance.html>"]
unsafe fn create_instance(
&self,
create_info: &vk::InstanceCreateInfo,
@ -159,6 +166,7 @@ impl<L> EntryV1_0 for EntryCustom<L> {
pub trait EntryV1_1: EntryV1_0 {
fn fp_v1_1(&self) -> &vk::EntryFnV1_1;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceVersion.html>"]
fn enumerate_instance_version(&self) -> VkResult<u32> {
unsafe {
let mut api_version = 0;
@ -170,6 +178,41 @@ pub trait EntryV1_1: EntryV1_0 {
}
}
}
impl EntryCustom<Arc<DynamicLibrary>> {
/// ```rust,no_run
/// # #[macro_use]
/// # extern crate ash;
/// use ash::{vk, Entry, version::EntryV1_0};
/// # fn main() -> Result<(), Box<std::error::Error>> {
/// let entry = Entry::new()?;
/// let app_info = vk::ApplicationInfo {
/// api_version: vk_make_version!(1, 0, 0),
/// ..Default::default()
/// };
/// let create_info = vk::InstanceCreateInfo {
/// p_application_info: &app_info,
/// ..Default::default()
/// };
/// let instance = unsafe { entry.create_instance(&create_info, None)? };
/// # Ok(()) }
/// ```
pub fn new() -> Result<Entry, LoadingError> {
Self::new_custom(
|| {
DynamicLibrary::open(Some(&Path::new(LIB_PATH)))
.map_err(|err| LoadingError::LibraryLoadError(err.clone()))
.map(|dl| Arc::new(dl))
},
|vk_lib, name| unsafe {
vk_lib
.symbol(&*name.to_string_lossy())
.unwrap_or(ptr::null_mut())
},
)
}
}
impl<L> EntryCustom<L> {
pub fn new_custom<Open, Load>(open: Open, mut load: Load) -> Result<Self, LoadingError>
where
@ -194,21 +237,45 @@ impl<L> EntryCustom<L> {
lib,
})
}
}
impl Entry {
pub fn new() -> Result<Self, LoadingError> {
Self::new_custom(
|| {
DynamicLibrary::open(Some(&Path::new(LIB_PATH)))
.map_err(|err| LoadingError::LibraryLoadError(err.clone()))
.map(|dl| Arc::new(dl))
},
|vk_lib, name| unsafe {
vk_lib
.symbol(&*name.to_string_lossy())
.unwrap_or(ptr::null_mut())
},
)
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceVersion.html>"]
/// ```rust,no_run
/// # #[macro_use]
/// # extern crate ash;
/// # use ash::Entry;
/// # fn main() -> Result<(), Box<std::error::Error>> {
/// let entry = Entry::new()?;
/// match entry.try_enumerate_instance_version()? {
/// // Vulkan 1.1+
/// Some(version) => {
/// let major = vk_version_major!(version);
/// let minor = vk_version_minor!(version);
/// let patch = vk_version_patch!(version);
/// },
/// // Vulkan 1.0
/// None => {},
/// }
/// # Ok(()) }
/// ```
pub fn try_enumerate_instance_version(&self) -> VkResult<Option<u32>> {
unsafe {
let mut api_version = 0;
let enumerate_instance_version: Option<vk::PFN_vkEnumerateInstanceVersion> = {
let name = b"vkEnumerateInstanceVersion\0".as_ptr() as *const _;
mem::transmute(
self.static_fn()
.get_instance_proc_addr(vk::Instance::null(), name),
)
};
if let Some(enumerate_instance_version) = enumerate_instance_version {
let err_code = (enumerate_instance_version)(&mut api_version);
match err_code {
vk::Result::SUCCESS => Ok(Some(api_version)),
_ => Err(err_code),
}
} else {
Ok(None)
}
}
}
}

View file

@ -24,6 +24,7 @@ impl DebugMarker {
vk::ExtDebugMarkerFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>"]
pub unsafe fn debug_marker_set_object_name(
&self,
device: vk::Device,
@ -38,6 +39,7 @@ impl DebugMarker {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDebugMarkerBeginEXT.html>"]
pub unsafe fn cmd_debug_marker_begin(
&self,
command_buffer: vk::CommandBuffer,
@ -47,11 +49,13 @@ impl DebugMarker {
.cmd_debug_marker_begin_ext(command_buffer, marker_info);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDebugMarkerEndEXT.html>"]
pub unsafe fn cmd_debug_marker_end(&self, command_buffer: vk::CommandBuffer) {
self.debug_marker_fn
.cmd_debug_marker_end_ext(command_buffer);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDebugMarkerInsertEXT.html>"]
pub unsafe fn cmd_debug_marker_insert(
&self,
command_buffer: vk::CommandBuffer,

View file

@ -27,6 +27,7 @@ impl DebugReport {
vk::ExtDebugReportFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDebugReportCallbackEXT.html>"]
pub unsafe fn destroy_debug_report_callback(
&self,
debug: vk::DebugReportCallbackEXT,
@ -39,6 +40,7 @@ impl DebugReport {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDebugReportCallbackEXT.html>"]
pub unsafe fn create_debug_report_callback(
&self,
create_info: &vk::DebugReportCallbackCreateInfoEXT,

View file

@ -26,6 +26,7 @@ impl DebugUtils {
vk::ExtDebugUtilsFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html>"]
pub unsafe fn debug_utils_set_object_name(
&self,
device: vk::Device,
@ -40,6 +41,7 @@ impl DebugUtils {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html>"]
pub unsafe fn debug_utils_set_object_tag(
&self,
device: vk::Device,
@ -54,6 +56,7 @@ impl DebugUtils {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBeginDebugUtilsLabelEXT.html>"]
pub unsafe fn cmd_begin_debug_utils_label(
&self,
command_buffer: vk::CommandBuffer,
@ -63,11 +66,13 @@ impl DebugUtils {
.cmd_begin_debug_utils_label_ext(command_buffer, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdEndDebugUtilsLabelEXT.html>"]
pub unsafe fn cmd_end_debug_utils_label(&self, command_buffer: vk::CommandBuffer) {
self.debug_utils_fn
.cmd_end_debug_utils_label_ext(command_buffer);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdInsertDebugUtilsLabelEXT.html>"]
pub unsafe fn cmd_insert_debug_utils_label(
&self,
command_buffer: vk::CommandBuffer,
@ -77,6 +82,7 @@ impl DebugUtils {
.cmd_insert_debug_utils_label_ext(command_buffer, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueBeginDebugUtilsLabelEXT.html>"]
pub unsafe fn queue_begin_debug_utils_label(
&self,
queue: vk::Queue,
@ -86,10 +92,12 @@ impl DebugUtils {
.queue_begin_debug_utils_label_ext(queue, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueEndDebugUtilsLabelEXT.html>"]
pub unsafe fn queue_end_debug_utils_label(&self, queue: vk::Queue) {
self.debug_utils_fn.queue_end_debug_utils_label_ext(queue);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueInsertDebugUtilsLabelEXT.html>"]
pub unsafe fn queue_insert_debug_utils_label(
&self,
queue: vk::Queue,
@ -99,6 +107,7 @@ impl DebugUtils {
.queue_insert_debug_utils_label_ext(queue, label);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDebugUtilsMessengerEXT.html>"]
pub unsafe fn create_debug_utils_messenger(
&self,
create_info: &vk::DebugUtilsMessengerCreateInfoEXT,
@ -117,6 +126,7 @@ impl DebugUtils {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyDebugUtilsMessengerEXT.html>"]
pub unsafe fn destroy_debug_utils_messenger(
&self,
messenger: vk::DebugUtilsMessengerEXT,
@ -129,6 +139,7 @@ impl DebugUtils {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkSubmitDebugUtilsMessageEXT.html>"]
pub unsafe fn submit_debug_utils_message(
&self,
instance: vk::Instance,

View file

@ -27,6 +27,7 @@ impl AndroidSurface {
vk::KhrAndroidSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateAndroidSurfaceKHR.html>"]
pub unsafe fn create_android_surface(
&self,
create_info: &vk::AndroidSurfaceCreateInfoKHR,

View file

@ -27,6 +27,7 @@ impl DisplaySwapchain {
vk::KhrDisplaySwapchainFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateSharedSwapchainsKHR.html>"]
pub unsafe fn create_shared_swapchains(
&self,
create_infos: &[vk::SwapchainCreateInfoKHR],

View file

@ -28,6 +28,7 @@ impl Surface {
vk::KhrSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html>"]
pub unsafe fn get_physical_device_surface_support(
&self,
physical_device: vk::PhysicalDevice,
@ -44,6 +45,7 @@ impl Surface {
b > 0
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html>"]
pub unsafe fn get_physical_device_surface_present_modes(
&self,
physical_device: vk::PhysicalDevice,
@ -73,6 +75,7 @@ impl Surface {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html>"]
pub unsafe fn get_physical_device_surface_capabilities(
&self,
physical_device: vk::PhysicalDevice,
@ -92,6 +95,7 @@ impl Surface {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html>"]
pub unsafe fn get_physical_device_surface_formats(
&self,
physical_device: vk::PhysicalDevice,
@ -118,6 +122,7 @@ impl Surface {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroySurfaceKHR.html>"]
pub unsafe fn destroy_surface(
&self,
surface: vk::SurfaceKHR,

View file

@ -28,6 +28,7 @@ impl Swapchain {
vk::KhrSwapchainFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroySwapchainKHR.html>"]
pub unsafe fn destroy_swapchain(
&self,
swapchain: vk::SwapchainKHR,
@ -41,6 +42,7 @@ impl Swapchain {
}
/// On success, returns the next image's index and whether the swapchain is suboptimal for the surface.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkAcquireNextImageKHR.html>"]
pub unsafe fn acquire_next_image(
&self,
swapchain: vk::SwapchainKHR,
@ -64,6 +66,7 @@ impl Swapchain {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateSwapchainKHR.html>"]
pub unsafe fn create_swapchain(
&self,
create_info: &vk::SwapchainCreateInfoKHR,
@ -83,6 +86,7 @@ impl Swapchain {
}
/// On success, returns whether the swapchain is suboptimal for the surface.
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueuePresentKHR.html>"]
pub unsafe fn queue_present(
&self,
queue: vk::Queue,
@ -96,6 +100,7 @@ impl Swapchain {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetSwapchainImagesKHR.html>"]
pub unsafe fn get_swapchain_images(
&self,
swapchain: vk::SwapchainKHR,

View file

@ -27,6 +27,7 @@ impl WaylandSurface {
vk::KhrWaylandSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateWaylandSurfaceKHR.html>"]
pub unsafe fn create_wayland_surface(
&self,
create_info: &vk::WaylandSurfaceCreateInfoKHR,

View file

@ -27,6 +27,7 @@ impl Win32Surface {
vk::KhrWin32SurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateWin32SurfaceKHR.html>"]
pub unsafe fn create_win32_surface(
&self,
create_info: &vk::Win32SurfaceCreateInfoKHR,

View file

@ -27,6 +27,7 @@ impl XcbSurface {
vk::KhrXcbSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateXcbSurfaceKHR.html>"]
pub unsafe fn create_xcb_surface(
&self,
create_info: &vk::XcbSurfaceCreateInfoKHR,

View file

@ -27,6 +27,7 @@ impl XlibSurface {
vk::KhrXlibSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateXlibSurfaceKHR.html>"]
pub unsafe fn create_xlib_surface(
&self,
create_info: &vk::XlibSurfaceCreateInfoKHR,

View file

@ -27,6 +27,7 @@ impl IOSSurface {
vk::MvkIosSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateIOSSurfaceMVK.html>"]
pub unsafe fn create_ios_surface_mvk(
&self,
create_info: &vk::IOSSurfaceCreateInfoMVK,

View file

@ -27,6 +27,7 @@ impl MacOSSurface {
vk::MvkMacosSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateMacOSSurfaceMVK.html>"]
pub unsafe fn create_mac_os_surface_mvk(
&self,
create_info: &vk::MacOSSurfaceCreateInfoMVK,

View file

@ -16,6 +16,7 @@ impl MeshShader {
});
MeshShader { mesh_shader_fn }
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawMeshTasksNV.html>"]
pub unsafe fn cmd_draw_mesh_tasks(
&self,
command_buffer: vk::CommandBuffer,
@ -25,6 +26,7 @@ impl MeshShader {
self.mesh_shader_fn
.cmd_draw_mesh_tasks_nv(command_buffer, task_count, first_task);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawMeshTasksIndirectNV.html>"]
pub unsafe fn cmd_draw_mesh_tasks_indirect(
&self,
command_buffer: vk::CommandBuffer,
@ -41,6 +43,7 @@ impl MeshShader {
stride,
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawMeshTasksIndirectCountNV.html>"]
pub unsafe fn cmd_draw_mesh_tasks_indirect_count(
&self,
command_buffer: vk::CommandBuffer,

View file

@ -35,6 +35,7 @@ impl RayTracing {
props_rt
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateAccelerationStructureNV.html>"]
pub unsafe fn create_acceleration_structure(
&self,
create_info: &vk::AccelerationStructureCreateInfoNV,
@ -53,6 +54,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyAccelerationStructureNV.html>"]
pub unsafe fn destroy_acceleration_structure(
&self,
accel_struct: vk::AccelerationStructureNV,
@ -65,6 +67,7 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsNV.html>"]
pub unsafe fn get_acceleration_structure_memory_requirements(
&self,
info: &vk::AccelerationStructureMemoryRequirementsInfoNV,
@ -79,6 +82,7 @@ impl RayTracing {
requirements
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkBindAccelerationStructureMemoryNV.html>"]
pub unsafe fn bind_acceleration_structure_memory(
&self,
bind_info: &[vk::BindAccelerationStructureMemoryInfoNV],
@ -94,6 +98,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBuildAccelerationStructureNV.html>"]
pub unsafe fn cmd_build_acceleration_structure(
&self,
command_buffer: vk::CommandBuffer,
@ -119,6 +124,7 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyAccelerationStructureNV.html>"]
pub unsafe fn cmd_copy_acceleration_structure(
&self,
command_buffer: vk::CommandBuffer,
@ -130,6 +136,7 @@ impl RayTracing {
.cmd_copy_acceleration_structure_nv(command_buffer, dst, src, mode);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdTraceRaysNV.html>"]
pub unsafe fn cmd_trace_rays(
&self,
command_buffer: vk::CommandBuffer,
@ -167,6 +174,7 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateRayTracingPipelinesNV.html>"]
pub unsafe fn create_ray_tracing_pipelines(
&self,
pipeline_cache: vk::PipelineCache,
@ -188,6 +196,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetRayTracingShaderGroupHandlesNV.html>"]
pub unsafe fn get_ray_tracing_shader_group_handles(
&self,
pipeline: vk::Pipeline,
@ -209,6 +218,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetAccelerationStructureHandleNV.html>"]
pub unsafe fn get_acceleration_structure_handle(
&self,
accel_struct: vk::AccelerationStructureNV,
@ -227,6 +237,7 @@ impl RayTracing {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html>"]
pub unsafe fn cmd_write_acceleration_structures_properties(
&self,
command_buffer: vk::CommandBuffer,
@ -246,6 +257,7 @@ impl RayTracing {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCompileDeferredNV.html>"]
pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
let err_code = self
.ray_tracing_fn

View file

@ -7,6 +7,7 @@ use std::ptr;
use vk;
use RawPtr;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkInstance.html>"]
#[derive(Clone)]
pub struct Instance {
handle: vk::Instance,
@ -32,6 +33,7 @@ impl Instance {
impl InstanceV1_0 for Instance {
type Device = Device;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDevice.html>"]
unsafe fn create_device(
&self,
physical_device: vk::PhysicalDevice,
@ -79,6 +81,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
group_count as usize
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumeratePhysicalDeviceGroups.html>"]
fn enumerate_physical_device_groups(
&self,
out: &mut [vk::PhysicalDeviceGroupProperties],
@ -98,6 +101,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceProperties2.html>"]
unsafe fn get_physical_device_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -107,6 +111,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
.get_physical_device_properties2(physical_device, prop);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceFormatProperties2.html>"]
unsafe fn get_physical_device_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -117,6 +122,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
.get_physical_device_format_properties2(physical_device, format, out);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2.html>"]
unsafe fn get_physical_device_image_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -148,6 +154,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
queue_count as usize
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties2.html>"]
unsafe fn get_physical_device_queue_family_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -161,6 +168,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2.html>"]
unsafe fn get_physical_device_memory_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -186,6 +194,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
format_count as usize
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceSparseImageFormatProperties2.html>"]
unsafe fn get_physical_device_sparse_image_format_properties2(
&self,
physical_device: vk::PhysicalDevice,
@ -202,6 +211,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceExternalBufferProperties.html>"]
unsafe fn get_physical_device_external_buffer_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -216,6 +226,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceExternalFenceProperties.html>"]
unsafe fn get_physical_device_external_fence_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -230,6 +241,7 @@ pub trait InstanceV1_1: InstanceV1_0 {
);
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceExternalSemaphoreProperties.html>"]
unsafe fn get_physical_device_external_semaphore_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -250,6 +262,7 @@ pub trait InstanceV1_0 {
type Device;
fn handle(&self) -> vk::Instance;
fn fp_v1_0(&self) -> &vk::InstanceFnV1_0;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCreateDevice.html>"]
unsafe fn create_device(
&self,
physical_device: vk::PhysicalDevice,
@ -257,6 +270,7 @@ pub trait InstanceV1_0 {
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> Result<Self::Device, vk::Result>;
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetDeviceProcAddr.html>"]
unsafe fn get_device_proc_addr(
&self,
device: vk::Device,
@ -265,11 +279,13 @@ pub trait InstanceV1_0 {
self.fp_v1_0().get_device_proc_addr(device, p_name)
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyInstance.html>"]
unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.fp_v1_0()
.destroy_instance(self.handle(), allocation_callbacks.as_raw_ptr());
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceFormatProperties.html>"]
unsafe fn get_physical_device_format_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -284,6 +300,7 @@ pub trait InstanceV1_0 {
format_prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties.html>"]
unsafe fn get_physical_device_image_format_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -310,6 +327,7 @@ pub trait InstanceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceMemoryProperties.html>"]
unsafe fn get_physical_device_memory_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -320,6 +338,7 @@ pub trait InstanceV1_0 {
memory_prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceProperties.html>"]
unsafe fn get_physical_device_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -330,6 +349,7 @@ pub trait InstanceV1_0 {
prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties.html>"]
unsafe fn get_physical_device_queue_family_properties(
&self,
physical_device: vk::PhysicalDevice,
@ -350,6 +370,7 @@ pub trait InstanceV1_0 {
queue_families_vec
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkGetPhysicalDeviceFeatures.html>"]
unsafe fn get_physical_device_features(
&self,
physical_device: vk::PhysicalDevice,
@ -360,6 +381,7 @@ pub trait InstanceV1_0 {
prop
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumeratePhysicalDevices.html>"]
unsafe fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
let mut num = mem::uninitialized();
self.fp_v1_0()
@ -377,6 +399,7 @@ pub trait InstanceV1_0 {
}
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateDeviceExtensionProperties.html>"]
unsafe fn enumerate_device_extension_properties(
&self,
device: vk::PhysicalDevice,

View file

@ -1,9 +1,32 @@
#[macro_use]
extern crate lazy_static;
//! # Vulkan API
//!
//! <https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/index.html>
//!
//! ## Examples
//!
//! ```rust,no_run
//! # #[macro_use]
//! # extern crate ash;
//! use ash::{vk, Entry, version::EntryV1_0};
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let entry = Entry::new()?;
//! let app_info = vk::ApplicationInfo {
//! api_version: vk_make_version!(1, 0, 0),
//! ..Default::default()
//! };
//! let create_info = vk::InstanceCreateInfo {
//! p_application_info: &app_info,
//! ..Default::default()
//! };
//! let instance = unsafe { entry.create_instance(&create_info, None)? };
//! # Ok(()) }
//! ```
//!
extern crate shared_library;
pub use device::Device;
pub use entry::{Entry, InstanceError, LoadingError};
pub use entry::{Entry, EntryCustom, InstanceError, LoadingError};
pub use instance::Instance;
mod device;

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,13 @@ pub extern crate vkxml;
use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
use itertools::Itertools;
use proc_macro2::Term;
use proc_macro2::{Literal, Term};
use quote::Tokens;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::fmt::Display;
use std::path::Path;
use syn::Ident;
pub trait ExtensionExt {}
#[derive(Copy, Clone, Debug)]
pub enum CType {
@ -85,13 +87,24 @@ named!(cfloat<&str, f32>,
terminated!(nom::float_s, char!('f'))
);
fn khronos_link<S: Display>(name: &S) -> Literal {
Literal::string(&format!(
"<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/{name}.html>",
name = name
))
}
pub fn define_handle_macro() -> Tokens {
quote! {
#[macro_export]
macro_rules! define_handle{
($name: ident, $ty: ident) => {
define_handle!($name, $ty, doc = "");
};
($name: ident, $ty: ident, $doc_link: meta) => {
#[repr(transparent)]
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash)]
#[$doc_link]
pub struct $name(*mut u8);
impl Default for $name {
fn default() -> $name {
@ -135,8 +148,12 @@ pub fn handle_nondispatchable_macro() -> Tokens {
#[macro_export]
macro_rules! handle_nondispatchable {
($name: ident, $ty: ident) => {
handle_nondispatchable!($name, $ty, doc = "");
};
($name: ident, $ty: ident, $doc_link: meta) => {
#[repr(transparent)]
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Default)]
#[$doc_link]
pub struct $name(u64);
impl Handle for $name {
@ -168,6 +185,7 @@ pub fn handle_nondispatchable_macro() -> Tokens {
}
pub fn vk_version_macros() -> Tokens {
quote! {
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_MAKE_VERSION.html>"]
#[macro_export]
macro_rules! vk_make_version {
($major:expr, $minor:expr, $patch:expr) => {
@ -175,6 +193,7 @@ pub fn vk_version_macros() -> Tokens {
};
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_VERSION_MAJOR.html>"]
#[macro_export]
macro_rules! vk_version_major {
($major:expr) => {
@ -182,6 +201,7 @@ pub fn vk_version_macros() -> Tokens {
};
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_VERSION_MINOR.html>"]
#[macro_export]
macro_rules! vk_version_minor {
($minor:expr) => {
@ -189,6 +209,7 @@ pub fn vk_version_macros() -> Tokens {
};
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_VERSION_PATCH.html>"]
#[macro_export]
macro_rules! vk_version_patch {
($minor:expr) => {
@ -700,6 +721,7 @@ fn generate_function_pointers<'a>(
let raw_names_ref = &raw_names;
let names_left = &names;
let names_right = &names;
let khronos_links: Vec<_> = raw_names.iter().map(|name| khronos_link(name)).collect();
let pfn_commands: Vec<_> = commands
.iter()
@ -847,6 +869,7 @@ fn generate_function_pointers<'a>(
}
}
#(
#[doc = #khronos_links]
pub unsafe fn #names_ref(&self, #expanded_params_ref) -> #return_types_ref {
(self.#names_left)(#(#param_names_ref,)*)
}
@ -1005,7 +1028,9 @@ pub fn generate_extension<'a>(
pub fn generate_typedef(typedef: &vkxml::Typedef) -> Tokens {
let typedef_name = to_type_tokens(&typedef.name, None);
let typedef_ty = to_type_tokens(&typedef.basetype, None);
let khronos_link = khronos_link(&typedef.name);
quote! {
#[doc = #khronos_link]
pub type #typedef_name = #typedef_ty;
}
}
@ -1028,9 +1053,11 @@ pub fn generate_bitmask(
return None;
};
bitflags_cache.insert(ident.clone());
let khronos_link = khronos_link(&bitmask.name);
Some(quote! {
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[doc = #khronos_link]
pub struct #ident(Flags);
vk_bitflags_wrapped!(#ident, 0b0, Flags);
})
@ -1134,6 +1161,8 @@ pub fn generate_enum<'a>(
values.push(constant.variant_ident(&_enum.name));
}
let khronos_link = khronos_link(&_enum.name);
if name.contains("Bit") {
let ident = Ident::from(_name.as_str());
let all_bits = constants
@ -1150,6 +1179,7 @@ pub fn generate_enum<'a>(
let q = quote! {
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[doc = #khronos_link]
pub struct #ident(pub(crate) Flags);
vk_bitflags_wrapped!(#ident, #all_bits_term, Flags);
#impl_bitflags
@ -1161,6 +1191,7 @@ pub fn generate_enum<'a>(
let enum_quote = quote! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
#[doc = #khronos_link]
pub struct #ident(pub(crate) i32);
impl #ident {
pub fn from_raw(x: i32) -> Self { #ident(x) }
@ -1745,9 +1776,11 @@ pub fn generate_struct(
} else {
quote!()
};
let khronos_link = khronos_link(&_struct.name);
quote! {
#[repr(C)]
#[derive(Copy, Clone, #default_str #dbg_str #manual_derive_tokens)]
#[doc = #khronos_link]
pub struct #name {
#(#params,)*
}
@ -1761,13 +1794,14 @@ pub fn generate_handle(handle: &vkxml::Handle) -> Option<Tokens> {
if handle.name == "" {
return None;
}
let khronos_link = khronos_link(&handle.name);
let tokens = match handle.ty {
vkxml::HandleType::Dispatch => {
let name = &handle.name[2..];
let ty = Ident::from(name.to_shouty_snake_case());
let name = Ident::from(name);
quote! {
define_handle!(#name, #ty);
define_handle!(#name, #ty, doc = #khronos_link);
}
}
vkxml::HandleType::NoDispatch => {
@ -1775,7 +1809,7 @@ pub fn generate_handle(handle: &vkxml::Handle) -> Option<Tokens> {
let ty = Ident::from(name.to_shouty_snake_case());
let name = Ident::from(name);
quote! {
handle_nondispatchable!(#name, #ty);
handle_nondispatchable!(#name, #ty, doc = #khronos_link);
}
}
};
@ -1791,8 +1825,10 @@ fn generate_funcptr(fnptr: &vkxml::FunctionPointer) -> Tokens {
#ident: #type_tokens
}
});
let khronos_link = khronos_link(&fnptr.name);
quote! {
#[allow(non_camel_case_types)]
#[doc = #khronos_link]
pub type #name = Option<unsafe extern "system" fn(#(#params),*) -> #ret_ty_tokens>;
}
}
@ -1806,9 +1842,11 @@ fn generate_union(union: &vkxml::Union) -> Tokens {
pub #name: #ty
}
});
let khronos_link = khronos_link(&union.name);
quote! {
#[repr(C)]
#[derive(Copy, Clone)]
#[doc = #khronos_link]
pub union #name {
#(#fields),*
}