Remove verbose debug logs from drawText

Eliminate periodic and per-frame debug prints to reduce console noise
and apply minor whitespace/formatting cleanup across VulkanRenderer.cpp
This commit is contained in:
ubuntu1804 2025-11-11 13:29:24 +08:00
parent 6722ed4d5c
commit cfd97e76ba
1 changed files with 16 additions and 34 deletions

View File

@ -240,21 +240,21 @@ uint32_t VulkanRenderer::getMaxUsableSampleCount()
std::cout << std::endl;
// Prefer higher sample counts for better quality
if (counts & VK_SAMPLE_COUNT_16_BIT) {
if (counts & VK_SAMPLE_COUNT_16_BIT) {
std::cout << "Selected: 16x MSAA" << std::endl;
return VK_SAMPLE_COUNT_16_BIT;
return VK_SAMPLE_COUNT_16_BIT;
}
if (counts & VK_SAMPLE_COUNT_8_BIT) {
if (counts & VK_SAMPLE_COUNT_8_BIT) {
std::cout << "Selected: 8x MSAA" << std::endl;
return VK_SAMPLE_COUNT_8_BIT;
return VK_SAMPLE_COUNT_8_BIT;
}
if (counts & VK_SAMPLE_COUNT_4_BIT) {
if (counts & VK_SAMPLE_COUNT_4_BIT) {
std::cout << "Selected: 4x MSAA" << std::endl;
return VK_SAMPLE_COUNT_4_BIT;
return VK_SAMPLE_COUNT_4_BIT;
}
if (counts & VK_SAMPLE_COUNT_2_BIT) {
if (counts & VK_SAMPLE_COUNT_2_BIT) {
std::cout << "Selected: 2x MSAA" << std::endl;
return VK_SAMPLE_COUNT_2_BIT;
return VK_SAMPLE_COUNT_2_BIT;
}
std::cout << "No MSAA support available" << std::endl;
@ -377,7 +377,7 @@ void VulkanRenderer::cleanup()
if (m_backgroundVertexMemory) vkFreeMemory(m_device, m_backgroundVertexMemory, nullptr);
if (m_backgroundIndexBuffer) vkDestroyBuffer(m_device, m_backgroundIndexBuffer, nullptr);
if (m_backgroundIndexMemory) vkFreeMemory(m_device, m_backgroundIndexMemory, nullptr);
if (m_textVertexBuffer) vkDestroyBuffer(m_device, m_textVertexBuffer, nullptr);
if (m_textVertexMemory) vkFreeMemory(m_device, m_textVertexMemory, nullptr);
if (m_textIndexBuffer) vkDestroyBuffer(m_device, m_textIndexBuffer, nullptr);
@ -530,13 +530,13 @@ void VulkanRenderer::recordCommandBuffer(VkCommandBuffer commandBuffer,
logError("Failed to create dynamic wave index buffer");
return;
}
std::cout << "Dynamic geometry buffers created (host-visible, no staging)" << std::endl;
}
// 直接更新 buffer 内容(通过内存映射,无需命令队列)
if (!circleVertices.empty() && !circleIndices.empty()) {
updateDynamicBuffer(m_circleVertexMemory, circleVertices.data(),
updateDynamicBuffer(m_circleVertexMemory, circleVertices.data(),
sizeof(Vertex) * circleVertices.size());
updateDynamicBuffer(m_circleIndexMemory, circleIndices.data(),
sizeof(uint16_t) * circleIndices.size());
@ -1849,7 +1849,7 @@ bool VulkanRenderer::createIndexBuffer(const std::vector<uint16_t>& indices,
bool VulkanRenderer::createDynamicVertexBuffer(uint64_t size, VkBuffer& buffer, VkDeviceMemory& memory)
{
// 创建 host-visible 的 vertex buffer可以直接映射更新无需 staging buffer
return createBuffer(size,
return createBuffer(size,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
buffer, memory);
@ -1925,7 +1925,7 @@ bool VulkanRenderer::copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, uint64_t
// vkDeviceWaitIdle 在三缓冲场景下会导致等待失败
// 因为双缓冲的 fence 机制只能确保 2 帧的同步
// Create a one-time command pool if not exists
if (m_transferCommandPool == VK_NULL_HANDLE) {
VkCommandPoolCreateInfo poolInfo = {};
@ -2651,11 +2651,6 @@ void VulkanRenderer::drawText(VkCommandBuffer commandBuffer, int frameCount,
bool paintingEnabled, const std::string& lockInfo)
{
static int textDebugCounter = 0;
if (textDebugCounter++ % 300 == 0) { // Every ~5 seconds at 60fps
std::cout << "drawText called: charMap=" << m_charInfoMap.size()
<< " pipeline=" << (m_textPipeline != VK_NULL_HANDLE ? "OK" : "NULL")
<< " fontTexView=" << (m_fontTextureView != VK_NULL_HANDLE ? "OK" : "NULL") << std::endl;
}
if (m_charInfoMap.empty() || m_textPipeline == VK_NULL_HANDLE) {
if (textDebugCounter % 300 == 1) {
@ -2664,8 +2659,6 @@ void VulkanRenderer::drawText(VkCommandBuffer commandBuffer, int frameCount,
return; // Text rendering not available
}
// 使用 host-visible buffers 后,每帧更新成本很低(只是 memcpy无需缓存
// Bind text pipeline
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_textPipeline);
@ -2781,22 +2774,11 @@ void VulkanRenderer::drawText(VkCommandBuffer commandBuffer, int frameCount,
return;
}
if (textDebugCounter % 300 == 1) {
std::cout << "Drawing text with " << vertices.size() << " vertices, "
<< indices.size() << " indices" << std::endl;
std::cout << "Window size: " << m_width << "x" << m_height << std::endl;
if (!vertices.empty()) {
std::cout << "First vertex pos: (" << vertices[0].pos[0] << ", " << vertices[0].pos[1] << ")" << std::endl;
std::cout << "First vertex color: (" << vertices[0].color[0] << ", " << vertices[0].color[1]
<< ", " << vertices[0].color[2] << ", " << vertices[0].color[3] << ")" << std::endl;
}
}
// 首次创建 text buffers使用 host-visible 内存)
if (m_textVertexBuffer == VK_NULL_HANDLE) {
VkDeviceSize textVertexSize = sizeof(Vertex) * 4096; // 预分配足够空间
VkDeviceSize textIndexSize = sizeof(uint16_t) * 6144;
if (!createDynamicVertexBuffer(textVertexSize, m_textVertexBuffer, m_textVertexMemory)) {
logError("Failed to create dynamic text vertex buffer");
return;
@ -2809,14 +2791,14 @@ void VulkanRenderer::drawText(VkCommandBuffer commandBuffer, int frameCount,
m_textVertexMemory = VK_NULL_HANDLE;
return;
}
std::cout << "Dynamic text buffers created (host-visible, no staging)" << std::endl;
}
// 每帧直接更新 buffer 内容(通过内存映射,无需命令队列)
// 使用 host-visible buffers 后,更新成本极低,无需缓存
if (!vertices.empty() && !indices.empty()) {
if (!updateDynamicBuffer(m_textVertexMemory, vertices.data(),
if (!updateDynamicBuffer(m_textVertexMemory, vertices.data(),
sizeof(Vertex) * vertices.size())) {
logError("Failed to update text vertex buffer");
return;