Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission: Megan Moore #5

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d4422db
first few steps
Oct 5, 2015
cc9d510
Update rasterize.cu
megmo21 Oct 5, 2015
81bb9b9
triangle working
ziyezhou-Jerry Oct 6, 2015
6074dfa
Update tri.obj
megmo21 Oct 6, 2015
fbd5507
bounding box
Oct 7, 2015
c5332cf
colors
Oct 8, 2015
0bcd8c2
image
Oct 8, 2015
9716f9b
normals
Oct 8, 2015
5c55d13
nothin new
Oct 8, 2015
bfe7e49
mouse movements
Oct 9, 2015
627582a
back culling?
Oct 10, 2015
77f5a7e
line rasterizer and anti aliasing
Oct 10, 2015
dc8035f
points
Oct 11, 2015
3bbad96
images
Oct 11, 2015
bfc0b8a
Update README.md
megmo21 Oct 11, 2015
f911f11
Update README.md
megmo21 Oct 11, 2015
a39c6e9
Update README.md
megmo21 Oct 11, 2015
895552e
Update README.md
megmo21 Oct 11, 2015
0a42b0c
Update README.md
megmo21 Oct 11, 2015
054d1eb
images
Oct 11, 2015
ac8b1b1
Update README.md
megmo21 Oct 11, 2015
f8bb6b6
Update README.md
megmo21 Oct 11, 2015
64755a3
Update README.md
megmo21 Oct 11, 2015
ccd1d3b
Update README.md
megmo21 Oct 11, 2015
8cc2cad
Update README.md
megmo21 Oct 11, 2015
2141af9
Update README.md
megmo21 Oct 11, 2015
2d5fda0
Update README.md
megmo21 Oct 11, 2015
962eb9e
Update README.md
megmo21 Oct 11, 2015
ff24b2c
Update README.md
megmo21 Oct 11, 2015
9f90c00
Update README.md
megmo21 Oct 11, 2015
64bb871
Update README.md
megmo21 Oct 11, 2015
682b1db
Update README.md
megmo21 Oct 11, 2015
c95abad
final stuff
Oct 11, 2015
01b7e60
Update README.md
megmo21 Oct 11, 2015
6d031f6
graphs
Oct 11, 2015
7acfd15
Merge branch 'master' of https://github.com/megmo21/Project4-CUDA-Ras…
Oct 11, 2015
3c38505
Update README.md
megmo21 Oct 11, 2015
238defd
Update README.md
megmo21 Oct 11, 2015
98e5c4e
Update README.md
megmo21 Oct 11, 2015
429f4af
more images smooth objs
Oct 11, 2015
a3a4e94
changed lookat position
Oct 11, 2015
5ad01a2
video
megmo21 Oct 11, 2015
0d03ede
Update README.md
megmo21 Oct 11, 2015
b174338
Update README.md
megmo21 Oct 11, 2015
27d268f
Update README.md
megmo21 Oct 11, 2015
11b07d6
Update README.md
megmo21 Oct 11, 2015
32c3ede
dragons
Oct 12, 2015
96ef425
Update README.md
megmo21 Oct 12, 2015
c1ce1ba
Update README.md
megmo21 Oct 12, 2015
0fc3614
Merge branch 'master' of https://github.com/megmo21/Project4-CUDA-Ras…
Oct 12, 2015
ca4ec6e
dragon video
Oct 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
graphs
unknown authored and unknown committed Oct 11, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6d031f66389fdc04b8275a5e792cd0d00619f89b
Binary file added img/Cube_pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/cow_pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/flower_pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/suzanne_pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 36 additions & 10 deletions src/rasterize.cu
Original file line number Diff line number Diff line change
@@ -552,6 +552,9 @@ __global__ void fragmentShader(Fragment* depth, Fragment* frag, int width, int h
* Perform rasterization.
*/
void rasterize(uchar4 *pbo) {
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
int sideLength2d = 8;
dim3 blockSize2d(sideLength2d, sideLength2d);
dim3 blockCount2d((width - 1) / blockSize2d.x + 1,
@@ -578,43 +581,60 @@ void rasterize(uchar4 *pbo) {
setDepth<<<blockCountAnti, blockSize2d>>>(dev_depthbuffer, width);
setDepth<<<blockCount2d, blockSize2d>>>(dev_fragbuffer, width);
//Transfer from VertexIn to VertexOut (vertex shading)
cudaEventRecord(start);
cudaEventSynchronize(start);
vertexShader<<<blockCount1d, blockSize1d>>>(dev_bufVertex, dev_bufTransformedVertex, vertCount, matrix, model);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
float milliseconds = 0;
cudaEventElapsedTime(&milliseconds, start, stop);
printf("vertex shader: %f \n", milliseconds);
checkCUDAError("rasterize");
int k;
//std::cin >> k;
//Transfer from VertexOut to Triangles (primitive assembly)
cudaEventRecord(start);
cudaEventSynchronize(start);
primitiveAssemble<<<blockCount1d, blockSize1d>>>(dev_bufTransformedVertex, dev_primitives, vertCount);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
milliseconds = 0;
cudaEventElapsedTime(&milliseconds, start, stop);
printf("primitive Assembly: %f \n", milliseconds);
checkCUDAError("rasterize");


//Scanline each triangle to get fragment color (rasterize)
int triCount = vertCount / 3;
blockCount1d = ((triCount + 64 - 1) / 64);
printf("old triangle count: %i \n", triCount);
//printf("old triangle count: %i \n", triCount);
//checkCUDAError("rasterize");
//THRUST REMOVE IF

cudaEventRecord(start);
cudaEventSynchronize(start);
if (backface) {
backWard<<<blockCount1d, blockSize1d>>>(dev_primitives, triCount);
Triangle* triEnd = thrust::remove_if(thrust::device, dev_primitives, dev_primitives + triCount, removeTriangles());
//printf("triEnd: %i , %i, %i\n", sizeof(triEnd), sizeof(Triangle), sizeof(triEnd)/sizeof(Triangle));
triCount = triEnd - dev_primitives;
blockCount1d = ((triCount + 64 - 1) / 64);
}

printf("new triangle count: %i \n", triCount);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
milliseconds = 0;
cudaEventElapsedTime(&milliseconds, start, stop);
printf("backface culling: %f \n", milliseconds);
//printf("new triangle count: %i \n", triCount);
//printf("tri count: %i, block count: %i \n", triCount, (triCount + 64 - 1) / 64);
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);

cudaEventRecord(start);
cudaEventSynchronize(start);
kernRasterize<<<blockCount1d, blockSize1d>>>(dev_primitives, dev_depthbuffer, width, height, triCount);
cudaEventRecord(stop);
cudaEventSynchronize(stop);
float milliseconds = 0;
milliseconds = 0;
cudaEventElapsedTime(&milliseconds, start, stop);
printf("time per iteration: %f \n", milliseconds);
printf("rasterize: %f \n", milliseconds);
checkCUDAError("Fragment Shader");
if (lines) {
lineRasterize<<<blockCount1d, blockSize1d>>>(dev_primitives, dev_depthbuffer, width, height, triCount, matrix);
@@ -627,8 +647,14 @@ void rasterize(uchar4 *pbo) {
//checkCUDAError("rasterize");

//Fragment shader
cudaEventRecord(start);
cudaEventSynchronize(start);
fragmentShader<<<blockCount2d, blockSize2d>>>(dev_depthbuffer, dev_fragbuffer, width, height);

cudaEventRecord(stop);
cudaEventSynchronize(stop);
milliseconds = 0;
cudaEventElapsedTime(&milliseconds, start, stop);
printf("fragment shader: %f \n", milliseconds);

// Copy depthbuffer colors into framebuffer
render<<<blockCount2d, blockSize2d>>>(width, height, dev_fragbuffer, dev_framebuffer);