@@ -386,10 +386,13 @@ impl PhysicalDeviceFeatures {
386
386
} else {
387
387
None
388
388
} ,
389
- shader_float16_int8 : if requested_features. contains ( wgt:: Features :: SHADER_F16 ) {
390
- Some ( vk:: PhysicalDeviceShaderFloat16Int8Features :: default ( ) . shader_float16 ( true ) )
391
- } else {
392
- None
389
+ shader_float16_int8 : match requested_features. contains ( wgt:: Features :: SHADER_F16 ) {
390
+ shader_float16 if shader_float16 || private_caps. shader_int8 => Some (
391
+ vk:: PhysicalDeviceShaderFloat16Int8Features :: default ( )
392
+ . shader_float16 ( shader_float16)
393
+ . shader_int8 ( private_caps. shader_int8 ) ,
394
+ ) ,
395
+ _ => None ,
393
396
} ,
394
397
_16bit_storage : if requested_features. contains ( wgt:: Features :: SHADER_F16 ) {
395
398
Some (
@@ -981,6 +984,15 @@ impl PhysicalDeviceProperties {
981
984
if requested_features. contains ( wgt:: Features :: TEXTURE_FORMAT_NV12 ) {
982
985
extensions. push ( khr:: sampler_ycbcr_conversion:: NAME ) ;
983
986
}
987
+
988
+ // Require `VK_KHR_16bit_storage` if the feature `SHADER_F16` was requested
989
+ if requested_features. contains ( wgt:: Features :: SHADER_F16 ) {
990
+ // - Feature `SHADER_F16` also requires `VK_KHR_shader_float16_int8`, but we always
991
+ // require that anyway (if it is available) below.
992
+ // - `VK_KHR_16bit_storage` requires `VK_KHR_storage_buffer_storage_class`, however
993
+ // we require that one already.
994
+ extensions. push ( khr:: _16bit_storage:: NAME ) ;
995
+ }
984
996
}
985
997
986
998
if self . device_api_version < vk:: API_VERSION_1_2 {
@@ -1004,13 +1016,13 @@ impl PhysicalDeviceProperties {
1004
1016
extensions. push ( ext:: descriptor_indexing:: NAME ) ;
1005
1017
}
1006
1018
1007
- // Require `VK_KHR_shader_float16_int8` and `VK_KHR_16bit_storage` if the associated feature was requested
1008
- if requested_features. contains ( wgt:: Features :: SHADER_F16 ) {
1019
+ // Always require `VK_KHR_shader_float16_int8` if available as it enables
1020
+ // Int8 optimizations. Also require it even if it's not available but
1021
+ // requested so that we get a corresponding error message.
1022
+ if requested_features. contains ( wgt:: Features :: SHADER_F16 )
1023
+ || self . supports_extension ( khr:: shader_float16_int8:: NAME )
1024
+ {
1009
1025
extensions. push ( khr:: shader_float16_int8:: NAME ) ;
1010
- // `VK_KHR_16bit_storage` requires `VK_KHR_storage_buffer_storage_class`, however we require that one already
1011
- if self . device_api_version < vk:: API_VERSION_1_1 {
1012
- extensions. push ( khr:: _16bit_storage:: NAME ) ;
1013
- }
1014
1026
}
1015
1027
1016
1028
if requested_features. intersects ( wgt:: Features :: EXPERIMENTAL_MESH_SHADER ) {
@@ -1479,12 +1491,17 @@ impl super::InstanceShared {
1479
1491
. insert ( vk:: PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT :: default ( ) ) ;
1480
1492
features2 = features2. push_next ( next) ;
1481
1493
}
1482
- if capabilities. supports_extension ( khr:: shader_float16_int8:: NAME ) {
1494
+
1495
+ // `VK_KHR_shader_float16_int8` is promoted to 1.2
1496
+ if capabilities. device_api_version >= vk:: API_VERSION_1_2
1497
+ || capabilities. supports_extension ( khr:: shader_float16_int8:: NAME )
1498
+ {
1483
1499
let next = features
1484
1500
. shader_float16_int8
1485
1501
. insert ( vk:: PhysicalDeviceShaderFloat16Int8FeaturesKHR :: default ( ) ) ;
1486
1502
features2 = features2. push_next ( next) ;
1487
1503
}
1504
+
1488
1505
if capabilities. supports_extension ( khr:: _16bit_storage:: NAME ) {
1489
1506
let next = features
1490
1507
. _16bit_storage
@@ -1728,6 +1745,9 @@ impl super::Instance {
1728
1745
shader_integer_dot_product : phd_features
1729
1746
. shader_integer_dot_product
1730
1747
. is_some_and ( |ext| ext. shader_integer_dot_product != 0 ) ,
1748
+ shader_int8 : phd_features
1749
+ . shader_float16_int8
1750
+ . is_some_and ( |features| features. shader_int8 != 0 ) ,
1731
1751
} ;
1732
1752
let capabilities = crate :: Capabilities {
1733
1753
limits : phd_capabilities. to_wgpu_limits ( ) ,
@@ -2029,6 +2049,10 @@ impl super::Adapter {
2029
2049
spv:: Capability :: DotProductKHR ,
2030
2050
] ) ;
2031
2051
}
2052
+ if self . private_caps . shader_int8 {
2053
+ // See <https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceShaderFloat16Int8Features.html#extension-features-shaderInt8>.
2054
+ capabilities. extend ( & [ spv:: Capability :: Int8 ] ) ;
2055
+ }
2032
2056
spv:: Options {
2033
2057
lang_version : match self . phd_capabilities . device_api_version {
2034
2058
// Use maximum supported SPIR-V version according to
0 commit comments