Imagination PowerVR SDK Blog

Simple C++ sample code for PVRTC compression?

pvrtextool

#1

PVR newbie here: Can anyone point me to C++ sample code for PVRTC compression?

I’ve just downloaded the sdk, successfully built and run the example projects (OS X) and have been browsing the FAQs, Forum, and documentation. The closest I’ve come is this: https://www.imgcommunity.local/forums/topic/switch-png-to-pvr-with-pvrtextool-in-c/

(and similar snippets elsewhere)

However, the snippet doesn’t show which headers I need, and searching on namespace “pvrtexture”, class “CPVRTextureHeader”, and method “Transcode” (all seen in the referenced code snippet) all turn up zero results when I search on the example projects or simply search the SDK install directory.

Any help getting initial setup appreciated.


#2

Hi,

the PVRTC source code is not open source/public.
There is a public whitepaper available about it: http://cdn.imgtec.com/sdk-documentation/PVR+Texture+Compression.Whitepaper.pdf
Otherwise you can just use the PVRTexTool (gui or command line) from the PVR SDK: https://www.imgcommunity.local/developers/powervr/installers/

bests,
Marton Tamas


#3

Hi B,

The SDK source does not contain code to create/compress textures, only code to load them up and push them to the graphics APIs.

What you are looking for is PVRTexTool. This is made up of a GUI tool, a command line tool, a dynamic/shared library and plugins for various applications such as Photoshop.

Install PVRTexTool, as Marton mentioned, and use the headers in PVRTexTool/Library/Include together with the library PVRTexTool/Library/OSX_x86/libPVRTexLib.dylib.

Let us know if you need any further help.

Lawrence


#4

All mobile texture formats are released with reference implementations for encoding and decoding with the exception of PVRTC. There are reasonable use cases for doing offline and online compilation of textures, and the various GPU drivers don’t offer calls to do this through the APIs.

Providing an offline tool doesn’t work for online texture compression. And the paper isn’t clear as to the implementation of sampling from the low and high-res textures. I’m sure there’s open source for PVRTC, but it would have been good to share this from the beginning.


#5

The IMG compressor may not be available in source form, but if you want to understand the decompression process, including how the sampling is done, the PowerVR SDK appears to include source for PVRTC1 in
Framework/PVRCore/Texture/PVRTDecompress.cpp

(By “appears”, I mean that this SDK code differs from the original decompression code which was written in C in a pixel-by-pixel form and so not terribly efficient for production use)


#6

Yes but it’s the encoder that is always the hard part and what you need when you’re starting with any compressed format. Not the decoder. I appreciate the suggestion about understanding the format, but good encoders/decoder source should just release with the hardware. It’s been something like 9 years with nothing released.