Wgpu-rs: How to enable validation layers?

Created on 16 Feb 2020  路  6Comments  路  Source: gfx-rs/wgpu-rs

Hi

Enabling validation layers in pure vulkan seems reasonably straightforward. However I cannot seem to figure out how to do so when developing with wgpu-rs. I couldn't find any documentation about this either.

Does anyone know how to do this?

Since validation layers are a pretty common thing to use in vulkan, it seems reasonable that the documentation should include a short note about this as well.

question

Most helpful comment

Thanks!
I added a get started wiki page: https://github.com/gfx-rs/wgpu-rs/wiki/Get-Started and filled it out to the best of my knowledge. But please do correct it if you find any errors in it.

All 6 comments

gfx-backend-vulkan enables the validation layers by default when building for debug mode.
These get routed to log according to severity. So you'd see all of them if enabling the logging (e.g. calling env_logger::init()) and running with the Vulkan backend (could be forced with the backend bits here - https://github.com/gfx-rs/wgpu-rs/blob/8b13a10d2d46cb8c8d709e46bd6d12ae1d487e29/src/lib.rs#L526)

Thank you! That did indeed work!

For others. This requires adding a dependency on these crates in your Cargo.toml

[dependencies]
log = "0.4"
env_logger = "0.7"

Initializing logging like

#[macro_use] extern crate log;

fn main () {
    env_logger::init();
    // Rest of the program
}

And finally running the program and setting the appropriate logging level (see https://docs.rs/log/0.4.10/log/) using an environment variable:

env RUST_LOG=trace cargo run

@HalfVoxel a few notes on your info.

  1. you don't need to depend on log unless you use it. If you just use wgpu-rs and want to see log messages from it, there is no need to directly involve log.
  2. env_logger is one of the way to put them on screen, but not the only way. It's what our examples use, so assume users consider this when writing their apps.

Finally, it would be great to have a "Getting Started" wiki page describing:

  • how to install/check Vulkan drivers
  • how to see the validation errors
  • how to run the examples?

A wiki page would be great indeed. I was actually about to add one previously, but it looks like the wiki has been disabled for this repository.

@HalfVoxel I added you to the team with rights to edit the wiki.

Thanks!
I added a get started wiki page: https://github.com/gfx-rs/wgpu-rs/wiki/Get-Started and filled it out to the best of my knowledge. But please do correct it if you find any errors in it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donpdonp picture donpdonp  路  3Comments

lordnoriyuki picture lordnoriyuki  路  4Comments

bvssvni picture bvssvni  路  5Comments

branpk picture branpk  路  3Comments

Lokathor picture Lokathor  路  3Comments