GPU 2014 — Homework #6

GPU 2014 — Homework #6

GPU Programming for Video Games

Summer 2014

Homework #6: Peeking at Performance

Due: Friday, July 25 at 23:59:59 (via T-square)



Predicting and measuring
the performance is tricky and often counterintuitive. Because of
the myriad of complex ways that GPU cores interact with the frame buffer,
the main memory, and the CPU, it is quite easy
to draw the wrong conclusions.


But, we’re going to take a stab at it anyway.


We began the course with the basic Blinn-Phong specular model, so that is
how we will end it.


For this assignment, you will Cg/HLSL code for a basic
pixel-lit, diffuse+specular
shader (using regular vertex and fragment shaders, not Unity’s
Surface Shaders)
two ways:


1) Using “max” and “pow,” as we have always done, and


2) Using the “lit” command, as described at
.


Your shaders need not use any textures. They should accept a single diffuse
material color and a single specular material color, along with a specular
power, all set in the Materials
inspector as usual. We recommend that you start with one of the specular
per-pixel shaders,
particularly “GPUXXSpecmapPixelLit.shader”
in the “GPU14 Introductory Shaders” demo from the main
website, and carefully strip out all the code you don’t need. Your code
should incorporate the color of the light and its position and handle
both spotlights and point lights, as in the original GPUXXSpecmapPixelLit
shader.


Try compiling each of your shaders, (1) and (2), both as shader model 2.0
and shader model 3.0. For each case, click “Show current” under “Debugging”
in the Inspector window for each shader to see the assembly code for
the vertex and fragment shaders. At the bottom of the fragment shaders,
you will see an instruction count.


Question 1:
For each shader model, how many fragment instructions do your shaders (1)
and (2) need?
(They will probably be very close).


Now,
let’s try to test performance directly. Create a scene in Unity with
a large cube that takes up most of the screen. Place roughly a hundred
point lights
near the cube.
Make sure each light has its render mode set to “important” and that its
range is lare enought to include the cube. You can readily make that many
lights by creating one and then using the command key for “Duplicate.”


Activate on “Maximize on Play” and “Status” in the Game window;


Deliverables:
Upload your
unityproject to T-square.
Include “HW5” and as much
as possible of your full name in the
filename, e.g., HW5_Aaron_Lanterman.doc. (The upload
procedure should be reasonably self explanatory once
you log in to T-square.)
Be sure to finish sufficiently in
advance of the deadline that you will
be able to work around any troubles
T-square gives you to successfully
submit before the deadline. If you have
trouble getting T-square to work,
please e-mail your compressed
file to Prof. Lanterman at lanterma@ece.gatech.edu,
with “GPU HW #5” and your full
name in the header line;
please only
use this e-mail submission as a last resort if T-square isn’t working.


If the file is too big to e-mail, see if you can upload it to one
of your web spaces and e-mail Prof. Lanterman a link, again with “GPU HW #5”
in the header.