Skip to content
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

[vulkan] set spir-v capabilities based on downlevel flags #4197

Merged
merged 2 commits into from
Oct 3, 2023
Merged
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
22 changes: 16 additions & 6 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,22 +1223,32 @@ impl super::Adapter {
let naga_options = {
use naga::back::spv;

// The following capabilities are always available
// see https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap52.html#spirvenv-capabilities
let mut capabilities = vec![
spv::Capability::Shader,
spv::Capability::Matrix,
spv::Capability::Sampled1D,
spv::Capability::Image1D,
spv::Capability::ImageQuery,
spv::Capability::DerivativeControl,
spv::Capability::SampledCubeArray,
spv::Capability::SampleRateShading,
//Note: this is requested always, no matter what the actual
// adapter supports. It's not the responsibility of SPV-out
// translation to handle the storage support for formats.
spv::Capability::StorageImageExtendedFormats,
//TODO: fill out the rest
];

if self
.downlevel_flags
.contains(wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES)
{
capabilities.push(spv::Capability::SampledCubeArray);
}

if self
.downlevel_flags
.contains(wgt::DownlevelFlags::MULTISAMPLED_SHADING)
{
capabilities.push(spv::Capability::SampleRateShading);
}

if features.contains(wgt::Features::MULTIVIEW) {
capabilities.push(spv::Capability::MultiView);
}
Expand Down