Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int boundingBoxWidth = maxx - minx;
- int boundingBoxHeight = maxy - miny;
- int numPixels = boundingBoxWidth * boundingBoxHeight;
- int parallelThreshold = 32;
- bool overThreshold = numPixels > parallelThreshold; // true if over threshold
- int votes = __ballot_sync(0xFFFFFFFF, overThreshold);
- int count = __popc(votes);
- for (int bigTriangle = 0; bigTriangle < count; bigTriangle++){ // 1.
- int position = __ffs(votes);
- //votes &= ~(1UL << position); // Set bit at position in votes to 0
- votes ^= 1UL << position;
- unsigned int triangleIndexP = __shfl_sync(0xFFFFFFFF, triangleIndex, position);
- int minxP = __shfl_sync(0xFFFFFFFF, minx, position);
- int maxxP = __shfl_sync(0xFFFFFFFF, maxx, position);
- int minyP = __shfl_sync(0xFFFFFFFF, miny, position);
- int maxyP = __shfl_sync(0xFFFFFFFF, maxy, position);
- int numPixelsP = __shfl_sync(0xFFFFFFFF, numPixels, position);
- float4 v0P = make_float4(0,0,0,0);
- float4 v1P = make_float4(0,0,0,0);
- float4 v2P = make_float4(0,0,0,0);
- v0P.x = __shfl_sync(0xFFFFFFFF, v0.x, position);
- v0P.y = __shfl_sync(0xFFFFFFFF, v0.y, position);
- v0P.z = __shfl_sync(0xFFFFFFFF, v0.z, position);
- v0P.w = __shfl_sync(0xFFFFFFFF, v0.w, position);
- v1P.x = __shfl_sync(0xFFFFFFFF, v1.x, position);
- v1P.y = __shfl_sync(0xFFFFFFFF, v1.y, position);
- v1P.z = __shfl_sync(0xFFFFFFFF, v1.z, position);
- v1P.w = __shfl_sync(0xFFFFFFFF, v1.w, position);
- v2P.x = __shfl_sync(0xFFFFFFFF, v2.x, position);
- v2P.y = __shfl_sync(0xFFFFFFFF, v2.y, position);
- v2P.z = __shfl_sync(0xFFFFFFFF, v2.z, position);
- v2P.w = __shfl_sync(0xFFFFFFFF, v2.w, position);
- for (int id = 0; id < numPixelsP; id += 32 ){
- // int currentIndex = id + (int(fmod(float(threadIdx.x), float(32))));
- int threadId = threadIdx.x + threadIdx.y * blockDim.x;
- int currentIndex = id + (threadId % 32);
- if (currentIndex > numPixelsP) {break;}
- //int xP = minxP + int(fmod(float(currentIndex), float(maxxP - minxP)));//(currentIndex % (maxxP - minxP));
- int xP = minxP + (currentIndex % (maxxP - minxP));
- int yP = minyP + int(currentIndex / (maxxP - minxP));
- rasteriseSinglePixel(v0P, v1P, v2P, xP, yP, mesh, triangleIndexP, frameBuffer, depthBuffer, width, height);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement