vulkan validation layer config
This commit is contained in:
@@ -41,11 +41,6 @@ const VALIDATION_LAYERS: &[&str] = &[
|
||||
"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)]
|
||||
pub struct Vertex {
|
||||
pub position: [f32; 3],
|
||||
@@ -61,6 +56,8 @@ pub struct LinePoint {
|
||||
vulkano::impl_vertex!(LinePoint, position);
|
||||
|
||||
pub trait Game {
|
||||
fn validation_layers_enabled(self: &Self) -> bool;
|
||||
|
||||
fn update(self: &mut Self, game_data: &mut GameData);
|
||||
|
||||
/// 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]
|
||||
};
|
||||
|
||||
if ENABLE_VALIDATION_LAYERS {
|
||||
if game.validation_layers_enabled() {
|
||||
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 })
|
||||
};
|
||||
|
||||
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>>();
|
||||
|
||||
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!
|
||||
let mut _debug_callback = None;
|
||||
if ENABLE_VALIDATION_LAYERS {
|
||||
if game.validation_layers_enabled() {
|
||||
let msg_types = MessageTypes {
|
||||
error: true,
|
||||
warning: true,
|
||||
|
||||
Reference in New Issue
Block a user