107#if HAVE_SSE_EXTENSIONS
110 const __m128 mmNF = _mm_mul_ps(mmNear, mmFar);
111 const __m128 mmF_N = _mm_sub_ps(mmFar, mmNear);
112 static const __m128 mmOnes = _mm_set1_ps(1);
113 static const __m128 mmZeros = _mm_set1_ps(0);
116 if (!isAligned16(depth))
119 unsigned first = 16 - alignment16(depth);
123 const float nf = near * far;
124 const float f_n = far - near;
126 while (depth < depthEnd && idx++ < first)
127 if (*depth != 0 && *depth != 1)
128 *depth = nf / (far - *depth * f_n);
134 float* depth2 = depthEnd - last;
135 while (depth2 < depthEnd)
136 if (*depth2 != 0 && *depth2 != 1)
137 *depth2 = nf / (far - *depth2 * f_n);
144 const __m128* mmEnd = (__m128*)depthEnd;
145 __m128* mmDepth = (__m128*)depth;
147 while (mmDepth < mmEnd)
149 __m128 mask = _mm_and_ps(_mm_cmpneq_ps(*mmDepth, mmOnes), _mm_cmpneq_ps(*mmDepth, mmZeros));
150 *mmDepth = _mm_mul_ps(*mmDepth, mmF_N);
151 *mmDepth = _mm_sub_ps(mmFar, *mmDepth);
152 *mmDepth = _mm_div_ps(mmNF, *mmDepth);
153 *mmDepth = _mm_and_ps(*mmDepth, mask);
161 const float nf = near * far;
162 const float f_n = far - near;
165 while (depth < depth_end)
167 if (*depth != 0 && *depth != 1)
169 *depth = nf / (far - *depth * f_n);
183#if HAVE_SSE_EXTENSIONS
187 const __m128 mmScale = _mm_sub_ps(mmFar, mmNear);
190 if (!isAligned16(depth))
193 unsigned first = 16 - alignment16(depth);
197 while (depth < depthEnd && idx++ < first)
198 if (*depth != 0 && *depth != 1.0)
199 *depth = *depth * scale + offset;
205 float* depth2 = depthEnd - last;
206 while (depth2 < depthEnd)
207 if (*depth2 != 0 && *depth != 1.0)
208 *depth2 = *depth2 * scale + offset;
215 const __m128* mmEnd = (__m128*)depthEnd;
216 __m128* mmDepth = (__m128*)depth;
218 while (mmDepth < mmEnd)
220 *mmDepth = _mm_mul_ps(*mmDepth, mmScale);
221 *mmDepth = _mm_add_ps(*mmDepth, mmNear);
222 *mmDepth = _mm_and_ps(*mmDepth, _mm_and_ps(_mm_cmpneq_ps(*mmDepth, mmNear), _mm_cmpneq_ps(*mmDepth, mmFar)));
229 while (depth < depth_end)
233 if (*depth != 0 && *depth != 1.0)
235 *depth = *depth * scale + offset;
Parameters(unsigned width, unsigned height, float near_clipping_plane_distance, float far_clipping_plane_distance)
Constructor taking core parameters that are required for all sensors.