MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / v_screen_size_b

Function v_screen_size_b

include/vecmath/dag_vecMath_common.h:2144–2245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2142// also, screen_box is minX, maxX, minY, maxY - in clipspace coordinates (-1, -1) .. (1,1)
2143
2144VECTORCALL VECMATH_FINLINE int v_screen_size_b(vec3f bmin, vec3f bmax, vec3f threshold, vec4f &screen_box, mat44f_cref clip)
2145{
2146 // get aabb points (SoA)
2147 vec4f minmax_x = v_perm_xXxX(bmin, bmax);
2148 vec4f minmax_y = v_perm_yyYY(bmin, bmax);
2149 vec4f minmax_z_0 = v_splat_z(bmin);
2150 vec4f minmax_z_1 = v_splat_z(bmax);
2151
2152 // transform points to clip space
2153 vec4f points_cs_0[4];
2154 vec4f points_cs_1[4];
2155
2156 vis_transform_points_4(points_cs_0, minmax_x, minmax_y, minmax_z_0, clip);
2157 vis_transform_points_4(points_cs_1, minmax_x, minmax_y, minmax_z_1, clip);
2158
2159 // calculate -w
2160 vec4f points_cs_0_negw = v_neg(points_cs_0[3]);
2161 vec4f points_cs_1_negw = v_neg(points_cs_1[3]);
2162
2163#if _TARGET_SIMD_SSE
2164 #define NOUT(a, b, c, d) (unsigned(-_mm_movemask_ps(v_or(v_cmp_gt(a, b), v_cmp_gt(c, d)))))
2165 unsigned nout;
2166 nout = (NOUT(points_cs_0[0], points_cs_0_negw, points_cs_1[0], points_cs_1_negw));
2167 nout &= (NOUT(points_cs_0[3], points_cs_0[0], points_cs_1[3], points_cs_1[0]));
2168 nout &= (NOUT(points_cs_0[1], points_cs_0_negw, points_cs_1[1], points_cs_1_negw));
2169 nout &= (NOUT(points_cs_0[3], points_cs_0[1], points_cs_1[3], points_cs_1[1]));
2170 nout &= (NOUT(points_cs_0[2], v_zero(), points_cs_1[2], v_zero()));
2171 nout &= (NOUT(points_cs_0[3], points_cs_0[2], points_cs_1[3], points_cs_1[2]));
2172
2173 // merge "not outside" flags
2174 if ((nout&(1<<31)) == 0)
2175 return 0;
2176
2177#else
2178 #define NOUT(a, b, c, d) v_hor(v_or(v_cmp_gt(a, b), v_cmp_gt(c, d)))
2179 vec4f nout0 = NOUT(points_cs_0[0], points_cs_0_negw, points_cs_1[0], points_cs_1_negw);
2180 vec4f nout1 = NOUT(points_cs_0[3], points_cs_0[0], points_cs_1[3], points_cs_1[0]);
2181 vec4f nout2 = NOUT(points_cs_0[1], points_cs_0_negw, points_cs_1[1], points_cs_1_negw);
2182 vec4f nout3 = NOUT(points_cs_0[3], points_cs_0[1], points_cs_1[3], points_cs_1[1]);
2183 vec4f nout4 = NOUT(points_cs_0[2], v_zero(), points_cs_1[2], v_zero());
2184 vec4f nout5 = NOUT(points_cs_0[3], points_cs_0[2], points_cs_1[3], points_cs_1[2]);
2185
2186 // merge "not outside" flags
2187 vec4f nout01 = v_and(nout0, nout1);
2188 vec4f nout012 = v_and(nout01, nout2);
2189
2190 vec4f nout34 = v_and(nout3, nout4);
2191 vec4f nout345 = v_and(nout34, nout5);
2192
2193 vec4f nout = v_and(nout012, nout345);
2194
2195 if (v_test_vec_x_eqi_0(nout)) //"not outside"=0 -> outside=1
2196 return 0;
2197
2198#endif
2199 #undef NOUT
2200 vec4f eps = *(vec4f*)v_screen_div_eps;
2201 vec4f valid_cs_0 = v_cmp_gt(points_cs_0[3], eps);

Callers

nothing calls this directly

Calls 15

vis_transform_points_4Function · 0.85
v_rcpFunction · 0.85
v_splat_zFunction · 0.70
v_negFunction · 0.70
v_zeroFunction · 0.70
v_andFunction · 0.70
v_test_vec_x_eqi_0Function · 0.70
v_cmp_gtFunction · 0.70
v_rot_1Function · 0.70
v_rot_2Function · 0.70
v_mulFunction · 0.70
v_merge_hwFunction · 0.70

Tested by

no test coverage detected