OpenGLES On the Pandora

From Pandora Wiki
Jump to: navigation, search

Contents

Introduction

(This is a W.I.P.)

For those coming from GP2X/GP32 development, the prospect of access to 3D accelerator hardware is an appealing one, but it may not be clear how to get started. This page collects information about the capabilities, tools, and processes that a programmer needs to understand or use when working with this shiny new feature.

Reference and learning material

Books

  • OpenGL ES 2.0 Programming Guide (OpenGL) (NB - Amazon.co.uk link) - This is a great book, very much like the defacto stadard text for OpenGL - the Red Book - I highly recommend this if you are serious about it. (£34+)

Online

Tools

(See also Development_Tools)

First, you will need to be able to test and run your programs on your development machine. For this you will need an OpenGL ES emulator and the OpenGL ES SDK. Note that to run the emulator on your machine, you need an OpenGL 2.0 compliant graphics card, any nVidia 6XXX+ or ATi 95XX+ should work. BUT you do not need any special graphics hardware if you only want to compile an application on your PC, and test it on the Pandora.

  • OpenGL ES 2.0 SDK for PC[1] This works both on Linux and Windows. You will need to register with imgtec before downloading.

Running an OpenGL ES application on your PC is not as simple as just downloading the SDK, building some demos, and running them. To run the demo applications, you will need to set a few environment variables so that your system can find the necessary libraries. Or, you can add the libraries to your system path as appropriate.

Directions for the linux version of the SDK - tested on Ubuntu Gutsy:

  • LD_LIBRARY_PATH needs to be set to the SDK folder containing the OpenGL ES libraries such as libEGL.so. ($SDK_PATH/Builds/OGLES2/LinuxPC/Lib should work)
  • To run the makefiles in the Training section you need to set a PLATFORM variable to either LinuxPC or LinuxGeneric. I have had success with LinuxPC.
  • See [2] for a script that you can run to set these for you.
  • If you are not afraid to use the commandline, try "export LD_LIBRARY_PATH=$SDK_PATH/Builds/OGLES2/LinuxPC/Lib" and "export PLATFORM=LinuxPC", where $SDK_PATH is the path of the unpacked SDK, such as "/home/username/OGLES_SDK/".

Directions for the Windows version of the SDK - tested on Windows Vista with Visual C++ Express Edition [3] :

  • The SDK works almost out of the box, with some minor modifications. The default configuration on VC++ works if you just want to compile. To actually run the code or debug it, you need to link VC++ with the PowerVR OGL ES emulation libraries. This can be done in two different ways:
    • By adding the path to the libraries in VC++. Go to (Tools > Options > Projects and solutions > VC++ Directories). Choose Library files in the drop-down menu labeled as Show directories for: and add the path to the libraries (SDKPackage\Builds\OGLES2\WindowsPC\Lib by default)
    • By copying the files in the (SDKPackage\Builds\OGLES2\WindowsPC\Lib) folder (libEGL.dll, libEGLv2.dll, etc) and pasting them in the Windows folder, which is already a default path in VC++. This method is preferred, since all the executables and projects that came with the SDK were programmed to find the DLL's in the folders that are configured by the default VC++ configuration.
  • Note that the projects included in the SDK were programmed in an older version of the VC++ IDE and need conversion if you are using the express edition. [4] This procedure is almost automatic and should not cause any problems. [5]
  • GLUT|ES

Pandora 3D acceleration capabilities (PowerVR SGX)

This is based on the specification of the OMAP 35xx chip found at [6]:

The main points of interest from the below list are:

  • OpenGL-ES 1.1 and 2.0
  • OpenVG 1.0.1 support
  • Bilinear, trilinear, and anisotropic texture filtering
  • Nonsquare textures
  • 2048 by 2048 maximum texture / framebuffer size
  • 4x multisampling
  • 16x full scene anti-aliasing
  • Multithreaded shader engine with 16 simultaneous threads of execution and up to 64 simultaneous data instances.

