diff --git a/src/atta/graphics/CMakeLists.txt b/src/atta/graphics/CMakeLists.txt index 2066871c..89ee2d41 100644 --- a/src/atta/graphics/CMakeLists.txt +++ b/src/atta/graphics/CMakeLists.txt @@ -12,35 +12,6 @@ set(ATTA_GRAPHICS_MODULE_SOURCE apis/openGL/indexBuffer.cpp apis/openGL/pipeline.cpp apis/openGL/mesh.cpp - apis/vulkan/buffer.cpp - apis/vulkan/commandBuffers.cpp - apis/vulkan/commandPool.cpp - apis/vulkan/common.cpp - apis/vulkan/debugMessenger.cpp - apis/vulkan/descriptorPool.cpp - apis/vulkan/descriptorSetLayout.cpp - apis/vulkan/descriptorSets.cpp - apis/vulkan/device.cpp - apis/vulkan/fence.cpp - apis/vulkan/framebuffer.cpp - apis/vulkan/image.cpp - apis/vulkan/indexBuffer.cpp - apis/vulkan/instance.cpp - apis/vulkan/mesh.cpp - apis/vulkan/physicalDevice.cpp - apis/vulkan/pipelineLayout.cpp - apis/vulkan/pushConstant.cpp - apis/vulkan/renderPass.cpp - apis/vulkan/renderQueue.cpp - apis/vulkan/semaphore.cpp - apis/vulkan/pipeline.cpp - apis/vulkan/shader.cpp - apis/vulkan/stagingBuffer.cpp - apis/vulkan/surface.cpp - apis/vulkan/swapChain.cpp - apis/vulkan/uniformBuffer.cpp - apis/vulkan/vertexBuffer.cpp - apis/vulkan/vulkanAPI.cpp cameras/camera.cpp cameras/perspectiveCamera.cpp @@ -75,6 +46,40 @@ set(ATTA_GRAPHICS_MODULE_SOURCE viewport.cpp ) +if(ATTA_VULKAN_SUPPORT) + list(ATTA_GRAPHICS_MODULE_SOURCE APPEND + apis/vulkan/buffer.cpp + apis/vulkan/commandBuffers.cpp + apis/vulkan/commandPool.cpp + apis/vulkan/common.cpp + apis/vulkan/debugMessenger.cpp + apis/vulkan/descriptorPool.cpp + apis/vulkan/descriptorSetLayout.cpp + apis/vulkan/descriptorSets.cpp + apis/vulkan/device.cpp + apis/vulkan/fence.cpp + apis/vulkan/framebuffer.cpp + apis/vulkan/image.cpp + apis/vulkan/indexBuffer.cpp + apis/vulkan/instance.cpp + apis/vulkan/mesh.cpp + apis/vulkan/physicalDevice.cpp + apis/vulkan/pipelineLayout.cpp + apis/vulkan/pushConstant.cpp + apis/vulkan/renderPass.cpp + apis/vulkan/renderQueue.cpp + apis/vulkan/semaphore.cpp + apis/vulkan/pipeline.cpp + apis/vulkan/shader.cpp + apis/vulkan/stagingBuffer.cpp + apis/vulkan/surface.cpp + apis/vulkan/swapChain.cpp + apis/vulkan/uniformBuffer.cpp + apis/vulkan/vertexBuffer.cpp + apis/vulkan/vulkanAPI.cpp + ) +endif() + add_library(atta_graphics_module STATIC ${ATTA_GRAPHICS_MODULE_SOURCE} ) diff --git a/src/atta/graphics/manager.cpp b/src/atta/graphics/manager.cpp index 634f3156..b372402a 100644 --- a/src/atta/graphics/manager.cpp +++ b/src/atta/graphics/manager.cpp @@ -8,7 +8,9 @@ #include #include +#if ATTA_VULKAN_SUPPORT #include +#endif #include #include #include @@ -31,8 +33,11 @@ namespace atta::graphics { Manager::Manager() { - // TODO check vulkan support +#if ATTA_VULKAN_SUPPORT _desiredGraphicsAPI = GraphicsAPI::VULKAN; +#else + _desiredGraphicsAPI = GraphicsAPI::OPENGL; +#endif } Manager& Manager::getInstance() { @@ -62,9 +67,11 @@ void Manager::startUpImpl() { _window = std::static_pointer_cast(std::make_shared(windowInfo)); //----- Renderer API -----// +#if ATTA_VULKAN_SUPPORT if (_desiredGraphicsAPI == GraphicsAPI::VULKAN) _graphicsAPI = std::static_pointer_cast(std::make_shared(_window)); else +#endif _graphicsAPI = std::static_pointer_cast(std::make_shared(_window)); _graphicsAPI->startUp(); @@ -299,34 +306,42 @@ const std::unordered_map>& Manager::getImages() // If the derived (e.g. VulkanImage) has the same type as the base (e.g. Image), it means that does not exists // an implementation of Image for vulkan +#if ATTA_VULKAN_SUPPORT +// Vulkan supported +#define CHECK_VK_SUPPORT(x) vk::x +#else +// Vulkan not supported +#define CHECK_VK_SUPPORT(x) x +#endif + template <> std::shared_ptr Manager::createImpl(Image::CreateInfo info) { - return createSpecific(info); + return createSpecific(info); } template <> std::shared_ptr Manager::createImpl(Mesh::CreateInfo info) { - return createSpecific(info); + return createSpecific(info); } template <> std::shared_ptr Manager::createImpl(Framebuffer::CreateInfo info) { - return createSpecific(info); + return createSpecific(info); } template <> std::shared_ptr Manager::createImpl(VertexBuffer::CreateInfo info) { - return createSpecific(info); + return createSpecific(info); } template <> std::shared_ptr Manager::createImpl(IndexBuffer::CreateInfo info) { - return createSpecific(info); + return createSpecific(info); } template <> std::shared_ptr Manager::createImpl(RenderPass::CreateInfo info) { - return createSpecific(info); + return createSpecific(info); } template <> @@ -336,17 +351,17 @@ std::shared_ptr Manager::createImpl(const char* file) { template <> std::shared_ptr Manager::createImpl(fs::path file) { - return createSpecific(file); + return createSpecific(file); } template <> std::shared_ptr Manager::createImpl(Pipeline::CreateInfo info) { - return createSpecific(info); + return createSpecific(info); } template <> std::shared_ptr Manager::createImpl() { - return createSpecific(); + return createSpecific(); } } // namespace atta::graphics diff --git a/src/atta/ui/editor/moduleWindows/graphicsModuleWindow.cpp b/src/atta/ui/editor/moduleWindows/graphicsModuleWindow.cpp index b9f393bc..e72e13d2 100644 --- a/src/atta/ui/editor/moduleWindows/graphicsModuleWindow.cpp +++ b/src/atta/ui/editor/moduleWindows/graphicsModuleWindow.cpp @@ -17,7 +17,12 @@ GraphicsModuleWindow::GraphicsModuleWindow() { void GraphicsModuleWindow::renderImpl() { // Graphics API control - const char* graphicsAPIs[] = {"OpenGL", "Vulkan"}; + const char* graphicsAPIs[] = { + "OpenGL", +#if ATTA_VULKAN_SUPPORT + "Vulkan" +#endif + }; int currentGraphicsAPI = int(graphics::getGraphicsAPI()->getType()); if (ImGui::Combo("Graphics API", ¤tGraphicsAPI, graphicsAPIs, IM_ARRAYSIZE(graphicsAPIs))) graphics::setGraphicsAPI(graphics::GraphicsAPI::Type(currentGraphicsAPI)); diff --git a/src/atta/ui/manager.cpp b/src/atta/ui/manager.cpp index ea0a5450..f15e1d59 100644 --- a/src/atta/ui/manager.cpp +++ b/src/atta/ui/manager.cpp @@ -13,7 +13,9 @@ #include #include #include +#if ATTA_VULKAN_SUPPORT #include +#endif #include #include // clang-format on @@ -72,7 +74,9 @@ void Manager::shutDownImpl() { ImGui_ImplOpenGL3_Shutdown(); break; case gfx::GraphicsAPI::VULKAN: +#if ATTA_VULKAN_SUPPORT ImGui_ImplVulkan_Shutdown(); +#endif break; } ImGui_ImplGlfw_Shutdown(); @@ -119,6 +123,7 @@ void Manager::initOpenGL() { } void Manager::initVulkan() { +#if ATTA_VULKAN_SUPPORT GLFWwindow* window = (GLFWwindow*)gfx::getWindow()->getHandle(); ImGui_ImplGlfw_InitForVulkan(window, true); std::shared_ptr vulkanAPI = std::dynamic_pointer_cast(gfx::getGraphicsAPI()); @@ -139,6 +144,7 @@ void Manager::initVulkan() { // Upload Fonts if (!ImGui_ImplVulkan_CreateFontsTexture()) LOG_WARN("ui::Manager", "Failed to created ImGui font texture"); +#endif } void Manager::render() { @@ -148,7 +154,9 @@ void Manager::render() { ImGui_ImplOpenGL3_NewFrame(); break; case gfx::GraphicsAPI::VULKAN: +#if ATTA_VULKAN_SUPPORT ImGui_ImplVulkan_NewFrame(); +#endif break; } ImGui_ImplGlfw_NewFrame(); @@ -165,8 +173,10 @@ void Manager::render() { ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); break; case gfx::GraphicsAPI::VULKAN: +#if ATTA_VULKAN_SUPPORT ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), std::dynamic_pointer_cast(gfx::getGraphicsAPI())->getCommandBuffers()->getCurrent()); +#endif break; } diff --git a/src/extern/solveVulkan.cmake b/src/extern/solveVulkan.cmake index 544aba84..36585e05 100644 --- a/src/extern/solveVulkan.cmake +++ b/src/extern/solveVulkan.cmake @@ -4,10 +4,10 @@ set(ATTA_VULKAN_TARGETS "") find_package(Vulkan) if(Vulkan_FOUND) - set(ATTA_VULKAN_SUPPORT TRUE) - set(ATTA_VULKAN_TARGETS ${Vulkan_LIBRARY}) - atta_add_include_dirs(${Vulkan_INCLUDE_DIRS}) - atta_log(Success Extern "Vulkan support (installed)") + #set(ATTA_VULKAN_SUPPORT TRUE) + #set(ATTA_VULKAN_TARGETS ${Vulkan_LIBRARY}) + #atta_add_include_dirs(${Vulkan_INCLUDE_DIRS}) + #atta_log(Success Extern "Vulkan support (installed)") else() atta_log(Warn Extern "Vulkan not supported") endif()