Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1102 - in trunk/Model: Intersections Primitives


Chronological Thread 
  • From: knolla@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1102 - in trunk/Model: Intersections Primitives
  • Date: Thu, 8 Jun 2006 01:02:24 -0600 (MDT)

Author: knolla
Date: Thu Jun  8 01:02:21 2006
New Revision: 1102

Modified:
   trunk/Model/Intersections/IsosurfaceImplicit.cc
   trunk/Model/Intersections/IsosurfaceImplicit.h
   trunk/Model/Primitives/IsosurfaceOctreeVolume.cc
   trunk/Model/Primitives/IsosurfaceOctreeVolume.h
Log:
fixed compile error in IsosurfaceOctreeVolume when MANTA_SSE was turned off.

Modified: trunk/Model/Intersections/IsosurfaceImplicit.cc
==============================================================================
--- trunk/Model/Intersections/IsosurfaceImplicit.cc     (original)
+++ trunk/Model/Intersections/IsosurfaceImplicit.cc     Thu Jun  8 01:02:21 
2006
@@ -118,17 +118,20 @@
 #ifdef MANTA_SSE
 //SSE packet implementation
 //Based on Marmitt et al. 04, Wald 05 SSE intersections (OpenRT)
-//  as well as Knoll DynRT implementation
+//  as well as Knoll DynRT-vol implementation
 void IsosurfaceImplicit::sse_intersect(RayPacket& rays, SSERayPacket& srp, 
             char first, char last, const Vector& pmin, const Vector& pmax, 
float rho[2][2][2], 
-            float isovalue, sse_t tenter[], sse_t texit[], sse_t hitmask[], 
+            float isovalue, sse_t tenter[], sse_t texit[], sse_t hitmask[], 
sse_t validmask[],
             const Manta::Primitive* prim, const Manta::Material* matl)
 {
     //cerr << "sse_intersect: first=" << (int)first << ",last=" << (int)last 
<< endl;
 
     for(int smd=first; smd<last; smd++)
     {
-        if (_mm_movemask_ps(hitmask[smd])==0)
+        sse_t sse_thisvoxelmask = and4(hitmask[smd], validmask[smd]);
+        int int_thisvoxelmask = _mm_movemask_ps(sse_thisvoxelmask);
+    
+        if (int_thisvoxelmask==0)
             continue;
     
         //compute p0, p1
@@ -155,8 +158,8 @@
 
         //find which rays have differing signs for D0, D1. Only retain the 
ones that have same signs?
         sse_t differingSigns = cmp4_lt(mul4(D0,D1), zero4());
-        sse_t sse_thisvoxelmask = and4(hitmask[smd], differingSigns);
-        int int_thisvoxelmask = _mm_movemask_ps(sse_thisvoxelmask);
+        sse_thisvoxelmask = and4(sse_thisvoxelmask, differingSigns);
+        int_thisvoxelmask = _mm_movemask_ps(sse_thisvoxelmask);
         
         if (int_thisvoxelmask == 0)    //if none of them hit, don't bother 
iterating any more
             continue;
@@ -206,6 +209,9 @@
                     rays.data->hitPrim[realray] = prim;
                 }
             }
+            
+            //set "validmask" to 0 for each ray that hit here.
+            validmask[smd] = andnot4(validmask[smd], sse_thisvoxelmask);
         }
     }
 }

