clean debug info in VulkanWidget::recordCommandBuffer

This commit is contained in:
ubuntu1804 2025-11-11 13:32:32 +08:00
parent cfd97e76ba
commit f594d28fde
1 changed files with 11 additions and 18 deletions

View File

@ -494,7 +494,7 @@ bool VulkanWidget::createSwapchain()
// Query surface capabilities
VkSurfaceCapabilitiesKHR capabilities;
VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(m_physicalDevice, m_surface, &capabilities);
if (result != VK_SUCCESS) {
qDebug() << "Failed to get surface capabilities, error code:" << result;
return false;
@ -506,7 +506,7 @@ bool VulkanWidget::createSwapchain()
<< capabilities.minImageExtent.width << "x" << capabilities.minImageExtent.height;
qDebug() << "Surface capabilities - max extent:"
<< capabilities.maxImageExtent.width << "x" << capabilities.maxImageExtent.height;
// Validate surface capabilities - detect invalid/corrupted values
// This can happen when the window is being destroyed
if (capabilities.currentExtent.width > 16384 || capabilities.currentExtent.height > 16384 ||
@ -638,7 +638,7 @@ bool VulkanWidget::createSwapchain()
m_swapchainImageViews[i] = reinterpret_cast<void*>(imageView);
}
qDebug() << "Swapchain created successfully with" << imageCount << "images (MAX_FRAMES_IN_FLIGHT="
qDebug() << "Swapchain created successfully with" << imageCount << "images (MAX_FRAMES_IN_FLIGHT="
<< MAX_FRAMES_IN_FLIGHT << "), size:" << m_surfaceWidth << "x" << m_surfaceHeight;
return true;
@ -708,7 +708,7 @@ bool VulkanWidget::createSyncObjects()
bool VulkanWidget::recreateSwapchain()
{
qDebug() << "Recreating swapchain...";
// Don't recreate if closing
if (m_isClosing) {
qDebug() << "Aborting swapchain recreation - widget is closing";
@ -746,7 +746,7 @@ void VulkanWidget::renderFrame()
// 关键修复:即使 renderingEnabled=false 也继续渲染,以显示锁屏状态
// 只是传递不同的 paintingEnabled 参数给 renderer
// Wait for previous frame
vkWaitForFences(m_device, 1, &m_inFlightFences[m_currentFrame], VK_TRUE, UINT64_MAX);
@ -866,13 +866,6 @@ void VulkanWidget::recordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t i
.arg(m_lockCount);
}
// Debug: Print dimensions occasionally to check for mismatch
static int debugCounter = 0;
if (debugCounter++ % 300 == 0) { // Every ~5 seconds at 60fps
qDebug() << "Rendering - Widget:" << width() << "x" << height()
<< "| Surface:" << m_surfaceWidth << "x" << m_surfaceHeight;
}
m_renderer->recordCommandBuffer(commandBuffer, imageIndex, imageView,
m_frameCount, m_rotationAngle, m_wavePhase,
m_renderingEnabled, lockInfo.toStdString());
@ -1026,22 +1019,22 @@ void VulkanWidget::hideEvent(QHideEvent *event)
void VulkanWidget::closeEvent(QCloseEvent *event)
{
qDebug() << "VulkanWidget closeEvent - stopping rendering and cleaning up";
// Set closing flag to prevent any further rendering attempts
m_isClosing = true;
// Stop the render timer immediately
if (m_renderTimer) {
m_renderTimer->stop();
qDebug() << "Render timer stopped on close";
}
// Wait for device to be idle before accepting close event
if (m_device != VK_NULL_HANDLE) {
vkDeviceWaitIdle(m_device);
qDebug() << "Vulkan device idle on close";
}
// Accept the close event
QWidget::closeEvent(event);
}
@ -1084,14 +1077,14 @@ void VulkanWidget::onRenderTimer()
if (m_wavePhase >= 2 * M_PI) {
m_wavePhase -= 2 * M_PI;
}
// 正常渲染
renderFrame();
} else if (m_needsLockedFrameUpdate) {
// 锁屏状态:只渲染一帧显示锁屏界面
m_needsLockedFrameUpdate = false;
renderFrame();
// 渲染完锁屏帧后停止定时器,避免浪费资源
m_renderTimer->stop();
qDebug() << "Locked frame rendered, timer stopped";