summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2011-08-11 11:49:54 -0400
committerStan Seibert <stan@mtrr.org>2011-08-11 11:49:54 -0400
commit6310592deb66d75f473c63fe286187ca41dae0f6 (patch)
tree67d60718b7ee21a8a7008a955c24afe0330c5cc8 /src
parent56afb978b2416ee9a14ecacdf41ab996d1747b66 (diff)
downloadchroma-6310592deb66d75f473c63fe286187ca41dae0f6.tar.gz
chroma-6310592deb66d75f473c63fe286187ca41dae0f6.tar.bz2
chroma-6310592deb66d75f473c63fe286187ca41dae0f6.zip
Switch from texture to float3 array for upper and lower bounds. 10% speed boost!
Diffstat (limited to 'src')
-rw-r--r--src/mesh.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mesh.h b/src/mesh.h
index b4714c4..bb30bef 100644
--- a/src/mesh.h
+++ b/src/mesh.h
@@ -13,8 +13,8 @@ __device__ unsigned int g_start_node;
__device__ unsigned int g_first_node;
/* lower/upper bounds for the bounding box associated with each node/leaf */
-texture<float4, 1, cudaReadModeElementType> upper_bounds;
-texture<float4, 1, cudaReadModeElementType> lower_bounds;
+__device__ float3 *g_lower_bounds;
+__device__ float3 *g_upper_bounds;
/* map to child node/triangle indices */
texture<unsigned int, 1, cudaReadModeElementType> node_map;
@@ -38,8 +38,8 @@ __device__ int convert(int c)
intersects the bounding box return true, else return false. */
__device__ bool intersect_node(const float3 &origin, const float3 &direction, const int &i)
{
- float3 lower_bound = make_float3(tex1Dfetch(lower_bounds, i));
- float3 upper_bound = make_float3(tex1Dfetch(upper_bounds, i));
+ float3 lower_bound = g_lower_bounds[i];
+ float3 upper_bound = g_upper_bounds[i];
return intersect_box(origin, direction, lower_bound, upper_bound);
}
@@ -134,13 +134,15 @@ __device__ int intersect_mesh(const float3 &origin, const float3& direction, flo
extern "C"
{
-__global__ void set_global_mesh_variables(uint4 *triangles, float3 *vertices, unsigned int *colors, unsigned int start_node, unsigned int first_node)
+ __global__ void set_global_mesh_variables(uint4 *triangles, float3 *vertices, unsigned int *colors, unsigned int start_node, unsigned int first_node, float3 *lower_bounds, float3 *upper_bounds)
{
g_triangles = triangles;
g_vertices = vertices;
g_colors = colors;
g_start_node = start_node;
g_first_node = first_node;
+ g_lower_bounds = lower_bounds;
+ g_upper_bounds = upper_bounds;
}
__global__ void set_colors(unsigned int *colors)