diff --git a/escher.blend b/escher.blend new file mode 100644 index 0000000..12d6c4b Binary files /dev/null and b/escher.blend differ diff --git a/src/debug/VulkanDebugLibs.cpp b/src/debug/VulkanDebugLibs.cpp new file mode 100644 index 0000000..1c06439 --- /dev/null +++ b/src/debug/VulkanDebugLibs.cpp @@ -0,0 +1,46 @@ +#include +#define GLFW_INCLUDE_VULKAN +#include + +#include "VulkanDebugLibs.h" +using namespace AgnosiaEngine; + +#include +#include +#include + + const std::vector validationLayers = { + "VK_LAYER_KHRONOS_validation" + }; + +void VulkanDebugLibs::vulkanDebugSetup(VkInstanceCreateInfo& createInfo) { + createInfo.enabledLayerCount = static_cast(validationLayers.size()); + createInfo.ppEnabledLayerNames = validationLayers.data(); +} + +bool VulkanDebugLibs::checkValidationLayerSupport() { // This function is used to check Validation Layer Support, validation layers are the debug trace tools in the Vulkan SDK. + uint32_t layerCount; // layerCount will be used as the var to keep track of the number of requested validation layerk + vkEnumerateInstanceLayerProperties(&layerCount, nullptr); // Set layerCount to the number of validation layers requested when pProperties is NULLPTR + + std::vector availableLayers(layerCount); // VkLayerProperties is a structure with data on the layername, desc, versions and etc. + vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());// Now that we have a VkLayerProperties fed in, as well as the num. of properties, we can fill layerCount with the VkResult + + for(const char* layerName : validationLayers) { // Pretty straightforward from here, just enumerate over all the VkResult data and see if we have any validationLayers + bool layerFound = false; + + for(const auto& layerProperties : availableLayers) { + if(strcmp(layerName, layerProperties.layerName) == 0) { + layerFound = true; + break; + } + } + + if(!layerFound) { + return false; + } + } + return true; +} + + + diff --git a/src/debug/VulkanDebugLibs.h b/src/debug/VulkanDebugLibs.h new file mode 100644 index 0000000..41799e9 --- /dev/null +++ b/src/debug/VulkanDebugLibs.h @@ -0,0 +1,10 @@ +#include + +namespace AgnosiaEngine { + class VulkanDebugLibs { + public: + void vulkanDebugSetup(VkInstanceCreateInfo& createInfo); + bool checkValidationLayerSupport(); + }; +} + diff --git a/src/main.cpp b/src/main.cpp index 2bb175d..cb246ce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,13 @@ -#include -#include -#include + #define GLFW_INCLUDE_VULKAN +#include #include +#include "debug/VulkanDebugLibs.h" +using namespace AgnosiaEngine; + +#include +#include #include #include #include @@ -13,10 +17,6 @@ class TriangleTestApplication { const uint32_t WIDTH = 800; const uint32_t HEIGHT = 600; - const std::vector validationLayers = { - "VK_LAYER_KHRONOS_validation" - }; - #ifdef DEBUG const bool enableValidationLayers = true; #else @@ -51,7 +51,9 @@ private: } void createInstance() { - if(enableValidationLayers && !checkValidationLayerSupport()) { + VulkanDebugLibs debug; + + if(enableValidationLayers && !debug.checkValidationLayerSupport()) { throw std::runtime_error("Validation layers requested, but not available!"); } @@ -81,8 +83,7 @@ private: createInfo.ppEnabledExtensionNames = glfwExtensions; if(enableValidationLayers) { // If we have validation layers, add them now, otherwise set it to 0 - createInfo.enabledLayerCount = static_cast(validationLayers.size()); - createInfo.ppEnabledLayerNames = validationLayers.data(); + debug.vulkanDebugSetup(createInfo); } else { createInfo.enabledLayerCount = 0; } @@ -92,30 +93,8 @@ private: throw std::runtime_error("Failed to create vulkan instance!"); } } - - bool checkValidationLayerSupport() { // This function is used to check Validation Layer Support, validation layers are the debug trace tools in the Vulkan SDK. - uint32_t layerCount; // layerCount will be used as the var to keep track of the number of requested validation layerk - vkEnumerateInstanceLayerProperties(&layerCount, nullptr); // Set layerCount to the number of validation layers requested when pProperties is NULLPTR - std::vector availableLayers(layerCount); // VkLayerProperties is a structure with data on the layername, desc, versions and etc. - vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());// Now that we have a VkLayerProperties fed in, as well as the num. of properties, we can fill layerCount with the VkResult - for(const char* layerName : validationLayers) { // Pretty straightforward from here, just enumerate over all the VkResult data and see if we have any validationLayers - bool layerFound = false; - - for(const auto& layerProperties : availableLayers) { - if(strcmp(layerName, layerProperties.layerName) == 0) { - layerFound = true; - break; - } - } - - if(!layerFound) { - return false; - } - } - return true; - } void mainLoop() { // Update window whilst open @@ -144,3 +123,4 @@ int main() { } return EXIT_SUCCESS; } +