Skip to content

Commit 404e7dc

Browse files
committed
ash: Hide provisional extensions behind new provisional feature flag
Provisional extensions are susceptible to **breaking** API changes at any point (with accompanying `SPEC_VERSION` bump). By hiding them behind a non-default feature flag, we can document that opting into this feature allows us to do breaking changes to these modules in non-breaking `ash` releases when driven by upstream `Vulkan-Headers` changes to `vk.xml`. Moreover, upstream Khronos repositories that build `ash` in their CI can continue to build-test their changes without compile-testing any extension behind a `provisional` flag, which is especially useful if we've already wrapped a `provisonal` extension that is seeing breaking changes.
1 parent 5916329 commit 404e7dc

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

ash/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ loaded = ["libloading", "std"]
3434
debug = []
3535
# Whether the standard library should be required
3636
std = []
37+
# Enable provisional Vulkan extensions. May see *semver-breaking* code changes in non-breaking releases!
38+
provisional = []
3739

3840
[package.metadata.release]
3941
no-dev-version = true

ash/src/extensions/amdx/shader_enqueue.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "provisional")]
12
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMDX_shader_enqueue.html>
23
34
use crate::prelude::*;

ash/src/extensions/nv/cuda_kernel_launch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg(feature = "provisional")]
12
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_NV_cuda_kernel_launch.html>
23
34
use crate::prelude::*;

ash/src/extensions_generated.rs

+4
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ pub mod amd {
511511
#[doc = "Extensions tagged AMDX"]
512512
pub mod amdx {
513513
#[doc = "VK_AMDX_shader_enqueue"]
514+
#[cfg(feature = "provisional")]
514515
pub mod shader_enqueue {
515516
use super::super::*;
516517
pub use {
@@ -14828,6 +14829,7 @@ pub mod khr {
1482814829
}
1482914830
}
1483014831
#[doc = "VK_KHR_portability_subset"]
14832+
#[cfg(feature = "provisional")]
1483114833
pub mod portability_subset {
1483214834
use super::super::*;
1483314835
pub use {
@@ -19248,6 +19250,7 @@ pub mod nv {
1924819250
};
1924919251
}
1925019252
#[doc = "VK_NV_cuda_kernel_launch"]
19253+
#[cfg(feature = "provisional")]
1925119254
pub mod cuda_kernel_launch {
1925219255
use super::super::*;
1925319256
pub use {
@@ -19656,6 +19659,7 @@ pub mod nv {
1965619659
}
1965719660
}
1965819661
#[doc = "VK_NV_displacement_micromap"]
19662+
#[cfg(feature = "provisional")]
1965919663
pub mod displacement_micromap {
1966019664
use super::super::*;
1966119665
pub use {

generator/src/lib.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,9 @@ impl<'a> ConstantExt for ExtensionConstant<'a> {
11791179
}
11801180
}
11811181

1182+
/// Generates constants for `<extension>` or `<feature>` children
11821183
pub fn generate_extension_constants<'a>(
1183-
extension_name: &str,
1184+
extension_name: &'a str,
11841185
extension_number: i64,
11851186
extension_items: &'a [vk_parse::ExtensionChild],
11861187
const_cache: &mut HashSet<&'a str>,
@@ -1268,13 +1269,13 @@ pub struct ExtensionCommands<'a> {
12681269
}
12691270

12701271
pub fn generate_extension_commands<'a>(
1271-
full_extension_name: &'a str,
1272-
items: &'a [vk_parse::ExtensionChild],
1272+
extension: &'a vk_parse::Extension,
12731273
cmd_map: &CommandMap<'a>,
12741274
cmd_aliases: &HashMap<&'a str, &'a str>,
12751275
fn_cache: &mut HashSet<&'a str>,
12761276
has_lifetimes: &HashSet<Ident>,
12771277
) -> ExtensionCommands<'a> {
1278+
let full_extension_name = &extension.name;
12781279
let byte_name_ident = Literal::byte_string(format!("{full_extension_name}\0").as_bytes());
12791280

12801281
let extension_name = full_extension_name.strip_prefix("VK_").unwrap();
@@ -1287,7 +1288,8 @@ pub fn generate_extension_commands<'a>(
12871288

12881289
let name_ident = format_ident!("{}_NAME", extension_name.to_uppercase());
12891290
let spec_version_ident = format_ident!("{}_SPEC_VERSION", extension_name.to_uppercase());
1290-
let spec_version = items
1291+
let spec_version = extension
1292+
.children
12911293
.iter()
12921294
.filter_map(get_variant!(vk_parse::ExtensionChild::Require { items }))
12931295
.flatten()
@@ -1306,7 +1308,8 @@ pub fn generate_extension_commands<'a>(
13061308
let mut device_commands = Vec::new();
13071309

13081310
let mut rename_commands = HashMap::new();
1309-
let names = items
1311+
let names = extension
1312+
.children
13101313
.iter()
13111314
.filter_map(get_variant!(vk_parse::ExtensionChild::Require {
13121315
api,
@@ -1431,6 +1434,10 @@ pub fn generate_extension_commands<'a>(
14311434
let (raw_instance_fp, hl_instance_fp) =
14321435
instance_fp.map_or((None, None), |(a, b)| (Some(a), Some(b)));
14331436

1437+
let provisional = extension
1438+
.provisional
1439+
.then(|| quote!(#[cfg(feature = "provisional")]));
1440+
14341441
ExtensionCommands {
14351442
vendor,
14361443
raw: quote! {
@@ -1443,6 +1450,7 @@ pub fn generate_extension_commands<'a>(
14431450
},
14441451
high_level: quote! {
14451452
#[doc = #full_extension_name]
1453+
#provisional
14461454
pub mod #extension_ident {
14471455
use super::super::*; // Use global imports (i.e. Vulkan structs and enums) from the root module defined by this file
14481456

@@ -3262,7 +3270,7 @@ pub fn write_source_code<P: AsRef<Path>>(vk_headers_dir: &Path, src_dir: P) {
32623270
.map(|ext| {
32633271
generate_extension_constants(
32643272
&ext.name,
3265-
ext.number.unwrap_or(0),
3273+
ext.number.unwrap(),
32663274
&ext.children,
32673275
&mut const_cache,
32683276
&mut const_values,
@@ -3274,8 +3282,7 @@ pub fn write_source_code<P: AsRef<Path>>(vk_headers_dir: &Path, src_dir: P) {
32743282
let mut extension_cmds = Vec::<TokenStream>::new();
32753283
for ext in extensions.iter() {
32763284
let cmds = generate_extension_commands(
3277-
&ext.name,
3278-
&ext.children,
3285+
ext,
32793286
&commands,
32803287
&cmd_aliases,
32813288
&mut fn_cache,

0 commit comments

Comments
 (0)