Skip to content

Commit

Permalink
Merge pull request #498 from inexorgame/hanni/swapchain_refactoring
Browse files Browse the repository at this point in the history
[merge] Refactoring swapchain
  • Loading branch information
IceflowRE authored Nov 27, 2022
2 parents 33187c4 + 2ff4400 commit ffa218a
Show file tree
Hide file tree
Showing 18 changed files with 638 additions and 637 deletions.
5 changes: 0 additions & 5 deletions include/inexor/vulkan-renderer/renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "inexor/vulkan-renderer/msaa_target.hpp"
#include "inexor/vulkan-renderer/octree_gpu_vertex.hpp"
#include "inexor/vulkan-renderer/render_graph.hpp"
#include "inexor/vulkan-renderer/settings_decision_maker.hpp"
#include "inexor/vulkan-renderer/time_step.hpp"
#include "inexor/vulkan-renderer/vk_tools/gpu_info.hpp"
#include "inexor/vulkan-renderer/wrapper/command_buffer.hpp"
Expand Down Expand Up @@ -36,9 +35,6 @@ namespace inexor::vulkan_renderer {

class VulkanRenderer {
protected:
std::shared_ptr<VulkanSettingsDecisionMaker> m_settings_decision_maker{
std::make_shared<VulkanSettingsDecisionMaker>()};

std::vector<VkPipelineShaderStageCreateInfo> m_shader_stages;

VkDebugReportCallbackEXT m_debug_report_callback{VK_NULL_HANDLE};
Expand All @@ -65,7 +61,6 @@ class VulkanRenderer {
std::unique_ptr<wrapper::WindowSurface> m_surface;
std::unique_ptr<wrapper::Swapchain> m_swapchain;
std::unique_ptr<ImGUIOverlay> m_imgui_overlay;
std::unique_ptr<wrapper::Semaphore> m_image_available_semaphore;
std::unique_ptr<RenderGraph> m_render_graph;

std::vector<wrapper::Shader> m_shaders;
Expand Down
85 changes: 0 additions & 85 deletions include/inexor/vulkan-renderer/settings_decision_maker.hpp

This file was deleted.

19 changes: 19 additions & 0 deletions include/inexor/vulkan-renderer/vk_tools/enumerate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace inexor::vulkan_renderer::vk_tools {

/// All functions which contain the word "all" in it, call some vkEnumerate.. function,
/// while all functions without it call vkGet..

/// Call vkEnumerateDeviceExtensionProperties
/// @note Because device layers are deprecated in Vulkan, we are not exposing the ``pLayerName`` parameter of
/// ``vkEnumerateDeviceExtensionProperties`` as a parameter here
Expand All @@ -26,4 +29,20 @@ namespace inexor::vulkan_renderer::vk_tools {
/// @return A std::vector of all queue families which are available on the system (this can be empty!)
[[nodiscard]] std::vector<VkQueueFamilyProperties> get_queue_family_properties(VkPhysicalDevice physical_device);

/// Call vkGetPhysicalDeviceSurfacePresentModesKHR
/// @param physical_device The physical device
/// @param surface The surface
/// @exception VulkanException vkGetPhysicalDeviceSurfaceFormatsKHR call failed
/// @return A std::vector of surface formats
[[nodiscard]] std::vector<VkSurfaceFormatKHR> get_surface_formats(VkPhysicalDevice physical_device,
VkSurfaceKHR surface);

/// Call vkGetPhysicalDeviceSurfacePresentModesKHR
/// @param physical_device The physical device
/// @param surface The surface
/// @exception VulkanException vkGetPhysicalDeviceSurfacePresentModesKHR call failed
/// @return A std::vector of present modes
[[nodiscard]] std::vector<VkPresentModeKHR> get_surface_present_modes(VkPhysicalDevice physical_device,
VkSurfaceKHR surface);

} // namespace inexor::vulkan_renderer::vk_tools
18 changes: 18 additions & 0 deletions include/inexor/vulkan-renderer/wrapper/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ class Device {
return m_device;
}

/// Call vkGetPhysicalDeviceSurfaceCapabilitiesKHR
/// @param surface The window surface
/// @exception VulkanException vkGetPhysicalDeviceSurfaceCapabilitiesKHR call failed
/// @return The surface capabilities
[[nodiscard]] VkSurfaceCapabilitiesKHR get_surface_capabilities(VkSurfaceKHR surface) const;

/// Check if a format supports a feature for images created with ``VK_IMAGE_TILING_OPTIMAL``
/// @param format The format
/// @param feature The requested format feature
/// @return ``true`` if the format feature is supported
[[nodiscard]] bool format_supports_feature(VkFormat format, VkFormatFeatureFlagBits feature) const;

/// Call vkGetPhysicalDeviceSurfaceSupportKHR
/// @param surface The window surface
/// @param queue_family_index The queue family index
Expand Down Expand Up @@ -307,6 +319,12 @@ class Device {
/// @param name The name which will be assigned to the command buffer
/// @return A command buffer from the thread_local command pool
[[nodiscard]] const CommandBuffer &request_command_buffer(const std::string &name);

/// Check if a surface supports a certain image usage
/// @param surface The window surface
/// @param usage The requested image usage
/// @return ``true`` if the format feature is supported
[[nodiscard]] bool surface_supports_usage(VkSurfaceKHR surface, VkImageUsageFlagBits usage) const;
};

} // namespace inexor::vulkan_renderer::wrapper
11 changes: 4 additions & 7 deletions include/inexor/vulkan-renderer/wrapper/semaphore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

namespace inexor::vulkan_renderer::wrapper {

// Forward declaration
class Device;

/// @brief RAII wrapper class for VkSemaphore.
/// RAII wrapper class for VkSemaphore
class Semaphore {
const Device &m_device;
VkSemaphore m_semaphore{VK_NULL_HANDLE};
std::string m_name;

public:
/// @brief Default constructor.
/// Default constructor
/// @param device The const reference to a device RAII wrapper instance.
/// @param name The internal debug marker name of the VkSemaphore.
Semaphore(const Device &device, const std::string &name);
Expand All @@ -26,11 +27,7 @@ class Semaphore {
Semaphore &operator=(const Semaphore &) = delete;
Semaphore &operator=(Semaphore &&) = delete;

[[nodiscard]] VkSemaphore get() const {
return m_semaphore;
}

[[nodiscard]] const VkSemaphore *ptr() const {
[[nodiscard]] const VkSemaphore *semaphore() const {
return &m_semaphore;
}
};
Expand Down
Loading

0 comments on commit ffa218a

Please sign in to comment.