@@ -386,10 +386,13 @@ impl PhysicalDeviceFeatures {
386386 } else {
387387 None
388388 } ,
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 ,
393396 } ,
394397 _16bit_storage : if requested_features. contains ( wgt:: Features :: SHADER_F16 ) {
395398 Some (
@@ -981,6 +984,15 @@ impl PhysicalDeviceProperties {
981984 if requested_features. contains ( wgt:: Features :: TEXTURE_FORMAT_NV12 ) {
982985 extensions. push ( khr:: sampler_ycbcr_conversion:: NAME ) ;
983986 }
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+ }
984996 }
985997
986998 if self . device_api_version < vk:: API_VERSION_1_2 {
@@ -1004,13 +1016,13 @@ impl PhysicalDeviceProperties {
10041016 extensions. push ( ext:: descriptor_indexing:: NAME ) ;
10051017 }
10061018
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+ {
10091025 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- }
10141026 }
10151027
10161028 if requested_features. intersects ( wgt:: Features :: EXPERIMENTAL_MESH_SHADER ) {
@@ -1479,12 +1491,17 @@ impl super::InstanceShared {
14791491 . insert ( vk:: PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT :: default ( ) ) ;
14801492 features2 = features2. push_next ( next) ;
14811493 }
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+ {
14831499 let next = features
14841500 . shader_float16_int8
14851501 . insert ( vk:: PhysicalDeviceShaderFloat16Int8FeaturesKHR :: default ( ) ) ;
14861502 features2 = features2. push_next ( next) ;
14871503 }
1504+
14881505 if capabilities. supports_extension ( khr:: _16bit_storage:: NAME ) {
14891506 let next = features
14901507 . _16bit_storage
@@ -1728,6 +1745,9 @@ impl super::Instance {
17281745 shader_integer_dot_product : phd_features
17291746 . shader_integer_dot_product
17301747 . 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 ) ,
17311751 } ;
17321752 let capabilities = crate :: Capabilities {
17331753 limits : phd_capabilities. to_wgpu_limits ( ) ,
@@ -2029,6 +2049,10 @@ impl super::Adapter {
20292049 spv:: Capability :: DotProductKHR ,
20302050 ] ) ;
20312051 }
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+ }
20322056 spv:: Options {
20332057 lang_version : match self . phd_capabilities . device_api_version {
20342058 // Use maximum supported SPIR-V version according to
0 commit comments