@@ -83,53 +83,6 @@ class WindowChangedCallback {
8383};
8484
8585class VulkanDisplay {
86- std::string path_to_shaders;
87- WindowChangedCallback* window = nullptr ;
88- detail::VulkanContext context;
89-
90- vk::Device device;
91- std::mutex device_mutex{};
92-
93- bool format_conversion_enabled = false ;
94- detail::ConversionPipeline conversion_pipeline;
95-
96- detail::RenderPipeline render_pipeline;
97-
98- vk::DescriptorPool descriptor_pool;
99- vk::CommandPool command_pool;
100-
101- std::array<detail::PerFrameResources, 3 > frame_resources;
102- std::vector<detail::PerFrameResources*> free_frame_resources;
103-
104- ImageDescription current_image_description;
105-
106- using TransferImageImpl = detail::TransferImageImpl;
107- std::deque<TransferImageImpl> transfer_images{};
108-
109- // / available_img_queue - producer is the render thread, consumer is the provided thread
110- detail::ConcurrentQueue<TransferImageImpl*> available_img_queue{};
111- // / filled_img_queue - producer is the provider thread, consumer is the render thread
112- detail::ConcurrentQueue<TransferImageImpl*, detail::filled_img_max_count> filled_img_queue{};
113- // / local to provider thread
114- std::vector<TransferImageImpl*> available_images;
115-
116- struct RenderedImage {
117- TransferImageImpl* image;
118- detail::PerFrameResources* gpu_commands;
119- };
120- std::queue<RenderedImage> rendered_images;
121-
122- bool destroyed = false ;
123- private:
124- void bind_transfer_image (TransferImageImpl& image, detail::PerFrameResources& resources);
125- // void create_transfer_image(transfer_image*& result, image_description description);
126- [[nodiscard]] TransferImageImpl& acquire_transfer_image ();
127-
128- void record_graphics_commands (detail::PerFrameResources& commands, TransferImageImpl& transfer_image, uint32_t swapchain_image_id);
129-
130- void reconfigure (const TransferImageImpl& transfer_image);
131-
132- void destroy_format_dependent_resources ();
13386public:
13487 // / TERMINOLOGY:
13588 // / render thread - thread which renders queued images on the screen
@@ -152,9 +105,12 @@ class VulkanDisplay {
152105 }
153106 }
154107
155- void init (VulkanInstance&& instance, vk::SurfaceKHR surface, uint32_t transfer_image_count,
156- WindowChangedCallback& window, uint32_t gpu_index = no_gpu_selected,
157- std::string path_to_shaders = " ./shaders" , bool vsync = true , bool tearing_permitted = false );
108+ void init (VulkanInstance&& instance, vk::SurfaceKHR surface,
109+ uint32_t transfer_image_count,
110+ WindowChangedCallback& window,
111+ uint32_t gpu_index = no_gpu_selected,
112+ std::string path_to_shaders = " ./shaders" ,
113+ bool vsync = true , bool tearing_permitted = false );
158114
159115 void destroy ();
160116
@@ -163,34 +119,26 @@ class VulkanDisplay {
163119
164120 /* * Thread-safe to call from provider thread.*/
165121 TransferImage acquire_image (ImageDescription description);
166-
167122 /* * Thread-safe to call from provider thread.
168123 **
169124 ** @return true if image was discarded
170125 */
171126 bool queue_image (TransferImage img, bool discardable);
172-
173127 /* * Thread-safe to call from provider thread.*/
174128 void copy_and_queue_image (unsigned char * frame, ImageDescription description);
175-
176129 /* * Thread-safe to call from provider thread.*/
177130 void discard_image (TransferImage image) {
178131 auto * ptr = image.get_transfer_image ();
179132 assert (ptr);
180133 available_images.push_back (ptr);
181134 }
182-
183-
184-
185135 /* * Thread-safe to call from render thread.
186136 **
187137 ** @return true if image was displayed
188138 */
189139 bool display_queued_image ();
190-
191140 /* * Thread-safe*/
192141 uint32_t get_vulkan_version () const { return context.get_vulkan_version (); }
193-
194142 /* * Thread-safe*/
195143 bool is_yCbCr_supported () const { return context.is_yCbCr_supported (); }
196144
@@ -199,12 +147,58 @@ class VulkanDisplay {
199147 * Thread-safe.
200148 */
201149 void window_parameters_changed (WindowParameters new_parameters);
202-
203-
204150 /* * Thread-safe */
205151 void window_parameters_changed () {
206152 window_parameters_changed (window->get_window_parameters ());
207153 }
154+
155+ private:
156+ using TransferImageImpl = detail::TransferImageImpl;
157+ void bind_transfer_image (TransferImageImpl& image,
158+ detail::PerFrameResources& resources);
159+ // void create_transfer_image(transfer_image*& result, image_description description);
160+ [[nodiscard]] TransferImageImpl& acquire_transfer_image ();
161+ void record_graphics_commands (detail::PerFrameResources& commands,
162+ TransferImageImpl& transfer_image, uint32_t swapchain_image_id);
163+ void reconfigure (const TransferImageImpl& transfer_image);
164+ void destroy_format_dependent_resources ();
165+
166+ std::string path_to_shaders;
167+ WindowChangedCallback* window = nullptr ;
168+ detail::VulkanContext context;
169+
170+ vk::Device device;
171+ std::mutex device_mutex{};
172+
173+ bool format_conversion_enabled = false ;
174+ detail::ConversionPipeline conversion_pipeline;
175+
176+ detail::RenderPipeline render_pipeline;
177+
178+ vk::DescriptorPool descriptor_pool;
179+ vk::CommandPool command_pool;
180+
181+ std::array<detail::PerFrameResources, 3 > frame_resources;
182+ std::vector<detail::PerFrameResources*> free_frame_resources;
183+
184+ ImageDescription current_image_description;
185+
186+ std::deque<TransferImageImpl> transfer_images{};
187+
188+ // / available_img_queue - producer is the render thread, consumer is the provided thread
189+ detail::ConcurrentQueue<TransferImageImpl*> available_img_queue{};
190+ // / filled_img_queue - producer is the provider thread, consumer is the render thread
191+ detail::ConcurrentQueue<TransferImageImpl*, detail::filled_img_max_count> filled_img_queue{};
192+ // / local to provider thread
193+ std::vector<TransferImageImpl*> available_images;
194+
195+ struct RenderedImage {
196+ TransferImageImpl* image;
197+ detail::PerFrameResources* gpu_commands;
198+ };
199+ std::queue<RenderedImage> rendered_images;
200+
201+ bool destroyed = false ;
208202};
209203
210204} // vulkan_display
0 commit comments