Creating Buffers in initView using PVRUtilsVk#

  1. Use the shortcut utilities pvr::createBuffer() for creating UBOs or SSBOs.

    ubo = pvr::utils::createBuffer(device, uboView.getSize(), pvrvk::BufferUsageFlags::e_UNIFORM_BUFFER_BIT, pvrvk::MemoryPropertyFlags::e_HOST_VISIBLE_BIT,
                            pvrvk::MemoryPropertyFlags::e_HOST_COHERENT_BIT |
                            pvrvk::MemoryPropertyFlags::e_DEVICE_LOCAL_BIT, &allocator);
    
  2. Connect the StructuredBufferView to the actual buffer with StructuredBufferView->pointToMappedMemory().

    To automatically layout buffers that will have a shader representation (UBOs or SSBOs), use StructuredBufferView. This is an incredibly useful class. The UBO/SSBO configuration needs to be described, and it will then automatically calculate all sizes and offsets based on STD140 rules. This includes array members, nested structs, and so on, automatically making it possible to both determine size, and set individual elements or block values.

    uboView.pointToMappedMemory(ubo->getDeviceMemory()->getMappedData());