aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/fieldsampler/include/FieldSamplerWrapper.h
blob: 4eebc10b670b1da849e8f4ba2e3e94282397e740 (plain) (blame)
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
/*
 * 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_WRAPPER_H__
#define __FIELD_SAMPLER_WRAPPER_H__

#include "Apex.h"
#include "ApexSDKHelpers.h"
#include "ApexActor.h"
#include "FieldSamplerIntl.h"

#if APEX_CUDA_SUPPORT
#include "ApexCudaWrapper.h"
#endif

#include "FieldSamplerSceneWrapper.h"
#include "FieldSamplerCommon.h"

namespace nvidia
{
namespace fieldsampler
{

class FieldSamplerManager;

class FieldBoundaryWrapper;

class FieldSamplerWrapper : 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;
	}

	FieldSamplerWrapper(ResourceList& list, FieldSamplerManager* manager, FieldSamplerIntl* fieldSampler, const FieldSamplerDescIntl& fieldSamplerDesc, FieldSamplerSceneWrapper* fieldSamplerSceneWrapper);

	virtual void update();

	PX_INLINE FieldSamplerIntl* getInternalFieldSampler() const
	{
		return mFieldSampler;
	}
	PX_INLINE const FieldSamplerDescIntl& getInternalFieldSamplerDesc() const
	{
		return mFieldSamplerDesc;
	}
	PX_INLINE FieldSamplerSceneWrapper* getFieldSamplerSceneWrapper() const
	{
		return mSceneWrapper;
	}

	bool addFieldBoundary(FieldBoundaryWrapper* wrapper);
	bool removeFieldBoundary(FieldBoundaryWrapper* wrapper);

	uint32_t getFieldBoundaryCount() const
	{
		return mFieldBoundaryInfoArray.size();
	}
	FieldBoundaryWrapper* getFieldBoundaryWrapper(uint32_t index) const
	{
		return mFieldBoundaryInfoArray[index]->getFieldBoundaryWrapper();
	}

	PX_INLINE const FieldShapeDescIntl&   getInternalFieldSamplerShape() const
	{
		return mFieldSamplerShape;
	}
	PX_INLINE bool                      isFieldSamplerChanged() const
	{
		return mFieldSamplerShapeChanged;
	}
	PX_INLINE bool                      isEnabled() const
	{
		return mIsEnabled;
	}
	PX_INLINE bool                      isEnabledChanged() const
	{
		return (mIsEnabled != mIsEnabledLast);
	}

protected:
	FieldSamplerManager*		mManager;
	FieldSamplerIntl*				mFieldSampler;
	FieldSamplerDescIntl			mFieldSamplerDesc;

	FieldShapeDescIntl			mFieldSamplerShape;
	bool						mFieldSamplerShapeChanged;

	FieldSamplerSceneWrapper*	mSceneWrapper;
	uint32_t				mQueryRefCount;

	nvidia::Array<FieldSamplerSceneWrapper::FieldBoundaryInfo*>	mFieldBoundaryInfoArray;
	bool														mFieldBoundaryInfoArrayChanged;

	bool						mIsEnabled;
	bool						mIsEnabledLast;

	friend class FieldSamplerManager;
};


class FieldSamplerWrapperCPU : public FieldSamplerWrapper
{
public:
	FieldSamplerWrapperCPU(ResourceList& list, FieldSamplerManager* manager, FieldSamplerIntl* fieldSampler, const FieldSamplerDescIntl& fieldSamplerDesc, FieldSamplerSceneWrapper* fieldSamplerSceneWrapper);

private:
};

#if APEX_CUDA_SUPPORT
class FieldSamplerWrapperGPU : public FieldSamplerWrapperCPU
{
public:
	FieldSamplerWrapperGPU(ResourceList& list, FieldSamplerManager* manager, FieldSamplerIntl* fieldSampler, const FieldSamplerDescIntl& fieldSamplerDesc, FieldSamplerSceneWrapper* fieldSamplerSceneWrapper);

	virtual void update();

	PX_INLINE InplaceHandle<FieldSamplerParams>   getParamsHandle() const
	{
		PX_ASSERT(mFieldSamplerParamsHandle.isNull() == false);
		return mFieldSamplerParamsHandle;
	}

private:
	ApexCudaConstMemGroup               mConstMemGroup;
	InplaceHandle<FieldSamplerParams>   mFieldSamplerParamsHandle;
};
#endif

}
} // end namespace nvidia::apex

#endif