diff options
Diffstat (limited to 'drivers/vulkan/vulkan_context.h')
-rw-r--r-- | drivers/vulkan/vulkan_context.h | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/drivers/vulkan/vulkan_context.h b/drivers/vulkan/vulkan_context.h index 9ebea42ecb..59e404512a 100644 --- a/drivers/vulkan/vulkan_context.h +++ b/drivers/vulkan/vulkan_context.h @@ -37,6 +37,7 @@ #include "core/rid_owner.h" #include "core/ustring.h" #include "servers/display_server.h" + #include <vulkan/vulkan.h> class VulkanContext { @@ -51,13 +52,15 @@ class VulkanContext { VkPhysicalDevice gpu; VkPhysicalDeviceProperties gpu_props; uint32_t queue_family_count; - VkQueueFamilyProperties *queue_props; + VkQueueFamilyProperties *queue_props = nullptr; VkDevice device; bool device_initialized = false; bool inst_initialized = false; - //present - bool queues_initialized; + bool buffers_prepared = false; + + // Present queue. + bool queues_initialized = false; uint32_t graphics_queue_family_index; uint32_t present_queue_family_index; bool separate_present_queue; @@ -78,7 +81,6 @@ class VulkanContext { VkCommandBuffer graphics_to_present_cmd; VkImageView view; VkFramebuffer framebuffer; - } SwapchainImageResources; struct Window { @@ -89,7 +91,7 @@ class VulkanContext { uint32_t current_buffer = 0; int width = 0; int height = 0; - VkCommandPool present_cmd_pool; //for separate present queue + VkCommandPool present_cmd_pool; // For separate present queue. VkRenderPass render_pass = VK_NULL_HANDLE; }; @@ -102,19 +104,24 @@ class VulkanContext { RID_Owner<LocalDevice, true> local_device_owner; Map<DisplayServer::WindowID, Window> windows; - uint32_t swapchainImageCount; + uint32_t swapchainImageCount = 0; - //commands + // Commands. bool prepared; - //extensions - bool VK_KHR_incremental_present_enabled; - bool VK_GOOGLE_display_timing_enabled; - const char **instance_validation_layers; - uint32_t enabled_extension_count; - uint32_t enabled_layer_count; + Vector<VkCommandBuffer> command_buffer_queue; + int command_buffer_count = 1; + + // Extensions. + + bool VK_KHR_incremental_present_enabled = true; + bool VK_GOOGLE_display_timing_enabled = true; + uint32_t enabled_extension_count = 0; const char *extension_names[MAX_EXTENSIONS]; + + const char **instance_validation_layers = nullptr; + uint32_t enabled_layer_count = 0; const char *enabled_layers[MAX_LAYERS]; PFN_vkCreateDebugUtilsMessengerEXT CreateDebugUtilsMessengerEXT; @@ -142,7 +149,8 @@ class VulkanContext { Error _initialize_extensions(); VkBool32 _check_layers(uint32_t check_count, const char **check_names, uint32_t layer_count, VkLayerProperties *layers); - static VKAPI_ATTR VkBool32 VKAPI_CALL _debug_messenger_callback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + static VKAPI_ATTR VkBool32 VKAPI_CALL _debug_messenger_callback( + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData); @@ -160,12 +168,11 @@ class VulkanContext { Error _create_swap_chain(); Error _create_semaphores(); - Vector<VkCommandBuffer> command_buffer_queue; - int command_buffer_count; - protected: virtual const char *_get_platform_surface_extension() const = 0; - // virtual VkResult _create_surface(VkSurfaceKHR *surface, VkInstance p_instance) = 0; + + // Enabled via command line argument. + bool use_validation_layers = false; virtual Error _window_create(DisplayServer::WindowID p_window_id, VkSurfaceKHR p_surface, int p_width, int p_height); @@ -173,10 +180,6 @@ protected: return inst; } - bool buffers_prepared; - - bool use_validation_layers; - public: VkDevice get_device(); VkPhysicalDevice get_physical_device(); |