Vulkan/VkLoader: Add EnumerateInstance[Extension|Layer]Properties helper
Former-commit-id: a7cfc73816266cef944f7cb3c668be0b86bbfcbf
This commit is contained in:
parent
22a31c72ed
commit
da401af52c
|
|
@ -22,6 +22,9 @@ namespace Nz
|
|||
Loader() = delete;
|
||||
~Loader() = delete;
|
||||
|
||||
static bool EnumerateInstanceExtensionProperties(std::vector<VkExtensionProperties>* properties, const char* layerName = nullptr);
|
||||
static bool EnumerateInstanceLayerProperties(std::vector<VkLayerProperties>* properties);
|
||||
|
||||
static inline PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const char* name);
|
||||
|
||||
static bool Initialize();
|
||||
|
|
@ -39,6 +42,7 @@ namespace Nz
|
|||
|
||||
private:
|
||||
static DynLib s_vulkanLib;
|
||||
static VkResult s_lastErrorCode;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,56 @@ namespace Nz
|
|||
{
|
||||
namespace Vk
|
||||
{
|
||||
bool Loader::EnumerateInstanceExtensionProperties(std::vector<VkExtensionProperties>* properties, const char* layerName)
|
||||
{
|
||||
NazaraAssert(properties, "Invalid device vector");
|
||||
|
||||
// First, query physical device count
|
||||
UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t
|
||||
s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data());
|
||||
if (s_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to get instance extension properties count");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now we can get the list of the available physical device
|
||||
properties->resize(propertyCount);
|
||||
s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data());
|
||||
if (s_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to enumerate instance extension properties");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Loader::EnumerateInstanceLayerProperties(std::vector<VkLayerProperties>* properties)
|
||||
{
|
||||
NazaraAssert(properties, "Invalid device vector");
|
||||
|
||||
// First, query physical device count
|
||||
UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t
|
||||
s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data());
|
||||
if (s_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to get instance layer properties count");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now we can get the list of the available physical device
|
||||
properties->resize(propertyCount);
|
||||
s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data());
|
||||
if (s_lastErrorCode != VkResult::VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to enumerate instance layer properties");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Loader::Initialize()
|
||||
{
|
||||
#ifdef NAZARA_PLATFORM_WINDOWS
|
||||
|
|
@ -42,6 +92,8 @@ namespace Nz
|
|||
|
||||
#undef NAZARA_VULKAN_LOAD_GLOBAL
|
||||
|
||||
s_lastErrorCode = VkResult::VK_SUCCESS;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -55,6 +107,7 @@ namespace Nz
|
|||
#undef NAZARA_VULKAN_GLOBAL_FUNCTION_IMPL
|
||||
|
||||
DynLib Loader::s_vulkanLib;
|
||||
VkResult Loader::s_lastErrorCode;
|
||||
|
||||
void Loader::Uninitialize()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue