Skip to content

Fix shaderf16 support on vulkan/nvidia #7656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,22 @@ impl PhysicalDeviceFeatures {
None
},
shader_float16: if requested_features.contains(wgt::Features::SHADER_F16) {
let supported_f16_features = _phd_features
.shader_float16
.map(|(_, s)| s)
.unwrap_or_default();

Some((
vk::PhysicalDeviceShaderFloat16Int8Features::default().shader_float16(true),
// Only enable the 16bit storage features that are actually supported by the hardware
vk::PhysicalDevice16BitStorageFeatures::default()
.storage_buffer16_bit_access(true)
.storage_input_output16(true)
.uniform_and_storage_buffer16_bit_access(true),
.storage_buffer16_bit_access(
supported_f16_features.storage_buffer16_bit_access != 0,
)
.uniform_and_storage_buffer16_bit_access(
supported_f16_features.uniform_and_storage_buffer16_bit_access != 0,
)
.storage_input_output16(supported_f16_features.storage_input_output16 != 0),
))
} else {
None
Expand Down Expand Up @@ -722,8 +732,7 @@ impl PhysicalDeviceFeatures {
F::SHADER_F16,
f16_i8.shader_float16 != 0
&& bit16.storage_buffer16_bit_access != 0
&& bit16.uniform_and_storage_buffer16_bit_access != 0
&& bit16.storage_input_output16 != 0,
&& bit16.uniform_and_storage_buffer16_bit_access != 0,
);
}

Expand Down
Loading