Monday 30 May 2011

BASIC VFP and a decision on OpenGL

The re-write of TAG as TAG32 continues.   Having completed a load of code relating to the structure of everything, we move on to the 3D library.    There are two options on the table:
1) Write a new version of the TAG calculation and rendering code based on VFPv3 and SIMD.   This will bring maximum performance.   All the various methods would be exposed through the TAG32 SWI calls.  This method fits with the RISC OS legacy in that there is assembler code at the core of the operating system.  The down-side is a lack of standards implementation, making it RISC OS only code.   That said the Windows/Airplay version of TAG wouldn't require this code, so it's not necessarily that much of a limitation.

2) Use OpenGL as the 3D library.  This requires reviving the port of Mesa, and may open up hardware acceleration in the future. While this is an attractive option in many ways, the problem is a lack of performance.   In order to squeeze high quality 3D graphics in a higher resolutions and colour depths out of the Cortex A8 it is essential to optimise the code.  The Mesa code from the old RISC OS port is C code full of floating point and non-optimised functions and methods.

For now I've started work on adding VFPv3 and SIMD into the BASIC assembler.   The ARM 'ARM' manual is a bit tricky to read, but after a couple of days of studying I now understand VFPv3 and at least some of the ideas behind SIMD.

The first version is a BASIC library which implements FNvfp("instruction") to assemble the instruction.  All of the logic is based on lookup tables and a small amount of string processing code so it can be incorporated into the BASIC source in assembler at a later date.    It uses EVAL so that expressions can be used with variables as with other instructions.

So far I've tested VMOV, VCVT, VSQRT, VDIV, and VMRS/VMSR and it works very nicely.

The VFPSupport module in RISC OS 5.17 is used to first make a context and enable VFP/SIMD operation as it's switched off by default.

I hope to put up a getting started with VFPv3 post in due course once I've completed work on the library and carried out some more testing.