Creating Textures using PVRUtilsVk#
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));
Create the memory objects such as buffers, images and samplers.
Get streams to the texture data on disk:
getAssetStream(…):To access CPU-side texture data, load the images into
pvr::assets::Textureobjects usingpvr::assets::textureLoad(), then upload them to the GPU aspvrvk::Imageandpvrvk::ImageViewusingpvr::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.