What is PVRUtils?

PVRUtils works directly with the rendering API by providing tools to simplify boilerplate API code

About PVRUtils

PVRUtils is another central part of developer-facing Framework code. Where PVRShell abstracts and provides the platform, PVRUtils provides tools and facilitates working with the rendering API, by automating and assisting with common initialisation and rendering tasks.

It provides higher level utilities and helpers for tedious tasks such as context creation, vertex configuration based on models, and texture loading. These extend right up to very high level complex areas like the UIRenderer which is a full-fledged 2D renderer itself, threading, and access to the hardware camera.

There are two versions available covering Vulkan and OpenGL ES:
  1. PVRUtilsVk
  2. PVRUtilsGles
They provide a similar but not identical API, as they have several key differences which allow them to be better optimised for their underlying API.

PVRUtils Features

The most typical functionality in PVRUtils (either version) is boilerplate removal. Tasks such as creating contexts, surfaces, queues, and devices can be reduced to one line of code. There is also support for creating VBOs from a model, uploading textures to the GPU, and much more.

For Vulkan, this reduces the usually hundreds of lines of code to create physical devices, surfaces, devices, queues, and backbuffers to around ten lines. Loading textures or buffers with an allocator becomes a single line for each.

For both OpenGL ES and Vulkan, StructuredBufferView is a very important and incredibly useful tool, as it is used to determine the shader std140 layout of buffers. It makes mapping and setting members straightforward, eliminating complicated packing/padding calculations.

PVRUtils also contains the UIRenderer. This is a very powerful library, which provides the capability of rendering 2D objects in a 2D or 3D environment, especially text and images. For text rendering, font textures can be generated in a few seconds with PVRTexTool. An Arial font is provided and loaded by default.

Several methods of layout and positioning are provided, such as:

  • anchoring
  • custom matrices
  • hierarchical grouping with inherited transformations.

Other functionality provided by PVRUtils includes:

  • Asynchronous operations via a texture loading class that loads textures in the background
  • The Vulkan RenderManager. This is a class that can completely automate rendering by using the PowerVR POD and PFX formats for a complete scene description.

How to use PVRUtils

PVRUtilsVk is built on top of PVRVk, and PVRUtilsGles is built on top of raw OpenGL ES 2.0+. The main header files of PVRUtilsVk and PVRUtilsGles need to be included with #include “PVRUtils/PVRUtilsVk.h” or #include “PVRUtils/PVRUtilsGles.h” respectively. The topic Using UIRenderer explains how to do this.

Almost all the SDK examples use PVRUtils for some kinds of tasks. They use UIRenderer to display titles and logos. The exceptions are HelloAPI, IntroducingPVRShell and IntroducingPVRVk.

IntroducingUIRenderer and ExampleUI are both examples of more complex UIRenderer usage. Multithreading showcases the Asynchronous API for Vulkan.