From 98a8b2c715df4c860813616edd2ad108f870e5f0 Mon Sep 17 00:00:00 2001 From: ink-soul Date: Mon, 15 Apr 2024 15:55:08 +0800 Subject: [PATCH] fix validation no print --- base/VulkanTexture.hpp | 17 +++++++++-------- src/render/render.cpp | 14 ++++++-------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/base/VulkanTexture.hpp b/base/VulkanTexture.hpp index 29b2b5b..bca7d7e 100644 --- a/base/VulkanTexture.hpp +++ b/base/VulkanTexture.hpp @@ -78,8 +78,9 @@ namespace vks VkFormatProperties formatProperties; vkGetPhysicalDeviceFormatProperties(device->physicalDevice, format, &formatProperties); - VkMemoryAllocateInfo memAllocInfo{}; - memAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + + VkMemoryAllocateInfo texMemAllocInfo{}; + texMemAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; VkMemoryRequirements memReqs; // Use a separate command buffer for texture loading @@ -101,11 +102,11 @@ namespace vks // Get memory requirements for the staging buffer (alignment, memory type bits) vkGetBufferMemoryRequirements(device->logicalDevice, stagingBuffer, &memReqs); - memAllocInfo.allocationSize = memReqs.size; + texMemAllocInfo.allocationSize = memReqs.size; // Get memory type index for a host visible buffer - memAllocInfo.memoryTypeIndex = device->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + texMemAllocInfo.memoryTypeIndex = device->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); - VK_CHECK_RESULT(vkAllocateMemory(device->logicalDevice, &memAllocInfo, nullptr, &stagingMemory)); + VK_CHECK_RESULT(vkAllocateMemory(device->logicalDevice, &texMemAllocInfo, nullptr, &stagingMemory)); VK_CHECK_RESULT(vkBindBufferMemory(device->logicalDevice, stagingBuffer, stagingMemory, 0)); // Copy texture data into staging buffer @@ -157,10 +158,10 @@ namespace vks vkGetImageMemoryRequirements(device->logicalDevice, image, &memReqs); - memAllocInfo.allocationSize = memReqs.size; + texMemAllocInfo.allocationSize = memReqs.size; - memAllocInfo.memoryTypeIndex = device->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); - VK_CHECK_RESULT(vkAllocateMemory(device->logicalDevice, &memAllocInfo, nullptr, &deviceMemory)); + texMemAllocInfo.memoryTypeIndex = device->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + VK_CHECK_RESULT(vkAllocateMemory(device->logicalDevice, &texMemAllocInfo, nullptr, &deviceMemory)); VK_CHECK_RESULT(vkBindImageMemory(device->logicalDevice, image, deviceMemory, 0)); VkImageSubresourceRange subresourceRange = {}; diff --git a/src/render/render.cpp b/src/render/render.cpp index 359d1e8..e1e8de6 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -33,9 +33,6 @@ void PlumageRender::initVulkan() setupDebugMessager(); //createSurface(); - - - pickupPhysicalDevice(); createLogicalDevice(); @@ -164,9 +161,10 @@ VKAPI_ATTR VkBool32 VKAPI_CALL PlumageRender::debugMessageCallback(VkDebugReport if (flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) { prefix += "DEBUG:"; } - std::stringstream debugMessage; - debugMessage << prefix << " [" << pLayerPrefix << "] Code " << msgCode << " : " << pMsg; - fflush(stdout); + std::string debugMessage; + std::string msgCodeString = std::to_string(msgCode); + debugMessage = debugMessage + prefix + " [" + pLayerPrefix + "] Code " + msgCodeString + " : " + pMsg; + std::cout << debugMessage << std::endl; return VK_FALSE; } @@ -825,7 +823,7 @@ void PlumageRender::createImageView() memAlloc.allocationSize = 0; memAlloc.memoryTypeIndex = 0; VkMemoryRequirements depthAttachmentMemReqs; - vkGetImageMemoryRequirements(device, depthAttachment.image, &memReqs); + vkGetImageMemoryRequirements(device, depthAttachment.image, &depthAttachmentMemReqs); memAlloc.allocationSize = depthAttachmentMemReqs.size; memAlloc.memoryTypeIndex = getMemoryTypeIndex(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); VK_CHECK_RESULT(vkAllocateMemory(device, &memAlloc, nullptr, &depthAttachment.memory)); @@ -841,7 +839,7 @@ void PlumageRender::createImageView() depthStencilView.image = depthAttachment.image; depthStencilView.flags = 0; depthStencilView.subresourceRange = {}; - depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; + depthStencilView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; if (depthFormat >= VK_FORMAT_D16_UNORM_S8_UINT) { depthStencilView.subresourceRange.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;