1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
/*
* Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#ifndef __FIELD_SAMPLER_SCENE_WRAPPER_H__
#define __FIELD_SAMPLER_SCENE_WRAPPER_H__
#include "Apex.h"
#include "ApexSDKHelpers.h"
#include "ApexActor.h"
#include "FieldSamplerSceneIntl.h"
#if APEX_CUDA_SUPPORT
#include "ApexCudaWrapper.h"
#endif
#include "FieldSamplerCommon.h"
namespace nvidia
{
namespace fieldsampler
{
class FieldSamplerManager;
class FieldSamplerWrapper;
class FieldBoundaryWrapper;
class FieldSamplerSceneWrapper : public ApexResourceInterface, public ApexResource
{
public:
// ApexResourceInterface methods
void release();
void setListIndex(ResourceList& list, uint32_t index)
{
m_listIndex = index;
m_list = &list;
}
uint32_t getListIndex() const
{
return m_listIndex;
}
FieldSamplerSceneWrapper(ResourceList& list, FieldSamplerManager* manager, FieldSamplerSceneIntl* fieldSamplerScene);
FieldSamplerSceneIntl* getInternalFieldSamplerScene() const
{
return mFieldSamplerScene;
}
const FieldSamplerSceneDescIntl& getInternalFieldSamplerSceneDesc() const
{
return mFieldSamplerSceneDesc;
}
virtual void update();
virtual void postUpdate() = 0;
class FieldBoundaryInfo;
FieldBoundaryInfo* addFieldBoundary(FieldBoundaryWrapper* fieldBoundaryWrapper);
void removeFieldBoundary(FieldBoundaryInfo* fieldBoundaryInfo);
protected:
virtual FieldBoundaryInfo* createFieldBoundaryInfo(FieldBoundaryWrapper* fieldBoundaryWrapper) = 0;
protected:
FieldSamplerManager* mManager;
FieldSamplerSceneIntl* mFieldSamplerScene;
FieldSamplerSceneDescIntl mFieldSamplerSceneDesc;
ResourceList mFieldBoundaryList;
bool mFieldBoundaryListChanged;
};
class FieldSamplerSceneWrapper::FieldBoundaryInfo : public ApexResourceInterface, public ApexResource
{
protected:
FieldBoundaryWrapper* mFieldBoundaryWrapper;
uint32_t mRefCount;
FieldBoundaryInfo(ResourceList& list, FieldBoundaryWrapper* fieldBoundaryWrapper)
: mFieldBoundaryWrapper(fieldBoundaryWrapper), mRefCount(0)
{
list.add(*this);
}
public:
FieldBoundaryWrapper* getFieldBoundaryWrapper() const
{
return mFieldBoundaryWrapper;
}
virtual void update() {}
void addRef()
{
++mRefCount;
}
bool releaseRef()
{
if (--mRefCount == 0)
{
release();
return true;
}
return false;
}
// ApexResourceInterface methods
void release()
{
delete this;
}
void setListIndex(ResourceList& list, uint32_t index)
{
m_listIndex = index;
m_list = &list;
}
uint32_t getListIndex() const
{
return m_listIndex;
}
};
/******************************** CPU Version ********************************/
class FieldSamplerSceneWrapperCPU : public FieldSamplerSceneWrapper
{
public:
FieldSamplerSceneWrapperCPU(ResourceList& list, FieldSamplerManager* manager, FieldSamplerSceneIntl* fieldSamplerScene);
virtual void postUpdate() {}
class FieldBoundaryInfoCPU : public FieldBoundaryInfo
{
public:
FieldBoundaryInfoCPU(ResourceList& list, FieldBoundaryWrapper* fieldBoundaryWrapper)
: FieldBoundaryInfo(list, fieldBoundaryWrapper)
{
}
};
protected:
virtual FieldBoundaryInfo* createFieldBoundaryInfo(FieldBoundaryWrapper* fieldBoundaryWrapper)
{
return PX_NEW(FieldBoundaryInfoCPU)(mFieldBoundaryList, fieldBoundaryWrapper);
}
};
/******************************** GPU Version ********************************/
#if APEX_CUDA_SUPPORT
class FieldSamplerSceneWrapperGPU : public FieldSamplerSceneWrapper
{
public:
FieldSamplerSceneWrapperGPU(ResourceList& list, FieldSamplerManager* manager, FieldSamplerSceneIntl* fieldSamplerScene);
virtual void postUpdate();
PX_INLINE ApexCudaConstStorage& getConstStorage()
{
return mConstStorage;
}
class FieldBoundaryInfoGPU : public FieldBoundaryInfo
{
public:
FieldBoundaryInfoGPU(ResourceList& list, FieldBoundaryWrapper* fieldBoundaryWrapper, ApexCudaConstStorage& constStorage);
virtual void update();
PX_INLINE InplaceHandle<FieldShapeGroupParams> getShapeGroupParamsHandle() const
{
PX_ASSERT(mFieldShapeGroupParamsHandle.isNull() == false);
return mFieldShapeGroupParamsHandle;
}
private:
ApexCudaConstMemGroup mConstMemGroup;
InplaceHandle<FieldShapeGroupParams> mFieldShapeGroupParamsHandle;
};
protected:
virtual FieldBoundaryInfo* createFieldBoundaryInfo(FieldBoundaryWrapper* fieldBoundaryWrapper)
{
return PX_NEW(FieldBoundaryInfoGPU)(mFieldBoundaryList, fieldBoundaryWrapper, getConstStorage());
}
private:
FieldSamplerSceneWrapperGPU& operator=(const FieldSamplerSceneWrapperGPU&);
ApexCudaConstStorage& mConstStorage;
};
#endif // APEX_CUDA_SUPPORT
}
} // end namespace nvidia::apex
#endif
|