38 vk::SurfaceKHR intrinsic;
40 vk::SwapchainKHR swapchain;
42 constexpr static uint32_t defaultNumberOfSwapchainImages = 2;
44 uint32_t nrSwapchainImages;
45 vk::Extent2D swapchainImageExtent;
46 vk::SurfaceFormatKHR swapchainImageFormat;
50 static const vk::Format depthImageFormat = vk::Format::eD16Unorm;
51 VmaAllocation depthImageAllocation;
53 vk::ImageView depthImageView;
55 static const vk::Format colorImageFormat = vk::Format::eR16G16B16A16Sfloat;
61 vk::RenderPass renderPass;
63 vk::CommandBuffer commandBuffer;
65 vk::Semaphore imageAvailableSemaphore;
66 vk::Semaphore renderFinishedSemaphore;
67 vk::Fence renderFinishedFence;
75 gfx_surface(vk::SurfaceKHR surface) : intrinsic(surface)
77 box_pipeline = std::make_unique<gfx_pipeline_box>(
this);
78 image_pipeline = std::make_unique<gfx_pipeline_image>(
this);
79 SDF_pipeline = std::make_unique<gfx_pipeline_SDF>(
this);
80 override_pipeline = std::make_unique<gfx_pipeline_override>(
this);
81 tone_mapper_pipeline = std::make_unique<gfx_pipeline_tone_mapper>(
this);
86 if (state != gfx_surface_state::no_window) {
88 loss = gfx_surface_loss::window_lost;
90 hi_assert(state == gfx_surface_state::no_window);
106 [[nodiscard]]
gfx_device *device()
const noexcept
111 [[nodiscard]] extent2 size()
const noexcept;
113 void update(extent2 new_size)
noexcept;
115 [[nodiscard]] draw_context render_start(aarectangle redraw_rectangle);
116 void render_finish(draw_context
const& context);
122 struct delegate_type {
124 vk::Semaphore semaphore;
133 extent2 _render_area_granularity;
135 void teardown()
noexcept;
136 void build(extent2 new_size)
noexcept;
141 void teardown_for_swapchain_lost()
noexcept;
142 void teardown_for_device_lost()
noexcept;
143 void teardown_for_window_lost()
noexcept;
145 std::optional<uint32_t> acquire_next_image_from_swapchain();
146 void present_image_to_queue(uint32_t frameBufferIndex, vk::Semaphore renderFinishedSemaphore);
152 void fill_command_buffer(
swapchain_image_info const& current_image, draw_context
const& context, vk::Rect2D render_area);
158 void submit_command_buffer(vk::Semaphore delegate_semaphore);
160 bool read_surface_extent(extent2 minimum_size, extent2 maximum_size);
161 bool check_surface_extent();
163 void build_semaphores();
164 void teardown_semaphores();
166 void teardown_swapchain();
167 void build_command_buffers();
168 void teardown_command_buffers();
169 void build_render_passes();
170 void teardown_render_passes();
171 void build_frame_buffers();
172 void teardown_frame_buffers();
173 void build_pipelines();
174 void teardown_pipelines();
gfx_device * find_best_device(gfx_surface const &surface)
Find the best device for a surface.
Definition gfx_surface_vulkan_intf.hpp:191
unfair_recursive_mutex gfx_system_mutex
Global mutex for GUI elements, like gfx_system, gfx_device, Windows and Widgets.
Definition gfx_system_globals.hpp:18