diff options
author | Stan Seibert <stan@mtrr.org> | 2011-08-14 21:05:07 -0400 |
---|---|---|
committer | Stan Seibert <stan@mtrr.org> | 2011-08-14 21:05:07 -0400 |
commit | 2d7220415ec99a80a794f6c642d6e14de8481945 (patch) | |
tree | 9ad4d2a847efffdd9e34562f56fe63ff3e25a119 /src | |
parent | 9d61786d403a340d5ceb88b1c565cf0362c00580 (diff) | |
download | chroma-2d7220415ec99a80a794f6c642d6e14de8481945.tar.gz chroma-2d7220415ec99a80a794f6c642d6e14de8481945.tar.bz2 chroma-2d7220415ec99a80a794f6c642d6e14de8481945.zip |
Rewrite the color_solid function in gpu.GPU (and associated CUDA code)
to make it 100x faster. Instead of having each CUDA thread loop over
the full triangle list, we give each thread a single triangle and ask
it to look up the hit status and color for that triangle. The hit
array and color array are small enough (approx 30,000 entries) to fit
into the cache, so this goes much faster.
Now the event viewer is quite snappy!
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh.h | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -167,21 +167,20 @@ __global__ void set_colors(unsigned int *colors) g_colors = colors; } -__global__ void color_solids(int nthreads, unsigned int ntriangles, int *solid_id_map, int *solid_ids, unsigned int *solid_colors) +__global__ void color_solids(int first_triangle, int nthreads, + int *solid_id_map, + bool *solid_hit, + unsigned int *solid_colors) { int id = blockIdx.x*blockDim.x + threadIdx.x; if (id >= nthreads) return; - int solid_id = solid_ids[id]; - unsigned int color = solid_colors[id]; - - for (int i=0; i < ntriangles; i++) - { - if (solid_id_map[i] == solid_id) - g_colors[i] = color; - } + int triangle_id = first_triangle + id; + int solid_id = solid_id_map[triangle_id]; + if (solid_hit[solid_id]) + g_colors[triangle_id] = solid_colors[solid_id]; } } // extern "c" |