RavEngine
Loading...
Searching...
No Matches
GuBV4_Slabs_SwizzledOrdered.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef GU_BV4_SLABS_SWIZZLED_ORDERED_H
30#define GU_BV4_SLABS_SWIZZLED_ORDERED_H
31
32 // Generic + PNS
33/* template<class LeafTestT, class ParamsT>
34 static void BV4_ProcessStreamSwizzledOrdered(const BVDataPacked* PX_RESTRICT node, PxU32 initData, ParamsT* PX_RESTRICT params)
35 {
36 const BVDataPacked* root = node;
37
38 PxU32 nb=1;
39 PxU32 stack[GU_BV4_STACK_SIZE];
40 stack[0] = initData;
41
42 const PxU32* tmp = reinterpret_cast<const PxU32*>(&params->mLocalDir_Padded);
43 const PxU32 X = tmp[0]>>31;
44 const PxU32 Y = tmp[1]>>31;
45 const PxU32 Z = tmp[2]>>31;
46// const PxU32 X = PX_IR(params->mLocalDir_Padded.x)>>31;
47// const PxU32 Y = PX_IR(params->mLocalDir_Padded.y)>>31;
48// const PxU32 Z = PX_IR(params->mLocalDir_Padded.z)>>31;
49 const PxU32 bitIndex = 3+(Z|(Y<<1)|(X<<2));
50 const PxU32 dirMask = 1u<<bitIndex;
51
52 do
53 {
54 const PxU32 childData = stack[--nb];
55 node = root + getChildOffset(childData);
56 const PxU32 nodeType = getChildType(childData);
57
58 const BVDataSwizzled* tn = reinterpret_cast<const BVDataSwizzled*>(node);
59
60 PxU32 code2 = 0;
61 BV4_ProcessNodeOrdered2_Swizzled<LeafTestT, 0>(code2, tn, params);
62 BV4_ProcessNodeOrdered2_Swizzled<LeafTestT, 1>(code2, tn, params);
63 if(nodeType>0)
64 BV4_ProcessNodeOrdered2_Swizzled<LeafTestT, 2>(code2, tn, params);
65 if(nodeType>1)
66 BV4_ProcessNodeOrdered2_Swizzled<LeafTestT, 3>(code2, tn, params);
67
68 SLABS_PNS
69
70 }while(nb);
71 }*/
72
73 // Generic + PNS
74 template<class LeafTestT, class ParamsT>
75 static void BV4_ProcessStreamSwizzledOrderedQ(const BVDataPackedQ* PX_RESTRICT node, PxU32 initData, ParamsT* PX_RESTRICT params)
76 {
77 const BVDataPackedQ* root = node;
78
79 PxU32 nb=1;
80 PxU32 stack[GU_BV4_STACK_SIZE];
81 stack[0] = initData;
82
83 const PxU32* tmp = reinterpret_cast<const PxU32*>(&params->mLocalDir_Padded);
84 const PxU32 X = tmp[0]>>31;
85 const PxU32 Y = tmp[1]>>31;
86 const PxU32 Z = tmp[2]>>31;
87// const PxU32 X = PX_IR(params->mLocalDir_Padded.x)>>31;
88// const PxU32 Y = PX_IR(params->mLocalDir_Padded.y)>>31;
89// const PxU32 Z = PX_IR(params->mLocalDir_Padded.z)>>31;
90 const PxU32 bitIndex = 3+(Z|(Y<<1)|(X<<2));
91 const PxU32 dirMask = 1u<<bitIndex;
92
93 do
94 {
95 const PxU32 childData = stack[--nb];
96 node = root + getChildOffset(childData);
97 const PxU32 nodeType = getChildType(childData);
98
99 const BVDataSwizzledQ* tn = reinterpret_cast<const BVDataSwizzledQ*>(node);
100
101 PxU32 code2 = 0;
102 BV4_ProcessNodeOrdered2_SwizzledQ<LeafTestT, 0>(code2, tn, params);
103 BV4_ProcessNodeOrdered2_SwizzledQ<LeafTestT, 1>(code2, tn, params);
104 if(nodeType>0)
105 BV4_ProcessNodeOrdered2_SwizzledQ<LeafTestT, 2>(code2, tn, params);
106 if(nodeType>1)
107 BV4_ProcessNodeOrdered2_SwizzledQ<LeafTestT, 3>(code2, tn, params);
108
109 SLABS_PNS
110
111 }while(nb);
112 }
113
114 // Generic + PNS
115 template<class LeafTestT, class ParamsT>
116 static void BV4_ProcessStreamSwizzledOrderedNQ(const BVDataPackedNQ* PX_RESTRICT node, PxU32 initData, ParamsT* PX_RESTRICT params)
117 {
118 const BVDataPackedNQ* root = node;
119
120 PxU32 nb=1;
121 PxU32 stack[GU_BV4_STACK_SIZE];
122 stack[0] = initData;
123
124 const PxU32* tmp = reinterpret_cast<const PxU32*>(&params->mLocalDir_Padded);
125 const PxU32 X = tmp[0]>>31;
126 const PxU32 Y = tmp[1]>>31;
127 const PxU32 Z = tmp[2]>>31;
128// const PxU32 X = PX_IR(params->mLocalDir_Padded.x)>>31;
129// const PxU32 Y = PX_IR(params->mLocalDir_Padded.y)>>31;
130// const PxU32 Z = PX_IR(params->mLocalDir_Padded.z)>>31;
131 const PxU32 bitIndex = 3+(Z|(Y<<1)|(X<<2));
132 const PxU32 dirMask = 1u<<bitIndex;
133
134 do
135 {
136 const PxU32 childData = stack[--nb];
137 node = root + getChildOffset(childData);
138 const PxU32 nodeType = getChildType(childData);
139
140 const BVDataSwizzledNQ* tn = reinterpret_cast<const BVDataSwizzledNQ*>(node);
141
142 PxU32 code2 = 0;
143 BV4_ProcessNodeOrdered2_SwizzledNQ<LeafTestT, 0>(code2, tn, params);
144 BV4_ProcessNodeOrdered2_SwizzledNQ<LeafTestT, 1>(code2, tn, params);
145 if(nodeType>0)
146 BV4_ProcessNodeOrdered2_SwizzledNQ<LeafTestT, 2>(code2, tn, params);
147 if(nodeType>1)
148 BV4_ProcessNodeOrdered2_SwizzledNQ<LeafTestT, 3>(code2, tn, params);
149
150 SLABS_PNS
151
152 }while(nb);
153 }
154
155
156#endif // GU_BV4_SLABS_SWIZZLED_ORDERED_H
#define PX_RESTRICT
Definition PxPreprocessor.h:355