So I've written a GPU based pathtracer using OpenCL-GL interoperability. The system uses the Mega-Kernel Approach instead of a wavefront one as I was aiming it as an educational software for other young people who wanted to dive into raytracing/pathtracing but didn't want to mess with all the boilerplate code (opening windows, getting opengl context, etc) similar to coding it on shadertoy but with the added feature of loading models, having other benchmarking facilities etc.
I basically spawn as many work-items as there are pixels. Then each work-item shoots a single ray through that pixel and calculates the color. Currently on my GTX 1660, rendering around 5-6k Triangles give only 5-10 fps in 1280x720 resolution. I suppose its fairly slow even though I implemented a SAH based BVH and Möller–Trumbore ray-triangle intersection. Hence one big problem is that since the kernel takes too much time, loading big models causes a timeout error. I've already extended the timeout delay through the registery. In order to avoid it, I've also currently broken the image into 4 blocks and passed 4 mega kernels to do the job. This reduces the time of a single kernel, nevertheless the problem still remains.
I've looked into the paper for Brigade renderer which is a realtime GPU pathtracer but couldn't understand what approach they followed. According to the text, they are talking about a single kernel per pixel,
The path tracing algorithm can be efficiently implemented as on the GPU, using a single kernel per pixel. The kernel loops over the samples for a pixel and outputs the final color. This limits memory access to read-only scene access and a single write for the final pixel color.
However the looping part is strange. If there is supposed to be a single kernel launched for every pixel, then the global work items or the threads must be the samples for that pixel. Why are they looping over the samples inside the kernel?
Secondly, I've also found sources that suggest that Brigade, infact used the wavefront approach?
I also realize the old Brigade demos are done with either a single or dual Titan X but the difference isn't that great. I admit I haven't taken cache coherency and such things into account but these are hard to do with the mega-kernel approach anyway. So in short the main crux of what I want to know is, Is the megakernel approach bound to give this FPS OR Am I doing something wrong here? Any tips on how I can improve the FPS for my mega-kernel pathtracer would be appreciated. Link to the kernel.