vulkan validation layer config

This commit is contained in:
2019-07-27 19:30:45 +02:00
parent 3ec4f59f58
commit 7bf72001f4
4 changed files with 13 additions and 10 deletions

View File

@@ -1 +1,2 @@
input = false input = false
vulkan_validation_layers = true

View File

@@ -4,7 +4,8 @@ use std::fs;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct LogConfig { pub struct LogConfig {
pub input: bool pub input: bool,
pub vulkan_validation_layers: bool,
} }
impl LogConfig { impl LogConfig {

View File

@@ -99,6 +99,10 @@ impl Game for TestGame {
_ => {} _ => {}
} }
} }
fn validation_layers_enabled(self: &Self) -> bool {
self.log_config.vulkan_validation_layers
}
} }
fn main() { fn main() {

View File

@@ -41,11 +41,6 @@ const VALIDATION_LAYERS: &[&str] = &[
"VK_LAYER_LUNARG_standard_validation" "VK_LAYER_LUNARG_standard_validation"
]; ];
#[cfg(all(debug_assertions))]
const ENABLE_VALIDATION_LAYERS: bool = true;
#[cfg(not(debug_assertions))]
const ENABLE_VALIDATION_LAYERS: bool = false;
#[derive(Default, Debug, Clone)] #[derive(Default, Debug, Clone)]
pub struct Vertex { pub struct Vertex {
pub position: [f32; 3], pub position: [f32; 3],
@@ -61,6 +56,8 @@ pub struct LinePoint {
vulkano::impl_vertex!(LinePoint, position); vulkano::impl_vertex!(LinePoint, position);
pub trait Game { pub trait Game {
fn validation_layers_enabled(self: &Self) -> bool;
fn update(self: &mut Self, game_data: &mut GameData); fn update(self: &mut Self, game_data: &mut GameData);
/// Returns true if event should be ignored by the vulkan handler /// Returns true if event should be ignored by the vulkan handler
@@ -98,7 +95,7 @@ pub fn init(mesh_path: &str, line_vertices: Vec<LinePoint>, game: &mut dyn Game)
dimensions: [0, 0] dimensions: [0, 0]
}; };
if ENABLE_VALIDATION_LAYERS { if game.validation_layers_enabled() {
println!("Enabling validation layers..."); println!("Enabling validation layers...");
} }
@@ -115,7 +112,7 @@ pub fn init(mesh_path: &str, line_vertices: Vec<LinePoint>, game: &mut dyn Game)
engine_version: Some(Version { major: 0, minor: 1, patch: 0 }) engine_version: Some(Version { major: 0, minor: 1, patch: 0 })
}; };
if ENABLE_VALIDATION_LAYERS { if game.validation_layers_enabled() {
let available_layers = vulkano::instance::layers_list().unwrap().map(|layer| String::from(layer.name())).collect::<Vec<String>>(); let available_layers = vulkano::instance::layers_list().unwrap().map(|layer| String::from(layer.name())).collect::<Vec<String>>();
VALIDATION_LAYERS.iter().for_each(|wanted_layer_name| { VALIDATION_LAYERS.iter().for_each(|wanted_layer_name| {
@@ -132,7 +129,7 @@ pub fn init(mesh_path: &str, line_vertices: Vec<LinePoint>, game: &mut dyn Game)
// lifetime of this is important, even tho it isn't used! // lifetime of this is important, even tho it isn't used!
let mut _debug_callback = None; let mut _debug_callback = None;
if ENABLE_VALIDATION_LAYERS { if game.validation_layers_enabled() {
let msg_types = MessageTypes { let msg_types = MessageTypes {
error: true, error: true,
warning: true, warning: true,