@@ -161,7 +161,7 @@ void Application::DeleteSwapChain()
161161
162162void Application::DrawFrame ()
163163{
164- const auto noTimeout = std::numeric_limits<uint64_t >::max ();
164+ constexpr auto noTimeout = std::numeric_limits<uint64_t >::max ();
165165
166166 auto & inFlightFence = inFlightFences_[currentFrame_];
167167 const auto imageAvailableSemaphore = imageAvailableSemaphores_[currentFrame_].Handle ();
@@ -183,11 +183,11 @@ void Application::DrawFrame()
183183 Throw (std::runtime_error (std::string (" failed to acquire next image (" ) + ToString (result) + " )" ));
184184 }
185185
186- const auto commandBuffer = commandBuffers_->Begin (imageIndex );
187- Render (commandBuffer, imageIndex);
188- commandBuffers_->End (imageIndex );
186+ const auto commandBuffer = commandBuffers_->Begin (currentFrame_ );
187+ Render (commandBuffer, currentFrame_, imageIndex);
188+ commandBuffers_->End (currentFrame_ );
189189
190- UpdateUniformBuffer (imageIndex );
190+ UpdateUniformBuffer ();
191191
192192 VkSubmitInfo submitInfo = {};
193193 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
@@ -236,7 +236,7 @@ void Application::DrawFrame()
236236 currentFrame_ = (currentFrame_ + 1 ) % inFlightFences_.size ();
237237}
238238
239- void Application::Render (VkCommandBuffer commandBuffer, const uint32_t imageIndex)
239+ void Application::Render (VkCommandBuffer commandBuffer, const size_t currentFrame, const uint32_t imageIndex)
240240{
241241 std::array<VkClearValue, 2 > clearValues = {};
242242 clearValues[0 ].color = { {0 .0f , 0 .0f , 0 .0f , 1 .0f } };
@@ -255,7 +255,7 @@ void Application::Render(VkCommandBuffer commandBuffer, const uint32_t imageInde
255255 {
256256 const auto & scene = GetScene ();
257257
258- VkDescriptorSet descriptorSets[] = { graphicsPipeline_->DescriptorSet (imageIndex ) };
258+ VkDescriptorSet descriptorSets[] = { graphicsPipeline_->DescriptorSet (currentFrame ) };
259259 VkBuffer vertexBuffers[] = { scene.VertexBuffer ().Handle () };
260260 const VkBuffer indexBuffer = scene.IndexBuffer ().Handle ();
261261 VkDeviceSize offsets[] = { 0 };
@@ -282,9 +282,9 @@ void Application::Render(VkCommandBuffer commandBuffer, const uint32_t imageInde
282282 vkCmdEndRenderPass (commandBuffer);
283283}
284284
285- void Application::UpdateUniformBuffer (const uint32_t imageIndex )
285+ void Application::UpdateUniformBuffer ()
286286{
287- uniformBuffers_[imageIndex ].SetValue (GetUniformBufferObject (swapChain_->Extent ()));
287+ uniformBuffers_[currentFrame_ ].SetValue (GetUniformBufferObject (swapChain_->Extent ()));
288288}
289289
290290void Application::RecreateSwapChain ()
0 commit comments