Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-120058

Vulkan memory requirements is NOT satisfied

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2, 6.6.1
    • None
    • All

    Description

       VkMemoryRequirements::memoryTypeBits is IGNORED in "Hello Vulkan Triangle Example" when it invokes vkAllocateMemory function. This may result in validation error, e.g. 

       

      vkDebug: Validation Error: [ VUID-vkBindBufferMemory-memory-01035 ] Object 0: handle = 0xf443490000000006, type = VK_OBJECT_TYPE_DEVICE_MEMORY; | MessageID = 0x1dc7f8e6 | vkBindBufferMemory(): buffer require memoryTypeBits (0xf) but VkDeviceMemory 0xf443490000000006[] was allocated with memoryTypeIndex (7). The Vulkan spec states: memory must have been allocated using one of the memory types allowed in the memoryTypeBits member of the VkMemoryRequirements structure returned from a call to vkGetBufferMemoryRequirements with buffer (https://vulkan.lunarg.com/doc/view/1.3.268.0/windows/1.3-extensions/vkspec.html#VUID-vkBindBufferMemory-memory-01035)

       

      I try to fix it by add a findMemoryType method which takes VkMemoryRequirements::memoryTypeBits as an input argument.

       

       

      uint32_t TriangleRenderer::findMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties) {
          VkPhysicalDeviceMemoryProperties memProperties;
          m_window->vulkanInstance()->functions()->vkGetPhysicalDeviceMemoryProperties(m_window->physicalDevice(), &memProperties);
      
            for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) {
              if ((typeFilter & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & properties) == properties) {
                  return i;
              }
          }    
            
            qFatal("failed to find suitable memory type!");
          return -1;
      } 

       

      And VkMemoryRequirements::memoryTypeBits is used when allocate memory:

      VkMemoryAllocateInfo memAllocInfo = {
              VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
              nullptr,
              memReq.size,
              findMemoryType(memReq.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)
          };    
      
      err = m_devFuncs->vkAllocateMemory(dev, &memAllocInfo, nullptr, &m_bufMem); 

       

      In this way, validation error is fixed.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            yanzhikai Zhikai Yan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes