University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 4
- Ricky Rajani
- Tested on: Windows 7, i7-6700 @ 3.40GHz 16GB, NVIDIA Quadro K620 (Moore 100C Lab)
This project implements a simplified rasterized graphics pipeline, similar to the OpenGL pipeline, using CUDA.
- Vertex assembly
- Vertex shading
- Primitive assembly
- Depth test
- Rasterization
- Race avoidance using atomic function
- Fragment shading with lambertian shading
- Framebuffer
- Support for rasterizing additional primitives: lines and points
- UV texture mapping with bilinear texture filtering and perspective correct texture coordinates
These flags can be found at the top of rasterize.cu
LIGHTING
- Enables lambertian shadingTEXTURE
- Enables UV texture mapping, models are white by defaultBILINEAR
- Enables bilinear texture filtering whenTEXTURE
is enabledPERSPECTIVE
- Enables perspective correction whenTEXTURE
is enabledPOINTS
- Enables points instead of triangle primitivesPOINTCLOUD
- Sparsity of pointsLINE
- Enables lines instead of triangle primitives
Cow | Duck |
---|---|
Engine | Truck |
---|---|
Duck | Cow |
---|---|
Duck | Cow | Truck |
---|---|---|
The points have a step size of 50, so it is understandable that there is not as great a performance hit when using point primitives as it requires less iterations than using line primitives.
Duck | Truck |
---|---|
Checkerboard | Checkerboard with Bilinear Filtering | Checkerboard with Perspective Correction |
---|---|---|
Bilinear filtering is an antialiasing technique which creates smoother edges on the checkerboard compared to UV texture mapping without the filtering. In this method the four nearest texels to the pixel center are sampled, and their colors are combined by weighted average according to distance. This removes the 'blockiness' seen during magnification, as there is now a smooth gradient of color change from one texel to the next. After profiling kernTextureMap
when biliniear texture filtering is turned off and on, it seems that there is a performance hit. Without the filtering the kernel takes 0.88 ms for each iteration and 1.02 ms with filtering.
The perspective correction fixed the distortion that was occuring. As can be seen from the charts below, it greatly reduced the FPS causing a non-trivial performance hit. Likewise, the same occurs with bilinear texture filtering, but the performance hit is not as great as perspective correction.
It is important to note that the number of primitives in a scene does not have a direct effect on the time spent in each pipeline stage, specifically the rasterization stage which consumes the most amount of time. Examining the charts above with various scenes, the cow has over 5000 primitives and the rasterization stage takes a third of the total time, whereas the box only has 12 primitives but the rasterization stage takes up most of the total time. An explanation for this could be the size of the primitives. Each kernel iterates through an entire bounding box; therefore, if a primitive has a large size then its bounding box will be bigger and there is more work each kernel must do during each iteration. This may lead to a considerable performance hit.
*CMakeLists modified to include 'common.h' for recording performance time