Full feature list:

  • PowerVR SGX Main Features
    • 2D graphics, 3D graphics, vector graphics, and programmable GPU functions
    • Tile-based architecture
    • Universal scalable shader engine (USSE) – multithreaded engine incorporating vertex shader and fragment shader functionality
    • Advanced shader feature set – in excess of Microsoft VS3.0, PS3.0, and OGL2.0
    • Industry standard API support - OpenGL-ES 1.1 and 2.0, OpenVG 1.0.1
    • Fine-grained task switching, load balancing, and power management
    • Advanced geometry direct memory access (DMA) driven operation for minimum CPU interaction
    • Programmable high-quality image anti-aliasing
    • PowerVR SGX core MMU for address translation from the core virtual address to the external physical address (up to 4GB address range)
    • Fully virtualized memory addressing for OS operation in a unified memory architecture
    • 2D operations via the 3D pipeline
  • SGX 3D features
    • Deferred pixel shading
    • On-chip tile floating point depth buffer
    • 8-bit stencil with on-chip tile stencil buffer
    • 8 parallel depth/stencil tests per clock
    • Scissor test
    • Texture support:
      • Cube map
      • Projected textures
      • 2D textures
      • nonsquare textures
    • Texture formats:
      • RGBA 8888,565,1555
      • Monochromatic 8, 16, 16f, 32f, 32int
      • Dual channel, 8:8, 16:16, 16f:16f
      • Compressed textures PVR-TC1, PVR-TC2, ETC1
      • Programmable support for all YUV formats
    • Resolution support:
      • Frame buffer maximum size = 2048 x 2048
      • Texture maximum size = 2048 x 2048
    • Texture filtering:
      • Bilinear, tri-linear, anisotropic
      • Independent minimum and maximum control
    • Anti-aliasing:
      • 4x multisampling
      • Up to 16x full scene anti-aliasing
      • Programmable sample positions
    • Indexed primitive list support
      • Bus mastered
    • Programmable vertex DMA
    • Render to texture:
      • Including twiddled formats
      • Auto MipMap generation
    • Multiple on-chip render targets (MRT). Note: Performance is limited when the on-chip memory is not available.
  • Universal Scalable Shader Engine – Key Features - The (USSE) is the engine core of the PowerVR SGX architecture and supports a broad range of instructions.
    • Single programming model:
      • Multithreaded with 16 simultaneous execution threads and up to 64 simultaneous data instances
      • Zero-cost swapping in, and out, of threads
      • Cached program execution model
      • Dedicated pixel processing instructions
      • Dedicated video encode/decode instructions
    • SIMD execution unit supporting operations in:
      • 32-bit IEEE-compliant float
      • 2-way 16-bit fixed point
      • 4-way 8-bit integer
      • 32-bit bit-wise (logical only)
    • Static and dynamic flow control:
      • Subroutine calls
      • Loops
      • Conditional branches
      • Zero-cost instruction predication
    • Procedural geometry:
      • Allows generation of primitives
      • Effective geometry compression
      • High-order surface support
    • External data access:
      • Permits reads from main memory using cache
      • Permits writes to main memory
      • Data fence facility
      • Dependent texture reads

Compressing textures

ImgTec also supplies a tool that allows you to compress your textures to a format the OMAP chip natively supports, such as PVR-TC1, PVR-TC2 (PowerVR tex compression formats) and ETC1 (an Ericsson format)

This toolset comes in a variety of flavors, including a stand-alone GUI, a commandline tool, and plugins for Photoshop, Maya, and 3DS-Max. The tool is already included in the emulator+SDK package, but it is available separately at this page:

  • PowerVR Texture creation tool - "PVRTexTool enables conversion of standard bitmap files (e.g. BMP, JPG, PNG, TGA, etc.) to any texture type supported by POWERVR MBX or POWERVR SGX hardware including PVRTC, DXT and ETC compressed formats. Both a GUI and command line version are supplied for Windows and Linux. There are also plug-ins for Autodesk 3ds Max, Maya and Adobe Photoshop." - requires imgtec registration.
Personal tools
community