tuned stencil

This commit is contained in:
Evghenii
2013-11-08 14:15:27 +01:00
parent b3c68af40a
commit b2f62d51b0
2 changed files with 444 additions and 7 deletions

View File

@@ -281,14 +281,12 @@ volume_tile(uniform int x0, uniform int y0, uniform int x1,
// Work on 4x4=16 pixel big tiles of the image. This function thus
// implicitly assumes that both (x1-x0) and (y1-y0) are evenly divisble
// by 4.
for (uniform int y = y0; y < y1; y += 4) {
for (uniform int x = x0; x < x1; x += 4) {
for (uniform int y = y0; y < y1; y += 8) {
for (uniform int x = x0; x < x1; x += 8) {
// foreach (o = 0 ... 16) {
for (int ob = 0; ob < 32; ob += programCount)
for (uniform int ob = 0; ob < 64; ob += programCount)
{
const int o = ob + programIndex;
if (o >= 16) continue;
// These two arrays encode the mapping from [0,15] to
// offsets within the 4x4 pixel block so that we render
@@ -298,8 +296,12 @@ volume_tile(uniform int x0, uniform int y0, uniform int x1,
const uniform int yoffsets[16] = { 0, 0, 1, 1, 0, 0, 1, 1,
2, 2, 3, 3, 2, 2, 3, 3 };
const uniform int xblock[4] = {0, 4, 0, 4};
const uniform int yblock[4] = {0, 0, 4, 4};
// Figure out the pixel to render for this program instance
int xo = x + xoffsets[o], yo = y + yoffsets[o];
const int xo = x + xblock[o/16] + xoffsets[o&15];
const int yo = y + yblock[o/16] + yoffsets[o&15];
// Use viewing parameters to compute the corresponding ray
// for the pixel
@@ -309,7 +311,8 @@ volume_tile(uniform int x0, uniform int y0, uniform int x1,
// And raymarch through the volume to compute the pixel's
// value
int offset = yo * width + xo;
image[offset] = raymarch(density, nVoxels, ray);
if (xo < x1 && yo < y1)
image[offset] = raymarch(density, nVoxels, ray);
}
}
}