Commit graph

247 commits

Author SHA1 Message Date
Marijn Suijten ff54d22a15
Resolve lint warnings for deprecated_in_future, rust_2018_idioms and unused_qualifications (#803)
* generator: Add many missing lifetime parameters

* Globally find-replace common patterns that need a `<'_>` lifetime annotation

    perl -pi -E "s/(&(mut )?\[?vk::(?\!\w+(V1_\d|Fn|<))\w+)/\$1<'_>/" **/*.{rs,md}

* generator: Include aliased types in `has_lifetime` lookup table

* Manually revert wrong find-replace lifetimes

* Resolve lint warnings for `deprecated_in_future`, `rust_2018_idioms` and `unused_qualifications`

These are 3 non-default lints that cause a lot of violations in this
project that are sensible to resolve, and reduce noise when
test-including a local `ash` checkout in other projects that have
stricter lint setups.
2023-10-26 08:30:16 +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 49de0341a0
CI: Cross-lint for Mac, iOS and Windows (#796)
* CI: Cross-lint for Mac, iOS and Windows

We have some conditional code specific to Mac and iOS which is currently
untested in the CI, allowing non-compiling code in PRs like #795 to go
unnoticed.

* Fix new clippy lints
2023-10-11 20:58:21 +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
Jesse Natalie a0f8b9cf3e
Add MSFT vendor tag for enum variants (#762)
Otherwise enums with the MSFT suffix fail to parse.
2023-06-22 01:08:33 +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 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 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 ae53f73bae
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:44:15 +02:00
Marijn Suijten 30cb8f1d7c
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-07 01:48:26 +02:00
Marijn Suijten 5732d977cf
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-05 23:42:21 +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 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 61b7415156
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-03-21 06:30:05 +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 90ccc31f97
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-02-22 12:32:16 +01:00
Marijn Suijten ee86c65757
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-02-17 19:50:59 +01:00
Philippe Renon 9cd6c07744
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-02-17 18:11:44 +01:00
Marijn Suijten 720eb81048
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 19:42:05 +01:00
Marijn Suijten a7538ee986
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 10:17:48 -08:00
Marijn Suijten 86b0f45e48
generator: Do not generate code for "disabled" extensions (#448)
It is unlikely that disabled, reserved extensions (without naming
whatsoever) are used through Ash bindings generated from Vulkan-Headers
releases, and are best ignored to reduce diff noise and spurious issues
[1] with unfinished extension definitions.

This approach matches what is defined in the registry spec for
`supported="disabled"` [2]:

    use `supported="disabled"` to indicate this extension should never
    be processed.

[1]: https://github.com/KhronosGroup/Vulkan-Docs/issues/1549
[2]: b4e8cd820b/registry.txt (L1302-L1306)
2022-12-11 16:36:25 -08:00
Marijn Suijten ba37cf3fc2
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:13:09 +01:00
Marijn Suijten 8b4575086e
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 10:52:14 -08:00
Charles Giessen 29b935b1c1
generator: Update list of vendor names (#676) 2022-11-07 23:47:44 +01:00
Marijn Suijten 51f59976b4
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-10-20 10:41:23 -07:00
Marijn Suijten df87050610
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:00:54 +02:00
Marijn Suijten 02a60bd9cb
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-19 22:01:25 +02:00
Marijn Suijten 13fef40d48
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-19 12:39:54 +02:00
Marijn Suijten 9cb6d386eb
generator: Upgrade bindgen, heck and vk-parse
`heck` got its API slightly renamed, and `bindgen` fixed all code-smell
linter warnings in its output (except naming style, which is inherent).
2022-07-29 08:11:27 -07:00
Marijn Suijten 79f63e1cbc
extensions: Inline all trivial functions (#638)
* extensions: Inline simple getter functions

* extensions: Inline all `unsafe fn` helper functions

* instance: Inline "skipped" `read_into_uninitialized_vector()` functions

* enums: Inline `from_raw`/`as_raw` functions
2022-07-07 17:25:05 +02:00
Marijn Suijten 94fdc70a4c
Update Vulkan-Headers to 1.3.219 (#619)
* Update Vulkan-Headers to 1.3.212

* Update Vulkan-Headers to 1.3.213

* Update Vulkan-Headers to 1.3.214

* Update Vulkan-Headers to 1.3.215

* Update Vulkan-Headers to 1.3.216

* Update Vulkan-Headers to 1.3.217

* Update Vulkan-Headers to 1.3.218

* Update Vulkan-Headers to 1.3.219

* Changelog: reorder entries chronologically based on PR ID
2022-07-03 21:54:17 +02:00
Marijn Suijten 671f98ce55
generator: Fix clippy::is_digit_ascii_radix (#637) 2022-07-01 13:09:22 -07:00
Michael Pollind c4f1c053ea
generator: Upgrade nom to 0.7 where parser macros have been removed (#610) 2022-05-10 22:58:47 +02:00
Marijn Suijten 61ab543d75
generator: Use _ as suffix instead of prefix to mask keywords (#613)
`_` as prefix is intended for unused variables and bindings; it should
be used in suffix position when intending to prevent a clash with a
keyword instead.
2022-04-15 11:12:51 -07:00
Marijn Suijten 2a9a59e75c
Update Vulkan-Headers to 1.3.211 (#608) 2022-04-05 09:49:23 -07:00
Marijn Suijten 8dd682bac0
Update Vulkan-Headers to 1.3.210 (#605) 2022-03-31 21:31:19 -07:00
Benjamin Saunders 362cf83fa8
Inline Default impls and trivial instance/device wrapper methods (#606) 2022-03-29 19:54:38 +02:00
Benjamin Saunders 71bb3d337c
Replace builders with lifetimes/setters directly on Vulkan structs (#602)
* Replace builders with lifetimes/setters directly on Vulkan structs

* Inline setters
2022-03-29 19:15:14 +02:00
Marijn Suijten 8ae0312f03
Update Vulkan-Headers to 1.3.209 (#601) 2022-03-23 21:52:28 +01:00
Benjamin Saunders 84cddb7383
Omit wrapper functions on Fp structs (#599)
* Omit wrapper functions on Fp structs

These wrappers contributed thousands of lines of code but offered
insignificant ergonomic benefit as the same functions are also wrapped
at a higher level and, if necessary, wrapper functions can be called
directly.

* Standardize on direct fp table access in wrapper functions
2022-03-22 23:50:18 +01:00
Steve Wooster 1cd810653c
ash-window: Make enumerate_required_extensions return &[*const c_char] (#590)
* Constify generated extension names

* Constify hand-written extension names

* Make ash-window list extensions as &[*const c_char]

This alters enumerate_required_extensions() to return the same type that
is expected by vk::InstanceCreateInfoBuilder::enabled_extension_names(),
allowing simple Vulkan apps to omit the boilerplate of mapping to an
intermediate Vec<*const c_char>.

Co-authored-by: Steve Wooster <s.f.m.wooster@gmail.com>
2022-03-22 23:47:26 +01:00
Marijn Suijten fde6f92c70
Update Vulkan-Headers to 1.3.207 (#597)
* Update Vulkan-Headers to 1.3.207

* Update Vulkan-Headers to 1.3.208
2022-03-22 23:30:41 +01:00
Steve Wooster 3c7615b3bb
Iterator simplification (#565)
* Unnest iterators

This hopefully makes the iterator definitions better resemble paths into
the XML tree.

* Use for-loop instead of .for_each()

* Use elems.contains(x) instead of elems.iter().any(...)

* Shrink commands-related .fold()

Co-authored-by: Steve Wooster <s.f.m.wooster@gmail.com>
2022-02-26 15:03:54 -08:00
Steve Wooster b16bb4e62c
Appease clippy (#591)
* Simplify .map().flatten().next() and .filter_map().next() to .find_map()

* Avoid unnecessary closures for cheap expressions

* Use character instead of string for replacement pattern

Co-authored-by: Steve Wooster <s.f.m.wooster@gmail.com>
2022-02-26 13:01:28 -08:00
Marijn Suijten 955cb28d12
Update Vulkan-Headers to 1.3.206 (#563)
* Update Vulkan-Headers to 1.3.205

* Update Vulkan-Headers to 1.3.206
2022-02-19 10:18:21 +01:00
Marijn Suijten e18e0243ef
ash: Remove unnecessary trivial_casts and trivial_numeric_casts (#564)
While making the code only marginally harder to read such casts can also
introduce subtle bugs when used incorrectly, and are best omitted
whenever unnecessary: Rust already coerces borrows into raw pointers
when the types on both ends are clear, and even then there remain many
casts that are identical to the source type.

In addition these errors show up when using a local crate reference to
`ash` in a workspace that uses "the `.cargo/config.toml` setup" from
[EmbarkStudios/rust-ecosystem#68] to configure linter warnings
project-wide instead of for all crates in that workspace individually.
In our case aforementioned linter warnings are enabled on top of
Embark's configuration, leading to a lot of these warnings in our build
process.

[EmbarkStudios/rust-ecosystem#68]: https://github.com/EmbarkStudios/rust-ecosystem/pull/68
2022-02-18 16:01:46 -08:00
Marijn Suijten bb02b20339
Replace 1.2-extensions documentation links with 1.3-extensions (#569)
All these 1.2 links redirect to the 1.3 pages: spare the redirects by
specifying the right - latest - version directly.
2022-01-28 17:10:52 -08:00
Marijn Suijten 405449901c
generator: Exclude static macro code (macros.rs) from the generator (#552)
Much like `platform_types.rs` and `vk.rs` before, there is no need to
generate this file as its contents are completely static.  This allows
direct editing of the file without realizing that a copy lives in the
generator - and will overwrite `macros.rs` when the generator is being
run.
2022-01-10 12:07:54 -08:00