fix validation no print

ink-soul 2024-04-15 15:55:08 +08:00
parent 5c80c2b603
commit 98a8b2c715
2 changed files with 15 additions and 16 deletions

View File

@ -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 = {};

View File

@ -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;