@@ -161,7 +161,7 @@ void Application::DeleteSwapChain()
161
161
162
162
void Application::DrawFrame ()
163
163
{
164
- const auto noTimeout = std::numeric_limits<uint64_t >::max ();
164
+ constexpr auto noTimeout = std::numeric_limits<uint64_t >::max ();
165
165
166
166
auto & inFlightFence = inFlightFences_[currentFrame_];
167
167
const auto imageAvailableSemaphore = imageAvailableSemaphores_[currentFrame_].Handle ();
@@ -183,11 +183,11 @@ void Application::DrawFrame()
183
183
Throw (std::runtime_error (std::string (" failed to acquire next image (" ) + ToString (result) + " )" ));
184
184
}
185
185
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_ );
189
189
190
- UpdateUniformBuffer (imageIndex );
190
+ UpdateUniformBuffer ();
191
191
192
192
VkSubmitInfo submitInfo = {};
193
193
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
@@ -236,7 +236,7 @@ void Application::DrawFrame()
236
236
currentFrame_ = (currentFrame_ + 1 ) % inFlightFences_.size ();
237
237
}
238
238
239
- void Application::Render (VkCommandBuffer commandBuffer, const uint32_t imageIndex)
239
+ void Application::Render (VkCommandBuffer commandBuffer, const size_t currentFrame, const uint32_t imageIndex)
240
240
{
241
241
std::array<VkClearValue, 2 > clearValues = {};
242
242
clearValues[0 ].color = { {0 .0f , 0 .0f , 0 .0f , 1 .0f } };
@@ -255,7 +255,7 @@ void Application::Render(VkCommandBuffer commandBuffer, const uint32_t imageInde
255
255
{
256
256
const auto & scene = GetScene ();
257
257
258
- VkDescriptorSet descriptorSets[] = { graphicsPipeline_->DescriptorSet (imageIndex ) };
258
+ VkDescriptorSet descriptorSets[] = { graphicsPipeline_->DescriptorSet (currentFrame ) };
259
259
VkBuffer vertexBuffers[] = { scene.VertexBuffer ().Handle () };
260
260
const VkBuffer indexBuffer = scene.IndexBuffer ().Handle ();
261
261
VkDeviceSize offsets[] = { 0 };
@@ -282,9 +282,9 @@ void Application::Render(VkCommandBuffer commandBuffer, const uint32_t imageInde
282
282
vkCmdEndRenderPass (commandBuffer);
283
283
}
284
284
285
- void Application::UpdateUniformBuffer (const uint32_t imageIndex )
285
+ void Application::UpdateUniformBuffer ()
286
286
{
287
- uniformBuffers_[imageIndex ].SetValue (GetUniformBufferObject (swapChain_->Extent ()));
287
+ uniformBuffers_[currentFrame_ ].SetValue (GetUniformBufferObject (swapChain_->Extent ()));
288
288
}
289
289
290
290
void Application::RecreateSwapChain ()
0 commit comments