Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1431 - in trunk: Core/Math StandAlone
- Date: Wed, 27 Jun 2007 17:18:43 -0600 (MDT)
Author: bigler
Date: Wed Jun 27 17:18:42 2007
New Revision: 1431
Modified:
trunk/Core/Math/Noise.cc
trunk/Core/Math/Noise.h
trunk/StandAlone/manta.cc
Log:
Core/Math/Noise.cc
Core/Math/Noise.h
Added refactored code for CheapRNG, DissolveRNG, and
PermutationTable.
Use variables for contants in ssehash for easier twiddling.
StandAlone/manta.cc
Get rid of spurious output of "renderer".
Modified: trunk/Core/Math/Noise.cc
==============================================================================
--- trunk/Core/Math/Noise.cc (original)
+++ trunk/Core/Math/Noise.cc Wed Jun 27 17:18:42 2007
@@ -345,39 +345,55 @@
return _mm_unpacklo_epi32( t0, t1 );
}
- // This will return a random hash number from 0 to 255
- /*static inline*/ __m128i permutationSSE(const __m128i& index)
+ __m128i CheapRNG(const __m128i& val)
+ {
+ return _mm_and_si128(_mm_set1_epi32(0xFF),
+ _mm_add_epi32(_mm_set1_epi32(1013904223),
+
_mm_mullo_epi32(_mm_set1_epi32(1664525), val)));
+ }
+ __m128i DissolveRNG(const __m128i& val)
{
-#if 1 // 0 for table, 1 for RNG
-#if 0 // 0 for CheapRNG, 1 for DissolveRNG
-
// val = val & 255;
// if (val & 1)
// val = (val >> 1) ^ mask;
// else
// val = val >> 1;
- __m128i index_masked = _mm_and_si128(index, _mm_set1_epi32(0xFF));
- __m128i ifmask = _mm_cmpeq_epi32(_mm_and_si128(index_masked,
_mm_set1_epi32(1)), _mm_set1_epi32(1));
- return _mm_xor_si128(_mm_srli_epi32(index_masked, 1),
+ __m128i ifmask = _mm_cmpeq_epi32(_mm_and_si128(val, _mm_set1_epi32(1)),
_mm_set1_epi32(1));
+ return _mm_xor_si128(_mm_srli_epi32(val, 1),
_mm_and_si128(ifmask, _mm_set1_epi32(0xB8)));
-#else
- return _mm_mullo_epi32(index, _mm_set1_epi32(741103597));
-#if 0
- return /*_mm_and_si128(_mm_set1_epi32(0xFF), */_mm_srai_epi32(
- _mm_add_epi32(_mm_set1_epi32(1013904223),
-
_mm_mullo_epi32(_mm_set1_epi32(1664525), index)), 9)/*)*/;
-#endif
-#endif
-#else
+ }
+
+ __m128i PermutationTable(const __m128i& index)
+ {
union {
unsigned int i[4];
__m128i s;
} indicies, results;
indicies.s = index;
for(unsigned int i = 0; i < 4; ++i)
- results.i[i] = NoiseXPermutationTable[indicies.i[i]&255];
+ results.i[i] = NoiseXPermutationTable[indicies.i[i]];
return results.s;
+ }
+
+ // This will return a random hash number from 0 to 255
+ /*static inline*/ __m128i permutationSSE(const __m128i& index)
+ {
+ __m128i index_masked = _mm_and_si128(index, _mm_set1_epi32(0xFF));
+ __m128i result;
+#if 1 // 0 for table, 1 for RNG
+#if 0 // 0 for CheapRNG, 1 for DissolveRNG
+ result = DissolveRNG(index_masked);
+#else
+#if 1
+ result = _mm_mullo_epi32(index, _mm_set1_epi32(741103597));
+#else
+ result = CheapRNG(index_masked);
+#endif
+#endif
+#else
+ result = PermutationTable(index_masked);
#endif
+ return result;
}
/*static inline*/ __m128i ssehash(const __m128i& x, const __m128i& y,
const __m128i& z)
@@ -391,11 +407,13 @@
__m128 xx = _mm_cvtepi32_ps(x);
__m128 yy = _mm_cvtepi32_ps(y);
__m128 zz = _mm_cvtepi32_ps(z);
- xx = _mm_add_ps(xx, _mm_set1_ps(0.6180339887)); // Avoid singularity
when x==0
- yy = _mm_add_ps(yy, _mm_set1_ps(0.6180339887));
- zz = _mm_add_ps(zz, _mm_set1_ps(0.6180339887));
+ __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);
+ zz = _mm_add_ps(zz, inv_golden);
__m128 hh = _mm_mul_ps(_mm_mul_ps(xx, yy),
- _mm_mul_ps(zz, _mm_set1_ps(3.14159265389793)));
+ _mm_mul_ps(zz, pi));
return _mm_srai_epi32(_mm_castps_si128(hh), 17);
#endif
}
Modified: trunk/Core/Math/Noise.h
==============================================================================
--- trunk/Core/Math/Noise.h (original)
+++ trunk/Core/Math/Noise.h Wed Jun 27 17:18:42 2007
@@ -34,6 +34,9 @@
const __m128 & y,
const __m128 & z);
__m128i permutationSSE(const __m128i& index);
+ __m128i CheapRNG(const __m128i& val);
+ __m128i DissolveRNG(const __m128i& val);
+ __m128i PermutationTable(const __m128i& index);
#endif
/**
Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc (original)
+++ trunk/StandAlone/manta.cc Wed Jun 27 17:18:42 2007
@@ -563,7 +563,6 @@
throw IllegalArgument( s, i, args );
}
} else if(arg == "-renderer"){
- cerr << "renderer\n";
string s;
if(!getStringArg(i, args, s)){
usage(factory);
- [MANTA] r1431 - in trunk: Core/Math StandAlone, bigler, 06/27/2007
Archive powered by MHonArc 2.6.16.