Commit graph

134 commits

Author SHA1 Message Date
Marijn Suijten befb8cdd36
Switch to safe CStr::from_bytes_until_nul on sized c_char array wrapper (#746)
Certain structs contain sized character arrays that are converted to
`CStr` for convenient accss to the user and our `Debug` implementation
using unsafe `CStr::from_ptr(...as_ptr())`.  There is no need to
round-trip to a pointer and possibly read out of bounds if the
NUL-terminator index (string length) is instead searched for by the
newly stabilized `CStr::from_bytes_until_nul()` fn since Rust 1.69
(which panics if no NUL-terminator is found before the end of the
slice).

Unfortunately `unsafe` is still needed to cast the array from a `c_char`
(`i8` on most platforms) to `u8`, which is what `from_bytes_until_nul()`
accepts.
2023-12-02 20:04:57 +01:00
Marijn Suijten 02c7a83592
Provide CStr getters and setters for c_char pointers and arrays (#831)
It is a common operation to read and write NUL-terminated C string in
the Vulkan API, yet the only helpers for that were thus far open-coded
in the `Debug` printing implementations.

Move them to separate functions that are exposed to the user, in hopes
of helping them no longer misunderstand NUL-terminated strings (see
e.g. #830).

Important to note is that the array-copy for a static-sized `c_char`
array has also been replaced with a `CStr` wrapper: this forces the user
and our implementation to have a NUL-terminator at the end of the string,
and the setter returns `Err()` when the given `CStr (with NUL-terminator)
is too large for the static-sized array it has to be written to.
2023-11-29 00:37:21 +01:00
Marijn Suijten 5938fd2633
Update Vulkan-Headers to 1.3.271 (#816)
* Update Vulkan-Headers to 1.3.270

* Update Vulkan-Headers to 1.3.271

* extensions/nv/low_latency2: Support extension revision 2

Upon request the VK_NV_low_latency2 spec and API has been updated to move
the count pointer from the `vkGetLatencyTimingsNV()` function to
the `vkGetLatencyMarkerInfoNV` struct where the array pointer already
resided.

This got uncovered when it was realized that the `latency_marker_info`
argument isn't an array at all (which the original design of this
extension suggested), but a pointer to a single struct that _contains_
a pointer to an array, with the length passed as a separate argument to
the function instead.

The move of this count argument to a struct field - together with proper
array length annotations - gets our generator to automatically emit a
setter based on a slice argument.
2023-11-28 15:05:27 +01:00
Marijn Suijten b358b9dd8d
extensions/khr/ray_tracing_pipeline: Pass indirect SBT regions as single item (#829)
In an identical fashion to commit 84624fd ("ray_tracing_pipeline:
Pass SBT regions as reference instead of slice (#350)")
`cmd_trace_rays_indirect()` also only needs a pointer to a single
`StridedDeviceAddressRegionKHR` structure.  After all no length is ever
passed to the API anywhere, and this could also lead to users passing
empty slices, or passing too many elements that are never used.

Clear up the confusion by replacing the slice argument with a direct
borrow of the struct.
2023-11-25 11:08:48 +01:00
Marijn Suijten c87eb53b92
Update repository links and crate keywords/categories (#819)
Some links were still pointing to the (moved) `MaikKlein/ash` repo,
instead of the new shared `ash-rs/ash` repository under this
organisation, GitHub still provides a redirect, but we should aim to
provide the correct link from the get-go.  Only the gitter channel
remains as it was impossible to get the room to be renamed.  The
`ash-rs/ash` channel exists but there is currently no activity.
2023-11-17 16:55:05 +01:00
David Koloski d40ab4b367
Bump libloading to 0.8 (#739) 2023-11-15 10:19:14 +01:00
Marijn Suijten 335251d383
Enable descriptor_count() setter on ash::vk::WriteDescriptorSet (#809)
This parameter is not only used for the length of `pImageInfo`,
`pBufferInfo` or `pTexelBufferView`, but also matching the value
of `dataSize` when `VkWriteDescriptorSetInlineUniformBlock` is
appended in `pNext`, or the value of `accelerationStructureCount`
when `VkWriteDescriptorSetAccelerationStructureKHR` is in `pNext`.
Having the count setter directly avaialble makes builder code more
natural, instead of having to use a `mut` variable and manually assign
`.descriptor_count = xx.len();` afterwards.

https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkWriteDescriptorSet.html
2023-10-31 10:16:34 +01:00
Marijn Suijten f5e7606c03
extensions/nv: Add VK_NV_cuda_kernel_launch extension (#805) 2023-10-26 23:03:22 +02:00
Marijn Suijten a6f8450edf
extensions/ext: Add VK_EXT_hdr_metadata extension (#804) 2023-10-26 09:05:14 +02:00
Marijn Suijten 2d2aeac84a
extensions/nv: Add VK_NV_low_latency2 extension (#802) 2023-10-25 20:02:19 +02:00
Marijn Suijten 11647de859
Update Vulkan-Headers to 1.3.269 (#783)
* Update Vulkan-Headers to 1.3.261

* Update Vulkan-Headers to 1.3.262

* Update Vulkan-Headers to 1.3.263

* Update Vulkan-Headers to 1.3.264

* Update Vulkan-Headers to 1.3.266

* generator: Fix `clippy::filter_map_bool_then`

* Update Vulkan-Headers to 1.3.267

* Update Vulkan-Headers to 1.3.268

* Update Vulkan-Headers to 1.3.269
2023-10-21 00:47:28 +02:00
Marijn Suijten d0d5ea1370
platform_types: Convert Windows HANDLE types to isize (#797)
The `windows` crate treats these as `isize` rather than raw void
pointers:
https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/Foundation/struct.HWND.html

And `raw-window-handle 0.6` recently started to do the same:
https://github.com/rust-windowing/raw-window-handle/pull/136

However, the win32 documentation still states that these should be
`PVOID`:
https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
2023-10-14 11:18:23 +02:00
Marijn Suijten 0652aee695
extensions/ext: Add VK_EXT_swapchain_maintenance1 (#786) 2023-08-15 21:43:01 +02:00
Chris Spencer 5a9d779eef
extensions/khr: Add VK_KHR_sampler_ycbcr_conversion (#785) 2023-08-14 17:13:07 +02:00
Felipe 43d4a68ab2
extensions/ext: Add VK_EXT_vertex_input_dynamic_state (#784) 2023-08-14 16:57:11 +02:00
Marijn Suijten 39dc6d607c
extensions/khr: Add VK_KHR_cooperative_matrix (#782) 2023-08-14 16:49:32 +02:00
Marijn Suijten 3fa908c70a
extensions/nv: Add VK_NV_device_generated_commands_compute (#781) 2023-08-14 16:42:57 +02:00
Marijn Suijten b91c2aac92
extensions/khr: Add VK_KHR_maintenance5 (#780) 2023-08-14 16:09:06 +02:00
Marijn Suijten 95ff15ff72
extensions/ext: Add VK_EXT_host_image_copy (#779) 2023-08-14 15:56:42 +02:00
Marijn Suijten c3f322f65e
extensions/amdx: Add VK_AMDX_shader_enqueue (#776) 2023-08-14 15:51:20 +02:00
Marijn Suijten f558761997
extensions/amd: Add VK_AMD_shader_info (#773) 2023-07-29 10:51:03 +02:00
Marijn Suijten 884ac46e82
extensions/amd: Add VK_AMD_buffer_marker (#772) 2023-07-29 10:45:11 +02:00
Marijn Suijten 010df1b1b3
Update Vulkan-Headers to 1.3.260 (#763)
* Update Vulkan-Headers to 1.3.255

* Update Vulkan-Headers to 1.3.257

* Update Vulkan-Headers to 1.3.258

* Update Vulkan-Headers to 1.3.259

* Update Vulkan-Headers to 1.3.260
2023-07-29 10:44:49 +02:00
Chris Spencer 6b56444e79
extensions/android: Add VK_ANDROID_external_memory_android_hardware_buffer (#769) 2023-07-12 12:09:08 +02:00
Chris Spencer 369fe05e79
extensions/google: Add VK_GOOGLE_display_timing (#765) 2023-07-11 15:45:04 +02:00
BeastLe9enD 75089f487f
extensions/nv: Add VK_NV_memory_decompression (#761) 2023-06-21 22:14:38 +02:00
Marijn Suijten eb1712944e
Update Vulkan-Headers to 1.3.254 (#760)
* Update Vulkan-Headers to 1.3.252

* Update Vulkan-Headers to 1.3.253

* Update Vulkan-Headers to 1.3.254

* vk/platform_types: Add `_screen_buffer` type for QNX
2023-06-16 17:05:11 +02:00
Marijn Suijten 9985b2ca69
Rename vk::Instance-returning function from device() to instance() (#759) 2023-05-29 13:11:55 -07:00
Marijn Suijten d588de01aa
changelog: Import from and synchronize with 0.37.3 release 2023-05-29 21:25:48 +02:00
Marijn Suijten 5287371195
Update Vulkan-Headers to 1.3.251 (#741)
* Update Vulkan-Headers to 1.3.247

* Update Vulkan-Headers to 1.3.248

* Update Vulkan-Headers to 1.3.249

* Update Vulkan-Headers to 1.3.250

* Update Vulkan-Headers to 1.3.251
2023-05-29 11:04:51 +02:00
Marijn Suijten bdafbb4646
entry: Mark all extern "C" function-pointer calls unsafe
We don't mark any of the extern calls to Vulkan function-pointers safe
except for a few `Entry` functions.  Their safety contract was easy to
validate, but now that we exposed a constructor function to let the user
provide function pointers in the form of `Entry::from_parts_1_1()` it is
no longer safe to assume that we are calling the function that adheres
to the contract specified in the Vulkan reference.

Because we don't rigorously do this validation and safe-marking anywhere
else either, mark these function calls as `unsafe`.

Related discussion chain: https://github.com/ash-rs/ash/pull/748#discussion_r1186794284
2023-05-28 16:32:22 -07:00
antonino maniscalco 53c395b6b6
Allow building Entry/Instance/Device from handle+fns (#748)
* ash/device: Allow building device from handle+fns

Adds a constructor to build a device from a handle + functions.
Helps with interoperability with other vulkan wrappers

* ash/instance: Allow building instance from handle+fns

Adds a constructor to build an instance from a handle + functions.
Helps with interoperability with other vulkan wrappers

* ash/entry: Allow building entry from handle+fns

Adds a constructor to build an entry from a handle + functions.
Helps with interoperability with other vulkan wrappers

* changelog: Document #748 addition of `from_parts` constructors
2023-05-07 21:44:34 +02:00
i509VCB fca01159ab
Add Handle::is_null() (#694) 2023-05-06 21:25:42 +02:00
Kanashimia ad70ad7c60
extensions/ext: Make get_calibrated_timestamps() return single value for max_deviation (#738)
Per spec `max_deviation` is a single value, not an array.
2023-05-06 12:25:05 -07:00
Marijn Suijten aa8f600aa8
Generate generic builder setters for fields taking an objecttype (#724)
Generate templated builder setters for fields taking an `objecttype`

We already do this for hand-written extension functions but can now also
implement it for setters since `vk_parse` fields are available within
the builder generator code: when a field refers to another field for
setting its `objecttype`, that `VkObjectType` field setter is omitted
and instead assigned when the object is set, based on a type generic
that implements the `Handle` trait instead of an untyped `u64`.
2023-05-06 20:39:57 +02:00
Marijn Suijten f840977b72
extensions/ext: Add VK_EXT_pipeline_properties device extension (#622)
* extensions/ext: Add VK_EXT_pipeline_properties device extension

* Generate traits and impls for all `validstructs` on command parameters
2023-05-06 20:30:46 +02:00
Marijn Suijten cf1c92e664
Drop load() functions from empty Fn structs (#752)
These functions don't contribute anything and should be removed to clean
up the `features` and `extensions` files, while now also not showing in
the documentation anymore.  The structs remain in place for associated
constants but are replaced with true unit-like structs (no curly
brackets anymore), and unneeded `unsafe impl Send/Sync` are removed as
well.

As these `load()` functions have been removed from the empty
feature-levels on `Entry` and `Device` as well, rather than
instantiating the unit structs and returning those the fields and
`fp_vX_X()` getters have been removed entirely.
2023-05-06 20:22:32 +02:00
Marijn Suijten 8b1151350e
Define Display as c_void instead of *mut c_void to match Xlib (#751)
Xlib defines `Display` as follows:

    typedef struct _XDisplay Display;

And then always references this type as a pointer to it, e.g. `Display
*`.  The same happens in `ash`, where `Display` is only ever referenced
as a raw pointer via `*mut Display`, so making `Display` itself a type
alias to `*mut c_void` is wrong and confusing.  Switch it back to a
`c_void` to match the forward-declared (but otherwise undefined) `struct
_XDisplay`.
2023-05-06 20:21:48 +02:00
Marijn Suijten d783af0f33
extensions/khr/device_group_creation: Take borrow of Entry in new() (#753)
Looks like #630 typo'd the argument for `DeviceGroupCreation::new()` by
unnecessarily requiring a move (`Clone`) of `Entry` just to call
`get_instance_proc_addr()` on it.  Replace this with a borrow to match
all other extensions.
2023-05-06 10:29:28 -07:00
Marijn Suijten 1374996499
extensions/khr: Take the remaining p_next-containing structs as &mut (#744)
* extensions/khr: Take the remaining `p_next`-containing structs as `&mut`

Version 2 of `get_physical_device_surface_capabilities` and the matching
`vk::SurfaceCapabilitiesKHR` struct exist solely to provide an `sType`
and `pNext` field to allow extending the original query with additional
data via extension structs.  However, this API when introduced in #530
only returns the `default()`-initialized struct making it just as
constrained as `get_physical_device_surface_capabilities()`.  Solve this
by taking `vk::SurfaceCapabilities2KHR` as `&mut` just like any similar
API.

And just like this, do the same for the remaining:
- `AccelerationStructure::get_acceleration_structure_build_sizes()`
- `ExternalMemoryFd::get_memory_fd_properties()`
- `ExternalMemoryWin32::get_memory_win32_handle_properties()`

In case these structs get extended somewhere down the line, which the
Vulkan API allows for.

* extensions/khr/acceleration_structure: Use `mem::zeroed()` in place of `vk::AccelerationStructureCompatibilityKHR::default()`
2023-05-03 20:47:01 +02:00
Marijn Suijten dca1a004c1
changelog: Document #747 attachment_count() addition 2023-05-02 10:47:08 +02:00
Vinh Truong 88e46b43a4
ash/device: Add missing Device::get_device_queue2() wrapper (#736)
ash/device: Add missing Device::get_device_queue2() wrapper
2023-04-08 21:58:47 +02:00
Marijn Suijten 77e614d776
extensions/ext: Add VK_EXT_shader_object device extension (#732)
* extensions/ext: Add VK_EXT_shader_object device extension

* extensions/ext/shader_object: Copy remaining fn impls from `extended_dynamic_state*`
2023-04-03 10:39:06 +02:00
Marijn Suijten 7ac0027852
Update Vulkan-Headers to 1.3.246 (#723)
* Update Vulkan-Headers to 1.3.245

* Upgrade `bindgen` to `0.64`

* Update Vulkan-Headers to 1.3.246
2023-04-03 10:18:26 +02:00
Marijn Suijten 74f68f26a2
extensions/khr: Add VK_KHR_performance_query (#726) 2023-04-03 10:05:24 +02:00
Marijn Suijten f98cab47dd
extensions: Remove get_properties() helper from extension wrappers (#728)
This helper function isn't consistently implemented across most
extension wrappers, and promotes bad Vulkan patterns by not making it
obvious to the caller that `get_physical_device_properties2()` can and
should be used to fill multiple properties structs at once.
2023-03-30 11:12:36 +02:00
Marijn Suijten a9fbc7147b
Update Vulkan-Headers to 1.3.244 (#697)
* Update Vulkan-Headers to 1.3.239

* Update Vulkan-Headers to 1.3.240

* Upgrade to `bindgen 0.63` and `vk-parse 0.9`

Updates cause no semantic changes in usage nor generated output.

* generator: Support new `deprecated` attribute

* Update Vulkan-Headers to 1.3.241

* generator: Emit `#[deprecated]` annotation for type members (struct fields)

* Update Vulkan-Headers to 1.3.242

* Update Vulkan-Headers to 1.3.243

* Update Vulkan-Headers to 1.3.244
2023-03-21 07:19:17 +01:00
Marijn Suijten 7a1686014e
Replace const fn name() with associated NAME constants (#715)
`CStr::from_bytes_with_nul_unchecked` is `const`-stable since Rust 1.59
which is already required for `ash` so it is high time to finally turn
these inlined `name()` functions into associated constants (which is a
breaking change in itself that cannot be backported).
2023-03-09 23:53:04 +01:00
Marijn Suijten 7b3df8477d
changelog: Document removal of query_count parameter from get_query_pool_results() (#710)
Commit c66db26 ("device: Replace `query_count` parameter in
`get_query_pool_results` with `data.len()` (#644)") removed this
parameter in favour of using `data.len()` to make it more obvious to use
an appropriate element type that matches the kind of request (see also
 #639) so that the stride is filled in correctly, but it was not
mentioned in the changelog yet.
2023-02-24 22:33:24 +01:00
Marijn Suijten 9e71ab9e34
Bump MSRV to 1.60 to accomodate for winit 0.28/objc requirement (#709)
These dependencies fail to resolve on older Rust/cargo versions before
even complaining about them being a too-high MSRV.
2023-02-24 21:51:07 +01:00