@@ -123,6 +123,10 @@ pub struct PhysicalDeviceFeatures {
123
123
124
124
/// Features proved by `VK_EXT_mesh_shader`
125
125
mesh_shader : Option < vk:: PhysicalDeviceMeshShaderFeaturesEXT < ' static > > ,
126
+
127
+ /// Features provided by `VK_KHR_shader_integer_dot_product`, promoted to Vulkan 1.3.
128
+ shader_integer_dot_product :
129
+ Option < vk:: PhysicalDeviceShaderIntegerDotProductFeaturesKHR < ' static > > ,
126
130
}
127
131
128
132
impl PhysicalDeviceFeatures {
@@ -187,6 +191,9 @@ impl PhysicalDeviceFeatures {
187
191
if let Some ( ref mut feature) = self . mesh_shader {
188
192
info = info. push_next ( feature) ;
189
193
}
194
+ if let Some ( ref mut feature) = self . shader_integer_dot_product {
195
+ info = info. push_next ( feature) ;
196
+ }
190
197
info
191
198
}
192
199
@@ -499,6 +506,16 @@ impl PhysicalDeviceFeatures {
499
506
} else {
500
507
None
501
508
} ,
509
+ shader_integer_dot_product : if device_api_version >= vk:: API_VERSION_1_3
510
+ || enabled_extensions. contains ( & khr:: shader_integer_dot_product:: NAME )
511
+ {
512
+ Some (
513
+ vk:: PhysicalDeviceShaderIntegerDotProductFeaturesKHR :: default ( )
514
+ . shader_integer_dot_product ( private_caps. shader_integer_dot_product ) ,
515
+ )
516
+ } else {
517
+ None
518
+ } ,
502
519
}
503
520
}
504
521
@@ -1006,6 +1023,11 @@ impl PhysicalDeviceProperties {
1006
1023
if requested_features. intersects ( wgt:: Features :: EXPERIMENTAL_MESH_SHADER ) {
1007
1024
extensions. push ( khr:: maintenance4:: NAME ) ;
1008
1025
}
1026
+
1027
+ // Optional `VK_KHR_shader_integer_dot_product`
1028
+ if self . supports_extension ( khr:: shader_integer_dot_product:: NAME ) {
1029
+ extensions. push ( khr:: shader_integer_dot_product:: NAME ) ;
1030
+ }
1009
1031
}
1010
1032
1011
1033
// Optional `VK_KHR_swapchain_mutable_format`
@@ -1496,6 +1518,16 @@ impl super::InstanceShared {
1496
1518
features2 = features2. push_next ( next) ;
1497
1519
}
1498
1520
1521
+ // `VK_KHR_shader_integer_dot_product` is promoted to 1.3
1522
+ if capabilities. device_api_version >= vk:: API_VERSION_1_3
1523
+ || capabilities. supports_extension ( khr:: shader_integer_dot_product:: NAME )
1524
+ {
1525
+ let next = features
1526
+ . shader_integer_dot_product
1527
+ . insert ( vk:: PhysicalDeviceShaderIntegerDotProductFeatures :: default ( ) ) ;
1528
+ features2 = features2. push_next ( next) ;
1529
+ }
1530
+
1499
1531
unsafe { get_device_properties. get_physical_device_features2 ( phd, & mut features2) } ;
1500
1532
features2. features
1501
1533
} else {
@@ -1679,6 +1711,9 @@ impl super::Instance {
1679
1711
. properties
1680
1712
. limits
1681
1713
. max_sampler_allocation_count ,
1714
+ shader_integer_dot_product : phd_features
1715
+ . shader_integer_dot_product
1716
+ . is_some_and ( |ext| ext. shader_integer_dot_product != 0 ) ,
1682
1717
} ;
1683
1718
let capabilities = crate :: Capabilities {
1684
1719
limits : phd_capabilities. to_wgpu_limits ( ) ,
@@ -1971,13 +2006,24 @@ impl super::Adapter {
1971
2006
if features. contains ( wgt:: Features :: EXPERIMENTAL_RAY_HIT_VERTEX_RETURN ) {
1972
2007
capabilities. push ( spv:: Capability :: RayQueryPositionFetchKHR )
1973
2008
}
2009
+ if self . private_caps . shader_integer_dot_product {
2010
+ // See <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_shader_integer_dot_product.html#_new_spir_v_capabilities>.
2011
+ capabilities. extend ( & [
2012
+ spv:: Capability :: DotProductInputAllKHR ,
2013
+ spv:: Capability :: DotProductInput4x8BitKHR ,
2014
+ spv:: Capability :: DotProductInput4x8BitPackedKHR ,
2015
+ spv:: Capability :: DotProductKHR ,
2016
+ ] ) ;
2017
+ }
1974
2018
spv:: Options {
1975
- lang_version : if features
1976
- . intersects ( wgt:: Features :: SUBGROUP | wgt:: Features :: SUBGROUP_VERTEX )
1977
- {
1978
- ( 1 , 3 )
1979
- } else {
1980
- ( 1 , 0 )
2019
+ lang_version : match self . phd_capabilities . device_api_version {
2020
+ // Use maximum supported SPIR-V version according to
2021
+ // <https://github.com/KhronosGroup/Vulkan-Docs/blob/19b7651/appendices/spirvenv.adoc?plain=1#L21-L40>.
2022
+ vk:: API_VERSION_1_0 ..vk:: API_VERSION_1_1 => ( 1 , 0 ) ,
2023
+ vk:: API_VERSION_1_1 ..vk:: API_VERSION_1_2 => ( 1 , 3 ) ,
2024
+ vk:: API_VERSION_1_2 ..vk:: API_VERSION_1_3 => ( 1 , 5 ) ,
2025
+ vk:: API_VERSION_1_3 .. => ( 1 , 6 ) ,
2026
+ _ => unreachable ! ( ) ,
1981
2027
} ,
1982
2028
flags,
1983
2029
capabilities : Some ( capabilities. iter ( ) . cloned ( ) . collect ( ) ) ,
0 commit comments