1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://ogre.sourceforge.net/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #include "OgreStableHeaders.h"
|
---|
26 | #include "OgreGpuProgram.h"
|
---|
27 | #include "OgreHighLevelGpuProgram.h"
|
---|
28 | #include "OgreGpuProgramManager.h"
|
---|
29 | #include "OgreVector3.h"
|
---|
30 | #include "OgreVector4.h"
|
---|
31 | #include "OgreAutoParamDataSource.h"
|
---|
32 | #include "OgreLight.h"
|
---|
33 | #include "OgreRoot.h"
|
---|
34 | #include "OgreRenderSystem.h"
|
---|
35 | #include "OgreRenderSystemCapabilities.h"
|
---|
36 | #include "OgreStringConverter.h"
|
---|
37 |
|
---|
38 | namespace Ogre
|
---|
39 | {
|
---|
40 | //-----------------------------------------------------------------------------
|
---|
41 | GpuProgram::CmdType GpuProgram::msTypeCmd;
|
---|
42 | GpuProgram::CmdSyntax GpuProgram::msSyntaxCmd;
|
---|
43 | GpuProgram::CmdSkeletal GpuProgram::msSkeletalCmd;
|
---|
44 |
|
---|
45 |
|
---|
46 | GpuProgramParameters::AutoConstantDefinition GpuProgramParameters::AutoConstantDictionary[] = {
|
---|
47 | AutoConstantDefinition(ACT_WORLD_MATRIX, "world_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
48 | AutoConstantDefinition(ACT_INVERSE_WORLD_MATRIX, "inverse_world_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
49 | AutoConstantDefinition(ACT_TRANSPOSE_WORLD_MATRIX, "transpose_world_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
50 | AutoConstantDefinition(ACT_INVERSE_TRANSPOSE_WORLD_MATRIX, "inverse_transpose_world_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
51 |
|
---|
52 | AutoConstantDefinition(ACT_WORLD_MATRIX_ARRAY_3x4, "world_matrix_array_3x4", 12, ET_REAL, ACDT_NONE),
|
---|
53 | AutoConstantDefinition(ACT_WORLD_MATRIX_ARRAY, "world_matrix_array", 16, ET_REAL, ACDT_NONE),
|
---|
54 |
|
---|
55 | AutoConstantDefinition(ACT_VIEW_MATRIX, "view_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
56 | AutoConstantDefinition(ACT_INVERSE_VIEW_MATRIX, "inverse_view_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
57 | AutoConstantDefinition(ACT_TRANSPOSE_VIEW_MATRIX, "transpose_view_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
58 | AutoConstantDefinition(ACT_INVERSE_TRANSPOSE_VIEW_MATRIX, "inverse_transpose_view_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
59 |
|
---|
60 | AutoConstantDefinition(ACT_PROJECTION_MATRIX, "projection_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
61 | AutoConstantDefinition(ACT_INVERSE_PROJECTION_MATRIX, "inverse_projection_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
62 | AutoConstantDefinition(ACT_TRANSPOSE_PROJECTION_MATRIX, "transpose_projection_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
63 | AutoConstantDefinition(ACT_INVERSE_TRANSPOSE_PROJECTION_MATRIX, "inverse_transpose_projection_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
64 |
|
---|
65 | AutoConstantDefinition(ACT_VIEWPROJ_MATRIX, "viewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
66 | AutoConstantDefinition(ACT_INVERSE_VIEWPROJ_MATRIX, "inverse_viewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
67 | AutoConstantDefinition(ACT_TRANSPOSE_VIEWPROJ_MATRIX, "transpose_viewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
68 | AutoConstantDefinition(ACT_INVERSE_TRANSPOSE_VIEWPROJ_MATRIX, "inverse_transpose_viewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
69 |
|
---|
70 | AutoConstantDefinition(ACT_WORLDVIEW_MATRIX, "worldview_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
71 | AutoConstantDefinition(ACT_INVERSE_WORLDVIEW_MATRIX, "inverse_worldview_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
72 | AutoConstantDefinition(ACT_TRANSPOSE_WORLDVIEW_MATRIX, "transpose_worldview_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
73 | AutoConstantDefinition(ACT_INVERSE_TRANSPOSE_WORLDVIEW_MATRIX, "inverse_transpose_worldview_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
74 |
|
---|
75 | AutoConstantDefinition(ACT_WORLDVIEWPROJ_MATRIX, "worldviewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
76 | AutoConstantDefinition(ACT_INVERSE_WORLDVIEWPROJ_MATRIX, "inverse_worldviewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
77 | AutoConstantDefinition(ACT_TRANSPOSE_WORLDVIEWPROJ_MATRIX, "transpose_worldviewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
78 | AutoConstantDefinition(ACT_INVERSE_TRANSPOSE_WORLDVIEWPROJ_MATRIX, "inverse_transpose_worldviewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
79 |
|
---|
80 | AutoConstantDefinition(ACT_RENDER_TARGET_FLIPPING, "render_target_flipping", 1, ET_REAL, ACDT_NONE),
|
---|
81 |
|
---|
82 | AutoConstantDefinition(ACT_FOG_COLOUR, "fog_colour", 4, ET_REAL, ACDT_NONE),
|
---|
83 | AutoConstantDefinition(ACT_FOG_PARAMS, "fog_params", 4, ET_REAL, ACDT_NONE),
|
---|
84 |
|
---|
85 | AutoConstantDefinition(ACT_AMBIENT_LIGHT_COLOUR, "ambient_light_colour", 4, ET_REAL, ACDT_NONE),
|
---|
86 | AutoConstantDefinition(ACT_LIGHT_DIFFUSE_COLOUR, "light_diffuse_colour", 4, ET_REAL, ACDT_INT),
|
---|
87 | AutoConstantDefinition(ACT_LIGHT_SPECULAR_COLOUR, "light_specular_colour", 4, ET_REAL, ACDT_INT),
|
---|
88 | AutoConstantDefinition(ACT_LIGHT_ATTENUATION, "light_attenuation", 4, ET_REAL, ACDT_INT),
|
---|
89 | AutoConstantDefinition(ACT_LIGHT_POSITION, "light_position", 4, ET_REAL, ACDT_INT),
|
---|
90 | AutoConstantDefinition(ACT_LIGHT_POSITION_OBJECT_SPACE, "light_position_object_space", 4, ET_REAL, ACDT_INT),
|
---|
91 | AutoConstantDefinition(ACT_LIGHT_POSITION_VIEW_SPACE, "light_position_view_space", 4, ET_REAL, ACDT_INT),
|
---|
92 | AutoConstantDefinition(ACT_LIGHT_DIRECTION, "light_direction", 4, ET_REAL, ACDT_INT),
|
---|
93 | AutoConstantDefinition(ACT_LIGHT_DIRECTION_OBJECT_SPACE, "light_direction_object_space", 4, ET_REAL, ACDT_INT),
|
---|
94 | AutoConstantDefinition(ACT_LIGHT_DIRECTION_VIEW_SPACE, "light_direction_view_space", 4, ET_REAL, ACDT_INT),
|
---|
95 | AutoConstantDefinition(ACT_LIGHT_DISTANCE_OBJECT_SPACE, "light_distance_object_space", 1, ET_REAL, ACDT_INT),
|
---|
96 | AutoConstantDefinition(ACT_LIGHT_POWER_SCALE, "light_power", 1, ET_REAL, ACDT_INT),
|
---|
97 | AutoConstantDefinition(ACT_SHADOW_EXTRUSION_DISTANCE, "shadow_extrusion_distance", 1, ET_REAL, ACDT_INT),
|
---|
98 | AutoConstantDefinition(ACT_CAMERA_POSITION, "camera_position", 3, ET_REAL, ACDT_NONE),
|
---|
99 | AutoConstantDefinition(ACT_CAMERA_POSITION_OBJECT_SPACE, "camera_position_object_space", 3, ET_REAL, ACDT_NONE),
|
---|
100 | AutoConstantDefinition(ACT_TEXTURE_VIEWPROJ_MATRIX, "texture_viewproj_matrix", 16, ET_REAL, ACDT_NONE),
|
---|
101 | AutoConstantDefinition(ACT_CUSTOM, "custom", 4, ET_REAL, ACDT_INT), // *** needs to be tested
|
---|
102 | AutoConstantDefinition(ACT_TIME, "time", 1, ET_REAL, ACDT_REAL),
|
---|
103 | AutoConstantDefinition(ACT_TIME_0_X, "time_0_x", 4, ET_REAL, ACDT_REAL),
|
---|
104 | AutoConstantDefinition(ACT_COSTIME_0_X, "costime_0_x", 4, ET_REAL, ACDT_REAL),
|
---|
105 | AutoConstantDefinition(ACT_SINTIME_0_X, "sintime_0_x", 4, ET_REAL, ACDT_REAL),
|
---|
106 | AutoConstantDefinition(ACT_TANTIME_0_X, "tantime_0_x", 4, ET_REAL, ACDT_REAL),
|
---|
107 | AutoConstantDefinition(ACT_TIME_0_X_PACKED, "time_0_x_packed", 4, ET_REAL, ACDT_REAL),
|
---|
108 | AutoConstantDefinition(ACT_TIME_0_1, "time_0_1", 4, ET_REAL, ACDT_REAL),
|
---|
109 | AutoConstantDefinition(ACT_COSTIME_0_1, "costime_0_1", 4, ET_REAL, ACDT_REAL),
|
---|
110 | AutoConstantDefinition(ACT_SINTIME_0_1, "sintime_0_1", 4, ET_REAL, ACDT_REAL),
|
---|
111 | AutoConstantDefinition(ACT_TANTIME_0_1, "tantime_0_1", 4, ET_REAL, ACDT_REAL),
|
---|
112 | AutoConstantDefinition(ACT_TIME_0_1_PACKED, "time_0_1_packed", 4, ET_REAL, ACDT_REAL),
|
---|
113 | AutoConstantDefinition(ACT_TIME_0_2PI, "time_0_2pi", 4, ET_REAL, ACDT_REAL),
|
---|
114 | AutoConstantDefinition(ACT_COSTIME_0_2PI, "costime_0_2pi", 4, ET_REAL, ACDT_REAL),
|
---|
115 | AutoConstantDefinition(ACT_SINTIME_0_2PI, "sintime_0_2pi", 4, ET_REAL, ACDT_REAL),
|
---|
116 | AutoConstantDefinition(ACT_TANTIME_0_2PI, "tantime_0_2pi", 4, ET_REAL, ACDT_REAL),
|
---|
117 | AutoConstantDefinition(ACT_TIME_0_2PI_PACKED, "time_0_2pi_packed", 4, ET_REAL, ACDT_REAL),
|
---|
118 | AutoConstantDefinition(ACT_FRAME_TIME, "frame_time", 1, ET_REAL, ACDT_REAL),
|
---|
119 | AutoConstantDefinition(ACT_FPS, "fps", 1, ET_REAL, ACDT_NONE),
|
---|
120 | AutoConstantDefinition(ACT_VIEWPORT_WIDTH, "viewport_width", 1, ET_REAL, ACDT_NONE),
|
---|
121 | AutoConstantDefinition(ACT_VIEWPORT_HEIGHT, "viewport_height", 1, ET_REAL, ACDT_NONE),
|
---|
122 | AutoConstantDefinition(ACT_INVERSE_VIEWPORT_WIDTH, "inverse_viewport_width", 1, ET_REAL, ACDT_NONE),
|
---|
123 | AutoConstantDefinition(ACT_INVERSE_VIEWPORT_HEIGHT, "inverse_viewport_height", 1, ET_REAL, ACDT_NONE),
|
---|
124 | AutoConstantDefinition(ACT_VIEWPORT_SIZE, "viewport_size", 4, ET_REAL, ACDT_NONE),
|
---|
125 | AutoConstantDefinition(ACT_VIEW_DIRECTION, "view_direction", 3, ET_REAL, ACDT_NONE),
|
---|
126 | AutoConstantDefinition(ACT_VIEW_SIDE_VECTOR, "view_side_vector", 3, ET_REAL, ACDT_NONE),
|
---|
127 | AutoConstantDefinition(ACT_VIEW_UP_VECTOR, "view_up_vector", 3, ET_REAL, ACDT_NONE),
|
---|
128 | AutoConstantDefinition(ACT_FOV, "fov", 1, ET_REAL, ACDT_NONE),
|
---|
129 | AutoConstantDefinition(ACT_NEAR_CLIP_DISTANCE, "near_clip_distance", 1, ET_REAL, ACDT_NONE),
|
---|
130 | AutoConstantDefinition(ACT_FAR_CLIP_DISTANCE, "far_clip_distance", 1, ET_REAL, ACDT_NONE),
|
---|
131 | AutoConstantDefinition(ACT_PASS_NUMBER, "pass_number", 1, ET_REAL, ACDT_NONE),
|
---|
132 | AutoConstantDefinition(ACT_PASS_ITERATION_NUMBER, "pass_iteration_number", 1, ET_REAL, ACDT_NONE),
|
---|
133 | AutoConstantDefinition(ACT_ANIMATION_PARAMETRIC, "animation_parametric", 4, ET_REAL, ACDT_INT),
|
---|
134 | };
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | //-----------------------------------------------------------------------------
|
---|
139 | GpuProgram::GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
|
---|
140 | const String& group, bool isManual, ManualResourceLoader* loader)
|
---|
141 | :Resource(creator, name, handle, group, isManual, loader),
|
---|
142 | mType(GPT_VERTEX_PROGRAM), mLoadFromFile(true), mSkeletalAnimation(false),
|
---|
143 | mPassSurfaceAndLightStates(false)
|
---|
144 | {
|
---|
145 | }
|
---|
146 | //-----------------------------------------------------------------------------
|
---|
147 | void GpuProgram::setType(GpuProgramType t)
|
---|
148 | {
|
---|
149 | mType = t;
|
---|
150 | }
|
---|
151 | //-----------------------------------------------------------------------------
|
---|
152 | void GpuProgram::setSyntaxCode(const String& syntax)
|
---|
153 | {
|
---|
154 | mSyntaxCode = syntax;
|
---|
155 | }
|
---|
156 | //-----------------------------------------------------------------------------
|
---|
157 | void GpuProgram::setSourceFile(const String& filename)
|
---|
158 | {
|
---|
159 | mFilename = filename;
|
---|
160 | mSource = "";
|
---|
161 | mLoadFromFile = true;
|
---|
162 | }
|
---|
163 | //-----------------------------------------------------------------------------
|
---|
164 | void GpuProgram::setSource(const String& source)
|
---|
165 | {
|
---|
166 | mSource = source;
|
---|
167 | mFilename = "";
|
---|
168 | mLoadFromFile = false;
|
---|
169 | }
|
---|
170 |
|
---|
171 | //-----------------------------------------------------------------------------
|
---|
172 | void GpuProgram::loadImpl(void)
|
---|
173 | {
|
---|
174 | if (mLoadFromFile)
|
---|
175 | {
|
---|
176 | // find & load source code
|
---|
177 | DataStreamPtr stream =
|
---|
178 | ResourceGroupManager::getSingleton().openResource(
|
---|
179 | mFilename, mGroup, true, this);
|
---|
180 | mSource = stream->getAsString();
|
---|
181 | }
|
---|
182 |
|
---|
183 | // Call polymorphic load
|
---|
184 | loadFromSource();
|
---|
185 |
|
---|
186 | }
|
---|
187 | //-----------------------------------------------------------------------------
|
---|
188 | bool GpuProgram::isSupported(void) const
|
---|
189 | {
|
---|
190 | // If skeletal animation is being done, we need support for UBYTE4
|
---|
191 | if (isSkeletalAnimationIncluded() &&
|
---|
192 | !Root::getSingleton().getRenderSystem()->getCapabilities()
|
---|
193 | ->hasCapability(RSC_VERTEX_FORMAT_UBYTE4))
|
---|
194 | {
|
---|
195 | return false;
|
---|
196 | }
|
---|
197 | return GpuProgramManager::getSingleton().isSyntaxSupported(mSyntaxCode);
|
---|
198 | }
|
---|
199 | //-----------------------------------------------------------------------------
|
---|
200 | GpuProgramParametersSharedPtr GpuProgram::createParameters(void)
|
---|
201 | {
|
---|
202 | // Default implementation simply returns standard parameters.
|
---|
203 | GpuProgramParametersSharedPtr ret =
|
---|
204 | GpuProgramManager::getSingleton().createParameters();
|
---|
205 | // Copy in default parameters if present
|
---|
206 | if (!mDefaultParams.isNull())
|
---|
207 | ret->copyConstantsFrom(*(mDefaultParams.get()));
|
---|
208 |
|
---|
209 | return ret;
|
---|
210 | }
|
---|
211 | //-----------------------------------------------------------------------------
|
---|
212 | GpuProgramParametersSharedPtr GpuProgram::getDefaultParameters(void)
|
---|
213 | {
|
---|
214 | if (mDefaultParams.isNull())
|
---|
215 | {
|
---|
216 | mDefaultParams = createParameters();
|
---|
217 | }
|
---|
218 | return mDefaultParams;
|
---|
219 | }
|
---|
220 | //-----------------------------------------------------------------------------
|
---|
221 | void GpuProgram::setupBaseParamDictionary(void)
|
---|
222 | {
|
---|
223 | ParamDictionary* dict = getParamDictionary();
|
---|
224 |
|
---|
225 | dict->addParameter(
|
---|
226 | ParameterDef("type", "'vertex_program' or 'fragment_program'",
|
---|
227 | PT_STRING), &msTypeCmd);
|
---|
228 | dict->addParameter(
|
---|
229 | ParameterDef("syntax", "Syntax code, e.g. vs_1_1", PT_STRING), &msSyntaxCmd);
|
---|
230 | dict->addParameter(
|
---|
231 | ParameterDef("includes_skeletal_animation",
|
---|
232 | "Whether this vertex program includes skeletal animation", PT_BOOL),
|
---|
233 | &msSkeletalCmd);
|
---|
234 | }
|
---|
235 |
|
---|
236 | //-----------------------------------------------------------------------
|
---|
237 | const String& GpuProgram::getLanguage(void) const
|
---|
238 | {
|
---|
239 | static const String language = "asm";
|
---|
240 |
|
---|
241 | return language;
|
---|
242 | }
|
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 | //-----------------------------------------------------------------------------
|
---|
247 | // GpuProgramParameters Methods
|
---|
248 | //-----------------------------------------------------------------------------
|
---|
249 | GpuProgramParameters::GpuProgramParameters()
|
---|
250 | : mTransposeMatrices(false), mAutoAddParamName(false), mActivePassIterationEntry(0)
|
---|
251 | {
|
---|
252 | }
|
---|
253 | //-----------------------------------------------------------------------------
|
---|
254 |
|
---|
255 | GpuProgramParameters::GpuProgramParameters(const GpuProgramParameters& oth)
|
---|
256 | {
|
---|
257 | *this = oth;
|
---|
258 | }
|
---|
259 |
|
---|
260 | //-----------------------------------------------------------------------------
|
---|
261 | GpuProgramParameters& GpuProgramParameters::operator=(const GpuProgramParameters& oth)
|
---|
262 | {
|
---|
263 | // nfz: perform copy of all containers
|
---|
264 | // let compiler perform shallow copies of structures
|
---|
265 | // AutoConstantEntry, RealConstantEntry, IntConstantEntry
|
---|
266 | mRealConstants = oth.mRealConstants;
|
---|
267 | mIntConstants = oth.mIntConstants;
|
---|
268 | mAutoConstants = oth.mAutoConstants;
|
---|
269 | mParamNameMap = oth.mParamNameMap;
|
---|
270 |
|
---|
271 | mTransposeMatrices = oth.mTransposeMatrices;
|
---|
272 | mAutoAddParamName = oth.mAutoAddParamName;
|
---|
273 | mConstantDefinitions = oth.mConstantDefinitions;
|
---|
274 |
|
---|
275 | return *this;
|
---|
276 | }
|
---|
277 |
|
---|
278 | void GpuProgramParameters::setConstant(size_t index, const Vector4& vec)
|
---|
279 | {
|
---|
280 | setConstant(index, vec.val, 1);
|
---|
281 | }
|
---|
282 | //-----------------------------------------------------------------------------
|
---|
283 | void GpuProgramParameters::setConstant(size_t index, Real val)
|
---|
284 | {
|
---|
285 | setConstant(index, Vector4(val, 0.0f, 0.0f, 0.0f));
|
---|
286 | }
|
---|
287 | //-----------------------------------------------------------------------------
|
---|
288 | void GpuProgramParameters::setConstant(size_t index, const Vector3& vec)
|
---|
289 | {
|
---|
290 | setConstant(index, Vector4(vec.x, vec.y, vec.z, 1.0f));
|
---|
291 | }
|
---|
292 | //-----------------------------------------------------------------------------
|
---|
293 | void GpuProgramParameters::setConstant(size_t index, const Matrix4& m)
|
---|
294 | {
|
---|
295 | // set as 4x 4-element floats
|
---|
296 | if (mTransposeMatrices)
|
---|
297 | {
|
---|
298 | Matrix4 t = m.transpose();
|
---|
299 | GpuProgramParameters::setConstant(index++, t[0], 1);
|
---|
300 | GpuProgramParameters::setConstant(index++, t[1], 1);
|
---|
301 | GpuProgramParameters::setConstant(index++, t[2], 1);
|
---|
302 | GpuProgramParameters::setConstant(index, t[3], 1);
|
---|
303 | }
|
---|
304 | else
|
---|
305 | {
|
---|
306 | GpuProgramParameters::setConstant(index++, m[0], 1);
|
---|
307 | GpuProgramParameters::setConstant(index++, m[1], 1);
|
---|
308 | GpuProgramParameters::setConstant(index++, m[2], 1);
|
---|
309 | GpuProgramParameters::setConstant(index, m[3], 1);
|
---|
310 | }
|
---|
311 |
|
---|
312 | }
|
---|
313 | //-----------------------------------------------------------------------------
|
---|
314 | void GpuProgramParameters::setConstant(size_t index, const Matrix4* pMatrix,
|
---|
315 | size_t numEntries)
|
---|
316 | {
|
---|
317 | for (size_t i = 0; i < numEntries; ++i)
|
---|
318 | {
|
---|
319 | const Matrix4& m = pMatrix[i];
|
---|
320 |
|
---|
321 | if (mTransposeMatrices)
|
---|
322 | {
|
---|
323 | Matrix4 t = m.transpose();
|
---|
324 | GpuProgramParameters::setConstant(index++, t[0], 1);
|
---|
325 | GpuProgramParameters::setConstant(index++, t[1], 1);
|
---|
326 | GpuProgramParameters::setConstant(index++, t[2], 1);
|
---|
327 | GpuProgramParameters::setConstant(index++, t[3], 1);
|
---|
328 | }
|
---|
329 | else
|
---|
330 | {
|
---|
331 | GpuProgramParameters::setConstant(index++, m[0], 1);
|
---|
332 | GpuProgramParameters::setConstant(index++, m[1], 1);
|
---|
333 | GpuProgramParameters::setConstant(index++, m[2], 1);
|
---|
334 | GpuProgramParameters::setConstant(index++, m[3], 1);
|
---|
335 | }
|
---|
336 | }
|
---|
337 |
|
---|
338 | }
|
---|
339 | //-----------------------------------------------------------------------------
|
---|
340 | void GpuProgramParameters::setConstant(size_t index, const ColourValue& colour)
|
---|
341 | {
|
---|
342 | setConstant(index, colour.val, 1);
|
---|
343 | }
|
---|
344 | //-----------------------------------------------------------------------------
|
---|
345 | void GpuProgramParameters::setConstant(size_t index, const float *val, size_t count)
|
---|
346 | {
|
---|
347 | // Expand if required
|
---|
348 | if (mRealConstants.size() < index + count)
|
---|
349 | mRealConstants.resize(index + count);
|
---|
350 |
|
---|
351 | // Copy in chunks of 4
|
---|
352 | while (count--)
|
---|
353 | {
|
---|
354 | RealConstantEntry* e = &(mRealConstants[index++]);
|
---|
355 | e->isSet = true;
|
---|
356 | memcpy(e->val, val, sizeof(float) * 4);
|
---|
357 | val += 4;
|
---|
358 | }
|
---|
359 |
|
---|
360 | }
|
---|
361 | //-----------------------------------------------------------------------------
|
---|
362 | void GpuProgramParameters::setConstant(size_t index, const double *val, size_t count)
|
---|
363 | {
|
---|
364 | // Expand if required
|
---|
365 | if (mRealConstants.size() < index + count)
|
---|
366 | mRealConstants.resize(index + count);
|
---|
367 |
|
---|
368 | // Copy, casting to float
|
---|
369 | while (count--)
|
---|
370 | {
|
---|
371 | RealConstantEntry* e = &(mRealConstants[index++]);
|
---|
372 | e->isSet = true;
|
---|
373 | e->val[0] = static_cast<float>(val[0]);
|
---|
374 | e->val[1] = static_cast<float>(val[1]);
|
---|
375 | e->val[2] = static_cast<float>(val[2]);
|
---|
376 | e->val[3] = static_cast<float>(val[3]);
|
---|
377 | val += 4;
|
---|
378 | }
|
---|
379 |
|
---|
380 | }
|
---|
381 | //-----------------------------------------------------------------------------
|
---|
382 | void GpuProgramParameters::setConstant(size_t index, const int *val, size_t count)
|
---|
383 | {
|
---|
384 | // Expand if required
|
---|
385 | if (mIntConstants.size() < index + count)
|
---|
386 | mIntConstants.resize(index + count);
|
---|
387 |
|
---|
388 | // Copy in chunks of 4
|
---|
389 | while (count--)
|
---|
390 | {
|
---|
391 | IntConstantEntry* e = &(mIntConstants[index++]);
|
---|
392 | e->isSet = true;
|
---|
393 | memcpy(e->val, val, sizeof(int) * 4);
|
---|
394 | val += 4;
|
---|
395 | }
|
---|
396 |
|
---|
397 | }
|
---|
398 | //-----------------------------------------------------------------------------
|
---|
399 | void GpuProgramParameters::setAutoConstant(size_t index, AutoConstantType acType, size_t extraInfo)
|
---|
400 | {
|
---|
401 | mAutoConstants.push_back(AutoConstantEntry(acType, index, extraInfo));
|
---|
402 | }
|
---|
403 | //-----------------------------------------------------------------------------
|
---|
404 | void GpuProgramParameters::clearAutoConstants(void)
|
---|
405 | {
|
---|
406 | mAutoConstants.clear();
|
---|
407 | }
|
---|
408 | //-----------------------------------------------------------------------------
|
---|
409 | GpuProgramParameters::AutoConstantIterator GpuProgramParameters::getAutoConstantIterator(void) const
|
---|
410 | {
|
---|
411 | return AutoConstantIterator(mAutoConstants.begin(), mAutoConstants.end());
|
---|
412 | }
|
---|
413 | //-----------------------------------------------------------------------------
|
---|
414 | void GpuProgramParameters::setAutoConstantReal(size_t index, AutoConstantType acType, Real rData)
|
---|
415 | {
|
---|
416 | mAutoConstants.push_back(AutoConstantEntry(acType, index, rData));
|
---|
417 | }
|
---|
418 | //-----------------------------------------------------------------------------
|
---|
419 |
|
---|
420 | //-----------------------------------------------------------------------------
|
---|
421 | void GpuProgramParameters::_updateAutoParamsNoLights(const AutoParamDataSource& source)
|
---|
422 | {
|
---|
423 | if (!hasAutoConstants()) return; // abort early if no autos
|
---|
424 | Vector3 vec3;
|
---|
425 | Vector4 vec4;
|
---|
426 | size_t index;
|
---|
427 | size_t numMatrices;
|
---|
428 | const Matrix4* pMatrix;
|
---|
429 | size_t m;
|
---|
430 |
|
---|
431 | mActivePassIterationEntry = 0;
|
---|
432 |
|
---|
433 | AutoConstantList::const_iterator i, iend;
|
---|
434 | iend = mAutoConstants.end();
|
---|
435 | for (i = mAutoConstants.begin(); i != iend; ++i)
|
---|
436 | {
|
---|
437 | switch(i->paramType)
|
---|
438 | {
|
---|
439 | case ACT_WORLD_MATRIX:
|
---|
440 | setConstant(i->index, source.getWorldMatrix());
|
---|
441 | break;
|
---|
442 | case ACT_INVERSE_WORLD_MATRIX:
|
---|
443 | setConstant(i->index, source.getInverseWorldMatrix());
|
---|
444 | break;
|
---|
445 | case ACT_TRANSPOSE_WORLD_MATRIX:
|
---|
446 | setConstant(i->index, source.getTransposeWorldMatrix());
|
---|
447 | break;
|
---|
448 | case ACT_INVERSE_TRANSPOSE_WORLD_MATRIX:
|
---|
449 | setConstant(i->index, source.getInverseTransposeWorldMatrix());
|
---|
450 | break;
|
---|
451 |
|
---|
452 | case ACT_WORLD_MATRIX_ARRAY_3x4:
|
---|
453 | // Loop over matrices
|
---|
454 | pMatrix = source.getWorldMatrixArray();
|
---|
455 | numMatrices = source.getWorldMatrixCount();
|
---|
456 | index = i->index;
|
---|
457 | for (m = 0; m < numMatrices; ++m)
|
---|
458 | {
|
---|
459 | GpuProgramParameters::setConstant(index++, (*pMatrix)[0], 1);
|
---|
460 | GpuProgramParameters::setConstant(index++, (*pMatrix)[1], 1);
|
---|
461 | GpuProgramParameters::setConstant(index++, (*pMatrix)[2], 1);
|
---|
462 | ++pMatrix;
|
---|
463 | }
|
---|
464 |
|
---|
465 | break;
|
---|
466 | case ACT_WORLD_MATRIX_ARRAY:
|
---|
467 | setConstant(i->index, source.getWorldMatrixArray(),
|
---|
468 | source.getWorldMatrixCount());
|
---|
469 | break;
|
---|
470 | case ACT_VIEW_MATRIX:
|
---|
471 | setConstant(i->index, source.getViewMatrix());
|
---|
472 | break;
|
---|
473 | case ACT_INVERSE_VIEW_MATRIX:
|
---|
474 | setConstant(i->index, source.getInverseViewMatrix());
|
---|
475 | break;
|
---|
476 | case ACT_TRANSPOSE_VIEW_MATRIX:
|
---|
477 | setConstant(i->index, source.getTransposeViewMatrix());
|
---|
478 | break;
|
---|
479 | case ACT_INVERSE_TRANSPOSE_VIEW_MATRIX:
|
---|
480 | setConstant(i->index, source.getTransposeViewMatrix());
|
---|
481 | break;
|
---|
482 |
|
---|
483 | case ACT_PROJECTION_MATRIX:
|
---|
484 | setConstant(i->index, source.getProjectionMatrix());
|
---|
485 | break;
|
---|
486 | case ACT_INVERSE_PROJECTION_MATRIX:
|
---|
487 | setConstant(i->index, source.getInverseProjectionMatrix());
|
---|
488 | break;
|
---|
489 | case ACT_TRANSPOSE_PROJECTION_MATRIX:
|
---|
490 | setConstant(i->index, source.getTransposeProjectionMatrix());
|
---|
491 | break;
|
---|
492 | case ACT_INVERSE_TRANSPOSE_PROJECTION_MATRIX:
|
---|
493 | setConstant(i->index, source.getInverseTransposeProjectionMatrix());
|
---|
494 | break;
|
---|
495 |
|
---|
496 | case ACT_VIEWPROJ_MATRIX:
|
---|
497 | setConstant(i->index, source.getViewProjectionMatrix());
|
---|
498 | break;
|
---|
499 | case ACT_INVERSE_VIEWPROJ_MATRIX:
|
---|
500 | setConstant(i->index, source.getInverseViewProjMatrix());
|
---|
501 | break;
|
---|
502 | case ACT_TRANSPOSE_VIEWPROJ_MATRIX:
|
---|
503 | setConstant(i->index, source.getTransposeViewProjMatrix());
|
---|
504 | break;
|
---|
505 | case ACT_INVERSE_TRANSPOSE_VIEWPROJ_MATRIX:
|
---|
506 | setConstant(i->index, source.getInverseTransposeViewProjMatrix());
|
---|
507 | break;
|
---|
508 |
|
---|
509 | case ACT_WORLDVIEW_MATRIX:
|
---|
510 | setConstant(i->index, source.getWorldViewMatrix());
|
---|
511 | break;
|
---|
512 | case ACT_INVERSE_WORLDVIEW_MATRIX:
|
---|
513 | setConstant(i->index, source.getInverseWorldViewMatrix());
|
---|
514 | break;
|
---|
515 | case ACT_TRANSPOSE_WORLDVIEW_MATRIX:
|
---|
516 | setConstant(i->index, source.getTransposeWorldViewMatrix());
|
---|
517 | break;
|
---|
518 | case ACT_INVERSE_TRANSPOSE_WORLDVIEW_MATRIX:
|
---|
519 | setConstant(i->index, source.getInverseTransposeWorldViewMatrix());
|
---|
520 | break;
|
---|
521 |
|
---|
522 | case ACT_WORLDVIEWPROJ_MATRIX:
|
---|
523 | setConstant(i->index, source.getWorldViewProjMatrix());
|
---|
524 | break;
|
---|
525 | case ACT_INVERSE_WORLDVIEWPROJ_MATRIX:
|
---|
526 | setConstant(i->index, source.getInverseWorldViewProjMatrix());
|
---|
527 | break;
|
---|
528 | case ACT_TRANSPOSE_WORLDVIEWPROJ_MATRIX:
|
---|
529 | setConstant(i->index, source.getTransposeWorldViewProjMatrix());
|
---|
530 | break;
|
---|
531 | case ACT_INVERSE_TRANSPOSE_WORLDVIEWPROJ_MATRIX:
|
---|
532 | setConstant(i->index, source.getInverseTransposeWorldViewProjMatrix());
|
---|
533 | break;
|
---|
534 |
|
---|
535 | case ACT_RENDER_TARGET_FLIPPING:
|
---|
536 | setConstant(i->index, source.getCurrentRenderTarget()->requiresTextureFlipping() ? -1.f : +1.f);
|
---|
537 | break;
|
---|
538 |
|
---|
539 | // NB ambient light still here because it's not related to a specific light
|
---|
540 | case ACT_AMBIENT_LIGHT_COLOUR:
|
---|
541 | setConstant(i->index, source.getAmbientLightColour());
|
---|
542 | break;
|
---|
543 |
|
---|
544 | case ACT_FOG_COLOUR:
|
---|
545 | setConstant(i->index, source.getFogColour());
|
---|
546 | break;
|
---|
547 | case ACT_FOG_PARAMS:
|
---|
548 | setConstant(i->index, source.getFogParams());
|
---|
549 | break;
|
---|
550 |
|
---|
551 | case ACT_CAMERA_POSITION:
|
---|
552 | setConstant(i->index, source.getCameraPosition());
|
---|
553 | break;
|
---|
554 | case ACT_CAMERA_POSITION_OBJECT_SPACE:
|
---|
555 | setConstant(i->index, source.getCameraPositionObjectSpace());
|
---|
556 | break;
|
---|
557 |
|
---|
558 | case ACT_TIME:
|
---|
559 | setConstant(i->index, Vector4(source.getTime() * i->fData, 0.f, 0.f, 0.f));
|
---|
560 | break;
|
---|
561 | case ACT_TIME_0_X:
|
---|
562 | setConstant(i->index, Vector4(source.getTime_0_X(i->fData), 0.f, 0.f, 0.f));
|
---|
563 | break;
|
---|
564 | case ACT_COSTIME_0_X:
|
---|
565 | setConstant(i->index, Vector4(source.getCosTime_0_X(i->fData), 0.f, 0.f, 0.f));
|
---|
566 | break;
|
---|
567 | case ACT_SINTIME_0_X:
|
---|
568 | setConstant(i->index, Vector4(source.getSinTime_0_X(i->fData), 0.f, 0.f, 0.f));
|
---|
569 | break;
|
---|
570 | case ACT_TANTIME_0_X:
|
---|
571 | setConstant(i->index, Vector4(source.getTanTime_0_X(i->fData), 0.f, 0.f, 0.f));
|
---|
572 | break;
|
---|
573 | case ACT_TIME_0_X_PACKED:
|
---|
574 | setConstant(i->index, source.getTime_0_X_packed(i->fData));
|
---|
575 | break;
|
---|
576 | case ACT_TIME_0_1:
|
---|
577 | setConstant(i->index, Vector4(source.getTime_0_1(i->fData), 0.f, 0.f, 0.f));
|
---|
578 | break;
|
---|
579 | case ACT_COSTIME_0_1:
|
---|
580 | setConstant(i->index, Vector4(source.getCosTime_0_1(i->fData), 0.f, 0.f, 0.f));
|
---|
581 | break;
|
---|
582 | case ACT_SINTIME_0_1:
|
---|
583 | setConstant(i->index, Vector4(source.getSinTime_0_1(i->fData), 0.f, 0.f, 0.f));
|
---|
584 | break;
|
---|
585 | case ACT_TANTIME_0_1:
|
---|
586 | setConstant(i->index, Vector4(source.getTanTime_0_1(i->fData), 0.f, 0.f, 0.f));
|
---|
587 | break;
|
---|
588 | case ACT_TIME_0_1_PACKED:
|
---|
589 | setConstant(i->index, source.getTime_0_1_packed(i->fData));
|
---|
590 | break;
|
---|
591 | case ACT_TIME_0_2PI:
|
---|
592 | setConstant(i->index, Vector4(source.getTime_0_2Pi(i->fData), 0.f, 0.f, 0.f));
|
---|
593 | break;
|
---|
594 | case ACT_COSTIME_0_2PI:
|
---|
595 | setConstant(i->index, Vector4(source.getCosTime_0_2Pi(i->fData), 0.f, 0.f, 0.f));
|
---|
596 | break;
|
---|
597 | case ACT_SINTIME_0_2PI:
|
---|
598 | setConstant(i->index, Vector4(source.getSinTime_0_2Pi(i->fData), 0.f, 0.f, 0.f));
|
---|
599 | break;
|
---|
600 | case ACT_TANTIME_0_2PI:
|
---|
601 | setConstant(i->index, Vector4(source.getTanTime_0_2Pi(i->fData), 0.f, 0.f, 0.f));
|
---|
602 | break;
|
---|
603 | case ACT_TIME_0_2PI_PACKED:
|
---|
604 | setConstant(i->index, source.getTime_0_2Pi_packed(i->fData));
|
---|
605 | break;
|
---|
606 | case ACT_FRAME_TIME:
|
---|
607 | setConstant(i->index, source.getFrameTime() * i->fData);
|
---|
608 | break;
|
---|
609 | case ACT_FPS:
|
---|
610 | setConstant(i->index, source.getFPS());
|
---|
611 | break;
|
---|
612 | case ACT_VIEWPORT_WIDTH:
|
---|
613 | setConstant(i->index, source.getViewportWidth());
|
---|
614 | break;
|
---|
615 | case ACT_VIEWPORT_HEIGHT:
|
---|
616 | setConstant(i->index, source.getViewportHeight());
|
---|
617 | break;
|
---|
618 | case ACT_INVERSE_VIEWPORT_WIDTH:
|
---|
619 | setConstant(i->index, source.getInverseViewportWidth());
|
---|
620 | break;
|
---|
621 | case ACT_INVERSE_VIEWPORT_HEIGHT:
|
---|
622 | setConstant(i->index, source.getInverseViewportHeight());
|
---|
623 | break;
|
---|
624 | case ACT_VIEWPORT_SIZE:
|
---|
625 | setConstant(i->index, Vector4(
|
---|
626 | source.getViewportWidth(),
|
---|
627 | source.getViewportHeight(),
|
---|
628 | source.getInverseViewportWidth(),
|
---|
629 | source.getInverseViewportHeight()));
|
---|
630 | break;
|
---|
631 | case ACT_VIEW_DIRECTION:
|
---|
632 | setConstant(i->index, source.getViewDirection());
|
---|
633 | break;
|
---|
634 | case ACT_VIEW_SIDE_VECTOR:
|
---|
635 | setConstant(i->index, source.getViewSideVector());
|
---|
636 | break;
|
---|
637 | case ACT_VIEW_UP_VECTOR:
|
---|
638 | setConstant(i->index, source.getViewUpVector());
|
---|
639 | break;
|
---|
640 | case ACT_FOV:
|
---|
641 | setConstant(i->index, source.getFOV());
|
---|
642 | break;
|
---|
643 | case ACT_NEAR_CLIP_DISTANCE:
|
---|
644 | setConstant(i->index, source.getNearClipDistance());
|
---|
645 | break;
|
---|
646 | case ACT_FAR_CLIP_DISTANCE:
|
---|
647 | setConstant(i->index, source.getFarClipDistance());
|
---|
648 | break;
|
---|
649 | case ACT_TEXTURE_VIEWPROJ_MATRIX:
|
---|
650 | setConstant(i->index, source.getTextureViewProjMatrix());
|
---|
651 | break;
|
---|
652 | case ACT_PASS_NUMBER:
|
---|
653 | setConstant(i->index, (float)source.getPassNumber());
|
---|
654 | break;
|
---|
655 | case ACT_PASS_ITERATION_NUMBER:
|
---|
656 | setConstant(i->index, 0.0f);
|
---|
657 | mActivePassIterationEntry = getRealConstantEntry(i->index);
|
---|
658 | mActivePassIterationEntryIndex = i->index;
|
---|
659 | break;
|
---|
660 | case ACT_CUSTOM:
|
---|
661 | case ACT_ANIMATION_PARAMETRIC:
|
---|
662 | source.getCurrentRenderable()->_updateCustomGpuParameter(*i, this);
|
---|
663 | break;
|
---|
664 | default:
|
---|
665 | break;
|
---|
666 | }
|
---|
667 | }
|
---|
668 | }
|
---|
669 | //-----------------------------------------------------------------------------
|
---|
670 | void GpuProgramParameters::_updateAutoParamsLightsOnly(const AutoParamDataSource& source)
|
---|
671 | {
|
---|
672 | if (!hasAutoConstants()) return; // abort early if no autos
|
---|
673 | Vector3 vec3;
|
---|
674 | Vector4 vec4;
|
---|
675 |
|
---|
676 | AutoConstantList::const_iterator i, iend;
|
---|
677 | iend = mAutoConstants.end();
|
---|
678 | for (i = mAutoConstants.begin(); i != iend; ++i)
|
---|
679 | {
|
---|
680 | switch(i->paramType)
|
---|
681 | {
|
---|
682 | case ACT_LIGHT_DIFFUSE_COLOUR:
|
---|
683 | setConstant(i->index, source.getLight(i->data).getDiffuseColour());
|
---|
684 | break;
|
---|
685 | case ACT_LIGHT_SPECULAR_COLOUR:
|
---|
686 | setConstant(i->index, source.getLight(i->data).getSpecularColour());
|
---|
687 | break;
|
---|
688 | case ACT_LIGHT_POSITION:
|
---|
689 | // Get as 4D vector, works for directional lights too
|
---|
690 | setConstant(i->index,
|
---|
691 | source.getLight(i->data).getAs4DVector());
|
---|
692 | break;
|
---|
693 | case ACT_LIGHT_DIRECTION:
|
---|
694 | #ifdef GAMETOOLS_ILLUMINATION_MODULE
|
---|
695 | if(source.getLight(i->data).getType() == Light::LT_POINT)
|
---|
696 | setConstant(i->index, Vector4(0, 0, 0, 0));
|
---|
697 | else
|
---|
698 | {
|
---|
699 | vec3 = source.getLight(i->data).getDerivedDirection();
|
---|
700 | // Set as 4D vector for compatibility
|
---|
701 | setConstant(i->index, Vector4(vec3.x, vec3.y, vec3.z, 1.0f));
|
---|
702 | }
|
---|
703 | #else
|
---|
704 | vec3 = source.getLight(i->data).getDerivedDirection();
|
---|
705 | // Set as 4D vector for compatibility
|
---|
706 | setConstant(i->index, Vector4(vec3.x, vec3.y, vec3.z, 1.0f));
|
---|
707 | #endif
|
---|
708 | break;
|
---|
709 | case ACT_LIGHT_POSITION_OBJECT_SPACE:
|
---|
710 | setConstant(i->index,
|
---|
711 | source.getInverseWorldMatrix() * source.getLight(i->data).getAs4DVector());
|
---|
712 | break;
|
---|
713 | case ACT_LIGHT_DIRECTION_OBJECT_SPACE:
|
---|
714 | vec3 = source.getInverseWorldMatrix() *
|
---|
715 | source.getLight(i->data).getDerivedDirection();
|
---|
716 | vec3.normalise();
|
---|
717 | // Set as 4D vector for compatibility
|
---|
718 | setConstant(i->index, Vector4(vec3.x, vec3.y, vec3.z, 1.0f));
|
---|
719 | break;
|
---|
720 | case ACT_LIGHT_POSITION_VIEW_SPACE:
|
---|
721 | setConstant(i->index,
|
---|
722 | source.getWorldViewMatrix() * source.getLight(i->data).getAs4DVector());
|
---|
723 | break;
|
---|
724 | case ACT_LIGHT_DIRECTION_VIEW_SPACE:
|
---|
725 | vec3 = source.getWorldViewMatrix() *
|
---|
726 | source.getLight(i->data).getDerivedDirection();
|
---|
727 | vec3.normalise();
|
---|
728 | // Set as 4D vector for compatibility
|
---|
729 | setConstant(i->index, Vector4(vec3.x, vec3.y, vec3.z, 1.0f));
|
---|
730 | break;
|
---|
731 | case ACT_LIGHT_DISTANCE_OBJECT_SPACE:
|
---|
732 | vec3 = source.getInverseWorldMatrix() * source.getLight(i->data).getDerivedPosition();
|
---|
733 | setConstant(i->index, vec3.length());
|
---|
734 | break;
|
---|
735 | case ACT_SHADOW_EXTRUSION_DISTANCE:
|
---|
736 | setConstant(i->index, source.getShadowExtrusionDistance());
|
---|
737 | break;
|
---|
738 | case ACT_LIGHT_POWER_SCALE:
|
---|
739 | setConstant(i->index, source.getLight(i->data).getPowerScale());
|
---|
740 | break;
|
---|
741 | case ACT_LIGHT_ATTENUATION:
|
---|
742 | // range, const, linear, quad
|
---|
743 | const Light& l = source.getLight(i->data);
|
---|
744 | vec4.x = l.getAttenuationRange();
|
---|
745 | vec4.y = l.getAttenuationConstant();
|
---|
746 | vec4.z = l.getAttenuationLinear();
|
---|
747 | vec4.w = l.getAttenuationQuadric();
|
---|
748 | setConstant(i->index, vec4);
|
---|
749 | break;
|
---|
750 | }
|
---|
751 | }
|
---|
752 | }
|
---|
753 | //---------------------------------------------------------------------------
|
---|
754 | void GpuProgramParameters::_mapParameterNameToIndex(const String& name, const size_t index)
|
---|
755 | {
|
---|
756 | mParamNameMap[name] = index;
|
---|
757 | }
|
---|
758 | //---------------------------------------------------------------------------
|
---|
759 | size_t GpuProgramParameters::getParamIndex(const String& name)
|
---|
760 | {
|
---|
761 | ParamNameMap::const_iterator i = mParamNameMap.find(name);
|
---|
762 | if (i == mParamNameMap.end())
|
---|
763 | {
|
---|
764 | // name not found in map, should it be added to the map?
|
---|
765 | if(mAutoAddParamName)
|
---|
766 | {
|
---|
767 | // determine index
|
---|
768 | // don't know which Constants list the name is for
|
---|
769 | // so pick the largest index - a waste
|
---|
770 | size_t index = (mRealConstants.size() > mIntConstants.size()) ?
|
---|
771 | mRealConstants.size() : mIntConstants.size();
|
---|
772 |
|
---|
773 | _mapParameterNameToIndex(name, index);
|
---|
774 | return index;
|
---|
775 | }
|
---|
776 | else
|
---|
777 | {
|
---|
778 | OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Cannot find a parameter named " + name,
|
---|
779 | "GpuProgramParameters::getParamIndex");
|
---|
780 | }
|
---|
781 | }
|
---|
782 | return i->second;
|
---|
783 | }
|
---|
784 | //---------------------------------------------------------------------------
|
---|
785 | void GpuProgramParameters::setNamedConstant(const String& name, Real val)
|
---|
786 | {
|
---|
787 | setConstant(getParamIndex(name), val);
|
---|
788 | }
|
---|
789 | //---------------------------------------------------------------------------
|
---|
790 | void GpuProgramParameters::setNamedConstant(const String& name, int val)
|
---|
791 | {
|
---|
792 | setConstant(getParamIndex(name), val);
|
---|
793 | }
|
---|
794 | //---------------------------------------------------------------------------
|
---|
795 | void GpuProgramParameters::setNamedConstant(const String& name, const Vector4& vec)
|
---|
796 | {
|
---|
797 | setConstant(getParamIndex(name), vec);
|
---|
798 | }
|
---|
799 | //---------------------------------------------------------------------------
|
---|
800 | void GpuProgramParameters::setNamedConstant(const String& name, const Vector3& vec)
|
---|
801 | {
|
---|
802 | setConstant(getParamIndex(name), vec);
|
---|
803 | }
|
---|
804 | //---------------------------------------------------------------------------
|
---|
805 | void GpuProgramParameters::setNamedConstant(const String& name, const Matrix4& m)
|
---|
806 | {
|
---|
807 | setConstant(getParamIndex(name), m);
|
---|
808 | }
|
---|
809 | //---------------------------------------------------------------------------
|
---|
810 | void GpuProgramParameters::setNamedConstant(const String& name, const Matrix4* m,
|
---|
811 | size_t numEntries)
|
---|
812 | {
|
---|
813 | setConstant(getParamIndex(name), m, numEntries);
|
---|
814 | }
|
---|
815 | //---------------------------------------------------------------------------
|
---|
816 | void GpuProgramParameters::setNamedConstant(const String& name, const float *val, size_t count)
|
---|
817 | {
|
---|
818 | setConstant(getParamIndex(name), val, count);
|
---|
819 | }
|
---|
820 | //---------------------------------------------------------------------------
|
---|
821 | void GpuProgramParameters::setNamedConstant(const String& name, const double *val, size_t count)
|
---|
822 | {
|
---|
823 | setConstant(getParamIndex(name), val, count);
|
---|
824 | }
|
---|
825 | //---------------------------------------------------------------------------
|
---|
826 | void GpuProgramParameters::setNamedConstant(const String& name, const ColourValue& colour)
|
---|
827 | {
|
---|
828 | setConstant(getParamIndex(name), colour);
|
---|
829 | }
|
---|
830 | //---------------------------------------------------------------------------
|
---|
831 | void GpuProgramParameters::setNamedConstant(const String& name, const int *val, size_t count)
|
---|
832 | {
|
---|
833 | setConstant(getParamIndex(name), val, count);
|
---|
834 | }
|
---|
835 | //---------------------------------------------------------------------------
|
---|
836 | void GpuProgramParameters::setNamedAutoConstant(const String& name, AutoConstantType acType, size_t extraInfo)
|
---|
837 | {
|
---|
838 | setAutoConstant(getParamIndex(name), acType, extraInfo);
|
---|
839 | }
|
---|
840 | //---------------------------------------------------------------------------
|
---|
841 | void GpuProgramParameters::setConstantFromTime(size_t index, Real factor)
|
---|
842 | {
|
---|
843 | setAutoConstantReal(index, ACT_TIME, factor);
|
---|
844 | }
|
---|
845 | //---------------------------------------------------------------------------
|
---|
846 | void GpuProgramParameters::setNamedConstantFromTime(const String& name, Real factor)
|
---|
847 | {
|
---|
848 | setConstantFromTime(getParamIndex(name), factor);
|
---|
849 | }
|
---|
850 | //---------------------------------------------------------------------------
|
---|
851 | GpuProgramParameters::RealConstantIterator GpuProgramParameters::getRealConstantIterator(void) const
|
---|
852 | {
|
---|
853 | return RealConstantIterator(mRealConstants.begin(), mRealConstants.end());
|
---|
854 | }
|
---|
855 | //---------------------------------------------------------------------------
|
---|
856 | GpuProgramParameters::IntConstantIterator GpuProgramParameters::getIntConstantIterator(void) const
|
---|
857 | {
|
---|
858 | return IntConstantIterator(mIntConstants.begin(), mIntConstants.end());
|
---|
859 | }
|
---|
860 |
|
---|
861 | //---------------------------------------------------------------------------
|
---|
862 | GpuProgramParameters::RealConstantEntry* GpuProgramParameters::getRealConstantEntry(const size_t index)
|
---|
863 | {
|
---|
864 | if (index < mRealConstants.size())
|
---|
865 | {
|
---|
866 | return &(mRealConstants[index]);
|
---|
867 | }
|
---|
868 | else
|
---|
869 | {
|
---|
870 | return NULL;
|
---|
871 | }
|
---|
872 | }
|
---|
873 |
|
---|
874 | //---------------------------------------------------------------------------
|
---|
875 | GpuProgramParameters::IntConstantEntry* GpuProgramParameters::getIntConstantEntry(const size_t index)
|
---|
876 | {
|
---|
877 | if (index < mIntConstants.size())
|
---|
878 | {
|
---|
879 | return &(mIntConstants[index]);
|
---|
880 | }
|
---|
881 | else
|
---|
882 | {
|
---|
883 | return NULL;
|
---|
884 | }
|
---|
885 | }
|
---|
886 |
|
---|
887 | //---------------------------------------------------------------------------
|
---|
888 | GpuProgramParameters::AutoConstantEntry* GpuProgramParameters::getAutoConstantEntry(const size_t index)
|
---|
889 | {
|
---|
890 | if (index < mAutoConstants.size())
|
---|
891 | {
|
---|
892 | return &(mAutoConstants[index]);
|
---|
893 | }
|
---|
894 | else
|
---|
895 | {
|
---|
896 | return NULL;
|
---|
897 | }
|
---|
898 | }
|
---|
899 |
|
---|
900 | //---------------------------------------------------------------------------
|
---|
901 | GpuProgramParameters::RealConstantEntry* GpuProgramParameters::getNamedRealConstantEntry(const String& name)
|
---|
902 | {
|
---|
903 | // check if name is found
|
---|
904 | ParamNameMap::const_iterator i = mParamNameMap.find(name);
|
---|
905 |
|
---|
906 | if (i == mParamNameMap.end())
|
---|
907 | {
|
---|
908 | // no valid name found
|
---|
909 | return NULL;
|
---|
910 | }
|
---|
911 | else
|
---|
912 | {
|
---|
913 | // name found: return the entry
|
---|
914 | return getRealConstantEntry(i->second);
|
---|
915 | }
|
---|
916 |
|
---|
917 | }
|
---|
918 |
|
---|
919 | //---------------------------------------------------------------------------
|
---|
920 | GpuProgramParameters::IntConstantEntry* GpuProgramParameters::getNamedIntConstantEntry(const String& name)
|
---|
921 | {
|
---|
922 | // check if name is found
|
---|
923 | ParamNameMap::const_iterator i = mParamNameMap.find(name);
|
---|
924 |
|
---|
925 | if (i == mParamNameMap.end())
|
---|
926 | {
|
---|
927 | // no valid name found
|
---|
928 | return NULL;
|
---|
929 | }
|
---|
930 | else
|
---|
931 | {
|
---|
932 | // name found: return the entry
|
---|
933 | return getIntConstantEntry(i->second);
|
---|
934 | }
|
---|
935 |
|
---|
936 | }
|
---|
937 |
|
---|
938 | //---------------------------------------------------------------------------
|
---|
939 | void GpuProgramParameters::copyConstantsFrom(const GpuProgramParameters& source)
|
---|
940 | {
|
---|
941 | // Iterate over fixed parameters
|
---|
942 | RealConstantIterator ri = source.getRealConstantIterator();
|
---|
943 | ushort i = 0;
|
---|
944 | while(ri.hasMoreElements())
|
---|
945 | {
|
---|
946 | RealConstantEntry re = ri.getNext();
|
---|
947 | if (re.isSet)
|
---|
948 | {
|
---|
949 | setConstant(i, re.val, 4);
|
---|
950 | }
|
---|
951 | ++i;
|
---|
952 |
|
---|
953 | }
|
---|
954 | IntConstantIterator ii = source.getIntConstantIterator();
|
---|
955 | i = 0;
|
---|
956 | while (ii.hasMoreElements())
|
---|
957 | {
|
---|
958 | IntConstantEntry ie = ii.getNext();
|
---|
959 | if (ie.isSet)
|
---|
960 | {
|
---|
961 | setConstant(i, ie.val, 4);
|
---|
962 | }
|
---|
963 | ++i;
|
---|
964 | }
|
---|
965 |
|
---|
966 | // Iterate over auto parameters
|
---|
967 | // Clear existing auto constants
|
---|
968 | clearAutoConstants();
|
---|
969 | AutoConstantIterator ai = source.getAutoConstantIterator();
|
---|
970 | while (ai.hasMoreElements())
|
---|
971 | {
|
---|
972 | AutoConstantEntry ae = ai.getNext();
|
---|
973 | setAutoConstant(ae.index, ae.paramType, ae.data);
|
---|
974 | }
|
---|
975 |
|
---|
976 | // need to copy Parameter names from the source
|
---|
977 | mParamNameMap = source.mParamNameMap;
|
---|
978 | // copy constant definitions
|
---|
979 | mConstantDefinitions = source.mConstantDefinitions;
|
---|
980 |
|
---|
981 |
|
---|
982 | }
|
---|
983 |
|
---|
984 | //-----------------------------------------------------------------------
|
---|
985 | size_t GpuProgramParameters::addConstantDefinition(const String& name,
|
---|
986 | const size_t index, const size_t elementCount,
|
---|
987 | const ElementType elementType)
|
---|
988 | {
|
---|
989 | size_t idx;
|
---|
990 |
|
---|
991 | // check if definition already exists
|
---|
992 | const ConstantDefinition* foundDef =
|
---|
993 | findMatchingConstantDefinition(name, index, elementType);
|
---|
994 |
|
---|
995 | // add the definition if it doesn't exist
|
---|
996 | if(!foundDef)
|
---|
997 | {
|
---|
998 | ConstantDefinition def;
|
---|
999 | def.elementType = elementType;
|
---|
1000 | def.entryIndex = index;
|
---|
1001 | def.elementCount = elementCount;
|
---|
1002 | def.name = name;
|
---|
1003 |
|
---|
1004 | mConstantDefinitions.push_back( def );
|
---|
1005 | idx = mConstantDefinitions.size() - 1;
|
---|
1006 | }
|
---|
1007 | else
|
---|
1008 | {
|
---|
1009 | // calc the index of the found constant definition
|
---|
1010 | idx = foundDef - &(*mConstantDefinitions.begin());
|
---|
1011 | // update element count if it was 0 before
|
---|
1012 | if (foundDef->elementCount == 0)
|
---|
1013 | mConstantDefinitions[idx].elementCount = elementCount;
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | return idx;
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | //-----------------------------------------------------------------------
|
---|
1020 | const GpuProgramParameters::ConstantDefinition*
|
---|
1021 | GpuProgramParameters::getConstantDefinition(const String& name) const
|
---|
1022 | {
|
---|
1023 | // find a constant definition that matches name by iterating through
|
---|
1024 | // the constant definition array
|
---|
1025 | ConstantDefinitionContainer::const_iterator currentConstDef
|
---|
1026 | = mConstantDefinitions.begin();
|
---|
1027 | ConstantDefinitionContainer::const_iterator endConstDef
|
---|
1028 | = mConstantDefinitions.end();
|
---|
1029 | while (currentConstDef != endConstDef)
|
---|
1030 | {
|
---|
1031 | if (name == (*currentConstDef).name)
|
---|
1032 | break;
|
---|
1033 | ++currentConstDef;
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 | if (currentConstDef != endConstDef)
|
---|
1037 | return &(*currentConstDef);
|
---|
1038 | else
|
---|
1039 | return 0;
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | //-----------------------------------------------------------------------
|
---|
1043 | const GpuProgramParameters::ConstantDefinition*
|
---|
1044 | GpuProgramParameters::getConstantDefinition(const size_t idx) const
|
---|
1045 | {
|
---|
1046 | if (idx < mConstantDefinitions.size())
|
---|
1047 | return &mConstantDefinitions[idx];
|
---|
1048 | else
|
---|
1049 | return 0;
|
---|
1050 | }
|
---|
1051 |
|
---|
1052 | //-----------------------------------------------------------------------
|
---|
1053 | const GpuProgramParameters::ConstantDefinition*
|
---|
1054 | GpuProgramParameters::findMatchingConstantDefinition(const String& name,
|
---|
1055 | const size_t entryIndex, const ElementType elementType) const
|
---|
1056 | {
|
---|
1057 | ConstantDefinitionContainer::const_iterator currentConstDef
|
---|
1058 | = mConstantDefinitions.begin();
|
---|
1059 | ConstantDefinitionContainer::const_iterator endConstDef
|
---|
1060 | = mConstantDefinitions.end();
|
---|
1061 |
|
---|
1062 | while (currentConstDef != endConstDef)
|
---|
1063 | {
|
---|
1064 | if ((name == (*currentConstDef).name)
|
---|
1065 | && (entryIndex == (*currentConstDef).entryIndex)
|
---|
1066 | && (elementType == (*currentConstDef).elementType))
|
---|
1067 | break;
|
---|
1068 |
|
---|
1069 | ++currentConstDef;
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | if (currentConstDef != endConstDef)
|
---|
1073 | return &(*currentConstDef);
|
---|
1074 | else
|
---|
1075 | return 0;
|
---|
1076 |
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | //-----------------------------------------------------------------------
|
---|
1080 | void GpuProgramParameters::setConstantDefinitionAutoState(
|
---|
1081 | const size_t index, const bool isAuto, const size_t autoIndex )
|
---|
1082 | {
|
---|
1083 | if (index < mConstantDefinitions.size())
|
---|
1084 | {
|
---|
1085 | ConstantDefinition* cDef = &mConstantDefinitions[index];
|
---|
1086 | cDef->isAuto = isAuto;
|
---|
1087 | // if auto then check to make sure enough storage is allocated and
|
---|
1088 | // update element count
|
---|
1089 | if (isAuto)
|
---|
1090 | {
|
---|
1091 | // get the auto constant entry associated with this constant definition
|
---|
1092 | const GpuProgramParameters::AutoConstantEntry* autoEntry =
|
---|
1093 | getAutoConstantEntry(autoIndex);
|
---|
1094 |
|
---|
1095 | if (autoEntry)
|
---|
1096 | {
|
---|
1097 | // get auto constant defintion
|
---|
1098 | const AutoConstantDefinition* autoCDef =
|
---|
1099 | getAutoConstantDefinition(autoEntry->paramType);
|
---|
1100 |
|
---|
1101 | // if auto constant exists then its definition will override
|
---|
1102 | // constant definition attributes
|
---|
1103 | if (autoCDef)
|
---|
1104 | {
|
---|
1105 | cDef->autoIndex = autoIndex;
|
---|
1106 | cDef->elementType = autoCDef->elementType;
|
---|
1107 |
|
---|
1108 | if (cDef->elementCount < autoCDef->elementCount)
|
---|
1109 | {
|
---|
1110 | cDef->elementCount = autoCDef->elementCount;
|
---|
1111 | // check constant entry list for proper size
|
---|
1112 | const size_t endPos = cDef->entryIndex +
|
---|
1113 | (cDef->elementCount - 1) / 4 + 1;
|
---|
1114 | switch(cDef->elementType)
|
---|
1115 | {
|
---|
1116 | case ET_INT:
|
---|
1117 | if (mIntConstants.size() < endPos)
|
---|
1118 | mIntConstants.resize(endPos);
|
---|
1119 | break;
|
---|
1120 |
|
---|
1121 | case ET_REAL:
|
---|
1122 | if (mRealConstants.size() < endPos)
|
---|
1123 | mRealConstants.resize(endPos);
|
---|
1124 | break;
|
---|
1125 | } // end switch
|
---|
1126 | }
|
---|
1127 | }
|
---|
1128 | }
|
---|
1129 | }
|
---|
1130 | }
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | //-----------------------------------------------------------------------
|
---|
1134 | const GpuProgramParameters::AutoConstantDefinition*
|
---|
1135 | GpuProgramParameters::getAutoConstantDefinition(const String& name)
|
---|
1136 | {
|
---|
1137 | // find a constant definition that matches name by iterating through the
|
---|
1138 | // constant definition array
|
---|
1139 | bool nameFound = false;
|
---|
1140 | size_t i = 0;
|
---|
1141 | const size_t numDefs = getNumAutoConstantDefinitions();
|
---|
1142 | while (!nameFound && (i < numDefs))
|
---|
1143 | {
|
---|
1144 | if (name == AutoConstantDictionary[i].name)
|
---|
1145 | nameFound = true;
|
---|
1146 | else
|
---|
1147 | ++i;
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | if (nameFound)
|
---|
1151 | return &AutoConstantDictionary[i];
|
---|
1152 | else
|
---|
1153 | return 0;
|
---|
1154 | }
|
---|
1155 |
|
---|
1156 | //-----------------------------------------------------------------------
|
---|
1157 | const GpuProgramParameters::AutoConstantDefinition*
|
---|
1158 | GpuProgramParameters::getAutoConstantDefinition(const size_t idx)
|
---|
1159 | {
|
---|
1160 |
|
---|
1161 | if (idx < getNumAutoConstantDefinitions())
|
---|
1162 | {
|
---|
1163 | assert(idx == AutoConstantDictionary[idx].acType);
|
---|
1164 | return &AutoConstantDictionary[idx];
|
---|
1165 | }
|
---|
1166 | else
|
---|
1167 | return 0;
|
---|
1168 | }
|
---|
1169 | //-----------------------------------------------------------------------
|
---|
1170 | size_t GpuProgramParameters::getNumAutoConstantDefinitions(void)
|
---|
1171 | {
|
---|
1172 | return sizeof(AutoConstantDictionary)/sizeof(AutoConstantDefinition);
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 | //-----------------------------------------------------------------------
|
---|
1176 | void GpuProgramParameters::incPassIterationNumber(void)
|
---|
1177 | {
|
---|
1178 | if (mActivePassIterationEntry)
|
---|
1179 | {
|
---|
1180 | // only increment first element
|
---|
1181 | ++mActivePassIterationEntry->val[0];
|
---|
1182 | mActivePassIterationEntry->isSet = true;
|
---|
1183 | }
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 | //-----------------------------------------------------------------------
|
---|
1187 | GpuProgramParameters::RealConstantEntry* GpuProgramParameters::getPassIterationEntry(void)
|
---|
1188 | {
|
---|
1189 | return mActivePassIterationEntry;
|
---|
1190 | }
|
---|
1191 | //-----------------------------------------------------------------------
|
---|
1192 | //-----------------------------------------------------------------------
|
---|
1193 | String GpuProgram::CmdType::doGet(const void* target) const
|
---|
1194 | {
|
---|
1195 | const GpuProgram* t = static_cast<const GpuProgram*>(target);
|
---|
1196 | if (t->getType() == GPT_VERTEX_PROGRAM)
|
---|
1197 | {
|
---|
1198 | return "vertex_program";
|
---|
1199 | }
|
---|
1200 | else
|
---|
1201 | {
|
---|
1202 | return "fragment_program";
|
---|
1203 | }
|
---|
1204 | }
|
---|
1205 | void GpuProgram::CmdType::doSet(void* target, const String& val)
|
---|
1206 | {
|
---|
1207 | GpuProgram* t = static_cast<GpuProgram*>(target);
|
---|
1208 | if (val == "vertex_program")
|
---|
1209 | {
|
---|
1210 | t->setType(GPT_VERTEX_PROGRAM);
|
---|
1211 | }
|
---|
1212 | else
|
---|
1213 | {
|
---|
1214 | t->setType(GPT_FRAGMENT_PROGRAM);
|
---|
1215 | }
|
---|
1216 | }
|
---|
1217 | //-----------------------------------------------------------------------
|
---|
1218 | String GpuProgram::CmdSyntax::doGet(const void* target) const
|
---|
1219 | {
|
---|
1220 | const GpuProgram* t = static_cast<const GpuProgram*>(target);
|
---|
1221 | return t->getSyntaxCode();
|
---|
1222 | }
|
---|
1223 | void GpuProgram::CmdSyntax::doSet(void* target, const String& val)
|
---|
1224 | {
|
---|
1225 | GpuProgram* t = static_cast<GpuProgram*>(target);
|
---|
1226 | t->setSyntaxCode(val);
|
---|
1227 | }
|
---|
1228 | //-----------------------------------------------------------------------
|
---|
1229 | String GpuProgram::CmdSkeletal::doGet(const void* target) const
|
---|
1230 | {
|
---|
1231 | const GpuProgram* t = static_cast<const GpuProgram*>(target);
|
---|
1232 | return StringConverter::toString(t->isSkeletalAnimationIncluded());
|
---|
1233 | }
|
---|
1234 | void GpuProgram::CmdSkeletal::doSet(void* target, const String& val)
|
---|
1235 | {
|
---|
1236 | GpuProgram* t = static_cast<GpuProgram*>(target);
|
---|
1237 | t->setSkeletalAnimationIncluded(StringConverter::parseBool(val));
|
---|
1238 | }
|
---|
1239 | //-----------------------------------------------------------------------
|
---|
1240 | GpuProgramPtr& GpuProgramPtr::operator=(const HighLevelGpuProgramPtr& r)
|
---|
1241 | {
|
---|
1242 | // Can assign direct
|
---|
1243 | if (pRep == r.getPointer())
|
---|
1244 | return *this;
|
---|
1245 | release();
|
---|
1246 | // lock & copy other mutex pointer
|
---|
1247 | OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
|
---|
1248 | OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
|
---|
1249 | pRep = r.getPointer();
|
---|
1250 | pUseCount = r.useCountPointer();
|
---|
1251 | if (pUseCount)
|
---|
1252 | {
|
---|
1253 | ++(*pUseCount);
|
---|
1254 | }
|
---|
1255 | return *this;
|
---|
1256 | }
|
---|
1257 |
|
---|
1258 | }
|
---|