Creating Textures using PVRUtilsVk#

  1. Create a Vulkan Memory Allocator: pvr::utils::vma::createAllocator(…). Use it for all memory objects by passing it as a parameter to all the functions that support it.

    _deviceResources->vmaAllocator =
                    pvr::utils::vma::createAllocator(pvr::utils::vma::AllocatorCreateInfo(
                                                                   _deviceResources->device));
    
  2. Create the memory objects such as buffers, images and samplers.

  3. Get streams to the texture data on disk: getAssetStream(…):

    • To access CPU-side texture data, load the images into pvr::assets::Texture objects using pvr::assets::textureLoad(), then upload them to the GPU as pvrvk::Image and pvrvk::ImageView using pvr::utils::uploadImageAndView.

    • Otherwise, merge the two steps using pvr::utils::loadAndUploadImageAndView.

    pvr::Stream::ptr_type stream = assetProvider.getAssetStream(model->getTexture(i).getName());
    pvr::Texture tex = pvr::textureLoad(stream, pvr::TextureFileFormat::PVR);
    images.push_back(pvr::utils::uploadImageAndView(device, tex, true, uploadCmdBuffer, pvrvk::ImageUsageFlags::e_SAMPLED_BIT,
    pvrvk::ImageLayout::e_SHADER_READ_ONLY_OPTIMAL, &allocator, &allocator, pvr::utils::vma::AllocationCreateFlags::e_DEDICATED_MEMORY_BIT));
    

For a proper method to do this asynchronously in a multithreaded environment, see the Multithreading example.