Renderer: Allow to enable or disable API validation layers using config
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <Nazara/Platform/WindowHandle.hpp>
|
||||
#include <Nazara/Renderer/RenderDevice.hpp>
|
||||
#include <Nazara/Renderer/RenderDeviceInfo.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
@@ -23,7 +24,7 @@ namespace Nz
|
||||
friend GL::Context;
|
||||
|
||||
public:
|
||||
OpenGLDevice(GL::Loader& loader);
|
||||
OpenGLDevice(GL::Loader& loader, const Renderer::Config& config);
|
||||
OpenGLDevice(const OpenGLDevice&) = delete;
|
||||
OpenGLDevice(OpenGLDevice&&) = delete; ///TODO?
|
||||
~OpenGLDevice();
|
||||
|
||||
@@ -32,7 +32,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& config) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<GL::Loader> SelectLoader();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <Nazara/OpenGLRenderer/OpenGLVaoCache.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <array>
|
||||
#include <string>
|
||||
@@ -96,6 +97,7 @@ namespace Nz::GL
|
||||
struct ContextParams
|
||||
{
|
||||
ContextType type = ContextType::OpenGL_ES;
|
||||
RenderAPIValidationLevel validationLevel = RenderAPIValidationLevel::Warnings;
|
||||
bool doubleBuffering = true;
|
||||
bool wrapErrorHandling = false;
|
||||
unsigned int bitsPerPixel = 32;
|
||||
|
||||
@@ -122,6 +122,16 @@ namespace Nz
|
||||
|
||||
constexpr std::size_t RenderAPICount = static_cast<std::size_t>(RenderAPI::Max) + 1;
|
||||
|
||||
enum class RenderAPIValidationLevel
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Errors = 1,
|
||||
Warnings = 2,
|
||||
Verbose = 3,
|
||||
Debug = 4
|
||||
};
|
||||
|
||||
enum class RenderDeviceType
|
||||
{
|
||||
Integrated, ///< Hardware-accelerated chipset integrated to a CPU (ex: Intel Graphics HD 4000)
|
||||
|
||||
@@ -9,14 +9,16 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/DynLib.hpp>
|
||||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <Nazara/Platform/Platform.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RendererImpl.hpp>
|
||||
#include <Nazara/Renderer/RenderDevice.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Buffer;
|
||||
class RendererImpl;
|
||||
|
||||
class NAZARA_RENDERER_API Renderer : public ModuleBase<Renderer>
|
||||
{
|
||||
@@ -42,13 +44,20 @@ namespace Nz
|
||||
|
||||
struct Config
|
||||
{
|
||||
ParameterList customParameters;
|
||||
RenderAPI preferredAPI = RenderAPI::Unknown;
|
||||
#ifdef NAZARA_DEBUG
|
||||
RenderAPIValidationLevel validationLevel = RenderAPIValidationLevel::Verbose;
|
||||
#else
|
||||
RenderAPIValidationLevel validationLevel = RenderAPIValidationLevel::Errors;
|
||||
#endif
|
||||
};
|
||||
|
||||
private:
|
||||
void LoadBackend(const Config& config);
|
||||
|
||||
std::unique_ptr<RendererImpl> m_rendererImpl;
|
||||
Config m_config;
|
||||
DynLib m_rendererLib;
|
||||
|
||||
static Renderer* s_instance;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderDeviceInfo.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -44,7 +45,7 @@ namespace Nz
|
||||
|
||||
virtual const std::vector<RenderDeviceInfo>& QueryRenderDevices() const = 0;
|
||||
|
||||
virtual bool Prepare(const ParameterList& parameters) = 0;
|
||||
virtual bool Prepare(const Renderer::Config& config) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user