Preliminary cleanup pass (#339)
* Fix clippy::manual_strip
* Fix clippy::comparison_to_empty
* Fix clippy::needless_lifetimes
* generator: Drop unnecessary edgecase for charptr array in builder
* generator: Make array type handling more linear
* prelude: Provide Result -> VkResult<()> conversion
* Add #[must_use] to Result type
* Fix all unchecked vk::Result cases
* generator: Fix typos
* generator: Assert char ptrs have `"null-terminated"` len attribute
* prelude: Provide result_with_success helper for Result -> VKresult
* Cleanup match{success} blocks with SSR
{let $p = $f; match $q { vk::Result::SUCCESS => Ok($r), _ => Err($z), }} ==>> {$f.result_with_success($r)}
* Simplify matching on Result::SUCCESS
Using the following regex replacement:
let err_code =\s*(.*\((\n|[^;])*?\));\s*match err_code \{\s*vk::Result::SUCCESS => Ok\((.*)\),\s*_ => Err\(err_code\),\s*\}
$1.result_with_success($3)
* Simplify intermediate error return
let err_code =\s*(.*\((\n|[^;])*?\));\s*if err_code != vk::Result::SUCCESS \{\s*return Err\(err_code\);\s*\}
$1.result()?;
* Simplify error checking with .result()? and .result_with_success()
* generator: Ignore empty basetype in typedef (forward declaration)
ANativeWindow and AHardwareBuffer were [recently changed] to the
basetype category, but without an actual basetype, consequently failing
the Ident constructor with an empty name.
Since these types are already dealt with in platform_types, and there
doesn't seem to be anything sensical to define them to right now, just
ignore these cases.
[recently changed]: 0c5351f5e9 (diff-0ff049f722e55de41ee15b2c91ef380fL179-R180)
* Suggestion: Allocate data in get_ray_tracing_shader_group_handles
* generator: Update nom to 6.0
* generator: Generalize C expression conversion to TokenStream
* generator: Simplify ReferenceType::to_tokens with quote!
* generator: Refactor to not parse our own stringified token stream
* generator: Deal with pointers to static-sized arrays
* generator: Apply static-sized array pointer to size containing `*`
* generator: setter: Interpret all references as ptr, not just p_/pp_
* generator: quote::* is already imported
* generator: Replace manual fn to_tokens with quote::ToTokens trait impl
* generator: Return str reference from constant_name
* generator: Replace unused to_type_tokens with name_to_tokens
The reference argument was always None; replace it with a direct call to
name_to_tokens.
* generator: setters: Use safe mutable references instead of raw ptrs
This commit is contained in:
parent
29cab9e9b4
commit
bfa0309c97
|
@ -61,16 +61,14 @@ pub trait DeviceV1_2: DeviceV1_1 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::RenderPass> {
|
) -> VkResult<vk::RenderPass> {
|
||||||
let mut renderpass = mem::zeroed();
|
let mut renderpass = mem::zeroed();
|
||||||
let err_code = self.fp_v1_2().create_render_pass2(
|
self.fp_v1_2()
|
||||||
|
.create_render_pass2(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut renderpass,
|
&mut renderpass,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(renderpass)
|
||||||
vk::Result::SUCCESS => Ok(renderpass),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginRenderPass2.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginRenderPass2.html>"]
|
||||||
|
@ -122,13 +120,9 @@ pub trait DeviceV1_2: DeviceV1_1 {
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreCounterValue.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreCounterValue.html>"]
|
||||||
unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult<u64> {
|
unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult<u64> {
|
||||||
let mut value = 0;
|
let mut value = 0;
|
||||||
let err_code =
|
|
||||||
self.fp_v1_2()
|
self.fp_v1_2()
|
||||||
.get_semaphore_counter_value(self.handle(), semaphore, &mut value);
|
.get_semaphore_counter_value(self.handle(), semaphore, &mut value)
|
||||||
match err_code {
|
.result_with_success(value)
|
||||||
vk::Result::SUCCESS => Ok(value),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitSemaphores.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitSemaphores.html>"]
|
||||||
|
@ -137,22 +131,16 @@ pub trait DeviceV1_2: DeviceV1_1 {
|
||||||
wait_info: &vk::SemaphoreWaitInfo,
|
wait_info: &vk::SemaphoreWaitInfo,
|
||||||
timeout: u64,
|
timeout: u64,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.fp_v1_2()
|
||||||
.fp_v1_2()
|
.wait_semaphores(self.handle(), wait_info, timeout)
|
||||||
.wait_semaphores(self.handle(), wait_info, timeout);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> {
|
unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_2().signal_semaphore(self.handle(), signal_info);
|
self.fp_v1_2()
|
||||||
match err_code {
|
.signal_semaphore(self.handle(), signal_info)
|
||||||
vk::Result::SUCCESS => Ok(()),
|
.into()
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -186,28 +174,16 @@ pub trait DeviceV1_1: DeviceV1_0 {
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindBufferMemory2.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindBufferMemory2.html>"]
|
||||||
unsafe fn bind_buffer_memory2(&self, bind_infos: &[vk::BindBufferMemoryInfo]) -> VkResult<()> {
|
unsafe fn bind_buffer_memory2(&self, bind_infos: &[vk::BindBufferMemoryInfo]) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_1().bind_buffer_memory2(
|
self.fp_v1_1()
|
||||||
self.handle(),
|
.bind_buffer_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr())
|
||||||
bind_infos.len() as _,
|
.into()
|
||||||
bind_infos.as_ptr(),
|
|
||||||
);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
unsafe fn bind_image_memory2(&self, bind_infos: &[vk::BindImageMemoryInfo]) -> VkResult<()> {
|
unsafe fn bind_image_memory2(&self, bind_infos: &[vk::BindImageMemoryInfo]) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_1().bind_image_memory2(
|
self.fp_v1_1()
|
||||||
self.handle(),
|
.bind_image_memory2(self.handle(), bind_infos.len() as _, bind_infos.as_ptr())
|
||||||
bind_infos.len() as _,
|
.into()
|
||||||
bind_infos.as_ptr(),
|
|
||||||
);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -322,16 +298,14 @@ pub trait DeviceV1_1: DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SamplerYcbcrConversion> {
|
) -> VkResult<vk::SamplerYcbcrConversion> {
|
||||||
let mut ycbcr_conversion = mem::zeroed();
|
let mut ycbcr_conversion = mem::zeroed();
|
||||||
let err_code = self.fp_v1_1().create_sampler_ycbcr_conversion(
|
self.fp_v1_1()
|
||||||
|
.create_sampler_ycbcr_conversion(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut ycbcr_conversion,
|
&mut ycbcr_conversion,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(ycbcr_conversion)
|
||||||
vk::Result::SUCCESS => Ok(ycbcr_conversion),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySamplerYcbcrConversion.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySamplerYcbcrConversion.html>"]
|
||||||
|
@ -354,16 +328,14 @@ pub trait DeviceV1_1: DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::DescriptorUpdateTemplate> {
|
) -> VkResult<vk::DescriptorUpdateTemplate> {
|
||||||
let mut descriptor_update_template = mem::zeroed();
|
let mut descriptor_update_template = mem::zeroed();
|
||||||
let err_code = self.fp_v1_1().create_descriptor_update_template(
|
self.fp_v1_1()
|
||||||
|
.create_descriptor_update_template(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut descriptor_update_template,
|
&mut descriptor_update_template,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(descriptor_update_template)
|
||||||
vk::Result::SUCCESS => Ok(descriptor_update_template),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDescriptorUpdateTemplate.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDescriptorUpdateTemplate.html>"]
|
||||||
|
@ -456,16 +428,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::Event> {
|
) -> VkResult<vk::Event> {
|
||||||
let mut event = mem::zeroed();
|
let mut event = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_event(
|
self.fp_v1_0()
|
||||||
|
.create_event(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut event,
|
&mut event,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(event)
|
||||||
vk::Result::SUCCESS => Ok(event),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the event was set, and false if the event was reset, otherwise it will
|
/// Returns true if the event was set, and false if the event was reset, otherwise it will
|
||||||
|
@ -482,20 +452,12 @@ pub trait DeviceV1_0 {
|
||||||
|
|
||||||
#[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>"]
|
||||||
unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> {
|
unsafe fn set_event(&self, event: vk::Event) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().set_event(self.handle(), event);
|
self.fp_v1_0().set_event(self.handle(), event).into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> {
|
unsafe fn reset_event(&self, event: vk::Event) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().reset_event(self.handle(), event);
|
self.fp_v1_0().reset_event(self.handle(), event).into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[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>"]
|
||||||
unsafe fn cmd_set_event(
|
unsafe fn cmd_set_event(
|
||||||
|
@ -736,13 +698,15 @@ pub trait DeviceV1_0 {
|
||||||
&self,
|
&self,
|
||||||
pool: vk::DescriptorPool,
|
pool: vk::DescriptorPool,
|
||||||
descriptor_sets: &[vk::DescriptorSet],
|
descriptor_sets: &[vk::DescriptorSet],
|
||||||
) {
|
) -> VkResult<()> {
|
||||||
self.fp_v1_0().free_descriptor_sets(
|
self.fp_v1_0()
|
||||||
|
.free_descriptor_sets(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
pool,
|
pool,
|
||||||
descriptor_sets.len() as u32,
|
descriptor_sets.len() as u32,
|
||||||
descriptor_sets.as_ptr(),
|
descriptor_sets.as_ptr(),
|
||||||
);
|
)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -767,16 +731,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::Sampler> {
|
) -> VkResult<vk::Sampler> {
|
||||||
let mut sampler = mem::zeroed();
|
let mut sampler = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_sampler(
|
self.fp_v1_0()
|
||||||
|
.create_sampler(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut sampler,
|
&mut sampler,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(sampler)
|
||||||
vk::Result::SUCCESS => Ok(sampler),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBlitImage.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBlitImage.html>"]
|
||||||
|
@ -942,10 +904,7 @@ pub trait DeviceV1_0 {
|
||||||
);
|
);
|
||||||
|
|
||||||
desc_set.set_len(create_info.descriptor_set_count as usize);
|
desc_set.set_len(create_info.descriptor_set_count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(desc_set)
|
||||||
vk::Result::SUCCESS => Ok(desc_set),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDescriptorSetLayout.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDescriptorSetLayout.html>"]
|
||||||
|
@ -955,25 +914,19 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::DescriptorSetLayout> {
|
) -> VkResult<vk::DescriptorSetLayout> {
|
||||||
let mut layout = mem::zeroed();
|
let mut layout = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_descriptor_set_layout(
|
self.fp_v1_0()
|
||||||
|
.create_descriptor_set_layout(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut layout,
|
&mut layout,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(layout)
|
||||||
vk::Result::SUCCESS => Ok(layout),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
unsafe fn device_wait_idle(&self) -> VkResult<()> {
|
unsafe fn device_wait_idle(&self) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().device_wait_idle(self.handle());
|
self.fp_v1_0().device_wait_idle(self.handle()).into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -983,16 +936,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::DescriptorPool> {
|
) -> VkResult<vk::DescriptorPool> {
|
||||||
let mut pool = mem::zeroed();
|
let mut pool = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_descriptor_pool(
|
self.fp_v1_0()
|
||||||
|
.create_descriptor_pool(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pool,
|
&mut pool,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(pool)
|
||||||
vk::Result::SUCCESS => Ok(pool),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetDescriptorPool.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkResetDescriptorPool.html>"]
|
||||||
|
@ -1001,13 +952,9 @@ pub trait DeviceV1_0 {
|
||||||
pool: vk::DescriptorPool,
|
pool: vk::DescriptorPool,
|
||||||
flags: vk::DescriptorPoolResetFlags,
|
flags: vk::DescriptorPoolResetFlags,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.fp_v1_0()
|
||||||
.fp_v1_0()
|
.reset_descriptor_pool(self.handle(), pool, flags)
|
||||||
.reset_descriptor_pool(self.handle(), pool, flags);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1016,13 +963,9 @@ pub trait DeviceV1_0 {
|
||||||
command_pool: vk::CommandPool,
|
command_pool: vk::CommandPool,
|
||||||
flags: vk::CommandPoolResetFlags,
|
flags: vk::CommandPoolResetFlags,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.fp_v1_0()
|
||||||
.fp_v1_0()
|
.reset_command_pool(self.handle(), command_pool, flags)
|
||||||
.reset_command_pool(self.handle(), command_pool, flags);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1031,22 +974,16 @@ pub trait DeviceV1_0 {
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
flags: vk::CommandBufferResetFlags,
|
flags: vk::CommandBufferResetFlags,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().reset_command_buffer(command_buffer, flags);
|
self.fp_v1_0()
|
||||||
match err_code {
|
.reset_command_buffer(command_buffer, flags)
|
||||||
vk::Result::SUCCESS => Ok(()),
|
.into()
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
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()
|
self.fp_v1_0()
|
||||||
.reset_fences(self.handle(), fences.len() as u32, fences.as_ptr());
|
.reset_fences(self.handle(), fences.len() as u32, fences.as_ptr())
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1456,7 +1393,8 @@ pub trait DeviceV1_0 {
|
||||||
"query_count was higher than the length of the slice"
|
"query_count was higher than the length of the slice"
|
||||||
);
|
);
|
||||||
let data_size = mem::size_of::<T>() * data_length;
|
let data_size = mem::size_of::<T>() * data_length;
|
||||||
let err_code = self.fp_v1_0().get_query_pool_results(
|
self.fp_v1_0()
|
||||||
|
.get_query_pool_results(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
query_pool,
|
query_pool,
|
||||||
first_query,
|
first_query,
|
||||||
|
@ -1465,12 +1403,8 @@ pub trait DeviceV1_0 {
|
||||||
data.as_mut_ptr() as *mut _,
|
data.as_mut_ptr() as *mut _,
|
||||||
mem::size_of::<T>() as _,
|
mem::size_of::<T>() as _,
|
||||||
flags,
|
flags,
|
||||||
);
|
)
|
||||||
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1527,16 +1461,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::Semaphore> {
|
) -> VkResult<vk::Semaphore> {
|
||||||
let mut semaphore = mem::zeroed();
|
let mut semaphore = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_semaphore(
|
self.fp_v1_0()
|
||||||
|
.create_semaphore(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut semaphore,
|
&mut semaphore,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(semaphore)
|
||||||
vk::Result::SUCCESS => Ok(semaphore),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateGraphicsPipelines.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateGraphicsPipelines.html>"]
|
||||||
|
@ -1592,16 +1524,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::Buffer> {
|
) -> VkResult<vk::Buffer> {
|
||||||
let mut buffer = mem::zeroed();
|
let mut buffer = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_buffer(
|
self.fp_v1_0()
|
||||||
|
.create_buffer(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut buffer,
|
&mut buffer,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(buffer)
|
||||||
vk::Result::SUCCESS => Ok(buffer),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreatePipelineLayout.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreatePipelineLayout.html>"]
|
||||||
|
@ -1611,16 +1541,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::PipelineLayout> {
|
) -> VkResult<vk::PipelineLayout> {
|
||||||
let mut pipeline_layout = mem::zeroed();
|
let mut pipeline_layout = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_pipeline_layout(
|
self.fp_v1_0()
|
||||||
|
.create_pipeline_layout(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pipeline_layout,
|
&mut pipeline_layout,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(pipeline_layout)
|
||||||
vk::Result::SUCCESS => Ok(pipeline_layout),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreatePipelineCache.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreatePipelineCache.html>"]
|
||||||
|
@ -1630,17 +1558,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::PipelineCache> {
|
) -> VkResult<vk::PipelineCache> {
|
||||||
let mut pipeline_cache = mem::zeroed();
|
let mut pipeline_cache = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_pipeline_cache(
|
self.fp_v1_0()
|
||||||
|
.create_pipeline_cache(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pipeline_cache,
|
&mut pipeline_cache,
|
||||||
);
|
)
|
||||||
|
.result_with_success(pipeline_cache)
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(pipeline_cache),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineCacheData.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineCacheData.html>"]
|
||||||
|
@ -1649,15 +1574,14 @@ pub trait DeviceV1_0 {
|
||||||
pipeline_cache: vk::PipelineCache,
|
pipeline_cache: vk::PipelineCache,
|
||||||
) -> VkResult<Vec<u8>> {
|
) -> VkResult<Vec<u8>> {
|
||||||
let mut data_size: usize = 0;
|
let mut data_size: usize = 0;
|
||||||
let err_code = self.fp_v1_0().get_pipeline_cache_data(
|
self.fp_v1_0()
|
||||||
|
.get_pipeline_cache_data(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
pipeline_cache,
|
pipeline_cache,
|
||||||
&mut data_size,
|
&mut data_size,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
)
|
||||||
if err_code != vk::Result::SUCCESS {
|
.result()?;
|
||||||
return Err(err_code);
|
|
||||||
};
|
|
||||||
let mut data: Vec<u8> = Vec::with_capacity(data_size);
|
let mut data: Vec<u8> = Vec::with_capacity(data_size);
|
||||||
let err_code = self.fp_v1_0().get_pipeline_cache_data(
|
let err_code = self.fp_v1_0().get_pipeline_cache_data(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
|
@ -1666,10 +1590,7 @@ pub trait DeviceV1_0 {
|
||||||
data.as_mut_ptr() as _,
|
data.as_mut_ptr() as _,
|
||||||
);
|
);
|
||||||
data.set_len(data_size);
|
data.set_len(data_size);
|
||||||
match err_code {
|
err_code.result_with_success(data)
|
||||||
vk::Result::SUCCESS => Ok(data),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1681,13 +1602,9 @@ pub trait DeviceV1_0 {
|
||||||
flags: vk::MemoryMapFlags,
|
flags: vk::MemoryMapFlags,
|
||||||
) -> VkResult<*mut c_void> {
|
) -> VkResult<*mut c_void> {
|
||||||
let mut data: *mut c_void = ptr::null_mut();
|
let mut data: *mut c_void = ptr::null_mut();
|
||||||
let err_code =
|
|
||||||
self.fp_v1_0()
|
self.fp_v1_0()
|
||||||
.map_memory(self.handle(), memory, offset, size, flags, &mut data);
|
.map_memory(self.handle(), memory, offset, size, flags, &mut data)
|
||||||
match err_code {
|
.result_with_success(data)
|
||||||
vk::Result::SUCCESS => Ok(data),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkUnmapMemory.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkUnmapMemory.html>"]
|
||||||
|
@ -1700,28 +1617,16 @@ pub trait DeviceV1_0 {
|
||||||
&self,
|
&self,
|
||||||
ranges: &[vk::MappedMemoryRange],
|
ranges: &[vk::MappedMemoryRange],
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().invalidate_mapped_memory_ranges(
|
self.fp_v1_0()
|
||||||
self.handle(),
|
.invalidate_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr())
|
||||||
ranges.len() as u32,
|
.into()
|
||||||
ranges.as_ptr(),
|
|
||||||
);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
unsafe fn flush_mapped_memory_ranges(&self, ranges: &[vk::MappedMemoryRange]) -> VkResult<()> {
|
unsafe fn flush_mapped_memory_ranges(&self, ranges: &[vk::MappedMemoryRange]) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().flush_mapped_memory_ranges(
|
self.fp_v1_0()
|
||||||
self.handle(),
|
.flush_mapped_memory_ranges(self.handle(), ranges.len() as u32, ranges.as_ptr())
|
||||||
ranges.len() as u32,
|
.into()
|
||||||
ranges.as_ptr(),
|
|
||||||
);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1731,16 +1636,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::Framebuffer> {
|
) -> VkResult<vk::Framebuffer> {
|
||||||
let mut framebuffer = mem::zeroed();
|
let mut framebuffer = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_framebuffer(
|
self.fp_v1_0()
|
||||||
|
.create_framebuffer(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut framebuffer,
|
&mut framebuffer,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(framebuffer)
|
||||||
vk::Result::SUCCESS => Ok(framebuffer),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceQueue.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceQueue.html>"]
|
||||||
|
@ -1783,16 +1686,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::RenderPass> {
|
) -> VkResult<vk::RenderPass> {
|
||||||
let mut renderpass = mem::zeroed();
|
let mut renderpass = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_render_pass(
|
self.fp_v1_0()
|
||||||
|
.create_render_pass(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut renderpass,
|
&mut renderpass,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(renderpass)
|
||||||
vk::Result::SUCCESS => Ok(renderpass),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBeginCommandBuffer.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBeginCommandBuffer.html>"]
|
||||||
|
@ -1801,22 +1702,14 @@ pub trait DeviceV1_0 {
|
||||||
command_buffer: vk::CommandBuffer,
|
command_buffer: vk::CommandBuffer,
|
||||||
begin_info: &vk::CommandBufferBeginInfo,
|
begin_info: &vk::CommandBufferBeginInfo,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.fp_v1_0()
|
||||||
.fp_v1_0()
|
.begin_command_buffer(command_buffer, begin_info)
|
||||||
.begin_command_buffer(command_buffer, begin_info);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
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().end_command_buffer(command_buffer);
|
self.fp_v1_0().end_command_buffer(command_buffer).into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1826,17 +1719,15 @@ pub trait DeviceV1_0 {
|
||||||
wait_all: bool,
|
wait_all: bool,
|
||||||
timeout: u64,
|
timeout: u64,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().wait_for_fences(
|
self.fp_v1_0()
|
||||||
|
.wait_for_fences(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
fences.len() as u32,
|
fences.len() as u32,
|
||||||
fences.as_ptr(),
|
fences.as_ptr(),
|
||||||
wait_all as u32,
|
wait_all as u32,
|
||||||
timeout,
|
timeout,
|
||||||
);
|
)
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1851,11 +1742,7 @@ pub trait DeviceV1_0 {
|
||||||
|
|
||||||
#[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>"]
|
||||||
unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
|
unsafe fn queue_wait_idle(&self, queue: vk::Queue) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_0().queue_wait_idle(queue);
|
self.fp_v1_0().queue_wait_idle(queue).into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1865,13 +1752,9 @@ pub trait DeviceV1_0 {
|
||||||
submits: &[vk::SubmitInfo],
|
submits: &[vk::SubmitInfo],
|
||||||
fence: vk::Fence,
|
fence: vk::Fence,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code =
|
|
||||||
self.fp_v1_0()
|
self.fp_v1_0()
|
||||||
.queue_submit(queue, submits.len() as u32, submits.as_ptr(), fence);
|
.queue_submit(queue, submits.len() as u32, submits.as_ptr(), fence)
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -1881,16 +1764,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::BufferView> {
|
) -> VkResult<vk::BufferView> {
|
||||||
let mut buffer_view = mem::zeroed();
|
let mut buffer_view = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_buffer_view(
|
self.fp_v1_0()
|
||||||
|
.create_buffer_view(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut buffer_view,
|
&mut buffer_view,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(buffer_view)
|
||||||
vk::Result::SUCCESS => Ok(buffer_view),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyBufferView.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyBufferView.html>"]
|
||||||
|
@ -1913,16 +1794,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::ImageView> {
|
) -> VkResult<vk::ImageView> {
|
||||||
let mut image_view = mem::zeroed();
|
let mut image_view = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_image_view(
|
self.fp_v1_0()
|
||||||
|
.create_image_view(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut image_view,
|
&mut image_view,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(image_view)
|
||||||
vk::Result::SUCCESS => Ok(image_view),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAllocateCommandBuffers.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAllocateCommandBuffers.html>"]
|
||||||
|
@ -1937,10 +1816,7 @@ pub trait DeviceV1_0 {
|
||||||
buffers.as_mut_ptr(),
|
buffers.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
buffers.set_len(create_info.command_buffer_count as usize);
|
buffers.set_len(create_info.command_buffer_count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(buffers)
|
||||||
vk::Result::SUCCESS => Ok(buffers),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateCommandPool.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateCommandPool.html>"]
|
||||||
|
@ -1950,16 +1826,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::CommandPool> {
|
) -> VkResult<vk::CommandPool> {
|
||||||
let mut pool = mem::zeroed();
|
let mut pool = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_command_pool(
|
self.fp_v1_0()
|
||||||
|
.create_command_pool(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pool,
|
&mut pool,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(pool)
|
||||||
vk::Result::SUCCESS => Ok(pool),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateQueryPool.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateQueryPool.html>"]
|
||||||
|
@ -1969,16 +1843,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::QueryPool> {
|
) -> VkResult<vk::QueryPool> {
|
||||||
let mut pool = mem::zeroed();
|
let mut pool = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_query_pool(
|
self.fp_v1_0()
|
||||||
|
.create_query_pool(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut pool,
|
&mut pool,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(pool)
|
||||||
vk::Result::SUCCESS => Ok(pool),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateImage.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateImage.html>"]
|
||||||
|
@ -1988,16 +1860,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::Image> {
|
) -> VkResult<vk::Image> {
|
||||||
let mut image = mem::zeroed();
|
let mut image = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_image(
|
self.fp_v1_0()
|
||||||
|
.create_image(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut image,
|
&mut image,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(image)
|
||||||
vk::Result::SUCCESS => Ok(image),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetImageSubresourceLayout.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetImageSubresourceLayout.html>"]
|
||||||
|
@ -2039,16 +1909,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::DeviceMemory> {
|
) -> VkResult<vk::DeviceMemory> {
|
||||||
let mut memory = mem::zeroed();
|
let mut memory = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().allocate_memory(
|
self.fp_v1_0()
|
||||||
|
.allocate_memory(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut memory,
|
&mut memory,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(memory)
|
||||||
vk::Result::SUCCESS => Ok(memory),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateShaderModule.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateShaderModule.html>"]
|
||||||
|
@ -2058,16 +1926,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::ShaderModule> {
|
) -> VkResult<vk::ShaderModule> {
|
||||||
let mut shader = mem::zeroed();
|
let mut shader = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_shader_module(
|
self.fp_v1_0()
|
||||||
|
.create_shader_module(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut shader,
|
&mut shader,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(shader)
|
||||||
vk::Result::SUCCESS => Ok(shader),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateFence.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateFence.html>"]
|
||||||
|
@ -2077,16 +1943,14 @@ pub trait DeviceV1_0 {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::Fence> {
|
) -> VkResult<vk::Fence> {
|
||||||
let mut fence = mem::zeroed();
|
let mut fence = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_fence(
|
self.fp_v1_0()
|
||||||
|
.create_fence(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut fence,
|
&mut fence,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(fence)
|
||||||
vk::Result::SUCCESS => Ok(fence),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindBufferMemory.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindBufferMemory.html>"]
|
||||||
|
@ -2096,13 +1960,9 @@ pub trait DeviceV1_0 {
|
||||||
device_memory: vk::DeviceMemory,
|
device_memory: vk::DeviceMemory,
|
||||||
offset: vk::DeviceSize,
|
offset: vk::DeviceSize,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code =
|
|
||||||
self.fp_v1_0()
|
self.fp_v1_0()
|
||||||
.bind_buffer_memory(self.handle(), buffer, device_memory, offset);
|
.bind_buffer_memory(self.handle(), buffer, device_memory, offset)
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -2112,13 +1972,9 @@ pub trait DeviceV1_0 {
|
||||||
device_memory: vk::DeviceMemory,
|
device_memory: vk::DeviceMemory,
|
||||||
offset: vk::DeviceSize,
|
offset: vk::DeviceSize,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code =
|
|
||||||
self.fp_v1_0()
|
self.fp_v1_0()
|
||||||
.bind_image_memory(self.handle(), image, device_memory, offset);
|
.bind_image_memory(self.handle(), image, device_memory, offset)
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,17 +58,14 @@ pub trait EntryV1_0 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut num = 0;
|
let mut num = 0;
|
||||||
self.fp_v1_0()
|
self.fp_v1_0()
|
||||||
.enumerate_instance_layer_properties(&mut num, ptr::null_mut());
|
.enumerate_instance_layer_properties(&mut num, ptr::null_mut())
|
||||||
|
.result()?;
|
||||||
let mut v = Vec::with_capacity(num as usize);
|
let mut v = Vec::with_capacity(num as usize);
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.fp_v1_0()
|
.fp_v1_0()
|
||||||
.enumerate_instance_layer_properties(&mut num, v.as_mut_ptr());
|
.enumerate_instance_layer_properties(&mut num, v.as_mut_ptr());
|
||||||
v.set_len(num as usize);
|
v.set_len(num as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,11 +73,9 @@ pub trait EntryV1_0 {
|
||||||
fn enumerate_instance_extension_properties(&self) -> VkResult<Vec<vk::ExtensionProperties>> {
|
fn enumerate_instance_extension_properties(&self) -> VkResult<Vec<vk::ExtensionProperties>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut num = 0;
|
let mut num = 0;
|
||||||
self.fp_v1_0().enumerate_instance_extension_properties(
|
self.fp_v1_0()
|
||||||
ptr::null(),
|
.enumerate_instance_extension_properties(ptr::null(), &mut num, ptr::null_mut())
|
||||||
&mut num,
|
.result()?;
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut data = Vec::with_capacity(num as usize);
|
let mut data = Vec::with_capacity(num as usize);
|
||||||
let err_code = self.fp_v1_0().enumerate_instance_extension_properties(
|
let err_code = self.fp_v1_0().enumerate_instance_extension_properties(
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
|
@ -88,10 +83,7 @@ pub trait EntryV1_0 {
|
||||||
data.as_mut_ptr(),
|
data.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
data.set_len(num as usize);
|
data.set_len(num as usize);
|
||||||
match err_code {
|
err_code.result_with_success(data)
|
||||||
vk::Result::SUCCESS => Ok(data),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,14 +111,14 @@ impl<L> EntryV1_0 for EntryCustom<L> {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> Result<Self::Instance, InstanceError> {
|
) -> Result<Self::Instance, InstanceError> {
|
||||||
let mut instance: vk::Instance = mem::zeroed();
|
let mut instance: vk::Instance = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_instance(
|
self.fp_v1_0()
|
||||||
|
.create_instance(
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut instance,
|
&mut instance,
|
||||||
);
|
)
|
||||||
if err_code != vk::Result::SUCCESS {
|
.result()
|
||||||
return Err(InstanceError::VkError(err_code));
|
.map_err(InstanceError::VkError)?;
|
||||||
}
|
|
||||||
Ok(Instance::load(&self.static_fn, instance))
|
Ok(Instance::load(&self.static_fn, instance))
|
||||||
}
|
}
|
||||||
fn fp_v1_0(&self) -> &vk::EntryFnV1_0 {
|
fn fp_v1_0(&self) -> &vk::EntryFnV1_0 {
|
||||||
|
@ -146,11 +138,9 @@ pub trait EntryV1_1: EntryV1_0 {
|
||||||
fn enumerate_instance_version(&self) -> VkResult<u32> {
|
fn enumerate_instance_version(&self) -> VkResult<u32> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut api_version = 0;
|
let mut api_version = 0;
|
||||||
let err_code = self.fp_v1_1().enumerate_instance_version(&mut api_version);
|
self.fp_v1_1()
|
||||||
match err_code {
|
.enumerate_instance_version(&mut api_version)
|
||||||
vk::Result::SUCCESS => Ok(api_version),
|
.result_with_success(api_version)
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,11 +218,8 @@ impl<L> EntryCustom<L> {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
if let Some(enumerate_instance_version) = enumerate_instance_version {
|
if let Some(enumerate_instance_version) = enumerate_instance_version {
|
||||||
let err_code = (enumerate_instance_version)(&mut api_version);
|
(enumerate_instance_version)(&mut api_version)
|
||||||
match err_code {
|
.result_with_success(Some(api_version))
|
||||||
vk::Result::SUCCESS => Ok(Some(api_version)),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,9 @@ impl DebugMarker {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
name_info: &vk::DebugMarkerObjectNameInfoEXT,
|
name_info: &vk::DebugMarkerObjectNameInfoEXT,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.debug_marker_fn
|
||||||
.debug_marker_fn
|
.debug_marker_set_object_name_ext(device, name_info)
|
||||||
.debug_marker_set_object_name_ext(device, name_info);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
|
|
@ -47,16 +47,14 @@ impl DebugReport {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::DebugReportCallbackEXT> {
|
) -> VkResult<vk::DebugReportCallbackEXT> {
|
||||||
let mut debug_cb = mem::zeroed();
|
let mut debug_cb = mem::zeroed();
|
||||||
let err_code = self.debug_report_fn.create_debug_report_callback_ext(
|
self.debug_report_fn
|
||||||
|
.create_debug_report_callback_ext(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut debug_cb,
|
&mut debug_cb,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(debug_cb)
|
||||||
vk::Result::SUCCESS => Ok(debug_cb),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::ExtDebugReportFn {
|
pub fn fp(&self) -> &vk::ExtDebugReportFn {
|
||||||
|
|
|
@ -32,13 +32,9 @@ impl DebugUtils {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
name_info: &vk::DebugUtilsObjectNameInfoEXT,
|
name_info: &vk::DebugUtilsObjectNameInfoEXT,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.debug_utils_fn
|
||||||
.debug_utils_fn
|
.set_debug_utils_object_name_ext(device, name_info)
|
||||||
.set_debug_utils_object_name_ext(device, name_info);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -47,13 +43,9 @@ impl DebugUtils {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
tag_info: &vk::DebugUtilsObjectTagInfoEXT,
|
tag_info: &vk::DebugUtilsObjectTagInfoEXT,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.debug_utils_fn
|
||||||
.debug_utils_fn
|
.set_debug_utils_object_tag_ext(device, tag_info)
|
||||||
.set_debug_utils_object_tag_ext(device, tag_info);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -114,16 +106,14 @@ impl DebugUtils {
|
||||||
allocator: Option<&vk::AllocationCallbacks>,
|
allocator: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::DebugUtilsMessengerEXT> {
|
) -> VkResult<vk::DebugUtilsMessengerEXT> {
|
||||||
let mut messenger = mem::zeroed();
|
let mut messenger = mem::zeroed();
|
||||||
let err_code = self.debug_utils_fn.create_debug_utils_messenger_ext(
|
self.debug_utils_fn
|
||||||
|
.create_debug_utils_messenger_ext(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocator.as_raw_ptr(),
|
allocator.as_raw_ptr(),
|
||||||
&mut messenger,
|
&mut messenger,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(messenger)
|
||||||
vk::Result::SUCCESS => Ok(messenger),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugUtilsMessengerEXT.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugUtilsMessengerEXT.html>"]
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl MetalSurface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.metal_surface_fn.create_metal_surface_ext(
|
self.metal_surface_fn
|
||||||
|
.create_metal_surface_ext(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::ExtMetalSurfaceFn {
|
pub fn fp(&self) -> &vk::ExtMetalSurfaceFn {
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl ToolingInfo {
|
||||||
) -> VkResult<Vec<vk::PhysicalDeviceToolPropertiesEXT>> {
|
) -> VkResult<Vec<vk::PhysicalDeviceToolPropertiesEXT>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.tooling_info_fn
|
self.tooling_info_fn
|
||||||
.get_physical_device_tool_properties_ext(physical_device, &mut count, ptr::null_mut());
|
.get_physical_device_tool_properties_ext(physical_device, &mut count, ptr::null_mut())
|
||||||
|
.result()?;
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.tooling_info_fn
|
.tooling_info_fn
|
||||||
.get_physical_device_tool_properties_ext(physical_device, &mut count, v.as_mut_ptr());
|
.get_physical_device_tool_properties_ext(physical_device, &mut count, v.as_mut_ptr());
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::ExtToolingInfoFn {
|
pub fn fp(&self) -> &vk::ExtToolingInfoFn {
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl AndroidSurface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.android_surface_fn.create_android_surface_khr(
|
self.android_surface_fn
|
||||||
|
.create_android_surface_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn {
|
pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn {
|
||||||
|
|
|
@ -33,11 +33,13 @@ impl Display {
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
) -> VkResult<Vec<vk::DisplayPropertiesKHR>> {
|
) -> VkResult<Vec<vk::DisplayPropertiesKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.display_fn.get_physical_device_display_properties_khr(
|
self.display_fn
|
||||||
|
.get_physical_device_display_properties_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
&mut count,
|
&mut count,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
)
|
||||||
|
.result()?;
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self.display_fn.get_physical_device_display_properties_khr(
|
let err_code = self.display_fn.get_physical_device_display_properties_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
|
@ -45,10 +47,7 @@ impl Display {
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>"]
|
||||||
|
@ -57,12 +56,16 @@ impl Display {
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> {
|
) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.display_fn
|
let err_code = self
|
||||||
|
.display_fn
|
||||||
.get_physical_device_display_plane_properties_khr(
|
.get_physical_device_display_plane_properties_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
&mut count,
|
&mut count,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
);
|
||||||
|
if err_code != vk::Result::SUCCESS {
|
||||||
|
return Err(err_code);
|
||||||
|
}
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.display_fn
|
.display_fn
|
||||||
|
@ -72,10 +75,7 @@ impl Display {
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>"]
|
||||||
|
@ -85,12 +85,14 @@ impl Display {
|
||||||
plane_index: u32,
|
plane_index: u32,
|
||||||
) -> VkResult<Vec<vk::DisplayKHR>> {
|
) -> VkResult<Vec<vk::DisplayKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.display_fn.get_display_plane_supported_displays_khr(
|
self.display_fn
|
||||||
|
.get_display_plane_supported_displays_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
plane_index,
|
plane_index,
|
||||||
&mut count,
|
&mut count,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
)
|
||||||
|
.result()?;
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self.display_fn.get_display_plane_supported_displays_khr(
|
let err_code = self.display_fn.get_display_plane_supported_displays_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
|
@ -99,10 +101,7 @@ impl Display {
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayModePropertiesKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayModePropertiesKHR.html>"]
|
||||||
|
@ -112,12 +111,9 @@ impl Display {
|
||||||
display: vk::DisplayKHR,
|
display: vk::DisplayKHR,
|
||||||
) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> {
|
) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.display_fn.get_display_mode_properties_khr(
|
self.display_fn
|
||||||
physical_device,
|
.get_display_mode_properties_khr(physical_device, display, &mut count, ptr::null_mut())
|
||||||
display,
|
.result()?;
|
||||||
&mut count,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self.display_fn.get_display_mode_properties_khr(
|
let err_code = self.display_fn.get_display_mode_properties_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
|
@ -126,10 +122,7 @@ impl Display {
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayModeKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayModeKHR.html>"]
|
||||||
|
@ -141,17 +134,15 @@ impl Display {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::DisplayModeKHR> {
|
) -> VkResult<vk::DisplayModeKHR> {
|
||||||
let mut display_mode = mem::MaybeUninit::zeroed();
|
let mut display_mode = mem::MaybeUninit::zeroed();
|
||||||
let err_code = self.display_fn.create_display_mode_khr(
|
self.display_fn
|
||||||
|
.create_display_mode_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
display,
|
display,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
display_mode.as_mut_ptr(),
|
display_mode.as_mut_ptr(),
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(display_mode.assume_init())
|
||||||
vk::Result::SUCCESS => Ok(display_mode.assume_init()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>"]
|
||||||
|
@ -162,16 +153,14 @@ impl Display {
|
||||||
plane_index: u32,
|
plane_index: u32,
|
||||||
) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> {
|
) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> {
|
||||||
let mut display_plane_capabilities = mem::MaybeUninit::zeroed();
|
let mut display_plane_capabilities = mem::MaybeUninit::zeroed();
|
||||||
let err_code = self.display_fn.get_display_plane_capabilities_khr(
|
self.display_fn
|
||||||
|
.get_display_plane_capabilities_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
mode,
|
mode,
|
||||||
plane_index,
|
plane_index,
|
||||||
display_plane_capabilities.as_mut_ptr(),
|
display_plane_capabilities.as_mut_ptr(),
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(display_plane_capabilities.assume_init())
|
||||||
vk::Result::SUCCESS => Ok(display_plane_capabilities.assume_init()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html>"]
|
||||||
|
@ -181,16 +170,14 @@ impl Display {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::MaybeUninit::zeroed();
|
let mut surface = mem::MaybeUninit::zeroed();
|
||||||
let err_code = self.display_fn.create_display_plane_surface_khr(
|
self.display_fn
|
||||||
|
.create_display_plane_surface_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
surface.as_mut_ptr(),
|
surface.as_mut_ptr(),
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface.assume_init())
|
||||||
vk::Result::SUCCESS => Ok(surface.assume_init()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::KhrDisplayFn {
|
pub fn fp(&self) -> &vk::KhrDisplayFn {
|
||||||
|
|
|
@ -42,10 +42,7 @@ impl DisplaySwapchain {
|
||||||
swapchains.as_mut_ptr(),
|
swapchains.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
swapchains.set_len(create_infos.len());
|
swapchains.set_len(create_infos.len());
|
||||||
match err_code {
|
err_code.result_with_success(swapchains)
|
||||||
vk::Result::SUCCESS => Ok(swapchains),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn {
|
pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn {
|
||||||
|
|
|
@ -28,13 +28,10 @@ impl ExternalMemoryFd {
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdKHR.html>"]
|
||||||
pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> {
|
pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> {
|
||||||
let mut fd = -1;
|
let mut fd = -1;
|
||||||
let err_code =
|
|
||||||
self.external_memory_fd_fn
|
self.external_memory_fd_fn
|
||||||
.get_memory_fd_khr(self.handle, create_info, &mut fd);
|
.get_memory_fd_khr(self.handle, create_info, &mut fd)
|
||||||
match err_code {
|
.result_with_success(fd)
|
||||||
vk::Result::SUCCESS => Ok(fd),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdPropertiesKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdPropertiesKHR.html>"]
|
||||||
|
@ -44,16 +41,9 @@ impl ExternalMemoryFd {
|
||||||
fd: i32,
|
fd: i32,
|
||||||
) -> VkResult<vk::MemoryFdPropertiesKHR> {
|
) -> VkResult<vk::MemoryFdPropertiesKHR> {
|
||||||
let mut memory_fd_properties = mem::zeroed();
|
let mut memory_fd_properties = mem::zeroed();
|
||||||
let err_code = self.external_memory_fd_fn.get_memory_fd_properties_khr(
|
self.external_memory_fd_fn
|
||||||
self.handle,
|
.get_memory_fd_properties_khr(self.handle, handle_type, fd, &mut memory_fd_properties)
|
||||||
handle_type,
|
.result_with_success(memory_fd_properties)
|
||||||
fd,
|
|
||||||
&mut memory_fd_properties,
|
|
||||||
);
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(memory_fd_properties),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn {
|
pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn {
|
||||||
|
|
|
@ -39,26 +39,26 @@ impl PipelineExecutableProperties {
|
||||||
executable_info: &vk::PipelineExecutableInfoKHR,
|
executable_info: &vk::PipelineExecutableInfoKHR,
|
||||||
) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> {
|
) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.pipeline_executable_properties_fn
|
|
||||||
.get_pipeline_executable_internal_representations_khr(
|
|
||||||
device,
|
|
||||||
executable_info,
|
|
||||||
&mut count,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut v: Vec<_> = vec![Default::default(); count as usize];
|
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.pipeline_executable_properties_fn
|
.pipeline_executable_properties_fn
|
||||||
.get_pipeline_executable_internal_representations_khr(
|
.get_pipeline_executable_internal_representations_khr(
|
||||||
device,
|
device,
|
||||||
executable_info,
|
executable_info,
|
||||||
&mut count,
|
&mut count,
|
||||||
v.as_mut_ptr(),
|
ptr::null_mut(),
|
||||||
);
|
);
|
||||||
match err_code {
|
if err_code != vk::Result::SUCCESS {
|
||||||
vk::Result::SUCCESS => Ok(v),
|
return Err(err_code);
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
}
|
||||||
|
let mut v: Vec<_> = vec![Default::default(); count as usize];
|
||||||
|
self.pipeline_executable_properties_fn
|
||||||
|
.get_pipeline_executable_internal_representations_khr(
|
||||||
|
device,
|
||||||
|
executable_info,
|
||||||
|
&mut count,
|
||||||
|
v.as_mut_ptr(),
|
||||||
|
)
|
||||||
|
.result_with_success(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html"]
|
#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html"]
|
||||||
|
@ -68,26 +68,26 @@ impl PipelineExecutableProperties {
|
||||||
pipeline_info: &vk::PipelineInfoKHR,
|
pipeline_info: &vk::PipelineInfoKHR,
|
||||||
) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> {
|
) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.pipeline_executable_properties_fn
|
|
||||||
.get_pipeline_executable_properties_khr(
|
|
||||||
device,
|
|
||||||
pipeline_info,
|
|
||||||
&mut count,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut v: Vec<_> = vec![Default::default(); count as usize];
|
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.pipeline_executable_properties_fn
|
.pipeline_executable_properties_fn
|
||||||
.get_pipeline_executable_properties_khr(
|
.get_pipeline_executable_properties_khr(
|
||||||
device,
|
device,
|
||||||
pipeline_info,
|
pipeline_info,
|
||||||
&mut count,
|
&mut count,
|
||||||
v.as_mut_ptr(),
|
ptr::null_mut(),
|
||||||
);
|
);
|
||||||
match err_code {
|
if err_code != vk::Result::SUCCESS {
|
||||||
vk::Result::SUCCESS => Ok(v),
|
return Err(err_code);
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
}
|
||||||
|
let mut v: Vec<_> = vec![Default::default(); count as usize];
|
||||||
|
self.pipeline_executable_properties_fn
|
||||||
|
.get_pipeline_executable_properties_khr(
|
||||||
|
device,
|
||||||
|
pipeline_info,
|
||||||
|
&mut count,
|
||||||
|
v.as_mut_ptr(),
|
||||||
|
)
|
||||||
|
.result_with_success(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html"]
|
#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html"]
|
||||||
|
@ -97,26 +97,26 @@ impl PipelineExecutableProperties {
|
||||||
executable_info: &vk::PipelineExecutableInfoKHR,
|
executable_info: &vk::PipelineExecutableInfoKHR,
|
||||||
) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> {
|
) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.pipeline_executable_properties_fn
|
|
||||||
.get_pipeline_executable_statistics_khr(
|
|
||||||
device,
|
|
||||||
executable_info,
|
|
||||||
&mut count,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut v: Vec<_> = vec![Default::default(); count as usize];
|
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.pipeline_executable_properties_fn
|
.pipeline_executable_properties_fn
|
||||||
.get_pipeline_executable_statistics_khr(
|
.get_pipeline_executable_statistics_khr(
|
||||||
device,
|
device,
|
||||||
executable_info,
|
executable_info,
|
||||||
&mut count,
|
&mut count,
|
||||||
v.as_mut_ptr(),
|
ptr::null_mut(),
|
||||||
);
|
);
|
||||||
match err_code {
|
if err_code != vk::Result::SUCCESS {
|
||||||
vk::Result::SUCCESS => Ok(v),
|
return Err(err_code);
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
}
|
||||||
|
let mut v: Vec<_> = vec![Default::default(); count as usize];
|
||||||
|
self.pipeline_executable_properties_fn
|
||||||
|
.get_pipeline_executable_statistics_khr(
|
||||||
|
device,
|
||||||
|
executable_info,
|
||||||
|
&mut count,
|
||||||
|
v.as_mut_ptr(),
|
||||||
|
)
|
||||||
|
.result_with_success(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn {
|
pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn {
|
||||||
|
|
|
@ -42,16 +42,14 @@ impl RayTracing {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::AccelerationStructureKHR> {
|
) -> VkResult<vk::AccelerationStructureKHR> {
|
||||||
let mut accel_struct = mem::zeroed();
|
let mut accel_struct = mem::zeroed();
|
||||||
let err_code = self.ray_tracing_fn.create_acceleration_structure_khr(
|
self.ray_tracing_fn
|
||||||
|
.create_acceleration_structure_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut accel_struct,
|
&mut accel_struct,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(accel_struct)
|
||||||
vk::Result::SUCCESS => Ok(accel_struct),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureKHR.html>"]
|
||||||
|
@ -87,15 +85,13 @@ impl RayTracing {
|
||||||
&self,
|
&self,
|
||||||
bind_info: &[vk::BindAccelerationStructureMemoryInfoKHR],
|
bind_info: &[vk::BindAccelerationStructureMemoryInfoKHR],
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.ray_tracing_fn.bind_acceleration_structure_memory_khr(
|
self.ray_tracing_fn
|
||||||
|
.bind_acceleration_structure_memory_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
bind_info.len() as u32,
|
bind_info.len() as u32,
|
||||||
bind_info.as_ptr(),
|
bind_info.as_ptr(),
|
||||||
);
|
)
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureKHR.html>"]
|
||||||
|
@ -160,18 +156,16 @@ impl RayTracing {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<Vec<vk::Pipeline>> {
|
) -> VkResult<Vec<vk::Pipeline>> {
|
||||||
let mut pipelines = vec![mem::zeroed(); create_info.len()];
|
let mut pipelines = vec![mem::zeroed(); create_info.len()];
|
||||||
let err_code = self.ray_tracing_fn.create_ray_tracing_pipelines_khr(
|
self.ray_tracing_fn
|
||||||
|
.create_ray_tracing_pipelines_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
pipeline_cache,
|
pipeline_cache,
|
||||||
create_info.len() as u32,
|
create_info.len() as u32,
|
||||||
create_info.as_ptr(),
|
create_info.as_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
pipelines.as_mut_ptr(),
|
pipelines.as_mut_ptr(),
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(pipelines)
|
||||||
vk::Result::SUCCESS => Ok(pipelines),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesKHR.html>"]
|
||||||
|
@ -180,8 +174,9 @@ impl RayTracing {
|
||||||
pipeline: vk::Pipeline,
|
pipeline: vk::Pipeline,
|
||||||
first_group: u32,
|
first_group: u32,
|
||||||
group_count: u32,
|
group_count: u32,
|
||||||
data: &mut [u8],
|
data_size: usize,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<Vec<u8>> {
|
||||||
|
let mut data = Vec::<u8>::with_capacity(data_size);
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.ray_tracing_fn
|
.ray_tracing_fn
|
||||||
.get_ray_tracing_shader_group_handles_khr(
|
.get_ray_tracing_shader_group_handles_khr(
|
||||||
|
@ -189,13 +184,11 @@ impl RayTracing {
|
||||||
pipeline,
|
pipeline,
|
||||||
first_group,
|
first_group,
|
||||||
group_count,
|
group_count,
|
||||||
data.len(),
|
data_size,
|
||||||
data.as_mut_ptr() as *mut std::ffi::c_void,
|
data.as_mut_ptr() as *mut std::ffi::c_void,
|
||||||
);
|
);
|
||||||
match err_code {
|
data.set_len(data_size);
|
||||||
vk::Result::SUCCESS => Ok(()),
|
err_code.result_with_success(data)
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleKHR.html>"]
|
||||||
|
@ -250,13 +243,9 @@ impl RayTracing {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
info: &vk::CopyAccelerationStructureToMemoryInfoKHR,
|
info: &vk::CopyAccelerationStructureToMemoryInfoKHR,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.ray_tracing_fn
|
||||||
.ray_tracing_fn
|
.copy_acceleration_structure_to_memory_khr(device, info)
|
||||||
.copy_acceleration_structure_to_memory_khr(device, info);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn copy_memory_to_acceleration_structure(
|
pub unsafe fn copy_memory_to_acceleration_structure(
|
||||||
|
@ -264,14 +253,9 @@ impl RayTracing {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
info: &vk::CopyMemoryToAccelerationStructureInfoKHR,
|
info: &vk::CopyMemoryToAccelerationStructureInfoKHR,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.ray_tracing_fn
|
||||||
.ray_tracing_fn
|
.copy_memory_to_acceleration_structure_khr(device, info)
|
||||||
.copy_memory_to_acceleration_structure_khr(device, info);
|
.into()
|
||||||
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_copy_acceleration_structure_to_memory(
|
pub unsafe fn cmd_copy_acceleration_structure_to_memory(
|
||||||
|
@ -302,8 +286,7 @@ impl RayTracing {
|
||||||
) -> VkResult<Vec<u8>> {
|
) -> VkResult<Vec<u8>> {
|
||||||
let mut data: Vec<u8> = Vec::with_capacity(data_size);
|
let mut data: Vec<u8> = Vec::with_capacity(data_size);
|
||||||
|
|
||||||
let err_code = self
|
self.ray_tracing_fn
|
||||||
.ray_tracing_fn
|
|
||||||
.get_ray_tracing_capture_replay_shader_group_handles_khr(
|
.get_ray_tracing_capture_replay_shader_group_handles_khr(
|
||||||
device,
|
device,
|
||||||
pipeline,
|
pipeline,
|
||||||
|
@ -311,12 +294,8 @@ impl RayTracing {
|
||||||
group_count,
|
group_count,
|
||||||
data_size,
|
data_size,
|
||||||
data.as_mut_ptr() as *mut _,
|
data.as_mut_ptr() as *mut _,
|
||||||
);
|
)
|
||||||
|
.result_with_success(data)
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(data),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn cmd_trace_rays_indirect(
|
pub unsafe fn cmd_trace_rays_indirect(
|
||||||
|
@ -345,14 +324,9 @@ impl RayTracing {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
version: &vk::AccelerationStructureVersionKHR,
|
version: &vk::AccelerationStructureVersionKHR,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.ray_tracing_fn
|
||||||
.ray_tracing_fn
|
.get_device_acceleration_structure_compatibility_khr(device, version)
|
||||||
.get_device_acceleration_structure_compatibility_khr(device, version);
|
.into()
|
||||||
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name() -> &'static CStr {
|
pub fn name() -> &'static CStr {
|
||||||
|
|
|
@ -36,17 +36,9 @@ impl Surface {
|
||||||
surface: vk::SurfaceKHR,
|
surface: vk::SurfaceKHR,
|
||||||
) -> VkResult<bool> {
|
) -> VkResult<bool> {
|
||||||
let mut b = mem::zeroed();
|
let mut b = mem::zeroed();
|
||||||
let err_code = self.surface_fn.get_physical_device_surface_support_khr(
|
self.surface_fn
|
||||||
physical_device,
|
.get_physical_device_surface_support_khr(physical_device, queue_index, surface, &mut b)
|
||||||
queue_index,
|
.result_with_success(b > 0)
|
||||||
surface,
|
|
||||||
&mut b,
|
|
||||||
);
|
|
||||||
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(b > 0),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html>"]
|
||||||
|
@ -62,7 +54,8 @@ impl Surface {
|
||||||
surface,
|
surface,
|
||||||
&mut count,
|
&mut count,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
)
|
||||||
|
.result()?;
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self
|
let err_code = self
|
||||||
.surface_fn
|
.surface_fn
|
||||||
|
@ -73,10 +66,7 @@ impl Surface {
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html>"]
|
||||||
|
@ -86,17 +76,13 @@ impl Surface {
|
||||||
surface: vk::SurfaceKHR,
|
surface: vk::SurfaceKHR,
|
||||||
) -> VkResult<vk::SurfaceCapabilitiesKHR> {
|
) -> VkResult<vk::SurfaceCapabilitiesKHR> {
|
||||||
let mut surface_capabilities = mem::zeroed();
|
let mut surface_capabilities = mem::zeroed();
|
||||||
let err_code = self
|
self.surface_fn
|
||||||
.surface_fn
|
|
||||||
.get_physical_device_surface_capabilities_khr(
|
.get_physical_device_surface_capabilities_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
surface,
|
surface,
|
||||||
&mut surface_capabilities,
|
&mut surface_capabilities,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface_capabilities)
|
||||||
vk::Result::SUCCESS => Ok(surface_capabilities),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html>"]
|
||||||
|
@ -106,12 +92,14 @@ impl Surface {
|
||||||
surface: vk::SurfaceKHR,
|
surface: vk::SurfaceKHR,
|
||||||
) -> VkResult<Vec<vk::SurfaceFormatKHR>> {
|
) -> VkResult<Vec<vk::SurfaceFormatKHR>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.surface_fn.get_physical_device_surface_formats_khr(
|
self.surface_fn
|
||||||
|
.get_physical_device_surface_formats_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
surface,
|
surface,
|
||||||
&mut count,
|
&mut count,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
);
|
)
|
||||||
|
.result()?;
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self.surface_fn.get_physical_device_surface_formats_khr(
|
let err_code = self.surface_fn.get_physical_device_surface_formats_khr(
|
||||||
physical_device,
|
physical_device,
|
||||||
|
@ -120,10 +108,7 @@ impl Surface {
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySurfaceKHR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySurfaceKHR.html>"]
|
||||||
|
|
|
@ -73,16 +73,14 @@ impl Swapchain {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SwapchainKHR> {
|
) -> VkResult<vk::SwapchainKHR> {
|
||||||
let mut swapchain = mem::zeroed();
|
let mut swapchain = mem::zeroed();
|
||||||
let err_code = self.swapchain_fn.create_swapchain_khr(
|
self.swapchain_fn
|
||||||
|
.create_swapchain_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut swapchain,
|
&mut swapchain,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(swapchain)
|
||||||
vk::Result::SUCCESS => Ok(swapchain),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// On success, returns whether the swapchain is suboptimal for the surface.
|
/// On success, returns whether the swapchain is suboptimal for the surface.
|
||||||
|
@ -106,12 +104,9 @@ impl Swapchain {
|
||||||
swapchain: vk::SwapchainKHR,
|
swapchain: vk::SwapchainKHR,
|
||||||
) -> VkResult<Vec<vk::Image>> {
|
) -> VkResult<Vec<vk::Image>> {
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
self.swapchain_fn.get_swapchain_images_khr(
|
self.swapchain_fn
|
||||||
self.handle,
|
.get_swapchain_images_khr(self.handle, swapchain, &mut count, ptr::null_mut())
|
||||||
swapchain,
|
.result()?;
|
||||||
&mut count,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut v = Vec::with_capacity(count as usize);
|
let mut v = Vec::with_capacity(count as usize);
|
||||||
let err_code = self.swapchain_fn.get_swapchain_images_khr(
|
let err_code = self.swapchain_fn.get_swapchain_images_khr(
|
||||||
|
@ -121,10 +116,7 @@ impl Swapchain {
|
||||||
v.as_mut_ptr(),
|
v.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
v.set_len(count as usize);
|
v.set_len(count as usize);
|
||||||
match err_code {
|
err_code.result_with_success(v)
|
||||||
vk::Result::SUCCESS => Ok(v),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::KhrSwapchainFn {
|
pub fn fp(&self) -> &vk::KhrSwapchainFn {
|
||||||
|
|
|
@ -34,14 +34,9 @@ impl TimelineSemaphore {
|
||||||
semaphore: vk::Semaphore,
|
semaphore: vk::Semaphore,
|
||||||
) -> VkResult<u64> {
|
) -> VkResult<u64> {
|
||||||
let mut value = 0;
|
let mut value = 0;
|
||||||
let err_code = self
|
self.timeline_semaphore_fn
|
||||||
.timeline_semaphore_fn
|
.get_semaphore_counter_value_khr(device, semaphore, &mut value)
|
||||||
.get_semaphore_counter_value_khr(device, semaphore, &mut value);
|
.result_with_success(value)
|
||||||
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(value),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitSemaphores.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitSemaphores.html>"]
|
||||||
|
@ -51,14 +46,9 @@ impl TimelineSemaphore {
|
||||||
wait_info: &vk::SemaphoreWaitInfo,
|
wait_info: &vk::SemaphoreWaitInfo,
|
||||||
timeout: u64,
|
timeout: u64,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.timeline_semaphore_fn
|
||||||
.timeline_semaphore_fn
|
.wait_semaphores_khr(device, wait_info, timeout)
|
||||||
.wait_semaphores_khr(device, wait_info, timeout);
|
.into()
|
||||||
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -67,14 +57,9 @@ impl TimelineSemaphore {
|
||||||
device: vk::Device,
|
device: vk::Device,
|
||||||
signal_info: &vk::SemaphoreSignalInfo,
|
signal_info: &vk::SemaphoreSignalInfo,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self
|
self.timeline_semaphore_fn
|
||||||
.timeline_semaphore_fn
|
.signal_semaphore_khr(device, signal_info)
|
||||||
.signal_semaphore_khr(device, signal_info);
|
.into()
|
||||||
|
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn {
|
pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn {
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl WaylandSurface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.wayland_surface_fn.create_wayland_surface_khr(
|
self.wayland_surface_fn
|
||||||
|
.create_wayland_surface_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWaylandPresentationSupportKHR.html"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWaylandPresentationSupportKHR.html"]
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl Win32Surface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.win32_surface_fn.create_win32_surface_khr(
|
self.win32_surface_fn
|
||||||
|
.create_win32_surface_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html"]
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl XcbSurface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.xcb_surface_fn.create_xcb_surface_khr(
|
self.xcb_surface_fn
|
||||||
|
.create_xcb_surface_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXcbPresentationSupportKHR.html"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXcbPresentationSupportKHR.html"]
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl XlibSurface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.xlib_surface_fn.create_xlib_surface_khr(
|
self.xlib_surface_fn
|
||||||
|
.create_xlib_surface_khr(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXlibPresentationSupportKHR.html"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXlibPresentationSupportKHR.html"]
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl IOSSurface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.ios_surface_fn.create_ios_surface_mvk(
|
self.ios_surface_fn
|
||||||
|
.create_ios_surface_mvk(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::MvkIosSurfaceFn {
|
pub fn fp(&self) -> &vk::MvkIosSurfaceFn {
|
||||||
|
|
|
@ -34,16 +34,14 @@ impl MacOSSurface {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::SurfaceKHR> {
|
) -> VkResult<vk::SurfaceKHR> {
|
||||||
let mut surface = mem::zeroed();
|
let mut surface = mem::zeroed();
|
||||||
let err_code = self.macos_surface_fn.create_mac_os_surface_mvk(
|
self.macos_surface_fn
|
||||||
|
.create_mac_os_surface_mvk(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut surface,
|
&mut surface,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(surface)
|
||||||
vk::Result::SUCCESS => Ok(surface),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fp(&self) -> &vk::MvkMacosSurfaceFn {
|
pub fn fp(&self) -> &vk::MvkMacosSurfaceFn {
|
||||||
|
|
|
@ -42,16 +42,14 @@ impl RayTracing {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<vk::AccelerationStructureNV> {
|
) -> VkResult<vk::AccelerationStructureNV> {
|
||||||
let mut accel_struct = mem::zeroed();
|
let mut accel_struct = mem::zeroed();
|
||||||
let err_code = self.ray_tracing_fn.create_acceleration_structure_nv(
|
self.ray_tracing_fn
|
||||||
|
.create_acceleration_structure_nv(
|
||||||
self.handle,
|
self.handle,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut accel_struct,
|
&mut accel_struct,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(accel_struct)
|
||||||
vk::Result::SUCCESS => Ok(accel_struct),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureNV.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureNV.html>"]
|
||||||
|
@ -87,15 +85,13 @@ impl RayTracing {
|
||||||
&self,
|
&self,
|
||||||
bind_info: &[vk::BindAccelerationStructureMemoryInfoNV],
|
bind_info: &[vk::BindAccelerationStructureMemoryInfoNV],
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.ray_tracing_fn.bind_acceleration_structure_memory_nv(
|
self.ray_tracing_fn
|
||||||
|
.bind_acceleration_structure_memory_nv(
|
||||||
self.handle,
|
self.handle,
|
||||||
bind_info.len() as u32,
|
bind_info.len() as u32,
|
||||||
bind_info.as_ptr(),
|
bind_info.as_ptr(),
|
||||||
);
|
)
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -182,18 +178,16 @@ impl RayTracing {
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> VkResult<Vec<vk::Pipeline>> {
|
) -> VkResult<Vec<vk::Pipeline>> {
|
||||||
let mut pipelines = vec![mem::zeroed(); create_info.len()];
|
let mut pipelines = vec![mem::zeroed(); create_info.len()];
|
||||||
let err_code = self.ray_tracing_fn.create_ray_tracing_pipelines_nv(
|
self.ray_tracing_fn
|
||||||
|
.create_ray_tracing_pipelines_nv(
|
||||||
self.handle,
|
self.handle,
|
||||||
pipeline_cache,
|
pipeline_cache,
|
||||||
create_info.len() as u32,
|
create_info.len() as u32,
|
||||||
create_info.as_ptr(),
|
create_info.as_ptr(),
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
pipelines.as_mut_ptr(),
|
pipelines.as_mut_ptr(),
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(pipelines)
|
||||||
vk::Result::SUCCESS => Ok(pipelines),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesNV.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesNV.html>"]
|
||||||
|
@ -204,18 +198,16 @@ impl RayTracing {
|
||||||
group_count: u32,
|
group_count: u32,
|
||||||
data: &mut [u8],
|
data: &mut [u8],
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.ray_tracing_fn.get_ray_tracing_shader_group_handles_nv(
|
self.ray_tracing_fn
|
||||||
|
.get_ray_tracing_shader_group_handles_nv(
|
||||||
self.handle,
|
self.handle,
|
||||||
pipeline,
|
pipeline,
|
||||||
first_group,
|
first_group,
|
||||||
group_count,
|
group_count,
|
||||||
data.len(),
|
data.len(),
|
||||||
data.as_mut_ptr() as *mut std::ffi::c_void,
|
data.as_mut_ptr() as *mut std::ffi::c_void,
|
||||||
);
|
)
|
||||||
match err_code {
|
.into()
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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>"]
|
||||||
|
@ -225,16 +217,14 @@ impl RayTracing {
|
||||||
) -> VkResult<u64> {
|
) -> VkResult<u64> {
|
||||||
let mut handle: u64 = 0;
|
let mut handle: u64 = 0;
|
||||||
let handle_ptr: *mut u64 = &mut handle;
|
let handle_ptr: *mut u64 = &mut handle;
|
||||||
let err_code = self.ray_tracing_fn.get_acceleration_structure_handle_nv(
|
self.ray_tracing_fn
|
||||||
|
.get_acceleration_structure_handle_nv(
|
||||||
self.handle,
|
self.handle,
|
||||||
accel_struct,
|
accel_struct,
|
||||||
std::mem::size_of::<u64>(),
|
std::mem::size_of::<u64>(),
|
||||||
handle_ptr as *mut std::ffi::c_void,
|
handle_ptr as *mut std::ffi::c_void,
|
||||||
);
|
)
|
||||||
match err_code {
|
.result_with_success(handle)
|
||||||
vk::Result::SUCCESS => Ok(handle),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html>"]
|
||||||
|
@ -259,13 +249,9 @@ impl RayTracing {
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCompileDeferredNV.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCompileDeferredNV.html>"]
|
||||||
pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
|
pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> {
|
||||||
let err_code = self
|
self.ray_tracing_fn
|
||||||
.ray_tracing_fn
|
.compile_deferred_nv(self.handle, pipeline, shader)
|
||||||
.compile_deferred_nv(self.handle, pipeline, shader);
|
.into()
|
||||||
match err_code {
|
|
||||||
vk::Result::SUCCESS => Ok(()),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn name() -> &'static CStr {
|
pub fn name() -> &'static CStr {
|
||||||
|
|
|
@ -49,17 +49,16 @@ impl InstanceV1_0 for Instance {
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
create_info: &vk::DeviceCreateInfo,
|
create_info: &vk::DeviceCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> Result<Self::Device, vk::Result> {
|
) -> VkResult<Self::Device> {
|
||||||
let mut device: vk::Device = mem::zeroed();
|
let mut device: vk::Device = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().create_device(
|
self.fp_v1_0()
|
||||||
|
.create_device(
|
||||||
physical_device,
|
physical_device,
|
||||||
create_info,
|
create_info,
|
||||||
allocation_callbacks.as_raw_ptr(),
|
allocation_callbacks.as_raw_ptr(),
|
||||||
&mut device,
|
&mut device,
|
||||||
);
|
)
|
||||||
if err_code != vk::Result::SUCCESS {
|
.result()?;
|
||||||
return Err(err_code);
|
|
||||||
}
|
|
||||||
Ok(Device::load(&self.instance_fn_1_0, device))
|
Ok(Device::load(&self.instance_fn_1_0, device))
|
||||||
}
|
}
|
||||||
fn handle(&self) -> vk::Instance {
|
fn handle(&self) -> vk::Instance {
|
||||||
|
@ -92,14 +91,11 @@ pub trait InstanceV1_2: InstanceV1_1 {
|
||||||
pub trait InstanceV1_1: InstanceV1_0 {
|
pub trait InstanceV1_1: InstanceV1_0 {
|
||||||
fn fp_v1_1(&self) -> &vk::InstanceFnV1_1;
|
fn fp_v1_1(&self) -> &vk::InstanceFnV1_1;
|
||||||
|
|
||||||
unsafe fn enumerate_physical_device_groups_len(&self) -> usize {
|
unsafe fn enumerate_physical_device_groups_len(&self) -> VkResult<usize> {
|
||||||
let mut group_count = mem::zeroed();
|
let mut group_count = mem::zeroed();
|
||||||
self.fp_v1_1().enumerate_physical_device_groups(
|
self.fp_v1_1()
|
||||||
self.handle(),
|
.enumerate_physical_device_groups(self.handle(), &mut group_count, ptr::null_mut())
|
||||||
&mut group_count,
|
.result_with_success(group_count as usize)
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
group_count as usize
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumeratePhysicalDeviceGroups.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumeratePhysicalDeviceGroups.html>"]
|
||||||
|
@ -109,16 +105,9 @@ pub trait InstanceV1_1: InstanceV1_0 {
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut group_count = out.len() as u32;
|
let mut group_count = out.len() as u32;
|
||||||
let err_code = self.fp_v1_1().enumerate_physical_device_groups(
|
self.fp_v1_1()
|
||||||
self.handle(),
|
.enumerate_physical_device_groups(self.handle(), &mut group_count, out.as_mut_ptr())
|
||||||
&mut group_count,
|
.into()
|
||||||
out.as_mut_ptr(),
|
|
||||||
);
|
|
||||||
if err_code == vk::Result::SUCCESS {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(err_code)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,16 +149,13 @@ pub trait InstanceV1_1: InstanceV1_0 {
|
||||||
format_info: &vk::PhysicalDeviceImageFormatInfo2,
|
format_info: &vk::PhysicalDeviceImageFormatInfo2,
|
||||||
image_format_prop: &mut vk::ImageFormatProperties2,
|
image_format_prop: &mut vk::ImageFormatProperties2,
|
||||||
) -> VkResult<()> {
|
) -> VkResult<()> {
|
||||||
let err_code = self.fp_v1_1().get_physical_device_image_format_properties2(
|
self.fp_v1_1()
|
||||||
|
.get_physical_device_image_format_properties2(
|
||||||
physical_device,
|
physical_device,
|
||||||
format_info,
|
format_info,
|
||||||
image_format_prop,
|
image_format_prop,
|
||||||
);
|
)
|
||||||
if err_code == vk::Result::SUCCESS {
|
.into()
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(err_code)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn get_physical_device_queue_family_properties2_len(
|
unsafe fn get_physical_device_queue_family_properties2_len(
|
||||||
|
@ -304,7 +290,7 @@ pub trait InstanceV1_0 {
|
||||||
physical_device: vk::PhysicalDevice,
|
physical_device: vk::PhysicalDevice,
|
||||||
create_info: &vk::DeviceCreateInfo,
|
create_info: &vk::DeviceCreateInfo,
|
||||||
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
allocation_callbacks: Option<&vk::AllocationCallbacks>,
|
||||||
) -> Result<Self::Device, vk::Result>;
|
) -> VkResult<Self::Device>;
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceProcAddr.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceProcAddr.html>"]
|
||||||
unsafe fn get_device_proc_addr(
|
unsafe fn get_device_proc_addr(
|
||||||
|
@ -347,7 +333,8 @@ pub trait InstanceV1_0 {
|
||||||
flags: vk::ImageCreateFlags,
|
flags: vk::ImageCreateFlags,
|
||||||
) -> VkResult<vk::ImageFormatProperties> {
|
) -> VkResult<vk::ImageFormatProperties> {
|
||||||
let mut image_format_prop = mem::zeroed();
|
let mut image_format_prop = mem::zeroed();
|
||||||
let err_code = self.fp_v1_0().get_physical_device_image_format_properties(
|
self.fp_v1_0()
|
||||||
|
.get_physical_device_image_format_properties(
|
||||||
physical_device,
|
physical_device,
|
||||||
format,
|
format,
|
||||||
typ,
|
typ,
|
||||||
|
@ -355,12 +342,8 @@ pub trait InstanceV1_0 {
|
||||||
usage,
|
usage,
|
||||||
flags,
|
flags,
|
||||||
&mut image_format_prop,
|
&mut image_format_prop,
|
||||||
);
|
)
|
||||||
if err_code == vk::Result::SUCCESS {
|
.result_with_success(image_format_prop)
|
||||||
Ok(image_format_prop)
|
|
||||||
} else {
|
|
||||||
Err(err_code)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceMemoryProperties.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceMemoryProperties.html>"]
|
||||||
|
@ -421,7 +404,8 @@ pub trait InstanceV1_0 {
|
||||||
unsafe fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
|
unsafe fn enumerate_physical_devices(&self) -> VkResult<Vec<vk::PhysicalDevice>> {
|
||||||
let mut num = mem::zeroed();
|
let mut num = mem::zeroed();
|
||||||
self.fp_v1_0()
|
self.fp_v1_0()
|
||||||
.enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut());
|
.enumerate_physical_devices(self.handle(), &mut num, ptr::null_mut())
|
||||||
|
.result()?;
|
||||||
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
|
let mut physical_devices = Vec::<vk::PhysicalDevice>::with_capacity(num as usize);
|
||||||
let err_code = self.fp_v1_0().enumerate_physical_devices(
|
let err_code = self.fp_v1_0().enumerate_physical_devices(
|
||||||
self.handle(),
|
self.handle(),
|
||||||
|
@ -429,24 +413,18 @@ pub trait InstanceV1_0 {
|
||||||
physical_devices.as_mut_ptr(),
|
physical_devices.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
physical_devices.set_len(num as usize);
|
physical_devices.set_len(num as usize);
|
||||||
match err_code {
|
err_code.result_with_success(physical_devices)
|
||||||
vk::Result::SUCCESS => Ok(physical_devices),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumerateDeviceExtensionProperties.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkEnumerateDeviceExtensionProperties.html>"]
|
||||||
unsafe fn enumerate_device_extension_properties(
|
unsafe fn enumerate_device_extension_properties(
|
||||||
&self,
|
&self,
|
||||||
device: vk::PhysicalDevice,
|
device: vk::PhysicalDevice,
|
||||||
) -> Result<Vec<vk::ExtensionProperties>, vk::Result> {
|
) -> VkResult<Vec<vk::ExtensionProperties>> {
|
||||||
let mut num = 0;
|
let mut num = 0;
|
||||||
self.fp_v1_0().enumerate_device_extension_properties(
|
self.fp_v1_0()
|
||||||
device,
|
.enumerate_device_extension_properties(device, ptr::null(), &mut num, ptr::null_mut())
|
||||||
ptr::null(),
|
.result()?;
|
||||||
&mut num,
|
|
||||||
ptr::null_mut(),
|
|
||||||
);
|
|
||||||
let mut data = Vec::with_capacity(num as usize);
|
let mut data = Vec::with_capacity(num as usize);
|
||||||
let err_code = self.fp_v1_0().enumerate_device_extension_properties(
|
let err_code = self.fp_v1_0().enumerate_device_extension_properties(
|
||||||
device,
|
device,
|
||||||
|
@ -455,9 +433,6 @@ pub trait InstanceV1_0 {
|
||||||
data.as_mut_ptr(),
|
data.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
data.set_len(num as usize);
|
data.set_len(num as usize);
|
||||||
match err_code {
|
err_code.result_with_success(data)
|
||||||
vk::Result::SUCCESS => Ok(data),
|
|
||||||
_ => Err(err_code),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,21 @@
|
||||||
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 {
|
||||||
|
pub fn result(self) -> VkResult<()> {
|
||||||
|
self.result_with_success(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn result_with_success<T>(self, v: T) -> VkResult<T> {
|
||||||
|
match self {
|
||||||
|
vk::Result::SUCCESS => Ok(v),
|
||||||
|
_ => Err(self),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
#![allow(clippy::too_many_arguments, clippy::cognitive_complexity, clippy::wrong_self_convention)]
|
#![allow(
|
||||||
|
clippy::too_many_arguments,
|
||||||
|
clippy::cognitive_complexity,
|
||||||
|
clippy::wrong_self_convention
|
||||||
|
)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
pub use macros::*;
|
pub use macros::*;
|
||||||
|
|
|
@ -1543,16 +1543,16 @@ impl<'a> DeviceCreateInfoBuilder<'a> {
|
||||||
mut self,
|
mut self,
|
||||||
enabled_layer_names: &'a [*const c_char],
|
enabled_layer_names: &'a [*const c_char],
|
||||||
) -> DeviceCreateInfoBuilder<'a> {
|
) -> DeviceCreateInfoBuilder<'a> {
|
||||||
self.inner.pp_enabled_layer_names = enabled_layer_names.as_ptr();
|
|
||||||
self.inner.enabled_layer_count = enabled_layer_names.len() as _;
|
self.inner.enabled_layer_count = enabled_layer_names.len() as _;
|
||||||
|
self.inner.pp_enabled_layer_names = enabled_layer_names.as_ptr();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn enabled_extension_names(
|
pub fn enabled_extension_names(
|
||||||
mut self,
|
mut self,
|
||||||
enabled_extension_names: &'a [*const c_char],
|
enabled_extension_names: &'a [*const c_char],
|
||||||
) -> DeviceCreateInfoBuilder<'a> {
|
) -> DeviceCreateInfoBuilder<'a> {
|
||||||
self.inner.pp_enabled_extension_names = enabled_extension_names.as_ptr();
|
|
||||||
self.inner.enabled_extension_count = enabled_extension_names.len() as _;
|
self.inner.enabled_extension_count = enabled_extension_names.len() as _;
|
||||||
|
self.inner.pp_enabled_extension_names = enabled_extension_names.as_ptr();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn enabled_features(
|
pub fn enabled_features(
|
||||||
|
@ -1654,16 +1654,16 @@ impl<'a> InstanceCreateInfoBuilder<'a> {
|
||||||
mut self,
|
mut self,
|
||||||
enabled_layer_names: &'a [*const c_char],
|
enabled_layer_names: &'a [*const c_char],
|
||||||
) -> InstanceCreateInfoBuilder<'a> {
|
) -> InstanceCreateInfoBuilder<'a> {
|
||||||
self.inner.pp_enabled_layer_names = enabled_layer_names.as_ptr();
|
|
||||||
self.inner.enabled_layer_count = enabled_layer_names.len() as _;
|
self.inner.enabled_layer_count = enabled_layer_names.len() as _;
|
||||||
|
self.inner.pp_enabled_layer_names = enabled_layer_names.as_ptr();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn enabled_extension_names(
|
pub fn enabled_extension_names(
|
||||||
mut self,
|
mut self,
|
||||||
enabled_extension_names: &'a [*const c_char],
|
enabled_extension_names: &'a [*const c_char],
|
||||||
) -> InstanceCreateInfoBuilder<'a> {
|
) -> InstanceCreateInfoBuilder<'a> {
|
||||||
self.inner.pp_enabled_extension_names = enabled_extension_names.as_ptr();
|
|
||||||
self.inner.enabled_extension_count = enabled_extension_names.len() as _;
|
self.inner.enabled_extension_count = enabled_extension_names.len() as _;
|
||||||
|
self.inner.pp_enabled_extension_names = enabled_extension_names.as_ptr();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[doc = r" Prepends the given extension struct between the root and the first pointer. This"]
|
#[doc = r" Prepends the given extension struct between the root and the first pointer. This"]
|
||||||
|
@ -10527,8 +10527,11 @@ impl<'a> DisplayPropertiesKHRBuilder<'a> {
|
||||||
self.inner.display = display;
|
self.inner.display = display;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn display_name(mut self, display_name: *const c_char) -> DisplayPropertiesKHRBuilder<'a> {
|
pub fn display_name(
|
||||||
self.inner.display_name = display_name;
|
mut self,
|
||||||
|
display_name: &'a ::std::ffi::CStr,
|
||||||
|
) -> DisplayPropertiesKHRBuilder<'a> {
|
||||||
|
self.inner.display_name = display_name.as_ptr();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn physical_dimensions(
|
pub fn physical_dimensions(
|
||||||
|
@ -20903,7 +20906,7 @@ impl<'a> IOSSurfaceCreateInfoMVKBuilder<'a> {
|
||||||
self.inner.flags = flags;
|
self.inner.flags = flags;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn view(mut self, view: &'a c_void) -> IOSSurfaceCreateInfoMVKBuilder<'a> {
|
pub fn view(mut self, view: *const c_void) -> IOSSurfaceCreateInfoMVKBuilder<'a> {
|
||||||
self.inner.p_view = view;
|
self.inner.p_view = view;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -20983,7 +20986,7 @@ impl<'a> MacOSSurfaceCreateInfoMVKBuilder<'a> {
|
||||||
self.inner.flags = flags;
|
self.inner.flags = flags;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn view(mut self, view: &'a c_void) -> MacOSSurfaceCreateInfoMVKBuilder<'a> {
|
pub fn view(mut self, view: *const c_void) -> MacOSSurfaceCreateInfoMVKBuilder<'a> {
|
||||||
self.inner.p_view = view;
|
self.inner.p_view = view;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -21063,7 +21066,7 @@ impl<'a> MetalSurfaceCreateInfoEXTBuilder<'a> {
|
||||||
self.inner.flags = flags;
|
self.inner.flags = flags;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn layer(mut self, layer: &'a CAMetalLayer) -> MetalSurfaceCreateInfoEXTBuilder<'a> {
|
pub fn layer(mut self, layer: *const CAMetalLayer) -> MetalSurfaceCreateInfoEXTBuilder<'a> {
|
||||||
self.inner.p_layer = layer;
|
self.inner.p_layer = layer;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -33205,7 +33208,7 @@ impl<'a> RayTracingShaderGroupCreateInfoKHRBuilder<'a> {
|
||||||
}
|
}
|
||||||
pub fn shader_group_capture_replay_handle(
|
pub fn shader_group_capture_replay_handle(
|
||||||
mut self,
|
mut self,
|
||||||
shader_group_capture_replay_handle: &'a c_void,
|
shader_group_capture_replay_handle: *const c_void,
|
||||||
) -> RayTracingShaderGroupCreateInfoKHRBuilder<'a> {
|
) -> RayTracingShaderGroupCreateInfoKHRBuilder<'a> {
|
||||||
self.inner.p_shader_group_capture_replay_handle = shader_group_capture_replay_handle;
|
self.inner.p_shader_group_capture_replay_handle = shader_group_capture_replay_handle;
|
||||||
self
|
self
|
||||||
|
@ -37488,7 +37491,7 @@ impl<'a> ::std::ops::DerefMut for PipelineCreationFeedbackCreateInfoEXTBuilder<'
|
||||||
impl<'a> PipelineCreationFeedbackCreateInfoEXTBuilder<'a> {
|
impl<'a> PipelineCreationFeedbackCreateInfoEXTBuilder<'a> {
|
||||||
pub fn pipeline_creation_feedback(
|
pub fn pipeline_creation_feedback(
|
||||||
mut self,
|
mut self,
|
||||||
pipeline_creation_feedback: *mut PipelineCreationFeedbackEXT,
|
pipeline_creation_feedback: &'a mut PipelineCreationFeedbackEXT,
|
||||||
) -> PipelineCreationFeedbackCreateInfoEXTBuilder<'a> {
|
) -> PipelineCreationFeedbackCreateInfoEXTBuilder<'a> {
|
||||||
self.inner.p_pipeline_creation_feedback = pipeline_creation_feedback;
|
self.inner.p_pipeline_creation_feedback = pipeline_creation_feedback;
|
||||||
self
|
self
|
||||||
|
@ -44090,9 +44093,9 @@ impl<'a> ::std::ops::DerefMut for AccelerationStructureVersionKHRBuilder<'a> {
|
||||||
impl<'a> AccelerationStructureVersionKHRBuilder<'a> {
|
impl<'a> AccelerationStructureVersionKHRBuilder<'a> {
|
||||||
pub fn version_data(
|
pub fn version_data(
|
||||||
mut self,
|
mut self,
|
||||||
version_data: *const u8,
|
version_data: &'a [u8; 2 * UUID_SIZE],
|
||||||
) -> AccelerationStructureVersionKHRBuilder<'a> {
|
) -> AccelerationStructureVersionKHRBuilder<'a> {
|
||||||
self.inner.version_data = version_data;
|
self.inner.version_data = version_data.as_ptr();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[doc = r" Prepends the given extension struct between the root and the first pointer. This"]
|
#[doc = r" Prepends the given extension struct between the root and the first pointer. This"]
|
||||||
|
|
|
@ -869,6 +869,7 @@ impl SubpassContents {
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkResult.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkResult.html>"]
|
||||||
|
#[must_use]
|
||||||
pub struct Result(pub(crate) i32);
|
pub struct Result(pub(crate) i32);
|
||||||
impl Result {
|
impl Result {
|
||||||
pub const fn from_raw(x: i32) -> Self {
|
pub const fn from_raw(x: i32) -> Self {
|
||||||
|
|
|
@ -7,7 +7,7 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
vk-parse = { version = "0.5.0", features = ["vkxml-convert"] }
|
vk-parse = { version = "0.5.0", features = ["vkxml-convert"] }
|
||||||
vkxml = "0.3"
|
vkxml = "0.3"
|
||||||
nom = "4.0"
|
nom = "6.0"
|
||||||
heck = "0.3"
|
heck = "0.3"
|
||||||
proc-macro2 = "0.2"
|
proc-macro2 = "0.2"
|
||||||
itertools = "0.9"
|
itertools = "0.9"
|
||||||
|
|
|
@ -5,8 +5,7 @@ use quote::*;
|
||||||
|
|
||||||
use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
|
use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use proc_macro2::{Literal, Term};
|
use proc_macro2::{Literal, Term, TokenNode, TokenStream, TokenTree};
|
||||||
use quote::Tokens;
|
|
||||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::hash::BuildHasher;
|
use std::hash::BuildHasher;
|
||||||
|
@ -23,8 +22,8 @@ pub enum CType {
|
||||||
Bool32,
|
Bool32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CType {
|
impl quote::ToTokens for CType {
|
||||||
fn to_tokens(self) -> Tokens {
|
fn to_tokens(&self, tokens: &mut Tokens) {
|
||||||
let term = match self {
|
let term = match self {
|
||||||
CType::USize => Term::intern("usize"),
|
CType::USize => Term::intern("usize"),
|
||||||
CType::U32 => Term::intern("u32"),
|
CType::U32 => Term::intern("u32"),
|
||||||
|
@ -32,7 +31,7 @@ impl CType {
|
||||||
CType::Float => Term::intern("f32"),
|
CType::Float => Term::intern("f32"),
|
||||||
CType::Bool32 => Term::intern("Bool32"),
|
CType::Bool32 => Term::intern("Bool32"),
|
||||||
};
|
};
|
||||||
quote! {#term}
|
term.to_tokens(tokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@ named!(inverse_number<&str, (CType, String)>,
|
||||||
);
|
);
|
||||||
|
|
||||||
named!(cfloat<&str, f32>,
|
named!(cfloat<&str, f32>,
|
||||||
terminated!(nom::float, char!('f'))
|
terminated!(nom::number::complete::float, char!('f'))
|
||||||
);
|
);
|
||||||
|
|
||||||
fn khronos_link<S: Display>(name: &S) -> Literal {
|
fn khronos_link<S: Display>(name: &S) -> Literal {
|
||||||
|
@ -328,6 +327,20 @@ pub fn vk_bitflags_wrapped_macro() -> Tokens {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_opaque_type(ty: &str) -> bool {
|
||||||
|
matches!(
|
||||||
|
ty,
|
||||||
|
"void"
|
||||||
|
| "wl_display"
|
||||||
|
| "wl_surface"
|
||||||
|
| "Display"
|
||||||
|
| "xcb_connection_t"
|
||||||
|
| "ANativeWindow"
|
||||||
|
| "AHardwareBuffer"
|
||||||
|
| "CAMetalLayer"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn platform_specific_types() -> Tokens {
|
pub fn platform_specific_types() -> Tokens {
|
||||||
quote! {
|
quote! {
|
||||||
pub type RROutput = c_ulong;
|
pub type RROutput = c_ulong;
|
||||||
|
@ -359,7 +372,7 @@ pub fn platform_specific_types() -> Tokens {
|
||||||
// typedefs are only here so that the code compiles for now
|
// typedefs are only here so that the code compiles for now
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type SECURITY_ATTRIBUTES = ();
|
pub type SECURITY_ATTRIBUTES = ();
|
||||||
// Opage types
|
// Opaque types
|
||||||
pub type ANativeWindow = c_void;
|
pub type ANativeWindow = c_void;
|
||||||
pub type AHardwareBuffer = c_void;
|
pub type AHardwareBuffer = c_void;
|
||||||
pub type CAMetalLayer = c_void;
|
pub type CAMetalLayer = c_void;
|
||||||
|
@ -386,7 +399,6 @@ impl ConstVal {
|
||||||
pub trait ConstantExt {
|
pub trait ConstantExt {
|
||||||
fn constant(&self) -> Constant;
|
fn constant(&self) -> Constant;
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident;
|
fn variant_ident(&self, enum_name: &str) -> Ident;
|
||||||
fn to_tokens(&self) -> Tokens;
|
|
||||||
fn notation(&self) -> Option<&str>;
|
fn notation(&self) -> Option<&str>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,9 +409,6 @@ impl ConstantExt for vkxml::ExtensionEnum {
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident {
|
fn variant_ident(&self, enum_name: &str) -> Ident {
|
||||||
variant_ident(enum_name, &self.name)
|
variant_ident(enum_name, &self.name)
|
||||||
}
|
}
|
||||||
fn to_tokens(&self) -> Tokens {
|
|
||||||
Constant::from_extension_enum(self).expect("").to_tokens()
|
|
||||||
}
|
|
||||||
fn notation(&self) -> Option<&str> {
|
fn notation(&self) -> Option<&str> {
|
||||||
self.notation.as_deref()
|
self.notation.as_deref()
|
||||||
}
|
}
|
||||||
|
@ -412,9 +421,6 @@ impl ConstantExt for vkxml::Constant {
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident {
|
fn variant_ident(&self, enum_name: &str) -> Ident {
|
||||||
variant_ident(enum_name, &self.name)
|
variant_ident(enum_name, &self.name)
|
||||||
}
|
}
|
||||||
fn to_tokens(&self) -> Tokens {
|
|
||||||
Constant::from_constant(self).to_tokens()
|
|
||||||
}
|
|
||||||
fn notation(&self) -> Option<&str> {
|
fn notation(&self) -> Option<&str> {
|
||||||
self.notation.as_deref()
|
self.notation.as_deref()
|
||||||
}
|
}
|
||||||
|
@ -430,6 +436,36 @@ pub enum Constant {
|
||||||
Alias(Ident, Ident),
|
Alias(Ident, Ident),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl quote::ToTokens for Constant {
|
||||||
|
fn to_tokens(&self, tokens: &mut Tokens) {
|
||||||
|
match *self {
|
||||||
|
Constant::Number(n) => {
|
||||||
|
let number = interleave_number('_', 3, &n.to_string());
|
||||||
|
let term = Term::intern(&number);
|
||||||
|
term.to_tokens(tokens);
|
||||||
|
}
|
||||||
|
Constant::Hex(ref s) => {
|
||||||
|
let number = interleave_number('_', 4, s);
|
||||||
|
let term = Term::intern(&format!("0x{}", number));
|
||||||
|
term.to_tokens(tokens);
|
||||||
|
}
|
||||||
|
Constant::Text(ref text) => text.to_tokens(tokens),
|
||||||
|
Constant::CExpr(ref expr) => {
|
||||||
|
let (_, (_, rexpr)) = cexpr(expr).expect("Unable to parse cexpr");
|
||||||
|
tokens.append_all(rexpr.parse::<TokenStream>());
|
||||||
|
}
|
||||||
|
Constant::BitPos(pos) => {
|
||||||
|
let value = 1 << pos;
|
||||||
|
let bit_string = format!("{:b}", value);
|
||||||
|
let bit_string = interleave_number('_', 4, &bit_string);
|
||||||
|
let term = Term::intern(&format!("0b{}", bit_string));
|
||||||
|
term.to_tokens(tokens);
|
||||||
|
}
|
||||||
|
Constant::Alias(ref base, ref value) => tokens.append_all(quote!(#base::#value)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl quote::ToTokens for ConstVal {
|
impl quote::ToTokens for ConstVal {
|
||||||
fn to_tokens(&self, tokens: &mut Tokens) {
|
fn to_tokens(&self, tokens: &mut Tokens) {
|
||||||
match self {
|
match self {
|
||||||
|
@ -476,39 +512,6 @@ impl Constant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_tokens(&self) -> Tokens {
|
|
||||||
match *self {
|
|
||||||
Constant::Number(n) => {
|
|
||||||
let number = interleave_number('_', 3, &n.to_string());
|
|
||||||
let term = Term::intern(&number);
|
|
||||||
quote! {#term}
|
|
||||||
}
|
|
||||||
Constant::Hex(ref s) => {
|
|
||||||
let number = interleave_number('_', 4, s);
|
|
||||||
let term = Term::intern(&format!("0x{}", number));
|
|
||||||
quote! {#term}
|
|
||||||
}
|
|
||||||
Constant::Text(ref text) => {
|
|
||||||
quote! {#text}
|
|
||||||
}
|
|
||||||
Constant::CExpr(ref expr) => {
|
|
||||||
let (_, (_, rexpr)) = cexpr(expr).expect("Unable to parse cexpr");
|
|
||||||
let term = Term::intern(rexpr.as_str());
|
|
||||||
quote! {#term}
|
|
||||||
}
|
|
||||||
Constant::BitPos(pos) => {
|
|
||||||
let value = 1 << pos;
|
|
||||||
let bit_string = format!("{:b}", value);
|
|
||||||
let bit_string = interleave_number('_', 4, &bit_string);
|
|
||||||
let term = Term::intern(&format!("0b{}", bit_string));
|
|
||||||
quote! {#term}
|
|
||||||
}
|
|
||||||
Constant::Alias(ref base, ref value) => {
|
|
||||||
quote! {#base::#value}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn from_extension_enum(constant: &vkxml::ExtensionEnum) -> Option<Self> {
|
pub fn from_extension_enum(constant: &vkxml::ExtensionEnum) -> Option<Self> {
|
||||||
let number = constant.number.map(Constant::Number);
|
let number = constant.number.map(Constant::Number);
|
||||||
let hex = constant.hex.as_ref().map(|hex| Constant::Hex(hex.clone()));
|
let hex = constant.hex.as_ref().map(|hex| Constant::Hex(hex.clone()));
|
||||||
|
@ -547,6 +550,7 @@ impl FeatureExt for vkxml::Feature {
|
||||||
if version.len() == 1 {
|
if version.len() == 1 {
|
||||||
version = format!("{}_0", version)
|
version = format!("{}_0", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
version.replace(".", "_")
|
version.replace(".", "_")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,10 +606,17 @@ impl CommandExt for vkxml::Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FieldExt {
|
pub trait FieldExt {
|
||||||
/// Returns the name of the paramter that doesn't clash with Rusts resevered
|
/// Returns the name of the parameter that doesn't clash with Rusts reserved
|
||||||
/// keywords
|
/// keywords
|
||||||
fn param_ident(&self) -> Ident;
|
fn param_ident(&self) -> Ident;
|
||||||
|
|
||||||
|
/// The inner type of this field, with one level of pointers removed
|
||||||
|
fn inner_type_tokens(&self) -> Tokens;
|
||||||
|
|
||||||
|
/// Returns reference-types wrapped in their safe variant. (Dynamic) arrays become
|
||||||
|
/// slices, pointers become Rust references.
|
||||||
|
fn safe_type_tokens(&self, lifetime: Tokens) -> Tokens;
|
||||||
|
|
||||||
/// Returns the basetype ident and removes the 'Vk' prefix. When `is_ffi_param` is `true`
|
/// Returns the basetype ident and removes the 'Vk' prefix. When `is_ffi_param` is `true`
|
||||||
/// array types (e.g. `[f32; 3]`) will be converted to pointer types (e.g. `&[f32; 3]`),
|
/// array types (e.g. `[f32; 3]`) will be converted to pointer types (e.g. `&[f32; 3]`),
|
||||||
/// which is needed for `C` function parameters. Set to `false` for struct definitions.
|
/// which is needed for `C` function parameters. Set to `false` for struct definitions.
|
||||||
|
@ -615,29 +626,33 @@ pub trait FieldExt {
|
||||||
|
|
||||||
pub trait ToTokens {
|
pub trait ToTokens {
|
||||||
fn to_tokens(&self, is_const: bool) -> Tokens;
|
fn to_tokens(&self, is_const: bool) -> Tokens;
|
||||||
|
/// Returns the topmost pointer as safe reference
|
||||||
|
fn to_safe_tokens(&self, is_const: bool, lifetime: Tokens) -> Tokens;
|
||||||
}
|
}
|
||||||
impl ToTokens for vkxml::ReferenceType {
|
impl ToTokens for vkxml::ReferenceType {
|
||||||
fn to_tokens(&self, is_const: bool) -> Tokens {
|
fn to_tokens(&self, is_const: bool) -> Tokens {
|
||||||
let ptr_name = match self {
|
let r = if is_const {
|
||||||
vkxml::ReferenceType::Pointer => {
|
quote!(*const)
|
||||||
if is_const {
|
|
||||||
"*const"
|
|
||||||
} else {
|
} else {
|
||||||
"*mut"
|
quote!(*mut)
|
||||||
}
|
|
||||||
}
|
|
||||||
vkxml::ReferenceType::PointerToPointer => "*mut *mut",
|
|
||||||
vkxml::ReferenceType::PointerToConstPointer => {
|
|
||||||
if is_const {
|
|
||||||
"*const *const"
|
|
||||||
} else {
|
|
||||||
"*mut *const"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let ident = Term::intern(ptr_name);
|
match self {
|
||||||
quote! {
|
vkxml::ReferenceType::Pointer => quote!(#r),
|
||||||
#ident
|
vkxml::ReferenceType::PointerToPointer => quote!(#r *mut),
|
||||||
|
vkxml::ReferenceType::PointerToConstPointer => quote!(#r *const),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_safe_tokens(&self, is_const: bool, lifetime: Tokens) -> Tokens {
|
||||||
|
let r = if is_const {
|
||||||
|
quote!(&#lifetime)
|
||||||
|
} else {
|
||||||
|
quote!(&#lifetime mut)
|
||||||
|
};
|
||||||
|
match self {
|
||||||
|
vkxml::ReferenceType::Pointer => quote!(#r),
|
||||||
|
vkxml::ReferenceType::PointerToPointer => quote!(#r *mut),
|
||||||
|
vkxml::ReferenceType::PointerToConstPointer => quote!(#r *const),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,27 +673,52 @@ fn name_to_tokens(type_name: &str) -> Ident {
|
||||||
"float" => "f32",
|
"float" => "f32",
|
||||||
"double" => "f64",
|
"double" => "f64",
|
||||||
"long" => "c_ulong",
|
"long" => "c_ulong",
|
||||||
_ => {
|
_ => type_name.strip_prefix("Vk").unwrap_or(type_name),
|
||||||
if type_name.starts_with("Vk") {
|
|
||||||
&type_name[2..]
|
|
||||||
} else {
|
|
||||||
type_name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let new_name = new_name.replace("FlagBits", "Flags");
|
let new_name = new_name.replace("FlagBits", "Flags");
|
||||||
Ident::from(new_name.as_str())
|
Ident::from(new_name.as_str())
|
||||||
}
|
}
|
||||||
fn to_type_tokens(type_name: &str, reference: Option<&vkxml::ReferenceType>) -> Tokens {
|
|
||||||
let new_name = name_to_tokens(type_name);
|
fn map_identifier_to_rust(term: Term) -> Term {
|
||||||
let ptr_name = reference.map(|r| r.to_tokens(false)).unwrap_or(quote! {});
|
match term.as_str() {
|
||||||
quote! {#ptr_name #new_name}
|
"VK_MAKE_VERSION" => Term::intern("crate::vk::make_version"),
|
||||||
|
s => Term::intern(constant_name(s)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse and yield a C expression that is valid to write in Rust
|
||||||
|
/// Identifiers are replaced with their Rust vk equivalent.
|
||||||
|
///
|
||||||
|
/// Examples:
|
||||||
|
/// - `VK_MAKE_VERSION(1, 2, VK_HEADER_VERSION)` -> `crate::vk::make_version(1, 2, HEADER_VERSION)`
|
||||||
|
/// - `2*VK_UUID_SIZE` -> `2 * UUID_SIZE`
|
||||||
|
fn convert_c_expression(c_expr: &str) -> TokenStream {
|
||||||
|
fn rewrite_token_stream(stream: TokenStream) -> TokenStream {
|
||||||
|
stream
|
||||||
|
.into_iter()
|
||||||
|
.map(|tok| TokenTree {
|
||||||
|
kind: rewrite_token_node(tok.kind),
|
||||||
|
..tok
|
||||||
|
})
|
||||||
|
.collect::<TokenStream>()
|
||||||
|
}
|
||||||
|
fn rewrite_token_node(node: TokenNode) -> TokenNode {
|
||||||
|
match node {
|
||||||
|
TokenNode::Group(d, stream) => TokenNode::Group(d, rewrite_token_stream(stream)),
|
||||||
|
TokenNode::Term(term) => TokenNode::Term(map_identifier_to_rust(term)),
|
||||||
|
_ => node,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let c_expr = c_expr.parse().unwrap();
|
||||||
|
rewrite_token_stream(c_expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FieldExt for vkxml::Field {
|
impl FieldExt for vkxml::Field {
|
||||||
fn is_clone(&self) -> bool {
|
fn is_clone(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn param_ident(&self) -> Ident {
|
fn param_ident(&self) -> Ident {
|
||||||
let name = self.name.as_deref().unwrap_or("field");
|
let name = self.name.as_deref().unwrap_or("field");
|
||||||
let name_corrected = match name {
|
let name_corrected = match name {
|
||||||
|
@ -688,18 +728,41 @@ impl FieldExt for vkxml::Field {
|
||||||
Ident::from(name_corrected.to_snake_case().as_str())
|
Ident::from(name_corrected.to_snake_case().as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_tokens(&self, is_ffi_param: bool) -> Tokens {
|
fn inner_type_tokens(&self) -> Tokens {
|
||||||
|
let ty = name_to_tokens(&self.basetype);
|
||||||
|
|
||||||
|
match self.reference {
|
||||||
|
Some(vkxml::ReferenceType::PointerToPointer) => quote!(*mut #ty),
|
||||||
|
Some(vkxml::ReferenceType::PointerToConstPointer) => quote!(*const #ty),
|
||||||
|
_ => quote!(#ty),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn safe_type_tokens(&self, lifetime: Tokens) -> Tokens {
|
||||||
|
match self.array {
|
||||||
|
// The outer type fn type_tokens() returns is [], which fits our "safe" prescription
|
||||||
|
Some(vkxml::ArrayType::Static) => self.type_tokens(false),
|
||||||
|
Some(vkxml::ArrayType::Dynamic) => {
|
||||||
|
let ty = self.inner_type_tokens();
|
||||||
|
quote!([#ty])
|
||||||
|
}
|
||||||
|
None => {
|
||||||
let ty = name_to_tokens(&self.basetype);
|
let ty = name_to_tokens(&self.basetype);
|
||||||
let pointer = self
|
let pointer = self
|
||||||
.reference
|
.reference
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|r| r.to_tokens(self.is_const))
|
.map(|r| r.to_safe_tokens(self.is_const, lifetime));
|
||||||
.unwrap_or(quote! {});
|
quote!(#pointer #ty)
|
||||||
let pointer_ty = quote! {
|
}
|
||||||
#pointer #ty
|
}
|
||||||
};
|
}
|
||||||
let array = self.array.as_ref().and_then(|arraytype| match arraytype {
|
|
||||||
vkxml::ArrayType::Static => {
|
fn type_tokens(&self, is_ffi_param: bool) -> Tokens {
|
||||||
|
let ty = name_to_tokens(&self.basetype);
|
||||||
|
|
||||||
|
match self.array {
|
||||||
|
Some(vkxml::ArrayType::Static) => {
|
||||||
|
assert!(self.reference.is_none());
|
||||||
let size = self
|
let size = self
|
||||||
.size
|
.size
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -707,22 +770,19 @@ impl FieldExt for vkxml::Field {
|
||||||
.expect("Should have size");
|
.expect("Should have size");
|
||||||
// Make sure we also rename the constant, that is
|
// Make sure we also rename the constant, that is
|
||||||
// used inside the static array
|
// used inside the static array
|
||||||
let size = constant_name(size);
|
let size = Term::intern(constant_name(size));
|
||||||
let size = Term::intern(&size);
|
|
||||||
// arrays in c are always passed as a pointer
|
// arrays in c are always passed as a pointer
|
||||||
if is_ffi_param {
|
if is_ffi_param {
|
||||||
Some(quote! {
|
quote!(&[#ty; #size])
|
||||||
&[#ty; #size]
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
Some(quote! {
|
quote!([#ty; #size])
|
||||||
[#ty; #size]
|
}
|
||||||
})
|
}
|
||||||
|
_ => {
|
||||||
|
let pointer = self.reference.as_ref().map(|r| r.to_tokens(self.is_const));
|
||||||
|
quote!(#pointer #ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => None,
|
|
||||||
});
|
|
||||||
array.unwrap_or(pointer_ty)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,9 +1003,6 @@ impl<'a> ConstantExt for ExtensionConstant<'a> {
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident {
|
fn variant_ident(&self, enum_name: &str) -> Ident {
|
||||||
variant_ident(enum_name, self.name)
|
variant_ident(enum_name, self.name)
|
||||||
}
|
}
|
||||||
fn to_tokens(&self) -> Tokens {
|
|
||||||
self.constant.to_tokens()
|
|
||||||
}
|
|
||||||
fn notation(&self) -> Option<&str> {
|
fn notation(&self) -> Option<&str> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -971,6 +1028,7 @@ pub fn generate_extension_constants<'a>(
|
||||||
if const_cache.contains(_enum.name.as_str()) {
|
if const_cache.contains(_enum.name.as_str()) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let (constant, extends, is_alias) = match &_enum.spec {
|
let (constant, extends, is_alias) = match &_enum.spec {
|
||||||
EnumSpec::Bitpos { bitpos, extends } => {
|
EnumSpec::Bitpos { bitpos, extends } => {
|
||||||
Some((Constant::BitPos(*bitpos as u32), extends.clone(), false))
|
Some((Constant::BitPos(*bitpos as u32), extends.clone(), false))
|
||||||
|
@ -1150,7 +1208,7 @@ pub fn generate_extension<'a>(
|
||||||
}
|
}
|
||||||
pub fn generate_define(define: &vkxml::Define) -> Tokens {
|
pub fn generate_define(define: &vkxml::Define) -> Tokens {
|
||||||
let name = constant_name(&define.name);
|
let name = constant_name(&define.name);
|
||||||
let ident = Ident::from(name.as_str());
|
let ident = Ident::from(name);
|
||||||
let deprecated = define
|
let deprecated = define
|
||||||
.comment
|
.comment
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -1162,11 +1220,8 @@ pub fn generate_define(define: &vkxml::Define) -> Tokens {
|
||||||
str::parse::<u32>(value).map_or(quote!(), |v| quote!(pub const #ident: u32 = #v;))
|
str::parse::<u32>(value).map_or(quote!(), |v| quote!(pub const #ident: u32 = #v;))
|
||||||
} else if let Some(c_expr) = &define.c_expression {
|
} else if let Some(c_expr) = &define.c_expression {
|
||||||
if define.defref.contains(&"VK_MAKE_VERSION".to_string()) {
|
if define.defref.contains(&"VK_MAKE_VERSION".to_string()) {
|
||||||
let c_expr = c_expr.replace("VK_", "");
|
let c_expr = convert_c_expression(c_expr);
|
||||||
let c_expr = c_expr.replace("MAKE_VERSION", "crate::vk::make_version");
|
|
||||||
use proc_macro2::TokenStream;
|
|
||||||
use std::str::FromStr;
|
|
||||||
let c_expr = TokenStream::from_str(&c_expr).unwrap();
|
|
||||||
quote!(pub const #ident: u32 = #c_expr;)
|
quote!(pub const #ident: u32 = #c_expr;)
|
||||||
} else {
|
} else {
|
||||||
quote!()
|
quote!()
|
||||||
|
@ -1176,14 +1231,19 @@ pub fn generate_define(define: &vkxml::Define) -> Tokens {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn generate_typedef(typedef: &vkxml::Typedef) -> Tokens {
|
pub fn generate_typedef(typedef: &vkxml::Typedef) -> Tokens {
|
||||||
let typedef_name = to_type_tokens(&typedef.name, None);
|
if typedef.basetype.is_empty() {
|
||||||
let typedef_ty = to_type_tokens(&typedef.basetype, None);
|
// Ignore forward declarations
|
||||||
|
quote! {}
|
||||||
|
} else {
|
||||||
|
let typedef_name = name_to_tokens(&typedef.name);
|
||||||
|
let typedef_ty = name_to_tokens(&typedef.basetype);
|
||||||
let khronos_link = khronos_link(&typedef.name);
|
let khronos_link = khronos_link(&typedef.name);
|
||||||
quote! {
|
quote! {
|
||||||
#[doc = #khronos_link]
|
#[doc = #khronos_link]
|
||||||
pub type #typedef_name = #typedef_ty;
|
pub type #typedef_name = #typedef_ty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pub fn generate_bitmask(
|
pub fn generate_bitmask(
|
||||||
bitmask: &vkxml::Bitmask,
|
bitmask: &vkxml::Bitmask,
|
||||||
bitflags_cache: &mut HashSet<Ident, impl BuildHasher>,
|
bitflags_cache: &mut HashSet<Ident, impl BuildHasher>,
|
||||||
|
@ -1261,11 +1321,10 @@ pub fn bitflags_impl_block(
|
||||||
.map(|constant| {
|
.map(|constant| {
|
||||||
let variant_ident = constant.variant_ident(enum_name);
|
let variant_ident = constant.variant_ident(enum_name);
|
||||||
let constant = constant.constant();
|
let constant = constant.constant();
|
||||||
let tokens = constant.to_tokens();
|
|
||||||
let tokens = if let Constant::Alias(_, _) = &constant {
|
let tokens = if let Constant::Alias(_, _) = &constant {
|
||||||
tokens
|
quote!(#constant)
|
||||||
} else {
|
} else {
|
||||||
quote!(Self(#tokens))
|
quote!(Self(#constant))
|
||||||
};
|
};
|
||||||
(variant_ident, tokens)
|
(variant_ident, tokens)
|
||||||
})
|
})
|
||||||
|
@ -1351,11 +1410,18 @@ pub fn generate_enum<'a>(
|
||||||
EnumType::Bitflags(q)
|
EnumType::Bitflags(q)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let (struct_attribute, special_quote) = match _name.as_str() {
|
||||||
|
//"StructureType" => generate_structure_type(&_name, _enum, create_info_constants),
|
||||||
|
"Result" => (quote!(#[must_use]), generate_result(ident, _enum)),
|
||||||
|
_ => (quote!(), quote!()),
|
||||||
|
};
|
||||||
|
|
||||||
let impl_block = bitflags_impl_block(ident, &_enum.name, &constants);
|
let impl_block = bitflags_impl_block(ident, &_enum.name, &constants);
|
||||||
let enum_quote = quote! {
|
let enum_quote = quote! {
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[doc = #khronos_link]
|
#[doc = #khronos_link]
|
||||||
|
#struct_attribute
|
||||||
pub struct #ident(pub(crate) i32);
|
pub struct #ident(pub(crate) i32);
|
||||||
impl #ident {
|
impl #ident {
|
||||||
pub const fn from_raw(x: i32) -> Self { #ident(x) }
|
pub const fn from_raw(x: i32) -> Self { #ident(x) }
|
||||||
|
@ -1363,13 +1429,6 @@ pub fn generate_enum<'a>(
|
||||||
}
|
}
|
||||||
#impl_block
|
#impl_block
|
||||||
};
|
};
|
||||||
let special_quote = match _name.as_str() {
|
|
||||||
//"StructureType" => generate_structure_type(&_name, _enum, create_info_constants),
|
|
||||||
"Result" => generate_result(ident, _enum),
|
|
||||||
_ => {
|
|
||||||
quote! {}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let q = quote! {
|
let q = quote! {
|
||||||
#enum_quote
|
#enum_quote
|
||||||
#special_quote
|
#special_quote
|
||||||
|
@ -1443,9 +1502,9 @@ pub fn derive_default(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
// also doesn't mark them as pointers
|
// also doesn't mark them as pointers
|
||||||
let handles = ["LPCWSTR", "HANDLE", "HINSTANCE", "HWND", "HMONITOR"];
|
let handles = ["LPCWSTR", "HANDLE", "HINSTANCE", "HWND", "HMONITOR"];
|
||||||
let contains_ptr = members.clone().any(|field| field.reference.is_some());
|
let contains_ptr = members.clone().any(|field| field.reference.is_some());
|
||||||
let contains_strucutre_type = members.clone().any(is_structure_type);
|
let contains_structure_type = members.clone().any(is_structure_type);
|
||||||
let contains_static_array = members.clone().any(is_static_array);
|
let contains_static_array = members.clone().any(is_static_array);
|
||||||
if !(contains_ptr || contains_strucutre_type || contains_static_array) {
|
if !(contains_ptr || contains_structure_type || contains_static_array) {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let default_fields = members.clone().map(|field| {
|
let default_fields = members.clone().map(|field| {
|
||||||
|
@ -1602,19 +1661,9 @@ pub fn derive_setters(
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let (has_next, _is_next_const) = match members
|
let has_next = members
|
||||||
.clone()
|
.clone()
|
||||||
.find(|field| field.param_ident().as_ref() == "p_next")
|
.any(|field| field.param_ident().as_ref() == "p_next");
|
||||||
{
|
|
||||||
Some(p_next) => {
|
|
||||||
if p_next.type_tokens(false).to_string().starts_with("*const") {
|
|
||||||
(true, true)
|
|
||||||
} else {
|
|
||||||
(true, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => (false, false),
|
|
||||||
};
|
|
||||||
|
|
||||||
let nofilter_count_members = [
|
let nofilter_count_members = [
|
||||||
"VkPipelineViewportStateCreateInfo.pViewports",
|
"VkPipelineViewportStateCreateInfo.pViewports",
|
||||||
|
@ -1650,21 +1699,17 @@ pub fn derive_setters(
|
||||||
|
|
||||||
let setters = members.clone().filter_map(|field| {
|
let setters = members.clone().filter_map(|field| {
|
||||||
let param_ident = field.param_ident();
|
let param_ident = field.param_ident();
|
||||||
let param_ty_tokens = field.type_tokens(false);
|
let param_ty_tokens = field.safe_type_tokens(quote!('a));
|
||||||
let param_ty_string = param_ty_tokens.to_string();
|
|
||||||
|
|
||||||
let param_ident_string = param_ident.to_string();
|
let param_ident_string = param_ident.to_string();
|
||||||
if param_ident_string == "s_type" || param_ident_string == "p_next" {
|
if param_ident_string == "s_type" || param_ident_string == "p_next" {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut param_ident_short = param_ident_string.as_str();
|
let param_ident_short = param_ident_string
|
||||||
if param_ident_string.starts_with("p_") {
|
.strip_prefix("p_")
|
||||||
param_ident_short = ¶m_ident_string[2..];
|
.or_else(|| param_ident_string.strip_prefix("pp_"))
|
||||||
};
|
.unwrap_or_else(|| param_ident_string.as_str());
|
||||||
if param_ident_string.starts_with("pp_") {
|
|
||||||
param_ident_short = ¶m_ident_string[3..];
|
|
||||||
};
|
|
||||||
let param_ident_short = Term::intern(¶m_ident_short);
|
let param_ident_short = Term::intern(¶m_ident_short);
|
||||||
|
|
||||||
if let Some(name) = field.name.as_ref() {
|
if let Some(name) = field.name.as_ref() {
|
||||||
|
@ -1695,8 +1740,10 @@ pub fn derive_setters(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Improve in future when https://github.com/rust-lang/rust/issues/53667 is merged id:6
|
// TODO: Improve in future when https://github.com/rust-lang/rust/issues/53667 is merged id:6
|
||||||
if param_ident_string.starts_with("p_") || param_ident_string.starts_with("pp_") {
|
if field.reference.is_some() {
|
||||||
if param_ty_string == "*const c_char" {
|
if field.basetype == "char" && matches!(field.reference, Some(vkxml::ReferenceType::Pointer)) {
|
||||||
|
assert!(field.null_terminate);
|
||||||
|
assert_eq!(field.size, None);
|
||||||
return Some(quote!{
|
return Some(quote!{
|
||||||
pub fn #param_ident_short(mut self, #param_ident_short: &'a ::std::ffi::CStr) -> #name_builder<'a> {
|
pub fn #param_ident_short(mut self, #param_ident_short: &'a ::std::ffi::CStr) -> #name_builder<'a> {
|
||||||
self.inner.#param_ident = #param_ident_short.as_ptr();
|
self.inner.#param_ident = #param_ident_short.as_ptr();
|
||||||
|
@ -1705,49 +1752,46 @@ pub fn derive_setters(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref array_type) = field.array {
|
if matches!(field.array, Some(vkxml::ArrayType::Dynamic)) {
|
||||||
if let Some(ref array_size) = field.size {
|
if let Some(ref array_size) = field.size {
|
||||||
if !array_size.starts_with("latexmath") {
|
if !array_size.starts_with("latexmath") {
|
||||||
|
let mut slice_param_ty_tokens = field.safe_type_tokens(quote!('a));
|
||||||
|
|
||||||
|
let mut ptr = if field.is_const {
|
||||||
|
quote!(.as_ptr())
|
||||||
|
} else {
|
||||||
|
quote!(.as_mut_ptr())
|
||||||
|
};
|
||||||
|
|
||||||
|
// Interpret void array as byte array
|
||||||
|
if field.basetype == "void" {
|
||||||
|
let mutable = if field.is_const { quote!(const) } else { quote!(mut) };
|
||||||
|
|
||||||
|
slice_param_ty_tokens = quote!([u8]);
|
||||||
|
ptr = quote!(#ptr as *#mutable c_void);
|
||||||
|
};
|
||||||
|
|
||||||
|
let mutable = if field.is_const { quote!() } else { quote!(mut) };
|
||||||
|
|
||||||
|
// Apply some heuristics to determine whether the size is an expression.
|
||||||
|
// If so, this is a pointer to a piece of memory with statically known size.
|
||||||
|
let set_size_stmt = if array_size.contains("ename:") || array_size.contains('*') {
|
||||||
|
// c_size should contain the same minus `ename:`-prefixed identifiers
|
||||||
|
let array_size = field.c_size.as_ref().unwrap_or(array_size);
|
||||||
|
let c_size = convert_c_expression(array_size);
|
||||||
|
let inner_type = field.inner_type_tokens();
|
||||||
|
|
||||||
|
slice_param_ty_tokens = quote!([#inner_type; #c_size]);
|
||||||
|
|
||||||
|
quote!()
|
||||||
|
} else {
|
||||||
let array_size_ident = Ident::from(array_size.to_snake_case().as_str());
|
let array_size_ident = Ident::from(array_size.to_snake_case().as_str());
|
||||||
if param_ty_string == "*const *const c_char" {
|
quote!(self.inner.#array_size_ident = #param_ident_short.len() as _;)
|
||||||
return Some(quote!{
|
};
|
||||||
pub fn #param_ident_short(mut self, #param_ident_short: &'a [*const c_char]) -> #name_builder<'a> {
|
|
||||||
self.inner.#param_ident = #param_ident_short.as_ptr();
|
|
||||||
self.inner.#array_size_ident = #param_ident_short.len() as _;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let slice_param_ty_tokens;
|
|
||||||
let ptr;
|
|
||||||
if param_ty_string.starts_with("*const ") {
|
|
||||||
let slice_type = ¶m_ty_string[7..];
|
|
||||||
if slice_type == "c_void" {
|
|
||||||
slice_param_ty_tokens = "&'a [u8]".to_string();
|
|
||||||
ptr = ".as_ptr() as *const c_void";
|
|
||||||
} else {
|
|
||||||
slice_param_ty_tokens = "&'a [".to_string() + slice_type + "]";
|
|
||||||
ptr = ".as_ptr()";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// *mut
|
|
||||||
let slice_type = ¶m_ty_string[5..];
|
|
||||||
if slice_type == "c_void" {
|
|
||||||
slice_param_ty_tokens = "&'a mut [u8]".to_string();
|
|
||||||
ptr = ".as_mut_ptr() as *mut c_void";
|
|
||||||
} else {
|
|
||||||
slice_param_ty_tokens = "&'a mut [".to_string() + slice_type + "]";
|
|
||||||
ptr = ".as_mut_ptr()";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let slice_param_ty_tokens = Term::intern(&slice_param_ty_tokens);
|
|
||||||
let ptr = Term::intern(ptr);
|
|
||||||
|
|
||||||
if let vkxml::ArrayType::Dynamic = array_type {
|
|
||||||
return Some(quote! {
|
return Some(quote! {
|
||||||
pub fn #param_ident_short(mut self, #param_ident_short: #slice_param_ty_tokens) -> #name_builder<'a> {
|
pub fn #param_ident_short(mut self, #param_ident_short: &'a #mutable #slice_param_ty_tokens) -> #name_builder<'a> {
|
||||||
self.inner.#array_size_ident = #param_ident_short.len() as _;
|
#set_size_stmt
|
||||||
self.inner.#param_ident = #param_ident_short#ptr;
|
self.inner.#param_ident = #param_ident_short#ptr;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -1757,19 +1801,7 @@ pub fn derive_setters(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if param_ty_string.starts_with("*const ") {
|
if field.basetype == "VkBool32" {
|
||||||
let slice_param_ty_tokens = "&'a ".to_string() + ¶m_ty_string[7..];
|
|
||||||
let slice_param_ty_tokens = Term::intern(&slice_param_ty_tokens);
|
|
||||||
return Some(quote!{
|
|
||||||
pub fn #param_ident_short(mut self, #param_ident_short: #slice_param_ty_tokens) -> #name_builder<'a> {
|
|
||||||
self.inner.#param_ident = #param_ident_short;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if param_ty_string == "Bool32" {
|
|
||||||
return Some(quote!{
|
return Some(quote!{
|
||||||
pub fn #param_ident_short(mut self, #param_ident_short: bool) -> #name_builder<'a> {
|
pub fn #param_ident_short(mut self, #param_ident_short: bool) -> #name_builder<'a> {
|
||||||
self.inner.#param_ident = #param_ident_short.into();
|
self.inner.#param_ident = #param_ident_short.into();
|
||||||
|
@ -1778,6 +1810,13 @@ pub fn derive_setters(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let param_ty_tokens = if is_opaque_type(&field.basetype) {
|
||||||
|
// Use raw pointers for void/opaque types
|
||||||
|
field.type_tokens(false)
|
||||||
|
} else {
|
||||||
|
param_ty_tokens
|
||||||
|
};
|
||||||
|
|
||||||
Some(quote!{
|
Some(quote!{
|
||||||
pub fn #param_ident_short(mut self, #param_ident_short: #param_ty_tokens) -> #name_builder<'a> {
|
pub fn #param_ident_short(mut self, #param_ident_short: #param_ty_tokens) -> #name_builder<'a> {
|
||||||
self.inner.#param_ident = #param_ident_short;
|
self.inner.#param_ident = #param_ident_short;
|
||||||
|
@ -1983,7 +2022,7 @@ pub fn generate_struct(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_handle(handle: &vkxml::Handle) -> Option<Tokens> {
|
pub fn generate_handle(handle: &vkxml::Handle) -> Option<Tokens> {
|
||||||
if handle.name == "" {
|
if handle.name.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let khronos_link = khronos_link(&handle.name);
|
let khronos_link = khronos_link(&handle.name);
|
||||||
|
@ -2026,7 +2065,7 @@ fn generate_funcptr(fnptr: &vkxml::FunctionPointer) -> Tokens {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_union(union: &vkxml::Union) -> Tokens {
|
fn generate_union(union: &vkxml::Union) -> Tokens {
|
||||||
let name = to_type_tokens(&union.name, None);
|
let name = name_to_tokens(&union.name);
|
||||||
let fields = union.elements.iter().map(|field| {
|
let fields = union.elements.iter().map(|field| {
|
||||||
let name = field.param_ident();
|
let name = field.param_ident();
|
||||||
let ty = field.type_tokens(false);
|
let ty = field.type_tokens(false);
|
||||||
|
@ -2169,8 +2208,9 @@ pub fn generate_feature<'a>(
|
||||||
#device
|
#device
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn constant_name(name: &str) -> String {
|
|
||||||
name.replace("VK_", "")
|
pub fn constant_name(name: &str) -> &str {
|
||||||
|
name.strip_prefix("VK_").unwrap_or(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_constant<'a>(
|
pub fn generate_constant<'a>(
|
||||||
|
@ -2180,16 +2220,14 @@ pub fn generate_constant<'a>(
|
||||||
cache.insert(constant.name.as_str());
|
cache.insert(constant.name.as_str());
|
||||||
let c = Constant::from_constant(constant);
|
let c = Constant::from_constant(constant);
|
||||||
let name = constant_name(&constant.name);
|
let name = constant_name(&constant.name);
|
||||||
let ident = Ident::from(name.as_str());
|
let ident = Ident::from(name);
|
||||||
let value = c.to_tokens();
|
|
||||||
let ty = if name == "TRUE" || name == "FALSE" {
|
let ty = if name == "TRUE" || name == "FALSE" {
|
||||||
CType::Bool32
|
CType::Bool32
|
||||||
} else {
|
} else {
|
||||||
c.ty()
|
c.ty()
|
||||||
};
|
};
|
||||||
let ty = ty.to_tokens();
|
|
||||||
quote! {
|
quote! {
|
||||||
pub const #ident: #ty = #value;
|
pub const #ident: #ty = #c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2287,8 +2325,8 @@ pub fn generate_const_debugs(const_values: &BTreeMap<Ident, Vec<ConstantMatchInf
|
||||||
#(#impls)*
|
#(#impls)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn generate_aliases_of_types<'a>(
|
pub fn generate_aliases_of_types(
|
||||||
types: &'a vk_parse::Types,
|
types: &vk_parse::Types,
|
||||||
ty_cache: &mut HashSet<Ident, impl BuildHasher>,
|
ty_cache: &mut HashSet<Ident, impl BuildHasher>,
|
||||||
) -> Tokens {
|
) -> Tokens {
|
||||||
let aliases = types
|
let aliases = types
|
||||||
|
|
Loading…
Reference in a new issue