le3d - LightEngine 3D
A straightforward C++ 3D software engine for real-time graphics
flattexalphazc.h
Go to the documentation of this file.
1 
33 inline void LeRasterizer::fillFlatTexAlphaZC(int y, int x1, int x2, int w1, int w2, int u1, int u2, int v1, int v2)
34 {
35  int d = x2 - x1;
36  if (d == 0) return;
37 
38  int au = (u2 - u1) / d;
39  int av = (v2 - v1) / d;
40  int aw = (w2 - w1) / d;
41 
42  if (++x2 > frame.tx) x2 = frame.tx;
43  LeColor * p = x1 + y * frame.tx + pixels;
44 
45  __m128i sc = _mm_set1_epi32(0x01000100);
46  for (int x = x1; x < x2; x ++) {
47  int32_t z = (1 << 30) / (w1 >> 8);
48  uint32_t tu = (((int64_t) u1 * z) >> 24) & texMaskU;
49  uint32_t tv = (((int64_t) v1 * z) >> 24) & texMaskV;
50 
51  __m128i zv = _mm_set1_epi32(0);
52  __m128i tp, fp;
53  fp = _mm_loadl_epi64((__m128i *) p);
54  tp = _mm_loadl_epi64((__m128i *) &texDiffusePixels[tu + (tv << texSizeU)]);
55  fp = _mm_unpacklo_epi8(fp, zv);
56  tp = _mm_unpacklo_epi8(tp, zv);
57 
58  __m128i ap;
59  ap = _mm_shufflelo_epi16(tp, 0xFF);
60  ap = _mm_sub_epi16(sc, ap);
61 
62  tp = _mm_mullo_epi16(tp, color_4);
63  fp = _mm_mullo_epi16(fp, ap);
64  tp = _mm_adds_epu16(tp, fp);
65  tp = _mm_srli_epi16(tp, 8);
66  tp = _mm_packus_epi16(tp, zv);
67  *p++ = _mm_cvtsi128_si32(tp);
68 
69  u1 += au;
70  v1 += av;
71  w1 += aw;
72  }
73 }
int tx
Definition: bitmap.h:81
LeBitmap frame
Definition: rasterizer_float.h:61
Represent an RGBA color.
Definition: color.h:42