Mastering regular expression searches inside PVRTraceGUI

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

As part of our PowerVR SDK v3.3 development, we chose to refine navigation in PVRTraceGUI – our OpenGL ES analysis utility. This work consisted of many minor tweaks to simplify the interface. It also included a bigger change – a brand new search engine. One of the most important features of the new, streamlined Find dialog is its powerful regular expression search engine.


In this blog post, I’ll detail a few tricks I’ve picked so far (despite being a regular expression novice) to significantly speed up my OpenGL ES debugging process.

What are regular expressions?

For those unfamiliar, regular expressions (a.k.a. RegEx) allow explicit definition of search patterns. They’re extremely useful when you want to search for something more specific than a single keyword. Before going any further, it’s worth mentioning that PVRTraceGUI actually supports Extended RegEx. This basically means there are some additional metacharacters to make life easier (this section of the Wikipedia RegEx article explains the differences).

Complex regular expressions can look a little daunting. Appendix A of the PVRTrace User Manual includes a table of all supported metacharacters. For convenience, I’ve included a cheat sheet below. If you can, I’d recommend also trying an online RegEx prototyping tool while reading this (e.g. to help you wrap your head around the basics.

.Matches any single character.
[ ]A bracket expression. Matches a single character that is contained within the brackets.
[^ ]Matches a single character that is not contained within the brackets.
^Matches the starting position within the string.
$Matches the ending position of the string or the position just before a string-ending newline.
( )Defines a marked subexpression.
nMatches what the nth marked subexpression matched, where n is a digit from 1 to 9
*Matches the preceding element zero or more times.
{m,n}Matches the preceding element at least m and not more than n times. For example, a{3,5} matches only “aaa”, “aaaa”, and “aaaaa”.
?Matches the preceding element zero or one time. For example, ab?c matches only “ac” or “abc”.
+Matches the preceding element one or more times. For example, ab+c matches “abc”, “abbc”, “abbbc”, and so on, but not “ac”.
|The choice (also known as alternation or set union) operator matches either the expression before or the expression after the operator. For example, abc|def matches “abc” or “def”.
bMatches a word boundary.

Do the Find dialog’s options affect the search?


Regular expression searches can be used at the same time as the dialog’s other options.

  • “Look in” – Search in the Current Frame, the Whole Trace or a Frame Range. In multi-threaded applications, you can also choose which rendering thread should be searched
  • “Match case” – By default, the search is case-insensitive. Enabling this flag forces all pattern matches to be case-sensitive

How can I use regular expressions?

A very simple use I’ve found is to isolate all occurrences of a specific GL name with a family of calls. For example, the pattern below will find the creation, linking & binding of a particular shader program (135311933).



This pattern uses the ‘.’ metacharacter to capture any character type (a-z, A-Z, 0-9 etc.). The ‘*’ indicates that any number of the previous character should be captured (zero or more). Together, ‘.*’ tells the RegEx engine that we don’t care what characters are between the two search terms. The ‘b’ word boundary metacharacters ensure we match the word exactly and ignore cases where the word is a sub-string of a larger word (e.g. ignore 135311933456). When the expression is executed, PVRTraceGUI’s Search widget will list all matches in call order, grouped by the frame number they occurred in.


From this expression, we can go further and expand the search to include other GL calls that take the program name as an argument.



In this search, the ‘(‘ and ‘)’ brackets are used to define a sub expression. ‘|’ metacharacters indicate an OR operation. It’s possible to include multiple sub-expressions, so we can easily expand this search to include several GL names:



Any more suggestions?

As the search is performed on all textual data captured in the GL and EGL call stream, we can search for any call and/or parameter name. For example, the pattern below finds all compressed ETC2 texture data uploads where the resolution is 512×512, regardless of format (i.e. COMPRESSED_RGB8_ETC2, COMPRESSED_SRGB8_ETC2, COMPRESSED_SRGB8_ALPHA8_ETC2_EAC etc.).

glCompressedTex.*Image.*GL_COMPRESSED_.*ETC2.*b512b, b512b,

This is great! Where can I learn more?

There are countless wikis, blog posts and documents out there that explain clever uses of RegEx patterns to find needles in haystacks. The online tool I mentioned earlier is really useful ( The best thing to do though is capture a PVRT, load it into PVRTraceGUI and start experimenting!

Joe Davis

Joe Davis

Joe Davis leads the PowerVR Graphics developer support team. He and his team support a wide variety of graphics developers including those writing games, middleware, UIs, navigation systems, operating systems and web browsers. Joe regularly attends and presents at developer conferences to help graphics developers get the most out of PowerVR GPUs. You can follow him on Twitter @joedavisdev.

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
Tel: +44 (0)1923 260 511

Search by Tag

Search by Author

Related blog articles

bseries imgic technology

Back in the high-performance game

My first encounter with the PowerVR GPU was helping the then VideoLogic launch boards for Matrox in Europe. Not long after I joined the company, working on the rebrand to Imagination Technologies and promoting both our own VideoLogic-branded boards and those of our partners using ST’s Kyro processors. There were tens of board partners but only for one brief moment did we have two partners in the desktop space: NEC and ST.

Read More »
pvrtune complete

What is PVRTune Complete?

PVR Tune Complete highlights exactly what the application is doing at the GPU level, helping to identify any bottlenecks in the compute stage, the renderer, and the tiler.

Read More »


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