#include "detail/graphics.h" namespace deerith { void graphics::init_vulkan() { deerith_graphics_trace("Initializing Vulkan"); create_vulkan_validation_layer(); create_vulkan_instance(); create_vulkan_surface(); pick_vulkan_phisical_device(); create_vulkan_logical_device(); create_vulkan_swap_chain(); create_vulkan_image_view(); create_vulkan_render_pass(); create_vulkan_graphics_pipeline(); create_vulkan_frame_buffer(); create_vulkan_command_buffer(); create_vulkan_sync_objects(); vulkan_test_loop(); } void graphics::shutdown_vulkan() { deerith_graphics_trace("Waiting for Vulkan device to finish"); vkDeviceWaitIdle(device); deerith_graphics_trace("Shutting Vulkan"); for (size_t i = 0; i < MAX_FRAMES_IN_FLIGHT; i++) { vkDestroySemaphore(device, render_finished_semaphores[i], nullptr); vkDestroySemaphore(device, image_available_semaphores[i], nullptr); vkDestroyFence(device, in_flight_fences[i], nullptr); } vkDestroyCommandPool(device, command_pool, nullptr); vulkan_clean_swap_chain(); vkDestroyPipeline(device, graphics_pipeline, nullptr); vkDestroyRenderPass(device, render_pass, nullptr); vkDestroyPipelineLayout(device, pipeline_layout, nullptr); vkDestroySurfaceKHR(instance, surface, nullptr); vkDestroyDevice(device, nullptr); vkDestroyInstance(instance, nullptr); } void graphics::vulkan_clean_swap_chain() { for (auto framebuffer : swap_chain_frame_buffers) { vkDestroyFramebuffer(device, framebuffer, nullptr); } for (auto imageView : swap_chain_image_views) { vkDestroyImageView(device, imageView, nullptr); } vkDestroySwapchainKHR(device, swap_chain, nullptr); } void graphics::vulkan_recreate_swap_chain() { vkDeviceWaitIdle(device); vulkan_clean_swap_chain(); create_vulkan_swap_chain(); create_vulkan_image_view(); create_vulkan_frame_buffer(); } } // namespace deerith