Renderer: Allow to enable or disable API validation layers using config

This commit is contained in:
SirLynix
2022-08-10 00:04:46 +02:00
parent 38e32025e9
commit 117f7c2a4b
19 changed files with 101 additions and 37 deletions

View File

@@ -47,7 +47,7 @@ namespace Nz
static const std::vector<Vk::PhysicalDevice>& GetPhysicalDevices();
static const Vk::PhysicalDevice& GetPhysicalDeviceInfo(VkPhysicalDevice physDevice);
static bool Initialize(UInt32 targetApiVersion, const ParameterList& parameters);
static bool Initialize(UInt32 targetApiVersion, RenderAPIValidationLevel validationLevel, const ParameterList& parameters);
static bool IsInitialized();

View File

@@ -35,7 +35,7 @@ namespace Nz
UInt32 QueryAPIVersion() const override;
const std::vector<RenderDeviceInfo>& QueryRenderDevices() const override;
bool Prepare(const ParameterList& parameters) override;
bool Prepare(const Renderer::Config& parameters) override;
static constexpr UInt32 APIVersion = VK_API_VERSION_1_2;

View File

@@ -8,6 +8,7 @@
#define NAZARA_VULKANRENDERER_WRAPPER_INSTANCE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/VulkanRenderer/Config.hpp>
#include <Nazara/VulkanRenderer/Wrapper/Loader.hpp>
#include <vulkan/vulkan_core.h>
@@ -59,8 +60,8 @@ namespace Nz
Instance(Instance&&) = delete;
~Instance();
bool Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);
inline bool Create(const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator = nullptr);
bool Create(RenderAPIValidationLevel validationLevel, const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr);
inline bool Create(RenderAPIValidationLevel validationLevel, const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator = nullptr);
inline void Destroy();
bool EnumeratePhysicalDevices(std::vector<VkPhysicalDevice>* physicalDevices) const;
@@ -78,6 +79,7 @@ namespace Nz
inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device) const;
bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector<VkQueueFamilyProperties>* queueFamilyProperties) const;
inline PFN_vkVoidFunction GetProcAddr(const char* name) const;
inline RenderAPIValidationLevel GetValidationLevel() const;
void InstallDebugMessageCallback();
@@ -108,6 +110,7 @@ namespace Nz
VkAllocationCallbacks m_allocator;
VkInstance m_instance;
mutable VkResult m_lastErrorCode;
RenderAPIValidationLevel m_validationLevel;
UInt32 m_apiVersion;
};
}

View File

@@ -12,7 +12,7 @@ namespace Nz
{
namespace Vk
{
inline bool Instance::Create(const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator)
inline bool Instance::Create(RenderAPIValidationLevel validationLevel, const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, UInt32 apiVersion, const std::vector<const char*>& layers, const std::vector<const char*>& extensions, const VkAllocationCallbacks* allocator)
{
VkApplicationInfo appInfo =
{
@@ -37,7 +37,7 @@ namespace Nz
(!extensions.empty()) ? extensions.data() : nullptr
};
return Create(instanceInfo, allocator);
return Create(validationLevel, instanceInfo, allocator);
}
inline void Instance::Destroy()
@@ -77,6 +77,11 @@ namespace Nz
return func;
}
inline RenderAPIValidationLevel Instance::GetValidationLevel() const
{
return m_validationLevel;
}
inline bool Instance::IsExtensionLoaded(const std::string& extensionName) const
{
return m_loadedExtensions.count(extensionName) > 0;