File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ void SwapChainVk::destroy() {
124124 vkQueueWaitIdle (device_->get_graphics_queue ());
125125 vkQueueWaitIdle (device_->get_present_queue ());
126126
127- encoder_of_last_frame_. reset ();
127+ encoders_in_flight_. clear ();
128128
129129 // Clean up swap chain related resources.
130130 cleanup_swapchain ();
@@ -239,9 +239,9 @@ void SwapChainVk::create_sync_objects() {
239239}
240240
241241void SwapChainVk::submit (const std::shared_ptr<CommandEncoder> &encoder) {
242- // Cleanup last encoder.
243- if (encoder_of_last_frame_ ) {
244- encoder_of_last_frame_ = nullptr ;
242+ encoders_in_flight_. push_back (encoder);
243+ if (encoders_in_flight_. size () > MAX_FRAMES_IN_FLIGHT ) {
244+ encoders_in_flight_. erase (encoders_in_flight_. begin ()) ;
245245 }
246246
247247 if (encoder->submitted_ ) {
@@ -256,8 +256,6 @@ void SwapChainVk::submit(const std::shared_ptr<CommandEncoder> &encoder) {
256256 }
257257
258258 flush (encoder);
259-
260- encoder_of_last_frame_ = encoder;
261259}
262260
263261void SwapChainVk::flush (const std::shared_ptr<CommandEncoder> &encoder) {
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class SwapChainVk : public SwapChain {
8181 std::vector<VkFence> images_in_flight_;
8282 // --------------------------------------
8383
84- std::shared_ptr<CommandEncoder> encoder_of_last_frame_ ;
84+ std::vector<std:: shared_ptr<CommandEncoder>> encoders_in_flight_ ;
8585
8686private:
8787 void init_swapchain ();
You can’t perform that action at this time.
0 commit comments