Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1449 - in trunk: Core/Math Interface SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1449 - in trunk: Core/Math Interface SwigInterface
  • Date: Fri, 6 Jul 2007 13:45:50 -0600 (MDT)

Author: bigler
Date: Fri Jul  6 13:45:49 2007
New Revision: 1449

Modified:
   trunk/Core/Math/Noise.cc
   trunk/Core/Math/SSEDefs.h
   trunk/Interface/Interpolable.h
   trunk/SwigInterface/manta.i
   trunk/SwigInterface/mantainterface.i
Log:

Core/Math/Noise.cc
Core/Math/SSEDefs.h

  Moved _mm_mullo_epi32 to SSEDefs.h.

Interface/Interpolable.h

  Moved keyframe_t out of Interpolable class to help SWIG.

SwigInterface/manta.i

  Added Mesh class.

SwigInterface/mantainterface.i

  Added Interpolable class.

  Moved Group.h up to Groups section.


Modified: trunk/Core/Math/Noise.cc
==============================================================================
--- trunk/Core/Math/Noise.cc    (original)
+++ trunk/Core/Math/Noise.cc    Fri Jul  6 13:45:49 2007
@@ -330,21 +330,6 @@
   }
 
 #if MANTA_SSE
-  __m128i _mm_mullo_epi32( __m128i a, __m128i b )
-  {
-    __m128i t0;
-    __m128i t1;
-
-    t0 = _mm_mul_epu32(a,b);
-    t1 = _mm_mul_epu32( _mm_shuffle_epi32( a, 0xB1 ),
-                        _mm_shuffle_epi32( b, 0xB1 ) );
-
-    t0 = _mm_shuffle_epi32( t0, 0xD8 );
-    t1 = _mm_shuffle_epi32( t1, 0xD8 );
-
-    return _mm_unpacklo_epi32( t0, t1 );
-  } 
-
   __m128i CheapRNG(const __m128i& val)
   {
     return _mm_and_si128(_mm_set1_epi32(0xFF),
@@ -410,7 +395,7 @@
     __m128 pi = _mm_set1_ps(3.14159265389793);
     __m128 inv_golden = _mm_set1_ps(0.6180339887);
     xx = _mm_add_ps(xx, inv_golden); // Avoid singularity when x==0
-    yy = _mm_add_ps(yy, inv_golden);
+    yy = _mm_add_ps(yy, pi);
     zz = _mm_add_ps(zz, inv_golden);
     __m128 hh = _mm_mul_ps(_mm_mul_ps(xx, yy),
                            _mm_mul_ps(zz, pi));

Modified: trunk/Core/Math/SSEDefs.h
==============================================================================
--- trunk/Core/Math/SSEDefs.h   (original)
+++ trunk/Core/Math/SSEDefs.h   Fri Jul  6 13:45:49 2007
@@ -364,7 +364,7 @@
     
     inline int count_zeros(sse_t t)
     {
-      // You can use this if your compiler isn't stupid.
+      // You could use this if your compiler isn't stupid.
       // return 4-count_nonzeros(t);
 
       // But most compilers are stupid, so we'll manually inline it:
@@ -400,6 +400,46 @@
     __m128 fract_val = _mm_sub_ps(val, 
_mm_cvtepi32_ps(_mm_cvttps_epi32(val)));
     return _mm_sub_ps(val, _mm_add_ps(fract_val, 
_mm_and_ps(_mm_cmplt_ps(fract_val, _mm_set_ps1(0.f)), _mm_set_ps1(1.f))));
   }
+
+  // Packed 32 bit integer multiplication with truncation of the upper
+  // halves of the results.  This produces the same resaults as
+  // (int)(int * int).  It looks as though this function will be
+  // included in SSE4, but the rest of us need to use it now.
+  //
+  // I found this code on this web page:
+  // http://www.intel.com/cd/ids/developer/asmo-na/eng/254761.htm?page=4
+  // There isn't any indication that we can't simply include it in our
+  // own code.
+  inline __m128i _mm_mullo_epi32( __m128i a, __m128i b )
+  {
+#if 1
+    __m128i t0;
+    __m128i t1;
+
+    t0 = _mm_mul_epu32(a,b);
+    t1 = _mm_mul_epu32( _mm_shuffle_epi32( a, 0xB1 ),
+                        _mm_shuffle_epi32( b, 0xB1 ) );
+
+    t0 = _mm_shuffle_epi32( t0, 0xD8 );
+    t1 = _mm_shuffle_epi32( t1, 0xD8 );
+
+    return _mm_unpacklo_epi32( t0, t1 );
+#else
+    // Here's a version that Bigler came up with that is faster on
+    // some systems like the Opteron.
+    __m128i a_lo = _mm_unpacklo_epi32(a, a);   // a0a0a1a1
+    __m128i a_hi = _mm_unpackhi_epi32(a, a);   // a2a2a3a3
+    __m128i b_lo = _mm_unpacklo_epi32(b, b);   // b0b0b1b1
+    __m128i b_hi = _mm_unpackhi_epi32(b, b);   // b2b2b3b3
+    __m128i lo   = _mm_mul_epu32(a_lo, b_lo);  // a0b0l a0b0h a1b1l a1b1h
+    __m128i hi   = _mm_mul_epu32(a_hi, b_hi);  // a2b2l a2b2h a3b3l a3b3h
+    __m128i mix_lo = _mm_unpacklo_epi32(lo, hi); // a0b0l a2b2l a0b0h a2b2h
+    __m128i mix_hi = _mm_unpackhi_epi32(lo, hi); // a1b1l a3b3l a1b1h a3b3h
+    __m128i product = _mm_unpacklo_epi32(mix_lo, mix_hi); // a0b0l a1b1l 
a2b2l a3b3l
+
+    return product;
+#endif
+  } 
 
 
 };

Modified: trunk/Interface/Interpolable.h
==============================================================================
--- trunk/Interface/Interpolable.h      (original)
+++ trunk/Interface/Interpolable.h      Fri Jul  6 13:45:49 2007
@@ -5,18 +5,25 @@
 #include <vector>
 
 namespace Manta {
+  class Interpolable; // forward declaration for the keframe class.
+  
+  struct Interpolable_keyframe_t {
+    Interpolable* keyframe;
+    float t;
+  };
+
   class Interpolable : public Clonable {
   public:
     enum InterpErr{success, 
                    notInterpolable}; //cannot interpolate. No interpolation 
performed.
 
-    struct keyframe_t {
-      Interpolable* keyframe;
-      float t;
-    };
-
     virtual ~Interpolable() { }
 
+    // Swig doesn't like nested classes, so I pulled it out.  I'm
+    // defining a typedef here, so that I don't have to change all the
+    // places where it's used for now.
+    typedef Interpolable_keyframe_t keyframe_t;
+    
     //Assuming the following operators existed, this function is
     //supposed to do something like the following: 
     //       *this = keyframe[0]*t[0] + ... + keyframe[n]*t[n];

Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Fri Jul  6 13:45:49 2007
@@ -258,6 +258,7 @@
 #include <Model/Groups/Build_Approx_cc.h>
 #include <Model/Groups/RealisticBvh.h>
 #include <Model/Groups/DynBVH.h>
+#include <Model/Groups/Mesh.h>
 #include <Model/Groups/ObjGroup.h>
 %}
 
@@ -267,6 +268,7 @@
 %include <Model/Groups/Build_Approx_cc.h>
 %include <Model/Groups/RealisticBvh.h>
 %include <Model/Groups/DynBVH.h>
+%include <Model/Groups/Mesh.h>
 %include <Model/Groups/ObjGroup.h>
 
 /////////////////////////////////////////////////

Modified: trunk/SwigInterface/mantainterface.i
==============================================================================
--- trunk/SwigInterface/mantainterface.i        (original)
+++ trunk/SwigInterface/mantainterface.i        Fri Jul  6 13:45:49 2007
@@ -148,6 +148,7 @@
 #include <Interface/CallbackHandle.h>
 #include <Interface/Context.h>
 #include <Interface/Clonable.h>
+#include <Interface/Interpolable.h>
 #include <Interface/Object.h>
 #include <Interface/Primitive.h>
 #include <Interface/TexCoordMapper.h>
@@ -158,12 +159,11 @@
 #include <Interface/ShadowAlgorithm.h>
 %}
 
-typedef int CloneDepth;
-
 %include <Core/Geometry/Ray.h>
 %include <Interface/CallbackHandle.h>
 %include <Interface/Context.h>
 %include <Interface/Clonable.h>
+%include <Interface/Interpolable.h>
 %include <Interface/Object.h>
 %include <Interface/Primitive.h>
 %include <Interface/TexCoordMapper.h>
@@ -399,6 +399,11 @@
 
///////////////////////////////////////////////////////////////////////////////
 // Groups
 
+%{
+#include <Model/Groups/Group.h>
+%}
+%include <Model/Groups/Group.h>
+
 /////////////////////////////////////////////////
 // GLM.
 
@@ -418,11 +423,6 @@
 
 ////////////////////////////////////////////////
 // Thread stuff
-
-%{
-#include <Model/Groups/Group.h>
-%}
-%include <Model/Groups/Group.h>
 
 ////////////////////////////////////////////////
 // Python specific code




  • [MANTA] r1449 - in trunk: Core/Math Interface SwigInterface, bigler, 07/06/2007

Archive powered by MHonArc 2.6.16.

Top of page