VulkanRenderer: Fix unitybuild causing #define issue because of Windows.h
This commit is contained in:
@@ -7,143 +7,140 @@
|
||||
#include <cassert>
|
||||
#include <Nazara/VulkanRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
namespace Nz::Vk
|
||||
{
|
||||
namespace Vk
|
||||
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)
|
||||
{
|
||||
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 =
|
||||
{
|
||||
VkApplicationInfo appInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
nullptr,
|
||||
appName.data(),
|
||||
appVersion,
|
||||
engineName.data(),
|
||||
engineVersion,
|
||||
apiVersion
|
||||
};
|
||||
VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
nullptr,
|
||||
appName.data(),
|
||||
appVersion,
|
||||
engineName.data(),
|
||||
engineVersion,
|
||||
apiVersion
|
||||
};
|
||||
|
||||
VkInstanceCreateInfo instanceInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
nullptr,
|
||||
0,
|
||||
&appInfo,
|
||||
static_cast<UInt32>(layers.size()),
|
||||
(!layers.empty()) ? layers.data() : nullptr,
|
||||
static_cast<UInt32>(extensions.size()),
|
||||
(!extensions.empty()) ? extensions.data() : nullptr
|
||||
};
|
||||
VkInstanceCreateInfo instanceInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
nullptr,
|
||||
0,
|
||||
&appInfo,
|
||||
static_cast<UInt32>(layers.size()),
|
||||
(!layers.empty()) ? layers.data() : nullptr,
|
||||
static_cast<UInt32>(extensions.size()),
|
||||
(!extensions.empty()) ? extensions.data() : nullptr
|
||||
};
|
||||
|
||||
return Create(validationLevel, instanceInfo, allocator);
|
||||
return Create(validationLevel, instanceInfo, allocator);
|
||||
}
|
||||
|
||||
inline void Instance::Destroy()
|
||||
{
|
||||
if (m_instance)
|
||||
{
|
||||
DestroyInstance();
|
||||
ResetPointers();
|
||||
}
|
||||
}
|
||||
|
||||
inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) const
|
||||
{
|
||||
PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name);
|
||||
if (!func)
|
||||
NazaraError("Failed to get " + std::string(name) + " address");
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
inline UInt32 Instance::GetApiVersion() const
|
||||
{
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
inline VkResult Instance::GetLastErrorCode() const
|
||||
{
|
||||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) const
|
||||
{
|
||||
PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name);
|
||||
if (!func)
|
||||
NazaraError("Failed to get " + std::string(name) + " address");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
inline bool Instance::IsLayerLoaded(const std::string& layerName) const
|
||||
{
|
||||
return m_loadedLayers.count(layerName) > 0;
|
||||
}
|
||||
|
||||
inline bool Instance::IsValid() const
|
||||
{
|
||||
return m_instance != nullptr;
|
||||
}
|
||||
|
||||
inline Instance::operator VkInstance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
inline VkPhysicalDeviceFeatures Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device) const
|
||||
{
|
||||
VkPhysicalDeviceFeatures features;
|
||||
vkGetPhysicalDeviceFeatures(device, &features);
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
inline VkFormatProperties Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) const
|
||||
{
|
||||
VkFormatProperties formatProperties;
|
||||
vkGetPhysicalDeviceFormatProperties(device, format, &formatProperties);
|
||||
|
||||
return formatProperties;
|
||||
}
|
||||
|
||||
inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) const
|
||||
{
|
||||
m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties);
|
||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to get physical device image format properties: " + TranslateVulkanError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void Instance::Destroy()
|
||||
{
|
||||
if (m_instance)
|
||||
{
|
||||
DestroyInstance();
|
||||
ResetPointers();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) const
|
||||
{
|
||||
PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name);
|
||||
if (!func)
|
||||
NazaraError("Failed to get " + std::string(name) + " address");
|
||||
inline VkPhysicalDeviceMemoryProperties Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) const
|
||||
{
|
||||
VkPhysicalDeviceMemoryProperties memoryProperties;
|
||||
vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties);
|
||||
|
||||
return func;
|
||||
}
|
||||
return memoryProperties;
|
||||
}
|
||||
|
||||
inline UInt32 Instance::GetApiVersion() const
|
||||
{
|
||||
return m_apiVersion;
|
||||
}
|
||||
inline VkPhysicalDeviceProperties Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device) const
|
||||
{
|
||||
VkPhysicalDeviceProperties properties;
|
||||
vkGetPhysicalDeviceProperties(device, &properties);
|
||||
|
||||
inline VkResult Instance::GetLastErrorCode() const
|
||||
{
|
||||
return m_lastErrorCode;
|
||||
}
|
||||
|
||||
inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) const
|
||||
{
|
||||
PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name);
|
||||
if (!func)
|
||||
NazaraError("Failed to get " + std::string(name) + " address");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
inline bool Instance::IsLayerLoaded(const std::string& layerName) const
|
||||
{
|
||||
return m_loadedLayers.count(layerName) > 0;
|
||||
}
|
||||
|
||||
inline bool Instance::IsValid() const
|
||||
{
|
||||
return m_instance != nullptr;
|
||||
}
|
||||
|
||||
inline Instance::operator VkInstance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
inline VkPhysicalDeviceFeatures Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device) const
|
||||
{
|
||||
VkPhysicalDeviceFeatures features;
|
||||
vkGetPhysicalDeviceFeatures(device, &features);
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
inline VkFormatProperties Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) const
|
||||
{
|
||||
VkFormatProperties formatProperties;
|
||||
vkGetPhysicalDeviceFormatProperties(device, format, &formatProperties);
|
||||
|
||||
return formatProperties;
|
||||
}
|
||||
|
||||
inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) const
|
||||
{
|
||||
m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties);
|
||||
if (m_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to get physical device image format properties: " + TranslateVulkanError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline VkPhysicalDeviceMemoryProperties Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) const
|
||||
{
|
||||
VkPhysicalDeviceMemoryProperties memoryProperties;
|
||||
vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties);
|
||||
|
||||
return memoryProperties;
|
||||
}
|
||||
|
||||
inline VkPhysicalDeviceProperties Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device) const
|
||||
{
|
||||
VkPhysicalDeviceProperties properties;
|
||||
vkGetPhysicalDeviceProperties(device, &properties);
|
||||
|
||||
return properties;
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user