Enable Vulkan validation in SDL debug builds

This commit is contained in:
Henrik Rydgård 2020-06-23 21:57:02 +02:00
parent af7995c554
commit 7180c2a4c2
2 changed files with 15 additions and 2 deletions

View File

@ -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();

View File

@ -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();