Sorting Objects and Geometry on PowerVR Hardware

Share on linkedin
Share on twitter
Share on facebook
Share on reddit
Share on digg
Share on email

It can be tough trying to figure out the best way to optimise your applications during development. Luckily, we’re here to help – this is the first of an ongoing series of blog posts highlighting useful tips and tricks from our brand-new documentation website. Today, we’re looking at effectively sorting objects and geometry on PowerVR hardware from our revised and updated PowerVR Performance Recommendations. This document is packed with useful information that will help you squeeze the most out of graphics applications running on PowerVR hardware.

Opaque objects

As a rule, for opaque objects on PowerVR hardware, it is best to not sort draw calls based on the depth of the object in the scene. This is because, with deferred rendering systems, like PowerVR’s TBDR (tile-based deferred rendering) architecture, all the draw calls which affect a particular frame buffer are captured upfront, before beginning the render. This means the GPU will have a complete picture of all the geometry in the scene and can decide which bits can be discarded. This is different from immediate mode rendering (IMR) where all objects are shaded and textured regardless of visibility.

PowerVR has dedicated hardware for Hidden Surface Removal (HSR) which tests whether particular fragments are occluded based on their depth, and then only stores the visible ones. This means HSR cuts down on the amount of overdraw in a scene, helping to improve your application’s performance. It’s clear then that there’s not really any point trying to sort opaque geometry because the PowerVR GPU does all of this work for you. It just ends up being a waste of valuable resources!

HSR also avoids having to implement techniques like depth pre-pass, where an additional pass is used to fill a depth buffer with the depth value of the nearest opaque object at each pixel. On the next pass, these depth values are used to determine which fragments are visible and then remove the occluded ones, which is exactly what HSR does anyway, at the cost of extra clock cycles and memory bandwidth. To re-iterate: let HSR do its job!

With HSR still requires sorting objects and geometry in PowerVR
PowerVR Hidden Surface Removal means you don’t have to do a depth pre-pass, but sorting is still necessary for alpha-blended objects.

Alpha-blended objects

The story for sorting objects and geometry in PowerVR is slightly different for objects with transparency. Fragments which are occluded by partially transparent objects can still impact the final rendered image, as the colours of the foreground and background fragments need to be blended to produce the final fragment colour. This means that these partially-occluded fragments can’t simply be discarded by the HSR hardware, eliminating one of the key benefits of deferred rendering and likely resulting in some amount of overdraw. This is why our general advice is to keep the number of alpha-blended objects in a scene to a minimum.

If a scene must contain opaque, alpha-blended, and alpha-tested objects, then the application should sort and then render these objects in the order shown below:

  1. opaque (first)
  2. alpha-blended
  3. alpha-tested (last)

This ensures all objects will appear as expected.

Other methods of sorting objects and geometry in PowerVR

While sorting objects and geometry based on depth usually isn’t a good idea with PowerVR hardware, it is really important to try to sort objects with render state in mind. This means grouping based on shared resources such as materials or shaders. This helps to reduce CPU workload by minimising the number of state changes which need to be made by the driver during rendering.

Finally, when using OpenGL ES™ you can get significant performance benefits by sorting draw calls based on the frame buffer object (FBO). FBOs can contain several attachments in the form of textures which can be rendered into. We recommend submitting all the draw calls associated with the textures of a particular FBO, before moving on to the next one. This means that the FBOs are rendered in series, eliminating the extra bandwidth usage caused by storing and retrieving partially rendered FBOs from system memory.

Vertex Sorting

Sometimes sorting the render order isn’t quite enough . In cases where the application is rendering a large number of vertices, such as automotive displays (millions of triangles!), performance can really suffer if vertex data is stored sub-optimally. You need to ensure the vertex buffers are storing the data in a cache efficient way. This basically means trying to reorder the vertices to improve spatial locality, so the application doesn’t have to bounce around memory quite so much.

Luckily for you, sorting vertex data is really simple using PVRGeoPOD. This tool can be set to automatically sort mesh data when exporting a model to the POD file format. If you want to work with individual meshes the PVRGeoPOD GUI is simple, easy to use, and can be integrated with popular 3D graphics software, such as Autodesk 3ds Max and Blender. Or, if you want to churn through many meshes, there is also a command-line application which can be used for batch processing.

Want to hear more?

For more PowerVR performance recommendations and other information, please visit our website at docs.imgtec.com. It is regularly updated with new documents and features including Getting Started tutorials for Vulkan and OpenGL ES, optimisations and recommendations for PowerVR hardware, and guides to new graphics techniques.

Please do feel free to leave feedback through our usual forums or ticketing systems.

Follow @tom_devtech on Twitter for Developer Technology-related news, or @powervrinsider for the latest on PowerVR!

Benjamin Anuworakarn

Benjamin Anuworakarn

Ben Anuworakarn is a technical author in the PowerVR Developer Technology team and has a computer science engineering background. Primarily responsible for producing and maintaining both internal and external documentation, he has a knack for coming up with solutions to problems that don't exist yet. You can find him either clacking away at his keyboard or shuffling trading cards every few hours.

Please leave a comment below

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted. We respect your privacy and will not publish your personal details.

Blog Contact

If you have any enquiries regarding any of our blog posts, please contact:

United Kingdom

benny.har-even@imgtec.com
Tel: +44 (0)1923 260 511

Search by Tag

Search by Author

Related blog articles

Beaglebone Black

Fun with PowerVR and the BeagleBone Black: Low-Cost Development Made Easy

Development boards are cool and the BeagleBone® Black (BBB) is one of the more interesting ones around. This widely available tiny board costs around £35 and will boot Linux is only 10 seconds so anyone interested in development can get stuck in quickly. The Introduction to Mobile Graphics course has been recently revamped for 2020 for the Imagination’s University Programme and the widely available, low-cost BBB is an ideal platform for student teaching and exercises based on OpenGL® ES2.0, instead of an expensive standard PC.

Read More »
android background

The Android Invasion: Imagination GPU IP buddies up with Google-powered devices

Google Android continues to have the lion share of the mobile market, powering around 75% of all smartphones and tablets, making it the most used operating system in the world. Imagination’s PowerVR architecture-based IP and the Android OS are bedfellows, with a host of devices based on Android coming to market all the time. Here we list a few that have appeared in Q4 2020.

Read More »
pvrtextoolgui sunrise 2

PowerVR SDK and Tools 2020 Release 2 now available

We all know that 2020 has been quite a challenging year, but we hope you’re doing well. Over the last few months, here in DevTec, we’ve been working hard to get this new release out for you and the time has now come for our second release of the PowerVR SDK and Tools of 2020. So, what’s new with this latest release? Let’s take a quick look at a few of the major changes.

Read More »

Connect

Sign up to receive the latest news and product updates from Imagination straight to your inbox.