Modified: trunk/Model/Intersections/IsosurfaceImplicit.h
==============================================================================
--- trunk/Model/Intersections/IsosurfaceImplicit.h      (original)
+++ trunk/Model/Intersections/IsosurfaceImplicit.h      Thu Jun  8 01:02:21 
2006
@@ -28,7 +28,7 @@
 #ifdef MANTA_SSE
         static void sse_intersect(RayPacket& rays, SSERayPacket& srp, 
                     char first, char last, const Vector& pmin, const Vector& 
pmax, float rho[2][2][2], 
-                    float isovalue, sse_t tenter[], sse_t texit[], sse_t 
hitmask[], 
+                    float isovalue, sse_t tenter[], sse_t texit[], sse_t 
hitmask[], sse_t validmask[], 
                     const Manta::Primitive* prim, const Manta::Material* 
matl);
                     
         static void sse_normal(RayPacket &ray, SSERayPacket& srp, int smd, 

Modified: trunk/Model/Primitives/IsosurfaceOctreeVolume.cc
==============================================================================
--- trunk/Model/Primitives/IsosurfaceOctreeVolume.cc    (original)
+++ trunk/Model/Primitives/IsosurfaceOctreeVolume.cc    Thu Jun  8 01:02:21 
2006
@@ -113,7 +113,7 @@
 
 void IsosurfaceOctreeVolume::intersect(RenderContext const &context, 
RayPacket &packet) const
 {
-#if 1
+#ifdef MANTA_SSE
        packet_intersect_implicit_bvh(packet);
 #else
     for ( int i = packet.rayBegin; i < packet.rayEnd; i++ )
@@ -754,6 +754,9 @@
     rays.computeSigns();
     RayPacketData* data = rays.data;
     SSERayPacket srp;
+    
+    //tells us whether this ray is still worth computing; this is checked 
off if rays miss volume entirely or hit.
+    sse_t validmask[RayPacket::SSE_MaxSize];
 
     //intersect the global bounding box: find first, last
     //  this will require a special-case AABB intersection
@@ -795,10 +798,11 @@
         
         sse_t tenter_unpadded = max4(max4(tnear_unpadded[0], 
tnear_unpadded[1]), tnear_unpadded[2]);
         sse_t texit_unpadded = min4(min4(tfar_unpadded[0], 
tfar_unpadded[1]), tfar_unpadded[2]);
-                       
-        if (_mm_movemask_ps(_mm_cmple_ps(tenter_unpadded, texit_unpadded)) 
== 0)       //if none of them were valid
+               
+        validmask[smd] = cmp4_le(tenter_unpadded, texit_unpadded);
+        if (_mm_movemask_ps(validmask[smd]) == 0)      //if none of them 
were valid
             continue;
-               
+            
         first = MIN(first, smd);
         last = smd;
     }
@@ -811,10 +815,10 @@
        
     unsigned int index_trace[octdata->get_max_depth() + 1];
     Vec3i cell(0,0,0);
-    bvh_octnode(rays, srp, first, last, cell, octdata->get_cap_depth(), 0, 
0, index_trace);
+    bvh_octnode(rays, srp, first, last, validmask, cell, 
octdata->get_cap_depth(), 0, 0, index_trace);
 }
 
