Skip to content

Commit

Permalink
[vulkan] set spir-v capabilities based on downlevel flags
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed Oct 3, 2023
1 parent 6df7e2d commit 0836b13
Showing 1 changed file with 16 additions and 6 deletions.
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/chap51.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

0 comments on commit 0836b13

Please sign in to comment.