|
|
@ -562,7 +562,7 @@ void Context::create_instance(const ContextSettings& settings) { |
|
|
if(vkCreateInstance(&instance_info, nullptr, &m_instance) != VK_SUCCESS) |
|
|
if(vkCreateInstance(&instance_info, nullptr, &m_instance) != VK_SUCCESS) |
|
|
throw std::runtime_error("failed to create vulkan instance"); |
|
|
throw std::runtime_error("failed to create vulkan instance"); |
|
|
|
|
|
|
|
|
initialize_extension_functions(); |
|
|
initialize_instance_extension_functions(); |
|
|
|
|
|
|
|
|
if(settings.debug()) { |
|
|
if(settings.debug()) { |
|
|
createDebugUtilsMessenger( |
|
|
createDebugUtilsMessenger( |
|
|
@ -733,7 +733,9 @@ void Context::create_device(const ContextSettings& settings) { |
|
|
.geometryShader = true, |
|
|
.geometryShader = true, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
std::vector<const char*> extensions; |
|
|
std::vector<const char*> extensions { |
|
|
|
|
|
VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, |
|
|
|
|
|
}; |
|
|
if(m_window) { |
|
|
if(m_window) { |
|
|
extensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
|
|
extensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
|
|
}; |
|
|
}; |
|
|
@ -756,6 +758,8 @@ void Context::create_device(const ContextSettings& settings) { |
|
|
) != VK_SUCCESS) |
|
|
) != VK_SUCCESS) |
|
|
throw std::runtime_error("failed to create logical device"); |
|
|
throw std::runtime_error("failed to create logical device"); |
|
|
|
|
|
|
|
|
|
|
|
initialize_device_extension_functions(); |
|
|
|
|
|
|
|
|
m_queues.resize(m_queue_families.size()); |
|
|
m_queues.resize(m_queue_families.size()); |
|
|
for(size_t index = 0; index < m_queue_families.size(); ++index) { |
|
|
for(size_t index = 0; index < m_queue_families.size(); ++index) { |
|
|
vkGetDeviceQueue( |
|
|
vkGetDeviceQueue( |
|
|
@ -777,10 +781,10 @@ void Context::create_internal_objects() { |
|
|
m_transfer_fence = Fence(*this); |
|
|
m_transfer_fence = Fence(*this); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Context::initialize_extension_functions() { |
|
|
void Context::initialize_instance_extension_functions() { |
|
|
uint32_t errors_count = 0; |
|
|
uint32_t errors_count = 0; |
|
|
|
|
|
|
|
|
#define GET_PROC_ADDR(ptr_name, func_name) \ |
|
|
#define GET_INSTANCE_PROC_ADDR(ptr_name, func_name) \ |
|
|
ptr_name = (PFN_vk ## func_name)vkGetInstanceProcAddr( \ |
|
|
ptr_name = (PFN_vk ## func_name)vkGetInstanceProcAddr( \ |
|
|
m_instance, "vk" #func_name); \ |
|
|
m_instance, "vk" #func_name); \ |
|
|
if(ptr_name == nullptr) \ |
|
|
if(ptr_name == nullptr) \ |
|
|
@ -789,9 +793,27 @@ void Context::initialize_extension_functions() { |
|
|
errors_count += 1; \ |
|
|
errors_count += 1; \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
GET_PROC_ADDR(createDebugUtilsMessenger, CreateDebugUtilsMessengerEXT) |
|
|
GET_INSTANCE_PROC_ADDR(createDebugUtilsMessenger, CreateDebugUtilsMessengerEXT) |
|
|
GET_PROC_ADDR(destroyDebugUtilsMessenger, DestroyDebugUtilsMessengerEXT) |
|
|
GET_INSTANCE_PROC_ADDR(destroyDebugUtilsMessenger, DestroyDebugUtilsMessengerEXT) |
|
|
GET_PROC_ADDR(setDebugUtilsObjectName, SetDebugUtilsObjectNameEXT) |
|
|
GET_INSTANCE_PROC_ADDR(setDebugUtilsObjectName, SetDebugUtilsObjectNameEXT) |
|
|
|
|
|
|
|
|
|
|
|
if(errors_count != 0) |
|
|
|
|
|
throw std::runtime_error("failed to load extensions"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Context::initialize_device_extension_functions() { |
|
|
|
|
|
uint32_t errors_count = 0; |
|
|
|
|
|
|
|
|
|
|
|
#define GET_DEVICE_PROC_ADDR(ptr_name, func_name) \ |
|
|
|
|
|
ptr_name = (PFN_vk ## func_name)vkGetDeviceProcAddr( \ |
|
|
|
|
|
m_device, "vk" #func_name); \ |
|
|
|
|
|
if(ptr_name == nullptr) \ |
|
|
|
|
|
{ \ |
|
|
|
|
|
logger.error() << "failed to load extension function 'vk" #func_name "'"; \ |
|
|
|
|
|
errors_count += 1; \ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GET_DEVICE_PROC_ADDR(cmdDrawIndexedIndirectCount, CmdDrawIndexedIndirectCountKHR) |
|
|
|
|
|
|
|
|
if(errors_count != 0) |
|
|
if(errors_count != 0) |
|
|
throw std::runtime_error("failed to load extensions"); |
|
|
throw std::runtime_error("failed to load extensions"); |
|
|
|