Pass elapsed time to renderer and use for time UBO

This commit is contained in:
ubuntu1804 2025-11-11 13:39:17 +08:00
parent f594d28fde
commit e723636f9a
3 changed files with 10 additions and 2 deletions

View File

@ -483,6 +483,7 @@ void VulkanRenderer::recordCommandBuffer(VkCommandBuffer commandBuffer,
uint32_t imageIndex,
VkImageView imageView,
int frameCount,
double elapsedTime,
double rotationAngle,
double wavePhase,
bool paintingEnabled,
@ -553,7 +554,7 @@ void VulkanRenderer::recordCommandBuffer(VkCommandBuffer commandBuffer,
}
// Update uniform buffer
m_ubo.time = static_cast<float>(frameCount);
m_ubo.time = static_cast<float>(elapsedTime);
m_ubo.resolution[0] = static_cast<float>(m_width);
m_ubo.resolution[1] = static_cast<float>(m_height);
m_ubo.rotation = static_cast<float>(rotationAngle);

View File

@ -103,6 +103,7 @@ public:
* @param imageIndex
* @param imageView
* @param frameCount
* @param elapsedTime
* @param rotationAngle
* @param wavePhase
* @param paintingEnabled
@ -112,6 +113,7 @@ public:
uint32_t imageIndex,
VkImageView imageView,
int frameCount,
double elapsedTime,
double rotationAngle,
double wavePhase,
bool paintingEnabled,

View File

@ -866,8 +866,13 @@ void VulkanWidget::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t i
.arg(m_lockCount);
}
// Calculate elapsed time in seconds
QDateTime now = QDateTime::currentDateTime();
qint64 elapsedTime = m_startTime.secsTo(now);
m_renderer->recordCommandBuffer(commandBuffer, imageIndex, imageView,
m_frameCount, m_rotationAngle, m_wavePhase,
m_frameCount, static_cast<double>(elapsedTime),
m_rotationAngle, m_wavePhase,
m_renderingEnabled, lockInfo.toStdString());
return;
}