Game Designer & Developer

Game Dev

Bachelor's Capstone: GPU Base Rendering API bsc compsci gamedev


For my 4th year project I developed a GPU based rendering API written in OpenCL. Essentially this is a highly parallelised software renderer leveraging the vector processing capabilities of the GPU. For this project I had to develop a new model format (in the same vein of .obj or .fbx but much simpler) for the renderer because it would have taken far too long to write the code to interpret existing formats. With OpenCL what is being written is the kernel that will run on the GPU and because of this there are no libraries available, it has no access to RAM, the hard drive, the OS or anything else regular software does. In essence OpenCL is a high level firmware language because it can only be used to provide an interface to pass a byte stream to and receive output in the form of a byte stream.

My project took the necessary input and created a model of the scene by connecting all of the points according to the connection definition in the format I wrote and representing everything as a series of polygons. Polygons that were completely outside of the cameras field of view were immediately culled by first removing everything behind the camera and then calculating if a polygon had a line passing through the camera’s field of view.

Once this was done the research portion of my project came into play and where normally the scene is projected onto a view plane I instead kept this model and used the pixels of the monitor to ray cast and calculate intersections. This technique is called Image Order rendering which differs from the usual Object Order rendering primarily in that it shifts the predominant costly value from the number of vertices in a scene to the number of pixels on the screen.

In order to efficiently calculate if lines intersected triangles in three dimensional space I need to use techniques such as barycentric coordinates and affine surfaces which I found extremely interesting. As well as having to deal with such advanced and high level mathematical concepts I also had trouble testing the system because an OpenCL kernel is a complete black box. This made ensuring that the code worked very difficult since the only way I could be absolutely certain was to step through the code by hand recording the values on paper, this was even more difficult then it normally is due to the highly parallelised nature.

My research was in the differences and reasons for Object Order versus Image Order. To summarise my conclusions Object Order gives developers more control over the performance of the game since they can just reduce the number of polygons to get more speed. Image Order was intriguing to me in that regardless of how many polygons existed in a scene the performance was increased very little compared to the cost imposed by the pixel count, in other words more objects could be added and the frame rate would stay almost completely constant because the number of vertices needed to produce a noticeable dip in frame rate is considerably high since the number of pixels is extremely high and they have a much higher weighting in how they affect performance.