-bool IsosurfaceOctreeVolume::bvh_octnode(RayPacket& rays, SSERayPacket& srp, 
char first, char last, 
+bool IsosurfaceOctreeVolume::bvh_octnode(RayPacket& rays, SSERayPacket& srp, 
char first, char last, sse_t validmask[], 
             const Vec3i& cell, int stop_depth, int depth, unsigned int 
index, unsigned int index_trace[]) const
 {
     //cerr << "octnode " << (int)depth << ", " << index << "; first=" << 
(int)first << ",last=" << (int)last << endl;
@@ -829,7 +833,7 @@
     for(int midplane_x=0; midplane_x!=2; midplane_x++)
     {
         int target_x;
-        if (midplane_x - rays.getSign(0,0))
+        if (midplane_x - rays.getSign(first,0))
         {
             target_x = 4;
             child_cell.data[0] = cell.data[0] | child_bit;
@@ -843,7 +847,7 @@
         for(int midplane_y=0; midplane_y!=2; midplane_y++)
         {
             int target_xy;
-            if (midplane_y - rays.getSign(0,1))
+            if (midplane_y - rays.getSign(first,1))
             {
                 target_xy = target_x | 2;
                 child_cell.data[1] = cell.data[1] | child_bit;
@@ -857,7 +861,7 @@
             for(int midplane_z=0; midplane_z!=2; midplane_z++)
             {
                 int target_child;
-                if (midplane_z - rays.getSign(0,2))
+                if (midplane_z - rays.getSign(first,2))
                 {
                     target_child = target_xy | 1;
                     child_cell.data[2] = cell.data[2] | child_bit;
@@ -868,18 +872,17 @@
                     child_cell.data[2] = cell.data[2];
                 }
  
-                char newfirst, newlast;
                 Vector pmin(child_cell.data[0], child_cell.data[1], 
child_cell.data[2]);
                 Vector pmax(child_cell.data[0]+child_bit, 
child_cell.data[1]+child_bit, child_cell.data[2]+child_bit);
-                intersect_octant(srp, first, last, newfirst, newlast, pmin, 
pmax);
+                char newfirst = first_intersects_node_octant(srp, first, 
last, pmin, pmax);
                 
                 //cerr << "newfirst=" << (int)newfirst << ", newlast=" << 
(int)newlast << endl;
                 
-                if (newfirst < newlast && octdata->get_isovalue() >= 
node.mins[target_child] && octdata->get_isovalue() <= node.maxs[target_child])
+                if (newfirst < last && octdata->get_isovalue() >= 
node.mins[target_child] && octdata->get_isovalue() <= node.maxs[target_child])
                 {
                     if (node.offsets[target_child]==-1)
                     {
-                        if (bvh_octleaf(rays, srp, newfirst, newlast, 
child_cell, stop_depth, depth, node.values[target_child], index_trace))
+                        if (bvh_octleaf(rays, srp, newfirst, last, 
validmask, child_cell, stop_depth, depth, node.values[target_child], 
index_trace))
                             return true;
                     }
                     else
@@ -887,12 +890,12 @@
                         unsigned int child_idx = node.children_start + 
node.offsets[target_child];
                         if (depth == octdata->get_pre_cap_depth())     //cap
                         {
-                            if (bvh_octcap(rays, srp, newfirst, newlast, 
child_cell, stop_depth, depth+1, child_idx, index_trace))
+                            if (bvh_octcap(rays, srp, newfirst, last, 
validmask, child_cell, stop_depth, depth+1, child_idx, index_trace))
                                 return true;
                         }
                         else
                         {
-                            if (bvh_octnode(rays, srp, newfirst, newlast, 
child_cell, stop_depth, depth+1, child_idx, index_trace))
+                            if (bvh_octnode(rays, srp, newfirst, last, 
validmask, child_cell, stop_depth, depth+1, child_idx, index_trace))
                                 return true;
                         }
                     }
@@ -903,12 +906,12 @@
     return false;
 }
 
-bool IsosurfaceOctreeVolume::bvh_octleaf(RayPacket& rays, SSERayPacket& srp, 
char first, char last, 
+bool IsosurfaceOctreeVolume::bvh_octleaf(RayPacket& rays, SSERayPacket& srp, 
char first, char last, sse_t validmask[], 
             const Vec3i& cell, int stop_depth, int depth, ST value, unsigned 
int index_trace[]) const
 {
 }
 
-bool IsosurfaceOctreeVolume::bvh_octcap(RayPacket& rays, SSERayPacket& srp, 
char first, char last, 
+bool IsosurfaceOctreeVolume::bvh_octcap(RayPacket& rays, SSERayPacket& srp, 
char first, char last, sse_t validmask[], 
             const Vec3i& cell, int stop_depth, int depth, unsigned int 
index, unsigned int index_trace[]) const
 {
     //cerr << "octcap " << index << ", first=" << (int)first << ",last=" << 
(int)last << endl;
@@ -921,7 +924,7 @@
     for(int midplane_x=0; midplane_x<2; midplane_x++)
     {
         int target_x;
-        if (midplane_x - rays.getSign(0,0))
+        if (midplane_x - rays.getSign(first,0))
         {
             target_x = 4;
             child_cell.data[0] = cell.data[0] | 1;
@@ -935,7 +938,7 @@
         for(int midplane_y=0; midplane_y<2; midplane_y++)
         {
             int target_xy;
-            if (midplane_y - rays.getSign(0,1))
+            if (midplane_y - rays.getSign(first,1))
             {
                 target_xy = target_x | 2;
                 child_cell.data[1] = cell.data[1] | 1;
@@ -949,7 +952,7 @@
             for(int midplane_z=0; midplane_z<2; midplane_z++)
             {
                 int target_child;
-                if (midplane_z - rays.getSign(0,2))
+                if (midplane_z - rays.getSign(first,2))
                 {
                     target_child = target_xy | 1;
                     child_cell.data[2] = cell.data[2] | 1;
@@ -963,12 +966,12 @@
                 sse_t child_tenter[RayPacket::SSE_MaxSize];
                 sse_t child_texit[RayPacket::SSE_MaxSize];
                 sse_t hitmask[RayPacket::SSE_MaxSize];
-                char newfirst, newlast;
                 Vector cmin(child_cell.data[0], child_cell.data[1], 
child_cell.data[2]);
                 Vector cmax(child_cell.data[0]+1, child_cell.data[1]+1, 
child_cell.data[2]+1);
-                intersect_octant(srp, first, last, newfirst, newlast, cmin, 
cmax, child_tenter, child_texit, hitmask);
+                char newlast = last_intersects_cap_octant(srp, first, last, 
cmin, cmax, child_tenter, child_texit, hitmask);
+                newlast = MIN(last, newlast+1);
                 
-                if (newfirst >= newlast)
+                if (first >= newlast)
                     continue;
                     
 #ifdef USE_OCTREE_DATA
@@ -1000,8 +1003,8 @@
                 if (octdata->get_isovalue() >= min_rho && 
octdata->get_isovalue() <= max_rho)
                 {
                     //cerr << "in cap " << (unsigned long)(&cap) << ", 
octant " << target_child << endl;
-                    IsosurfaceImplicit::sse_intersect(rays, srp, newfirst, 
newlast, cmin, cmax, rho, 
-                        octdata->get_isovalue(), child_tenter, child_texit, 
hitmask, this, PrimitiveCommon::getMaterial());
+                    IsosurfaceImplicit::sse_intersect(rays, srp, first, 
newlast, cmin, cmax, rho, 
+                        octdata->get_isovalue(), child_tenter, child_texit, 
hitmask, validmask, this, PrimitiveCommon::getMaterial());
                 }
             }
         }

Modified: trunk/Model/Primitives/IsosurfaceOctreeVolume.h
==============================================================================
--- trunk/Model/Primitives/IsosurfaceOctreeVolume.h     (original)
+++ trunk/Model/Primitives/IsosurfaceOctreeVolume.h     Thu Jun  8 01:02:21 
2006
@@ -56,23 +56,21 @@
 #ifdef MANTA_SSE
                        void packet_intersect_implicit_bvh(RayPacket& rays) 
const;
             
-            bool bvh_octnode(RayPacket& rays, SSERayPacket& srp, char first, 
char last, 
+            bool bvh_octnode(RayPacket& rays, SSERayPacket& srp, char first, 
char last, sse_t validmask[], 
                             const Vec3i& cell, int stop_depth, int depth, 
unsigned int index, 
                             unsigned int index_trace[]) const;
                             
-            bool bvh_octleaf(RayPacket& rays, SSERayPacket& srp, char first, 
char last, 
+            bool bvh_octleaf(RayPacket& rays, SSERayPacket& srp, char first, 
char last, sse_t validmask[], 
                                         const Vec3i& cell, int stop_depth, 
int depth, ST value, 
                                         unsigned int index_trace[]) const;
             
-            bool bvh_octcap(RayPacket& rays, SSERayPacket& srp, char first, 
char last, 
+            bool bvh_octcap(RayPacket& rays, SSERayPacket& srp, char first, 
char last, sse_t validmask[], 
                 const Vec3i& cell, int stop_depth, int depth, unsigned int 
index, 
                 unsigned int index_trace[]) const;
             
-            inline void intersect_octant(SSERayPacket& srp, char first, char 
last, 
-                char& newfirst, char& newlast, const Vector& min, const 
Vector& max) const
+            inline char first_intersects_node_octant(SSERayPacket& srp, char 
first, char last, 
+                const Vector& min, const Vector& max) const
             {
-                newfirst = last;
-                newlast = first;                
                 for(char smd=first; smd<last; smd++)
                 {
                     sse_t dgt0[3];
@@ -93,25 +91,20 @@
                     sse_t texit = min4(min4(tfar[0], tfar[1]), tfar[2]);
                         
                     if (_mm_movemask_ps(cmp4_le(tenter, texit)) != 0)  //if 
any hit
-                    {
-                        newfirst = MIN(newfirst, smd);
-                        newlast = smd;
-                    }
+                        return smd;
                 }
-                newlast++;
+                return last;
             } 
             
-            inline void intersect_octant(SSERayPacket& srp, char first, char 
last, 
-                    char& newfirst, char& newlast, const Vector& min, 
-                    const Vector& max, sse_t tenter[], sse_t texit[], sse_t 
hitmask[]) const
+            inline char last_intersects_cap_octant(SSERayPacket& srp, char 
first, char last, 
+                    const Vector& min, const Vector& max, 
+                    sse_t tenter[], sse_t texit[], sse_t hitmask[]) const
             {
                 #pragma unroll(RayPacket::SSE_MaxSize)
-                for(char smd=0; smd<RayPacket::SSE_MaxSize; smd++)
+                for(char smd=first; smd<last; smd++)
                     hitmask[smd] = zero4();
                     
-                newfirst = last;
-                newlast = first;
-                for(char smd=first; smd<last; smd++)
+                for(char smd=last-1; smd>=first; smd--)
                 {
                     sse_t dgt0[3];
                     sse_t tnear[3];
@@ -132,12 +125,9 @@
                     
                     hitmask[smd] = cmp4_le(tenter[smd], texit[smd]);
                     if (_mm_movemask_ps(hitmask[smd]) != 0)    //if any hit
-                    {
-                        newfirst = MIN(newfirst, smd);
-                        newlast = smd;
-                    }
+                        return smd;
                 }
-                newlast++;
+                return first;
             }                 
 #endif                                           
     };




  • [MANTA] r1102 - in trunk/Model: Intersections Primitives, knolla, 06/08/2006

Archive powered by MHonArc 2.6.16.

Top of page