Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1487 - in trunk: Core/Math Interface Model/Primitives


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1487 - in trunk: Core/Math Interface Model/Primitives
  • Date: Tue, 17 Jul 2007 16:48:50 -0600 (MDT)

Author: boulos
Date: Tue Jul 17 16:48:50 2007
New Revision: 1487

Modified:
   trunk/Core/Math/CheapRNG.h
   trunk/Interface/RandomNumberGenerator.cc
   trunk/Model/Primitives/Parallelogram.cc
   trunk/Model/Primitives/Parallelogram.h
Log:
Core/Math/CheapRNG.h
  Some fixes for the SSE path of the random number generator.

Interface/RandomNumberGenerator.cc
  Changing the way the SSE conversion to float works, probably
need to propogate the constant to the scalar version.

Model/Primitives/Parallelogram.cc
Model/Primitives/Parallelogram.h
  Packet-izing the sampling of the parallelogram, still need
to do an SSE version.


Modified: trunk/Core/Math/CheapRNG.h
==============================================================================
--- trunk/Core/Math/CheapRNG.h  (original)
+++ trunk/Core/Math/CheapRNG.h  Tue Jul 17 16:48:50 2007
@@ -87,9 +87,9 @@
       // is make the sequences out of sync by one iteration... So you
       // want offsets.
       val_sse = _mm_set_epi32(seed_val,
-                              seed_val * 12345,
-                              seed_val * 12345 * 12345,
-                              seed_val * 12345 * 12345 * 12345);
+                              seed_val + 1,
+                              seed_val,
+                              seed_val + 1);
 #endif
     }
 
@@ -100,9 +100,9 @@
 
     virtual void nextIntPacket(Packet<unsigned int>& results) {
 #ifdef MANTA_SSE
-      for (int i = 0; i < Packet<unsigned int>::MaxSize; i++) {
-        val_sse = _mm_add_epi32(_mm_set1_epi32(1013904223),
-                                _mm_mullo_epi32(val_sse, 
_mm_set1_epi32(1664525)));
+      for (int i = 0; i < Packet<unsigned int>::MaxSize; i+=4) {
+        val_sse = _mm_add_epi32(_mm_set_epi32(2531011, 10395331, 13737667, 
1),
+                                _mm_mullo_epi32(val_sse, 
_mm_set_epi32(214013, 17405, 214013, 69069)));
         _mm_store_si128((__m128i*)&results.data[i], val_sse);
       }
 #else

Modified: trunk/Interface/RandomNumberGenerator.cc
==============================================================================
--- trunk/Interface/RandomNumberGenerator.cc    (original)
+++ trunk/Interface/RandomNumberGenerator.cc    Tue Jul 17 16:48:50 2007
@@ -1,4 +1,5 @@
 #include <Interface/RandomNumberGenerator.h>
+#include <Core/Exceptions/InternalError.h>
 
 namespace Manta {
 
@@ -16,9 +17,26 @@
     Packet<unsigned int> uints;
     nextIntPacket(uints);
     for (int i = 0; i < Packet<float>::MaxSize; i+= 4) {
+#if 0
       _mm_store_ps(&results.data[i],
                    
_mm_mul_ps(_mm_cvtepi32_ps(_mm_load_si128((__m128i*)&uints.data[i])),
                               _mm_set1_ps((float)(1./4294967296.))));
+#else
+      // Mask out the top bit (since that's a signed number) but divide by 
2/4294967296 instead
+      static const float scale_float = 4.65661e-10f;
+      _mm_store_ps(&results.data[i],
+                   
_mm_mul_ps(_mm_cvtepi32_ps(_mm_srli_epi32(_mm_load_si128((__m128i*)&uints.data[i]),
 1)),
+                              _mm_set1_ps(scale_float)));
+#if 0
+      // Sanity check for RNGs.
+      for (int c = 0; c < 4; c++) {
+        if (results.data[i + c] < 0.f || results.data[i + c] >= 1.f) {
+          throw SCIRun::InternalError("RNG generated number out of range 
[0,1).", __FILE__, __LINE__);
+        }
+      }
+#endif
+
+#endif
     }
 #else
     for (int i = 0; i < Packet::MaxSize; i++) {

Modified: trunk/Model/Primitives/Parallelogram.cc
==============================================================================
--- trunk/Model/Primitives/Parallelogram.cc     (original)
+++ trunk/Model/Primitives/Parallelogram.cc     Tue Jul 17 16:48:50 2007
@@ -1,4 +1,3 @@
-
 #include <Model/Primitives/Parallelogram.h>
 #include <Interface/RayPacket.h>
 #include <Core/Geometry/BBox.h>
@@ -556,4 +555,22 @@
   normal = this->normal;
 }
 
+void Parallelogram::getRandomPoints(Packet<Vector>& points,
+                                    Packet<Vector>& normals,
+                                    Packet<Real>& pdfs,
+                                    const RenderContext& context) const {
+  Packet<Real> r1;
+  Packet<Real> r2;
+  context.rng->nextPacket(r1);
+  context.rng->nextPacket(r2);
 
+  for (int i = 0; i < Packet<Vector>::MaxSize; i++) {
+    points.set(i, anchor + r1.get(i) * v1_unscaled + r2.get(i) * 
v2_unscaled);
+  }
+  for (int i = 0; i < Packet<Vector>::MaxSize; i++) {
+    normals.set(i, this->normal);
+  }
+  for (int i = 0; i < Packet<Real>::MaxSize; i++) {
+    pdfs.set(i, inv_area);
+  }
+}

Modified: trunk/Model/Primitives/Parallelogram.h
==============================================================================
--- trunk/Model/Primitives/Parallelogram.h      (original)
+++ trunk/Model/Primitives/Parallelogram.h      Tue Jul 17 16:48:50 2007
@@ -26,6 +26,11 @@
                                 Vector& normal,
                                 Real& pdf,
                                 const RenderContext& context) const;
+
+    virtual void getRandomPoints(Packet<Vector>& points,
+                                 Packet<Vector>& normals,
+                                 Packet<Real>& pdfs,
+                                 const RenderContext& context) const;
   private:
     Vector anchor;
     Vector v1, v2;




  • [MANTA] r1487 - in trunk: Core/Math Interface Model/Primitives, boulos, 07/17/2007

Archive powered by MHonArc 2.6.16.

Top of page