Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1231 - trunk/Model/Materials
- Date: Tue, 31 Oct 2006 21:27:36 -0700 (MST)
Author: bigler
Date: Tue Oct 31 21:27:35 2006
New Revision: 1231
Modified:
trunk/Model/Materials/Phong.cc
Log:
Tried to make use of the or(and, andnot) masked move functionality.
Functional, but not complete.
Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc (original)
+++ trunk/Model/Materials/Phong.cc Tue Oct 31 21:27:35 2006
@@ -49,6 +49,18 @@
using namespace Manta;
+#define USE_MASKEDSTORE 1
+static inline void maskedStore(__m128i mask, __m128i* oldD, __m128i newD) {
+ _mm_store_si128(oldD,
+ _mm_or_si128(_mm_and_si128(mask, newD),
+ _mm_andnot_si128(mask,
_mm_load_si128(oldD))));
+}
+static inline void maskedStore(__m128 mask, float* oldD, __m128 newD) {
+ _mm_store_ps(oldD,
+ _mm_or_ps(_mm_and_ps(mask, newD),
+ _mm_andnot_ps(mask, _mm_load_ps(oldD))));
+}
+
Phong::Phong(const Color& diffuse, const Color& specular,
int specpow, ColorComponent refl)
: specpow(specpow)
@@ -211,9 +223,33 @@
_mm_store_ps(&ambientAndDiffuseLight[1][i],
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]), _mm_mul_ps(lightg,
cos_theta)));
_mm_store_ps(&ambientAndDiffuseLight[2][i],
_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]), _mm_mul_ps(lightb,
cos_theta)));
} else {
+#if USE_MASKEDSTORE
+#if 0
+ maskedStore(_mm_castps_si128(mask),
+ (__m128i*)&ambientAndDiffuseLight[0][i],
+
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]),
_mm_mul_ps(lightr, cos_theta))));
+ maskedStore(_mm_castps_si128(mask),
+ (__m128i*)&ambientAndDiffuseLight[1][i],
+
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]),
_mm_mul_ps(lightg, cos_theta))));
+ maskedStore(_mm_castps_si128(mask),
+ (__m128i*)&ambientAndDiffuseLight[2][i],
+
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]),
_mm_mul_ps(lightb, cos_theta))));
+#else
+ maskedStore(mask,(float*)&ambientAndDiffuseLight[0][i],
+ _mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]),
+ _mm_mul_ps(lightr, cos_theta)));
+ maskedStore(mask,(float*)&ambientAndDiffuseLight[1][i],
+ _mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]),
+ _mm_mul_ps(lightg, cos_theta)));
+ maskedStore(mask,(float*)&ambientAndDiffuseLight[2][i],
+ _mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]),
+ _mm_mul_ps(lightb, cos_theta)));
+#endif
+#else // USE_MASKEDSTORE
_mm_maskmoveu_si128((__m128i)
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[0][i]),
_mm_mul_ps(lightr, cos_theta))), (__m128i) _mm_castps_si128(mask),
(char*)&ambientAndDiffuseLight[0][i]);
_mm_maskmoveu_si128((__m128i)
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[1][i]),
_mm_mul_ps(lightg, cos_theta))), (__m128i) _mm_castps_si128(mask),
(char*)&ambientAndDiffuseLight[1][i]);
_mm_maskmoveu_si128((__m128i)
_mm_castps_si128(_mm_add_ps(_mm_load_ps(&ambientAndDiffuseLight[2][i]),
_mm_mul_ps(lightb, cos_theta))), (__m128i) _mm_castps_si128(mask),
(char*)&ambientAndDiffuseLight[2][i]);
+#endif
}
__m128 Hx = _mm_sub_ps(sdx, _mm_load_ps(&data->direction[0][i]));
- [MANTA] r1231 - trunk/Model/Materials, bigler, 10/31/2006
Archive powered by MHonArc 2.6.16.