From 7180c2a4c28ec18667577d4f119a738ba8d8de52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 23 Jun 2020 21:57:02 +0200 Subject: [PATCH] Enable Vulkan validation in SDL debug builds --- Common/Vulkan/VulkanContext.cpp | 5 ++++- SDL/SDLVulkanGraphicsContext.cpp | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index 96c170423d..31cb1573d3 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -88,6 +88,9 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { return VK_ERROR_INITIALIZATION_FAILED; } + instance_layer_names_.clear(); + device_layer_names_.clear(); + // We can get the list of layers and extensions without an instance so we can use this information // to enable the extensions we need that are available. GetInstanceLayerProperties(); @@ -177,7 +180,7 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { #endif if (res != VK_SUCCESS) { if (res == VK_ERROR_LAYER_NOT_PRESENT) { - WLOG("Validation on but layers not available - dropping layers"); + WLOG("Validation on but instance layer not available - dropping layers"); // Drop the validation layers and try again. instance_layer_names_.clear(); device_layer_names_.clear(); diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp index 389030d594..45898f3826 100644 --- a/SDL/SDLVulkanGraphicsContext.cpp +++ b/SDL/SDLVulkanGraphicsContext.cpp @@ -9,10 +9,17 @@ #include "Core/System.h" #include "SDLVulkanGraphicsContext.h" + #if defined(VK_USE_PLATFORM_METAL_EXT) #include "SDLCocoaMetalLayer.h" #endif +#ifdef _DEBUG +static const bool g_Validate = true; +#else +static const bool g_Validate = false; +#endif + bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, std::string *error_message) { window = SDL_CreateWindow("Initializing Vulkan...", x, y, pixel_xres, pixel_yres, mode); if (!window) { @@ -35,7 +42,10 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, vulkan_ = new VulkanContext(); int vulkanFlags = VULKAN_FLAG_PRESENT_MAILBOX; - // vulkanFlags |= VULKAN_FLAG_VALIDATE; + if (g_Validate) { + vulkanFlags |= VULKAN_FLAG_VALIDATE; + } + VulkanContext::CreateInfo info{}; info.app_name = "PPSSPP"; info.app_ver = gitVer.ToInteger();