Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. VULKAN Staging buffer example

VULKAN Staging buffer example

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 1 Posters 673 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    glararan
    wrote on last edited by
    #1

    Hi,

    I would like to use staging buffer to get better performance. My intent is to render terrain. My issue is that I dont see rendered vertices using indices method.

    I use this hierarchy

    • MainWindow : QMainWindow
      • MapView : QVulkanWindow
        • MapViewRenderer : QVulkanWindowRenderer
          • World
            • MapTile (here I perform draw calls for terrain rendering)

    For now I use this code to create Vertex & Indices buffer via Staging buffers

            VK_CHECK_RESULT(vkManager.createBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, vertexBufferSize, &vertexStaging.buffer, &vertexStaging.memory, verticesList.data()));
            VK_CHECK_RESULT(vkManager.createBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, indexBufferSize, &indexStaging.buffer, &indexStaging.memory, indices.data()));
    	VK_CHECK_RESULT(vkManager.createBuffer(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, vertexBufferSize, &model.vertices.buffer, &model.vertices.memory));
    	VK_CHECK_RESULT(vkManager.createBuffer(VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, indexBufferSize, &model.indices.buffer, &model.indices.memory));
    
    	// Copy from staging buffers
            VkCommandBuffer copyCommandBuffer = vkManager.createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
    
    	VkBufferCopy copyRegion = {};
    
    	copyRegion.size = vertexBufferSize;
    
    	vkManager.deviceFuncs->vkCmdCopyBuffer(copyCommandBuffer, vertexStaging.buffer, model.vertices.buffer, 1, &copyRegion);
    
    	copyRegion.size = indexBufferSize;
    
    	vkManager.deviceFuncs->vkCmdCopyBuffer(copyCommandBuffer, indexStaging.buffer, model.indices.buffer, 1, &copyRegion);
    
        vkManager.flushCommandBuffer(copyCommandBuffer, true);
    

    I am creating my own Command Buffer but I dont know if that's correct design for QVulkanWindowRenderer. In all examples I dont see own command buffer creation. Should I use QVulkanWindow currentCommandBuffer() ? I couldn't find any github project using Qt 5.11 with Vulkan :/

    Source code is available here

    1 Reply Last reply
    0
    • G Offline
      G Offline
      glararan
      wrote on last edited by
      #2

      Now I am getting

      QVulkanWindow: Device lost
      qt.vulkan: Releasing all resources due to device lost
      qt.vulkan: Releasing swapchain
      

      What could lead to this? If I comment out this code it works.

      deviceFuncs->vkCmdDrawIndexed(commandBuffer, model.indexCount, 1, 0, 0, 0);
      

      Can I somehow enable logging? Or debug it, why it crash?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        glararan
        wrote on last edited by
        #3

        I found solution.. I was setting wrong
        VkPipelineMultisampleStateCreateInfo instead QVulkanWindow::getSampleCountFlagBits() I used VK_SAMPLE_COUNT_1_BIT

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved