Skip to content

Commit

Permalink
feat(vulkan): enable GPU-based validation for Vulkan backend
Browse files Browse the repository at this point in the history
Logic for doing this was sourced from page 3 of [LunarG's guide], with
the following section stack:

* Activating GPU-Assisted Validation
    * Enabling and Specifying Options with the Programmatic Interface

[LunarG's guide]: https://www.lunarg.com/wp-content/uploads/2019/02/GPU-Assisted-Validation_v3_02_22_19.pdf
  • Loading branch information
ErichDonGubler committed Jan 26, 2024
1 parent f4e6b32 commit 898c96f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Bottom level categories:
- `tan`
- `tanh`
- Eager release of GPU resources comes from device.trackers. By @bradwerth in [#5075](https://github.com/gfx-rs/wgpu/pull/5075)
- Added `InstanceFlags::GPU_BASED_VALIDATION`, which enables GPU-based validation for shaders. This is currently only supported on the DX12 back end; other platforms ignore this flag, for now.
- Added `InstanceFlags::GPU_BASED_VALIDATION`, which enables GPU-based validation for shaders. This is currently only supported on the DX12 and Vulkan back ends; other platforms ignore this flag, for now.
- This has been added to the set of flags set by `InstanceFlags::debugging` and `InstanceFlags::from_build_config`. If you notice your graphics workloads running more slowly, this may be the culprit.
- As with other instance flags, this flag can be changed in calls to `InstanceFlags::with_env` with the new `WGPU_GPU_BASED_VALIDATION` environment variable.

Expand Down
9 changes: 9 additions & 0 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,15 @@ impl crate::Instance<super::Api> for super::Instance {
create_info = create_info.push_next(vk_create_info);
}

let mut gpu_assisted_validation = vk::ValidationFeaturesEXT::builder()
.enabled_validation_features(&[vk::ValidationFeatureEnableEXT::GPU_ASSISTED]);
if desc
.flags
.intersects(wgt::InstanceFlags::GPU_BASED_VALIDATION)
{
create_info = create_info.push_next(&mut gpu_assisted_validation);
}

unsafe {
profiling::scope!("vkCreateInstance");
entry.create_instance(&create_info, None)
Expand Down
2 changes: 2 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ bitflags::bitflags! {
///
/// - D3D12; called ["GPU-based validation", or
/// "GBV"](https://web.archive.org/web/20230206120404/https://learn.microsoft.com/en-us/windows/win32/direct3d12/using-d3d12-debug-layer-gpu-based-validation)
/// - Vulkan, via the `VK_LAYER_KHRONOS_validation` layer; called ["GPU-Assisted
/// Validation"](https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/e45aeb85079e0835694cb8f03e6681fd18ae72c9/docs/gpu_validation.md#gpu-assisted-validation)
const GPU_BASED_VALIDATION = 1 << 4;
}
}
Expand Down

0 comments on commit 898c96f

Please sign in to comment.