Commit graph

1070 commits

Author SHA1 Message Date
Alex Janka 55628b4023 raw-window-handle 0.6 2024-02-08 15:07:56 +11:00
Marijn Suijten 66c0cf42a0
Release ash 0.37.3 (#758) 2023-05-29 20:51:14 +02:00
Marijn Suijten 550182e940
Remove "drop" mention from create_* docs when the result doesn't implement Drop (#625)
Ash doesn't implement `Drop` intentionally, to not be too opinionated
about holding (heap) references to their parent objects
(`Device`->`Instance`->`Entry`) and ensuring they are destroyed in the
right order.  As such, reword the `create` documentation for `Instance`
and `Device` to mention their respective `destroy_*` function instead of
referring to them as being "droppable".

Note that `Entry` is droppable as it does not have a Vulkan `destroy`
function _and_ the dynamically loaded library (behind the "loaded"
feature) is kept alive only for the lifetime of `Entry`.
2023-05-29 20:42:41 +02:00
Marijn Suijten a6df3b2192
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:06:53 +02:00
Marijn Suijten 81cf86eb44
[0.37-stable] extensions: Provide new_from_instance() fallback for Instance functions (#754)
extensions: Provide `new_from_instance()` fallback for `Instance` functions

This is a minimal, semver-compatible backport of #734 to the
`0.37-stable` branch, warning Ash users of the problem outlined below
while the issue is properly being solved in the next breaking Ash
release (by separating `Instance` and `Device` functions in the
generator to avert this problem entirely while also always providing
optimal `Device`-specific functions for extension wrappers that are
currently already loading _everything_ via `Instance` to forgo the
problem).

As discovered and detailed in #727 a few extension wrappers were loading
and calling `Instance` functions via `Device` and
`get_device_proc_addr()` which is [defined] to only return non-`NULL`
function pointers for `Device` functions.  Those wrapper functions will
always call into Ash's panicking NULL-stub functions as the desired
`Instance` function could not be loaded.

Deprecate the `new()` functions for extension wrappers that were doing
this, while pointing the reader to `new_from_instance()` and explaining
in the docs what function will always `panic!()` when the struct was
loaded using `new()` instead.

This function always takes a raw `vk::Device` directly to fill `handle`
(rather than `ash::Device` to retrieve `handle()` from), allowing users
to pass `vk::Device::null()` when they do intend to load this extension
wrapper just for calling the `Instance` function.

[defined]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceProcAddr.html#_description
2023-05-06 21:07:08 +02:00
Marijn Suijten a2d17fe5ba
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:49:51 +02:00
Marijn Suijten 33bc042e9c
Expose FramebufferCreateInfo::attachment_count builder for IMAGELESS (#747)
* Expose `FramebufferCreateInfo::attachment_count` builder for `IMAGELESS`

Don't omit the `attachment_count()` builder method, because it is valid
to set the number of attachments without providing attachments in the
`IMAGELESS` case.

Also change the generator array lookup to use the name of the count
field that is allowed to have a builder method, rather than the name of
the field that would use this as `len` field and hence cause it to be
skipped.

* Clean up clones
2023-05-02 10:54:36 +02:00
Vinh Truong 0cd90ef75d
ash/device: Add missing Device::get_device_queue2() wrapper (#736)
ash/device: Add missing Device::get_device_queue2() wrapper
2023-04-08 22:02:34 +02:00
Marijn Suijten b50a253be7
generator: Run rustfmt over generated output before writing to disk (#735)
Some users are confused by seeing wildly different output after running
the generator, which is simply solved by running `rustfmt`.  As this is
both confusing and "somewhat" slow, invoke `rustfmt` directly within the
generator by piping string contents through it before redirecting to
disk.  This not only makes the output consistent, it is the fastest way
to reformat generator changes by omitting the round-trip to disk
entirely, nor having `rustfmt` recursively go through the workspace and
all files (including those that are not generated).

On a many-core machine these times are a bit skewed, but I want to
include them to prove the "speed" point nevertheless, even if simplicity
and consistency is the main reason to make this change:

Before:

    time ./target/debug/generator && time cargo fmt --all
    ./target/debug/generator  3.51s user 1.25s system 99% cpu 4.769 total
    cargo fmt --all  0.79s user 0.06s system 99% cpu 0.853 total

After:

    time ./target/debug/generator
    ./target/debug/generator  4.51s user 0.41s system 99% cpu 4.931 total
2023-04-08 22:02:30 +02:00
Marijn Suijten 0428540fa3
CI: Replace deprecated actions-rs with simple run: cargo ... (#720)
There's no reason to use these steps anymore: besides being old,
unmaintained, and spitting out NodeJS deprecation warnings, GitHub's
`runner-images` come preloaded with all Rust tools and components we
need, and the syntax to run commands is more efficient, much shorter and
more apprehensible by simply matching what we'd use on our own
command-line, too.
2023-04-08 22:01:39 +02:00
Marijn Suijten 508fc4ff19
generator: Borrow all command names and disentangle "aliases" (#733)
Turns out we were doing the wrong thing for the right reason: the
`aliases` here aren't `vk.xml` aliases: they are renames.  When
generating function pointers for extensions, a list of command
_definitions_ is collected, which can only ever be "root" `command`s.
Extensions typically reference stabilized `command`s under an alias with
the vendor tag suffixed, which the `Fn` struct field name is renamed to
using this `aliases` - now replaced with `rename_commands` - list, while
generating the rest of the "function pointer" command bits using the
"root" `command` (as this mostly pertains the parameters and return
type).  With that explanation it becomes clear why
`generate_extension_commands()` was creating an "alias" mapping from
stabilized name to vendor-suffixed extension name, and calls
`generate_function_pointers()` with that mapping - and a list of
stabilized/root `command`s - rather than passing `cmd_aliases` directly.
(This `cmd_aliases` list exists because the rename always happens in the
root `<commands>` element: extensions then `<require>` the aliased
rather than the stabilized name, so the base for this alias is found
first to look up the base command, and then stored in `rename_commands`
to rename it back to the aliased name).

With improved clarity we can now also borrow the name strings rather
than cloning them in many places.
2023-04-08 21:59:55 +02:00
Marijn Suijten 115abf3dde
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 11:13:45 +02:00
Marijn Suijten ca68ebd61b
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 11:12:35 +02:00
Marijn Suijten 21f4f66095
extensions/khr: Add VK_KHR_performance_query (#726) 2023-04-03 10:40:25 +02:00
Marijn Suijten edfd3b9f8f
generator: Keep deprecated MIRROR_CLAMP_TO_EDGE_KHR alias
Somehow this stuck along when we removed all the other deprecated
aliases, because the comment annotation didn't match up with what was
normally used (but we did write a special `#[deprecated = ..]`
annotation based on `"Alias"`).  Now that this all has been normalized
in `vk.xml` behind a standardized `deprecated="reason"` attribute we
have to go out of our way to keep this constant alias alive.
2023-04-02 22:54:19 +02:00
Marijn Suijten e7cfe26dcb
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-04-02 22:54:19 +02:00
Marijn Suijten 5d130cb97d
generator: Handle <command> via vk-parse types and nom (#719)
For the upcoming `api` attribute in `vk.xml` commands also need to be
processed through `vk-parse` which has support for all the new
attributes, while `vkxml` is deprecated and completely untouched for
years.  This conversion unfortunately requires whipping up yet another
quick-and-dirty `nom` parser of a specific subset of C used in `vk.xml`
to describe parameter signatures.  This PR shows that conversion is
complete and provides no accidental semantic differences.

Also update `vk-parse` to `0.9` which contains a new `code` field on
`CommandParam` (`<param>` element) to be able to inspect the code
signature of individual parameters rather than parsing them out of (and
matching them back to `vk-parse`'s `params` array!) the `<command>`
/ `CommandDefinition` as a whole:
https://github.com/krolli/vk-parse/issues/25#issuecomment-1246330001
615ffb69eb
2023-04-02 22:54:18 +02:00
Marijn Suijten 449ef2f204
device: Correct #717 reqirements typo (#718) 2023-04-02 22:54:18 +02:00
lilly lizard 40c7509783
Rename some function arguments to match the vulkan spec (#717)
renamed some function arguments that were previously called 'create_info' to match the argument names in the vulkan spec
2023-04-02 22:54:18 +02:00
Marijn Suijten a6215f7b18
ash-window: Bump MSRV to 1.64 to match raw-window-handle 0.5.1 (#716)
`raw-window-handle 0.5.1` bumped from 1.60 to 1.64 in a
semver-compatible release, failing our CI infrastructure overnight.

Keep the `ash` version at `1.60` for now.
2023-04-02 22:54:18 +02:00
Marijn Suijten 8b195a8967
generator: Convert #define generation from vkxml to vk-parse (#708)
For upcoming `vk.xml` features (the new `api` attribute) some of our
codegen has to be converted to work on `vk-parse` types to make this
ergonomic (and there's a longstanding plan of factoring out `vkxml`
regardless).  Start with converting the `#define` code and showcasing
that it does not affect the output (beyond removing the unneeded
edgecase for `VK_HEADER_VERSION` resulting in a doc link).
2023-04-02 22:54:18 +02:00
Marijn Suijten 6b6f2ee8a8
generator: Limit pCode member workaround to VkShaderModuleCreateInfo (#707)
An upcoming extension will ship with an untyped `pCode` member (`void
*`) including a valid `len` field pointing to a `codeSize` field rather
than obscure Latex math and a `/4` expression in `altlen`.  Limit the
scope of our workaround for that SPIR-V-specific `pCode` field to
`VkShaderModuleCreateInfo`.
2023-04-02 22:29:27 +02:00
Philippe Renon 56d8507acb
fix clippy::uninlined_format_args (#705)
* ash/util: fix `clippy::seek_to_start_instead_of_rewind`

* examples: fix `clippy::uninlined_format_args`

* ash: fix `clippy::uninlined_format_args`

* generator: fix `clippy::uninlined_format_args`

* rust: upgrade to edition 2021
2023-04-02 22:29:25 +02:00
HugoPeters1024 aca947df12
examples: Fix error description in texture example (#696)
fix error description in texture example
2023-04-02 22:28:23 +02:00
Marijn Suijten 826bc89775 Release ash 0.37.2 2023-01-11 11:34:14 +01:00
Teodor Tanasoaia 5ffd797a83 extensions/khr/draw_indirect_count: Use the right function pointer for non-indexed draw call (#695) 2023-01-11 11:32:19 +01:00
Marijn Suijten c1d5b5794d
Update Vulkan-Headers to 1.3.238 (#688)
* Update Vulkan-Headers to 1.3.236

* Update Vulkan-Headers to 1.3.237

* Update Vulkan-Headers to 1.3.238
2022-12-19 20:01:06 +01:00
Marijn Suijten 61d33d50cb
examples: Remove unneeded casts as pointed out by Rust 1.66 (#692)
Strangely some no-op cast remained in the codebase, and are only now
caught since Rust 1.66.  In both cases the input value is already of the
correct type (independent of the platform).
2022-12-19 19:47:48 +01:00
Marijn Suijten c3212b8c7c
Replace <<ref>> in documentation with link to ref (#693)
Rustdoc since 1.66 points out that `<<ref>>` is malformed HTML, and the
resulting `<<devsandqueues-lost-device>>` isn't very helpful to users.
Convert it to the relevant link in both documentation and `Result`
`Display` to solve both issues at once.
2022-12-19 19:42:52 +01:00
Marijn Suijten e93dfdaaf5
Release ash 0.37.1 (#632) 2022-11-23 23:23:26 +01:00
Marijn Suijten 4b1c03e4d9 extensions/ext: Add VK_EXT_descriptor_buffer (#679) 2022-11-22 23:40:55 +01:00
Marijn Suijten 1d800d0d60 extensions/ext: Add VK_EXT_extended_dynamic_state3 (#671) 2022-11-22 23:40:55 +01:00
Marijn Suijten d176eef678 Call Vec::set_len() after checking for Vulkan errors (#684)
The entire reason for calling `unsafe` `set_len()` after the Vulkan
driver function call is to ensure the `Vec` never gives safe access to
uninitialized values (as allocted via `Vec::with_capacity()`).  This
contract is broken within the implementation of these functions by
temporarily setting a nonzero length when the Vulkan driver may not have
initialized the underlying data at all, and communicated this by
returning an error code.

Simply check the error code first, before jumping to a now-infallible
codepath that calls `.set_len()` and always returns `Ok()`.
2022-11-22 23:40:55 +01:00
Marijn Suijten 47ec56c30e Update Vulkan-Headers to 1.3.235 (#667)
* Update Vulkan-Headers to 1.3.229

* Update Vulkan-Headers to 1.3.230

* Update Vulkan-Headers to 1.3.231

* Update Vulkan-Headers to 1.3.232

* Update Vulkan-Headers to 1.3.233

* Update Vulkan-Headers to 1.3.235

* README: Document experimental Vulkan Video bindings being semver-exempt
2022-11-22 23:40:53 +01:00
Marijn Suijten 047676a443 Replace as *... raw pointer-type changes with more explicit .cast() (#685)
`.cast()` allows changing the pointer type without hiding (accidental)
mutability changes (noting that `*mut` still coerces to `*.const`).

For mutability changes Rust 1.65 included `cast_mut()` and
`cast_const()`, but those would bump our MSRV too eagerly for now.
2022-11-22 23:39:49 +01:00
Charles Giessen 24000c1249 generator: Update list of vendor names (#676) 2022-11-18 10:21:34 +01:00
Marijn Suijten ca9168bc3a CI: Only MSRV-test published ash and ash-window crates (#677)
`bytemuck` recently bumped its MSRV to 1.60 which is incompatible with
what we're currently advertising.  Fortunately this doesn't affect MSRV
of the publicly published crates, but only `dev-dependencies` inside
`ash-window` via `winit`: make sure the CI doesn't reject this.
2022-11-18 10:21:34 +01:00
Marijn Suijten e400f5150c generator: Upgrade to bindgen 0.61.0 (#673)
Seems to mostly result in less unused type aliases being generated, and
improved/reworked testing infrastructure.
2022-11-18 10:21:34 +01:00
Marijn Suijten 1d14729721 extensions: Only call assume_init() when Vulkan returns SUCCESS (#669)
It is undefined behaviour to construct a safe object by calling
`MaybeUninit::assume_init()` when the object in question hasn't been
initialized by anything (in this case the underlying Vulkan call) at
all, even if the object is never "used".  Postpone the `assume_init()`
call until after checking if `vk::Result::SUCCESS` has been returned by
the native implementation, by introducing a new
`assume_init_on_success()` helper that takes a `MaybeUninit<T>`.
2022-10-16 15:58:41 +02:00
AidoP 23856e9eb8 extensions/ext: Add VK_EXT_acquire_drm_display (#668)
Co-authored-by: Aidan Prangnell <aidop@trifuse.xyz>
2022-10-16 15:58:34 +02:00
Marijn Suijten 812b9bb214 generator: Support nested arrays in builders without hardcoding (#666)
Prepare the generator for more struct fields that have nested "dynamic
arrays" with a hardcoded size of `1` (effectively arrays with pointers
to single objects) in `vk.xml`s `len` attribute.  These structs are
introduced by `VK_EXT_opacity_micromap` in 1.3.230.
2022-10-03 12:02:49 +02:00
BeastLe9enD c2f21d2949 extensions/ext: Add VK_EXT_mesh_shader (#657) 2022-09-26 00:31:52 +02:00
BeastLe9enD 38543a1643 extensions/ext: Rename debug_utils_set_object_name to set_debug_utils_object_name and debug_utils_set_object_tag to set_debug_utils_object_tag for consistency and deprecate old ones (#661) 2022-09-24 11:09:20 +02:00
Marijn Suijten 359c1c1051
Release ash-window 0.12.0 2022-09-23 19:47:08 +02:00
Marijn Suijten 0a96643e26 ash-window: Upgrade to raw-window-handle 0.5.0 (#645)
* ash-window: Upgrade to raw-window-handle 0.5.0

* Bump `raw-window-metal` to recently-released `0.3`

https://github.com/norse-rs/raw-window-metal/pull/5

* examples: Bump `winit` to `0.27.1` to resolve our MSRV tests

While the examples technically aren't part of our MSRV requirement (it's
nice, but core crate compatibility is much more important), it's
annoying to exempt these especially now that `winit` removed some
unneeded MSRV 1.60/1.61 requirements.

* Take `Raw{Display,Window}Handle` directly instead of through trait
2022-09-23 12:43:45 +02:00
Marijn Suijten 7933bf5709 ash-window: Link to the ash gitter instead of nonexistent ash-window (#659)
It seems there's no gitter channel for `ash-window` (404), and since
everyone is in the `ash` channel already, just use the same one.
2022-09-23 12:41:23 +02:00
David Koloski cc3d65a486 extensions/khr/ray_tracing_pipeline: Set length of capture-replay shader handle buffer after filling (#658) 2022-09-22 10:51:12 +02:00
Marijn Suijten 6a7303271a Update Vulkan-Headers to 1.3.228 (#655)
* Update Vulkan-Headers to 1.3.220
* Update Vulkan-Headers to 1.3.221
* Update Vulkan-Headers to 1.3.222
* Update Vulkan-Headers to 1.3.223
* Update Vulkan-Headers to 1.3.224
* Update Vulkan-Headers to 1.3.225
* Update Vulkan-Headers to 1.3.226
* Update Vulkan-Headers to 1.3.227
* Update Vulkan-Headers to 1.3.228
2022-09-21 16:10:22 +02:00
Marijn Suijten 21bbc79188 ash: Add const STRUCTURE_TYPE to all Vulkan structures for matching with match_struct! macro (#614)
* ash: Add `const STRUCTURE_TYPE` to all Vulkan structures for matching with `match_struct!` macro

In Vulkan layers extracing a structure based on its `s_type` is a common
operation, but comparing against an enum value and subsequently casting
to the right type is verbose and error-prone.

By generating a `const STRUCTURE_TYPE` with the given value for every
Vulkan structure it becomes possible to implement a macro that abstracts
this logic away in a safer way.

* generator: Reuse `HasStructureType::STRUCTURE_TYPE` in `s_type` initializer
2022-09-21 15:58:21 +02:00
Marijn Suijten 45b2b12bbc Fix new/improved Rust 1.63 clippy lints (#649)
More `clippy::use_self` is found in manual code, and superfluous
transmutes in bindgen output are now also found and disallowed.
2022-09-05 11:33:52 +02:00