Giter Club home page Giter Club logo

project4-cuda-rasterizer's Introduction

CUDA Rasterizer

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.

Core Features:

  • Vertex assembly
  • Vertex shading
  • Primitive assembly
  • Depth test
  • Rasterization
  • Race avoidance using atomic function
  • Fragment shading with lambertian shading
  • Framebuffer

Extra Features:

  • Support for rasterizing additional primitives: lines and points
  • UV texture mapping with bilinear texture filtering and perspective correct texture coordinates

Flags:

These flags can be found at the top of rasterize.cu

  • LIGHTING - Enables lambertian shading
  • TEXTURE - Enables UV texture mapping, models are white by default
  • BILINEAR - Enables bilinear texture filtering when TEXTURE is enabled
  • PERSPECTIVE - Enables perspective correction when TEXTURE is enabled
  • POINTS - Enables points instead of triangle primitives
  • POINTCLOUD - Sparsity of points
  • LINE - Enables lines instead of triangle primitives

Samples

Demos of scenes using basic rasterization pipeline using Lambertian shading

Cow Duck
Engine Truck

Demos of scenes using additional primitives

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.

Demos of scenes using UV texture mapping

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.

Performance Analysis

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

Credits

project4-cuda-rasterizer's People

Contributors

shrekshao avatar kainino0x avatar rickyrajani avatar likangning93 avatar pjcozzi avatar ottaviohartman avatar rickyr avatar sarahforcier avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.