Changeset 2176 for GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
- Timestamp:
- 02/28/07 19:38:47 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r2170 r2176 22 22 #include "OspTree.h" 23 23 24 #if USE_SSE 25 #include <xmmintrin.h> 26 #endif 24 27 25 28 … … 3500 3503 } 3501 3504 3502 3503 } 3505 #if 0 3506 void VspTree::TraverseRayPacket(RayBundle &rays); 3507 { 3508 float splitPos [3]; 3509 float dist[3]; 3510 3511 const int allValid = 1xf; 3512 int mask = all_valid; 3513 3514 int comparisonResult = 0; 3515 3516 while (!node->IsLeaf()) 3517 { 3518 comparisonResult = 0; 3519 3520 for (int i = 0; i < 4; ++ i) 3521 { 3522 splitPos[i] = node->splitPos; 3523 dist[i] = (splitpos[i] rp.origin[i][axis]) / (rp.dir[i][axis]); 3524 3525 comparisonresult |= ((dist[i] <= tnear[i]) << i); 3526 } 3527 3528 comparisonresult &= mask; 3529 3530 if (comparisonresult == allValid) 3531 { 3532 node = node->far; 3533 continue 3534 } 3535 3536 comparisonresult = 0; 3537 3538 for (int i = 0; i < 4; ++ i){ 3539 3540 comparisonresult |= (dist[i] >= tfar[i]); 3541 } 3542 3543 comparisonresult &= mask; 3544 3545 if (comparisonresult == allValid) 3546 { 3547 node = node->near; 3548 continue; 3549 } 3550 3551 if (comparisonresult) 3552 { 3553 3554 Push( node->far, dist[0...3], tfar[0...3] ) 3555 3556 node = node->near; 3557 3558 mask = 0; 3559 3560 for (int i = 0; i < 4; ++ i) 3561 { 3562 bool b = (tnear[i] < tfar[i]); 3563 mask |= b; 3564 3565 if (b) 3566 { 3567 tfar[i] = dist[i]; 3568 } 3569 3570 } 3571 3572 } 3573 } 3574 #endif 3575 /* 3576 struct RayPacket 3577 { 3578 union { float ox[4]; __m128 ox4; }; 3579 union { float oy[4]; __m128 oy4; }; 3580 union { float oz[4]; __m128 oz4; }; 3581 union { float dx[4]; __m128 dx4; }; 3582 union { float dy[4]; __m128 dy4; }; 3583 union { float dz[4]; __m128 dz4; }; 3584 }; 3585 */ 3586 void VspTree::TraverseRayPacket()//RayBundle &rays) 3587 { 3588 #if USE_SSE 3589 VspNode *node; 3590 3591 RayPacket rp; 3592 3593 __m128 mask; 3594 __m128 tf4; 3595 __m128 tn4; 3596 //const int offs[4] = { (RP->dcell[0] >= 0)?1:0, (RP->dcell[4] >= 0)?1:0, (RP->dcell[8] >= 0)?1:0, 0 }; 3597 3598 const int offs[4] = { 0, 0, 0, 0 }; 3599 3600 while (!node->IsLeaf()) 3601 { 3602 VspInterior *interior = static_cast<VspInterior *>(node); 3603 3604 float pos = interior->GetPosition(); 3605 const __m128 spos = _mm_load_ps(&pos); 3606 3607 const int aidx = interior->GetAxis(); 3608 const __m128 d4;// = _mm_mul_ps( _mm_sub_ps( spos, RP->oc4[aidx] ), RP->rdc4[aidx] ); 3609 3610 VspNode* ln = interior->GetBack();// + offs[aidx]; 3611 3612 if (!_mm_movemask_ps( _mm_and_ps( _mm_cmpgt_ps( d4, tn4 ), mask ) )) 3613 { 3614 node = ln; 3615 continue; 3616 } 3617 3618 node = interior->GetBack();// + (offs[aidx]^1); 3619 3620 if (_mm_movemask_ps( _mm_and_ps( _mm_cmplt_ps( d4, tf4 ), mask ) )) 3621 { 3622 const __m128 mask2 = _mm_cmpgt_ps( d4, tn4 ); 3623 const __m128 mask3 = _mm_cmplt_ps( d4, tf4 ); 3624 3625 //m_Stack[stackptr].tf4 = tf4; 3626 3627 tf4 = _mm_or_ps( _mm_and_ps( mask3, d4 ), _mm_andnot_ps( mask3, tf4 ) ); 3628 3629 //m_Stack[stackptr].node = (KdTreeNode*)ln; 3630 //m_Stack[stackptr].mask = mask; 3631 //m_Stack[stackptr++].tn4 = _mm_or_ps( _mm_and_ps( mask2, d4 ), _mm_andnot_ps( mask2, tn4 ) ); 3632 mask = _mm_cmplt_ps( tn4, tf4 ); 3633 } 3634 } 3635 #endif 3636 3637 } 3638 3639 }
Note: See TracChangeset
for help on using the changeset viewer.