/src/ogre/OgreMain/include/OgreGpuProgramParams.h
Line | Count | Source |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #ifndef __GpuProgramParams_H_ |
29 | | #define __GpuProgramParams_H_ |
30 | | |
31 | | #include <limits> |
32 | | |
33 | | // Precompiler options |
34 | | #include "OgrePrerequisites.h" |
35 | | #include "OgreSharedPtr.h" |
36 | | #include "OgreSerializer.h" |
37 | | #include "OgreAny.h" |
38 | | #include "Threading/OgreThreadHeaders.h" |
39 | | #include "OgreHeaderPrefix.h" |
40 | | |
41 | | namespace Ogre { |
42 | | struct TransformBaseReal; |
43 | | template <typename T> class ConstMapIterator; |
44 | | |
45 | | /** \addtogroup Core |
46 | | * @{ |
47 | | */ |
48 | | /** \addtogroup Materials |
49 | | * @{ |
50 | | */ |
51 | | |
52 | | enum BaseConstantType |
53 | | { |
54 | | BCT_FLOAT = 0, |
55 | | BCT_INT = 0x10, |
56 | | BCT_DOUBLE = 0x20, |
57 | | BCT_UINT = 0x30, |
58 | | BCT_BOOL = 0x40, |
59 | | BCT_SAMPLER = 0x50, |
60 | | BCT_SPECIALIZATION = 0x60, //!< shader specialisation constant |
61 | | BCT_UNKNOWN = 0x70 |
62 | | }; |
63 | | |
64 | | /** Enumeration of the types of constant we may encounter in programs. |
65 | | @note Low-level programs, by definition, will always use either |
66 | | float4 or int4 constant types since that is the fundamental underlying |
67 | | type in assembler. |
68 | | */ |
69 | | enum GpuConstantType |
70 | | { |
71 | | GCT_FLOAT1 = BCT_FLOAT + 1, |
72 | | GCT_FLOAT2 = BCT_FLOAT + 2, |
73 | | GCT_FLOAT3 = BCT_FLOAT + 3, |
74 | | GCT_FLOAT4 = BCT_FLOAT + 4, |
75 | | GCT_SAMPLER1D = BCT_SAMPLER + 1, |
76 | | GCT_SAMPLER2D = BCT_SAMPLER + 2, |
77 | | GCT_SAMPLER3D = BCT_SAMPLER + 3, |
78 | | GCT_SAMPLERCUBE = BCT_SAMPLER + 4, |
79 | | GCT_SAMPLER1DSHADOW = BCT_SAMPLER + 6, |
80 | | GCT_SAMPLER2DSHADOW = BCT_SAMPLER + 7, |
81 | | GCT_SAMPLER2DARRAY = BCT_SAMPLER + 8, |
82 | | GCT_SAMPLER_EXTERNAL_OES = BCT_SAMPLER + 9, |
83 | | GCT_SAMPLER2DARRAYSHADOW = BCT_SAMPLER + 10, |
84 | | GCT_SAMPLERCUBESHADOW = BCT_SAMPLER + 11, |
85 | | GCT_MATRIX_2X2 = BCT_FLOAT + 5, |
86 | | GCT_MATRIX_2X3 = BCT_FLOAT + 6, |
87 | | GCT_MATRIX_2X4 = BCT_FLOAT + 7, |
88 | | GCT_MATRIX_3X2 = BCT_FLOAT + 8, |
89 | | GCT_MATRIX_3X3 = BCT_FLOAT + 9, |
90 | | GCT_MATRIX_3X4 = BCT_FLOAT + 10, |
91 | | GCT_MATRIX_4X2 = BCT_FLOAT + 11, |
92 | | GCT_MATRIX_4X3 = BCT_FLOAT + 12, |
93 | | GCT_MATRIX_4X4 = BCT_FLOAT + 13, |
94 | | GCT_INT1 = BCT_INT + 1, |
95 | | GCT_INT2 = BCT_INT + 2, |
96 | | GCT_INT3 = BCT_INT + 3, |
97 | | GCT_INT4 = BCT_INT + 4, |
98 | | GCT_SPECIALIZATION = BCT_SPECIALIZATION, |
99 | | GCT_DOUBLE1 = BCT_DOUBLE + 1, |
100 | | GCT_DOUBLE2 = BCT_DOUBLE + 2, |
101 | | GCT_DOUBLE3 = BCT_DOUBLE + 3, |
102 | | GCT_DOUBLE4 = BCT_DOUBLE + 4, |
103 | | GCT_MATRIX_DOUBLE_2X2 = BCT_DOUBLE + 5, |
104 | | GCT_MATRIX_DOUBLE_2X3 = BCT_DOUBLE + 6, |
105 | | GCT_MATRIX_DOUBLE_2X4 = BCT_DOUBLE + 7, |
106 | | GCT_MATRIX_DOUBLE_3X2 = BCT_DOUBLE + 8, |
107 | | GCT_MATRIX_DOUBLE_3X3 = BCT_DOUBLE + 9, |
108 | | GCT_MATRIX_DOUBLE_3X4 = BCT_DOUBLE + 10, |
109 | | GCT_MATRIX_DOUBLE_4X2 = BCT_DOUBLE + 11, |
110 | | GCT_MATRIX_DOUBLE_4X3 = BCT_DOUBLE + 12, |
111 | | GCT_MATRIX_DOUBLE_4X4 = BCT_DOUBLE + 13, |
112 | | GCT_UINT1 = BCT_UINT + 1, |
113 | | GCT_UINT2 = BCT_UINT + 2, |
114 | | GCT_UINT3 = BCT_UINT + 3, |
115 | | GCT_UINT4 = BCT_UINT + 4, |
116 | | GCT_BOOL1 = BCT_BOOL + 1, |
117 | | GCT_BOOL2 = BCT_BOOL + 2, |
118 | | GCT_BOOL3 = BCT_BOOL + 3, |
119 | | GCT_BOOL4 = BCT_BOOL + 4, |
120 | | GCT_UNKNOWN = BCT_UNKNOWN |
121 | | }; |
122 | | |
123 | | /** The variability of a GPU parameter, as derived from auto-params targeting it. |
124 | | These values must be powers of two since they are used in masks. |
125 | | */ |
126 | | enum GpuParamVariability : uint16 |
127 | | { |
128 | | /// No variation except by manual setting - the default |
129 | | GPV_GLOBAL = 1, |
130 | | /// Varies per object (based on an auto param usually), but not per light setup |
131 | | GPV_PER_OBJECT = 2, |
132 | | /// Varies with light setup |
133 | | GPV_LIGHTS = 4, |
134 | | /// Varies with pass iteration number |
135 | | GPV_PASS_ITERATION_NUMBER = 8, |
136 | | |
137 | | |
138 | | /// Full mask (16-bit) |
139 | | GPV_ALL = 0xFFFF |
140 | | }; |
141 | | |
142 | | /** Information about predefined program constants. |
143 | | @note Only available for high-level programs but is referenced generically |
144 | | by GpuProgramParameters. |
145 | | */ |
146 | | struct _OgreExport GpuConstantDefinition |
147 | | { |
148 | | /// Physical byte offset in buffer |
149 | | size_t physicalIndex; |
150 | | /// Logical index - used to communicate this constant to the rendersystem |
151 | | size_t logicalIndex; |
152 | | /** Number of typed slots per element |
153 | | (some programs pack each array element to float4, some do not) */ |
154 | | uint32 elementSize; |
155 | | /// Length of array |
156 | | uint32 arraySize; |
157 | | /// Data type |
158 | | GpuConstantType constType; |
159 | | /// How this parameter varies (bitwise combination of GpuProgramVariability) |
160 | | mutable uint16 variability; |
161 | | |
162 | | //TODO Should offset be added to list? |
163 | | // For instance, for GLSL atomic counters: |
164 | | // layout(binding = 1, offset = 10) atomic_uint atom_counter; |
165 | | // Binding goes in logicalIndex, but where does offset go? |
166 | | //size_t offset; |
167 | | |
168 | 0 | bool isFloat() const { return isFloat(constType); } |
169 | 0 | static bool isFloat(GpuConstantType c) { return getBaseType(c) == BCT_FLOAT; } |
170 | | |
171 | 0 | bool isDouble() const { return isDouble(constType); } |
172 | 0 | static bool isDouble(GpuConstantType c) { return getBaseType(c) == BCT_DOUBLE; } |
173 | | |
174 | 0 | bool isInt() const { return isInt(constType); } |
175 | 0 | static bool isInt(GpuConstantType c) { return getBaseType(c) == BCT_INT; } |
176 | | |
177 | 0 | bool isUnsignedInt() const { return isUnsignedInt(constType); } |
178 | 0 | static bool isUnsignedInt(GpuConstantType c) { return getBaseType(c) == BCT_UINT; } |
179 | | |
180 | 0 | bool isBool() const { return isBool(constType); } |
181 | 0 | static bool isBool(GpuConstantType c) { return getBaseType(c) == BCT_BOOL; } |
182 | | |
183 | 0 | bool isSampler() const { return isSampler(constType); } |
184 | 0 | static bool isSampler(GpuConstantType c) { return getBaseType(c) == BCT_SAMPLER; } |
185 | | |
186 | 0 | bool isSpecialization() const { return isSpecialization(constType); } |
187 | 0 | static bool isSpecialization(GpuConstantType c) { return getBaseType(c) == BCT_SPECIALIZATION; } |
188 | | |
189 | | static BaseConstantType getBaseType(GpuConstantType ctype) |
190 | 0 | { |
191 | 0 | return BaseConstantType(ctype / 0x10 * 0x10); |
192 | 0 | } |
193 | | |
194 | | /** Get the number of elements of a given type, including whether to pad the |
195 | | elements into multiples of 4 (e.g. SM1 and D3D does, GLSL doesn't) |
196 | | */ |
197 | | static uint32 getElementSize(GpuConstantType ctype, bool padToMultiplesOf4) |
198 | 0 | { |
199 | 0 | if (padToMultiplesOf4) |
200 | 0 | { |
201 | 0 | switch(ctype) |
202 | 0 | { |
203 | 0 | case GCT_FLOAT1: |
204 | 0 | case GCT_INT1: |
205 | 0 | case GCT_UINT1: |
206 | 0 | case GCT_BOOL1: |
207 | 0 | case GCT_SAMPLER1D: |
208 | 0 | case GCT_SAMPLER2D: |
209 | 0 | case GCT_SAMPLER2DARRAY: |
210 | 0 | case GCT_SAMPLER3D: |
211 | 0 | case GCT_SAMPLERCUBE: |
212 | 0 | case GCT_SAMPLER1DSHADOW: |
213 | 0 | case GCT_SAMPLER2DSHADOW: |
214 | 0 | case GCT_FLOAT2: |
215 | 0 | case GCT_INT2: |
216 | 0 | case GCT_UINT2: |
217 | 0 | case GCT_BOOL2: |
218 | 0 | case GCT_FLOAT3: |
219 | 0 | case GCT_INT3: |
220 | 0 | case GCT_UINT3: |
221 | 0 | case GCT_BOOL3: |
222 | 0 | case GCT_FLOAT4: |
223 | 0 | case GCT_INT4: |
224 | 0 | case GCT_UINT4: |
225 | 0 | case GCT_BOOL4: |
226 | 0 | return 4; |
227 | 0 | case GCT_MATRIX_2X2: |
228 | 0 | case GCT_MATRIX_2X3: |
229 | 0 | case GCT_MATRIX_2X4: |
230 | 0 | case GCT_DOUBLE1: |
231 | 0 | case GCT_DOUBLE2: |
232 | 0 | case GCT_DOUBLE3: |
233 | 0 | case GCT_DOUBLE4: |
234 | 0 | return 8; // 2 float4s |
235 | 0 | case GCT_MATRIX_3X2: |
236 | 0 | case GCT_MATRIX_3X3: |
237 | 0 | case GCT_MATRIX_3X4: |
238 | 0 | return 12; // 3 float4s |
239 | 0 | case GCT_MATRIX_4X2: |
240 | 0 | case GCT_MATRIX_4X3: |
241 | 0 | case GCT_MATRIX_4X4: |
242 | 0 | case GCT_MATRIX_DOUBLE_2X2: |
243 | 0 | case GCT_MATRIX_DOUBLE_2X3: |
244 | 0 | case GCT_MATRIX_DOUBLE_2X4: |
245 | 0 | return 16; // 4 float4s |
246 | 0 | case GCT_MATRIX_DOUBLE_3X2: |
247 | 0 | case GCT_MATRIX_DOUBLE_3X3: |
248 | 0 | case GCT_MATRIX_DOUBLE_3X4: |
249 | 0 | return 24; |
250 | 0 | case GCT_MATRIX_DOUBLE_4X2: |
251 | 0 | case GCT_MATRIX_DOUBLE_4X3: |
252 | 0 | case GCT_MATRIX_DOUBLE_4X4: |
253 | 0 | return 32; |
254 | 0 | default: |
255 | 0 | return 4; |
256 | 0 | }; |
257 | 0 | } |
258 | 0 | else |
259 | 0 | { |
260 | 0 | switch(ctype) |
261 | 0 | { |
262 | 0 | case GCT_SAMPLER1D: |
263 | 0 | case GCT_SAMPLER2D: |
264 | 0 | case GCT_SAMPLER2DARRAY: |
265 | 0 | case GCT_SAMPLER3D: |
266 | 0 | case GCT_SAMPLERCUBE: |
267 | 0 | case GCT_SAMPLER1DSHADOW: |
268 | 0 | case GCT_SAMPLER2DSHADOW: |
269 | 0 | return 1; |
270 | 0 | case GCT_MATRIX_2X2: |
271 | 0 | case GCT_MATRIX_DOUBLE_2X2: |
272 | 0 | return 4; |
273 | 0 | case GCT_MATRIX_2X3: |
274 | 0 | case GCT_MATRIX_3X2: |
275 | 0 | case GCT_MATRIX_DOUBLE_2X3: |
276 | 0 | case GCT_MATRIX_DOUBLE_3X2: |
277 | 0 | return 6; |
278 | 0 | case GCT_MATRIX_2X4: |
279 | 0 | case GCT_MATRIX_4X2: |
280 | 0 | case GCT_MATRIX_DOUBLE_2X4: |
281 | 0 | case GCT_MATRIX_DOUBLE_4X2: |
282 | 0 | return 8; |
283 | 0 | case GCT_MATRIX_3X3: |
284 | 0 | case GCT_MATRIX_DOUBLE_3X3: |
285 | 0 | return 9; |
286 | 0 | case GCT_MATRIX_3X4: |
287 | 0 | case GCT_MATRIX_4X3: |
288 | 0 | case GCT_MATRIX_DOUBLE_3X4: |
289 | 0 | case GCT_MATRIX_DOUBLE_4X3: |
290 | 0 | return 12; |
291 | 0 | case GCT_MATRIX_4X4: |
292 | 0 | case GCT_MATRIX_DOUBLE_4X4: |
293 | 0 | return 16; |
294 | 0 | default: |
295 | 0 | return ctype % 0x10; |
296 | 0 | }; |
297 | 0 |
|
298 | 0 | } |
299 | 0 | } |
300 | | |
301 | | GpuConstantDefinition() |
302 | | : physicalIndex((std::numeric_limits<size_t>::max)()) |
303 | | , logicalIndex(0) |
304 | | , elementSize(0) |
305 | | , arraySize(1) |
306 | | , constType(GCT_UNKNOWN) |
307 | 0 | , variability(GPV_GLOBAL) {} |
308 | | }; |
309 | | typedef std::map<String, GpuConstantDefinition> GpuConstantDefinitionMap; |
310 | | typedef ConstMapIterator<GpuConstantDefinitionMap> GpuConstantDefinitionIterator; |
311 | | |
312 | | /// Struct collecting together the information for named constants. |
313 | | struct _OgreExport GpuNamedConstants : public GpuParamsAlloc |
314 | | { |
315 | | /// Total size of the buffer required |
316 | | size_t bufferSize; |
317 | | /// Number of register type params (samplers) |
318 | | size_t registerCount; |
319 | | /// Map of parameter names to GpuConstantDefinition |
320 | | GpuConstantDefinitionMap map; |
321 | | |
322 | | GpuNamedConstants(); |
323 | | ~GpuNamedConstants(); |
324 | | |
325 | | /** Saves constant definitions to a file |
326 | | * compatible with @ref GpuProgram::setManualNamedConstantsFile. |
327 | | */ |
328 | | void save(const String& filename) const; |
329 | | /** Loads constant definitions from a stream |
330 | | * compatible with @ref GpuProgram::setManualNamedConstantsFile. |
331 | | */ |
332 | | void load(DataStreamPtr& stream); |
333 | | |
334 | | size_t calculateSize(void) const; |
335 | | }; |
336 | | |
337 | | /// Simple class for loading / saving GpuNamedConstants |
338 | | class _OgreExport GpuNamedConstantsSerializer : public Serializer |
339 | | { |
340 | | public: |
341 | | GpuNamedConstantsSerializer(); |
342 | | virtual ~GpuNamedConstantsSerializer(); |
343 | | void exportNamedConstants(const GpuNamedConstants* pConsts, const String& filename, |
344 | | Endian endianMode = ENDIAN_NATIVE); |
345 | | void exportNamedConstants(const GpuNamedConstants* pConsts, DataStreamPtr stream, |
346 | | Endian endianMode = ENDIAN_NATIVE); |
347 | | void importNamedConstants(DataStreamPtr& stream, GpuNamedConstants* pDest); |
348 | | }; |
349 | | |
350 | | /** Structure recording the use of a physical buffer by a logical parameter |
351 | | index. Only used for low-level programs. |
352 | | */ |
353 | | struct _OgreExport GpuLogicalIndexUse |
354 | | { |
355 | | /// Physical buffer index |
356 | | size_t physicalIndex; |
357 | | /// Current physical size allocation |
358 | | size_t currentSize; |
359 | | /// How the contents of this slot vary |
360 | | mutable uint16 variability; |
361 | | /// Data type |
362 | | BaseConstantType baseType; |
363 | | |
364 | | GpuLogicalIndexUse() |
365 | 0 | : physicalIndex(99999), currentSize(0), variability(GPV_GLOBAL), baseType(BCT_UNKNOWN) {} |
366 | | GpuLogicalIndexUse(size_t bufIdx, size_t curSz, uint16 v, BaseConstantType t) |
367 | 0 | : physicalIndex(bufIdx), currentSize(curSz), variability(v), baseType(t) {} |
368 | | }; |
369 | | typedef std::map<size_t, GpuLogicalIndexUse> GpuLogicalIndexUseMap; |
370 | | /// Container struct to allow params to safely & update shared list of logical buffer assignments |
371 | | struct _OgreExport GpuLogicalBufferStruct : public GpuParamsAlloc |
372 | | { |
373 | | OGRE_MUTEX(mutex); |
374 | | |
375 | | /// Map from logical index to physical buffer location |
376 | | GpuLogicalIndexUseMap map; |
377 | | /// Shortcut to know the buffer size needs |
378 | | size_t bufferSize; |
379 | | GpuLogicalBufferStruct(); |
380 | | ~GpuLogicalBufferStruct(); |
381 | | }; |
382 | | |
383 | | /** Definition of container that holds the current constants. |
384 | | @note Not necessarily in direct index order to constant indexes, logical |
385 | | to physical index map is derived from GpuProgram |
386 | | */ |
387 | | typedef std::vector<uchar> ConstantList; |
388 | | |
389 | | /** A group of manually updated parameters that are shared between many parameter sets. |
390 | | |
391 | | Sometimes you want to set some common parameters across many otherwise |
392 | | different parameter sets, and keep them all in sync together. This class |
393 | | allows you to define a set of parameters that you can share across many |
394 | | parameter sets and have the parameters that match automatically be pulled |
395 | | from the shared set, rather than you having to set them on all the parameter |
396 | | sets individually. |
397 | | @par |
398 | | Parameters in a shared set are matched up with instances in a GpuProgramParameters |
399 | | structure by matching names. It is up to you to define the named parameters |
400 | | that a shared set contains, and ensuring the definition matches. |
401 | | @note |
402 | | Shared parameter sets can be named, and looked up using the GpuProgramManager. |
403 | | */ |
404 | | class _OgreExport GpuSharedParameters : public GpuParamsAlloc |
405 | | { |
406 | | /// Name of the shared parameter set. |
407 | | String mName; |
408 | | |
409 | | /// Shared parameter definitions and related data. |
410 | | GpuNamedConstants mNamedConstants; |
411 | | |
412 | | /// List of constant values. |
413 | | ConstantList mConstants; |
414 | | |
415 | | /// Optional rendersystem backed storage |
416 | | HardwareBufferPtr mHardwareBuffer; |
417 | | |
418 | | /// Version number of the definitions in this buffer. |
419 | | uint32 mVersion; |
420 | | |
421 | | /// Accumulated offset used to calculate uniform location. |
422 | | size_t mOffset; |
423 | | |
424 | | bool mDirty; |
425 | | |
426 | | template <typename T> void _setNamedConstant(const String& name, const T* val, uint32 count); |
427 | | public: |
428 | | GpuSharedParameters(const String& name); |
429 | | |
430 | | /// Get the name of this shared parameter set. |
431 | 0 | const String& getName() { return mName; } |
432 | | |
433 | | /** Add a new constant definition to this shared set of parameters. |
434 | | |
435 | | Unlike GpuProgramParameters, where the parameter list is defined by the |
436 | | program being compiled, this shared parameter set is defined by the |
437 | | user. Only parameters which have been predefined here may be later |
438 | | updated. |
439 | | */ |
440 | | void addConstantDefinition(const String& name, GpuConstantType constType, uint32 arraySize = 1); |
441 | | |
442 | | /// @deprecated removing a constant requires a full rebuild due to changed alignments |
443 | | OGRE_DEPRECATED void removeConstantDefinition(const String& name); |
444 | | |
445 | | /** Remove a constant definition from this shared set of parameters. |
446 | | */ |
447 | | void removeAllConstantDefinitions(); |
448 | | |
449 | | /** Get the version number of this shared parameter set, can be used to identify when |
450 | | changes have occurred. |
451 | | */ |
452 | 0 | uint32 getVersion() const { return mVersion; } |
453 | | |
454 | | /** Calculate the expected size of the shared parameter buffer based |
455 | | on constant definition data types. |
456 | | */ |
457 | | size_t calculateSize(void) const; |
458 | | |
459 | | /** True if this parameter set is dirty (values have been modified, |
460 | | but the render system has not updated them yet). |
461 | | */ |
462 | 0 | bool isDirty() const { return mDirty; } |
463 | | |
464 | | /** Mark the shared set as being clean (values successfully updated |
465 | | by the render system). |
466 | | |
467 | | You do not need to call this yourself. The set is marked as clean |
468 | | whenever the render system updates dirty shared parameters. |
469 | | */ |
470 | | void _markClean(); |
471 | | |
472 | | /** Mark the shared set as being dirty (values modified and not yet |
473 | | updated in render system). |
474 | | |
475 | | You do not need to call this yourself. The set is marked as |
476 | | dirty whenever setNamedConstant or (non const) getFloatPointer |
477 | | et al are called. |
478 | | */ |
479 | | void _markDirty(); |
480 | | |
481 | | /// @deprecated use getConstantDefinitions() |
482 | | OGRE_DEPRECATED GpuConstantDefinitionIterator getConstantDefinitionIterator(void) const; |
483 | | |
484 | | /** Get a specific GpuConstantDefinition for a named parameter. |
485 | | */ |
486 | | const GpuConstantDefinition& getConstantDefinition(const String& name) const; |
487 | | |
488 | | /** Get the full list of GpuConstantDefinition instances. |
489 | | */ |
490 | | const GpuNamedConstants& getConstantDefinitions() const; |
491 | | |
492 | | /** @copydoc GpuProgramParameters::setNamedConstant(const String&, Real) */ |
493 | | template <typename T> void setNamedConstant(const String& name, T val) |
494 | | { |
495 | | setNamedConstant(name, &val, 1); |
496 | | } |
497 | | /// @overload |
498 | | template <int dims, typename T> |
499 | | void setNamedConstant(const String& name, const Vector<dims, T>& vec) |
500 | | { |
501 | | setNamedConstant(name, vec.ptr(), dims); |
502 | | } |
503 | | /** @copydoc GpuProgramParameters::setNamedConstant(const String& name, const Matrix4& m) */ |
504 | | void setNamedConstant(const String& name, const Matrix4& m); |
505 | | /** @copydoc GpuProgramParameters::setNamedConstant(const String& name, const Matrix4* m, size_t numEntries) */ |
506 | | void setNamedConstant(const String& name, const Matrix4* m, uint32 numEntries); |
507 | | void setNamedConstant(const String& name, const float *val, uint32 count); |
508 | | void setNamedConstant(const String& name, const double *val, uint32 count); |
509 | | /** @copydoc GpuProgramParameters::setNamedConstant(const String& name, const ColourValue& colour) */ |
510 | | void setNamedConstant(const String& name, const ColourValue& colour); |
511 | | void setNamedConstant(const String& name, const int *val, uint32 count); |
512 | | void setNamedConstant(const String& name, const uint *val, uint32 count); |
513 | | /// Get a pointer to the 'nth' item in the float buffer |
514 | 0 | float* getFloatPointer(size_t pos) { _markDirty(); return (float*)&mConstants[pos]; } |
515 | | /// Get a pointer to the 'nth' item in the float buffer |
516 | 0 | const float* getFloatPointer(size_t pos) const { return (const float*)&mConstants[pos]; } |
517 | | /// Get a pointer to the 'nth' item in the double buffer |
518 | 0 | double* getDoublePointer(size_t pos) { _markDirty(); return (double*)&mConstants[pos]; } |
519 | | /// Get a pointer to the 'nth' item in the double buffer |
520 | 0 | const double* getDoublePointer(size_t pos) const { return (const double*)&mConstants[pos]; } |
521 | | /// Get a pointer to the 'nth' item in the int buffer |
522 | 0 | int* getIntPointer(size_t pos) { _markDirty(); return (int*)&mConstants[pos]; } |
523 | | /// Get a pointer to the 'nth' item in the int buffer |
524 | 0 | const int* getIntPointer(size_t pos) const { return (const int*)&mConstants[pos]; } |
525 | | /// Get a pointer to the 'nth' item in the uint buffer |
526 | 0 | uint* getUnsignedIntPointer(size_t pos) { _markDirty(); return (uint*)&mConstants[pos]; } |
527 | | /// Get a pointer to the 'nth' item in the uint buffer |
528 | 0 | const uint* getUnsignedIntPointer(size_t pos) const { return (const uint*)&mConstants[pos]; } |
529 | | /// Get a reference to the list of constants |
530 | 0 | const ConstantList& getConstantList() const { return mConstants; } |
531 | | /** Internal method that the RenderSystem might use to store optional data. */ |
532 | 0 | void _setHardwareBuffer(const HardwareBufferPtr& data) { mHardwareBuffer = data; } |
533 | | /** Internal method that the RenderSystem might use to store optional data. */ |
534 | 0 | const HardwareBufferPtr& _getHardwareBuffer() const { return mHardwareBuffer; } |
535 | | /// upload parameter data to GPU memory. Must have a HardwareBuffer |
536 | | void _upload() const; |
537 | | /// download data from GPU memory. Must have a writable HardwareBuffer |
538 | | void download(); |
539 | | }; |
540 | | |
541 | | class GpuProgramParameters; |
542 | | |
543 | | /** This class records the usage of a set of shared parameters in a concrete |
544 | | set of GpuProgramParameters. |
545 | | */ |
546 | | class _OgreExport GpuSharedParametersUsage : public GpuParamsAlloc |
547 | | { |
548 | | private: |
549 | | GpuSharedParametersPtr mSharedParams; |
550 | | // Not a shared pointer since this is also parent |
551 | | GpuProgramParameters* mParams; |
552 | | // list of physical mappings that we are going to bring in |
553 | | struct CopyDataEntry |
554 | | { |
555 | | const GpuConstantDefinition* srcDefinition; |
556 | | const GpuConstantDefinition* dstDefinition; |
557 | | }; |
558 | | typedef std::vector<CopyDataEntry> CopyDataList; |
559 | | |
560 | | CopyDataList mCopyDataList; |
561 | | |
562 | | /// Version of shared params we based the copydata on |
563 | | uint32 mCopyDataVersion; |
564 | | |
565 | | void initCopyData(); |
566 | | |
567 | | |
568 | | public: |
569 | | /// Construct usage |
570 | | GpuSharedParametersUsage(GpuSharedParametersPtr sharedParams, |
571 | | GpuProgramParameters* params); |
572 | | |
573 | | /** Update the target parameters by copying the data from the shared |
574 | | parameters. |
575 | | @note This method may not actually be called if the RenderSystem |
576 | | supports using shared parameters directly in their own shared buffer; in |
577 | | which case the values should not be copied out of the shared area |
578 | | into the individual parameter set, but bound separately. |
579 | | */ |
580 | | void _copySharedParamsToTargetParams() const; |
581 | | |
582 | | /// Get the name of the shared parameter set |
583 | 0 | const String& getName() const { return mSharedParams->getName(); } |
584 | | |
585 | 0 | GpuSharedParametersPtr getSharedParams() const { return mSharedParams; } |
586 | 0 | GpuProgramParameters* getTargetParams() const { return mParams; } |
587 | | }; |
588 | | |
589 | | /** Collects together the program parameters used for a GpuProgram. |
590 | | |
591 | | Gpu program state includes constant parameters used by the program, and |
592 | | bindings to render system state which is propagated into the constants |
593 | | by the engine automatically if requested. |
594 | | @par |
595 | | GpuProgramParameters objects should be created through the GpuProgram and |
596 | | may be shared between multiple Pass instances. For this reason they |
597 | | are managed using a shared pointer, which will ensure they are automatically |
598 | | deleted when no Pass is using them anymore. |
599 | | @par |
600 | | High-level programs use named parameters (uniforms), low-level programs |
601 | | use indexed constants. This class supports both, but you can tell whether |
602 | | named constants are supported by calling hasNamedParameters(). There are |
603 | | references in the documentation below to 'logical' and 'physical' indexes; |
604 | | logical indexes are the indexes used by low-level programs and represent |
605 | | indexes into an array of float4's, some of which may be settable, some of |
606 | | which may be predefined constants in the program. We only store those |
607 | | constants which have actually been set, therefore our buffer could have |
608 | | gaps if we used the logical indexes in our own buffers. So instead we map |
609 | | these logical indexes to physical indexes in our buffer. When using |
610 | | high-level programs, logical indexes don't necessarily exist, although they |
611 | | might if the high-level program has a direct, exposed mapping from parameter |
612 | | names to logical indexes. In addition, high-level languages may or may not pack |
613 | | arrays of elements that are smaller than float4 (e.g. float2/vec2) contiguously. |
614 | | This kind of information is held in the ConstantDefinition structure which |
615 | | is only populated for high-level programs. You don't have to worry about |
616 | | any of this unless you intend to read parameters back from this structure |
617 | | rather than just setting them. |
618 | | */ |
619 | | class _OgreExport GpuProgramParameters : public GpuParamsAlloc |
620 | | { |
621 | | public: |
622 | | /** Defines the types of automatically updated values that may be bound to GpuProgram |
623 | | parameters, or used to modify parameters on a per-object basis. |
624 | | |
625 | | For use in @ref Program-Parameter-Specification, drop the `ACT_` prefix. |
626 | | E.g. `ACT_WORLD_MATRIX` becomes `world_matrix`. |
627 | | */ |
628 | | enum AutoConstantType |
629 | | { |
630 | | /// The current world matrix |
631 | | ACT_WORLD_MATRIX, |
632 | | /// The current world matrix, inverted |
633 | | ACT_INVERSE_WORLD_MATRIX, |
634 | | /** Provides transpose of world matrix. |
635 | | */ |
636 | | ACT_TRANSPOSE_WORLD_MATRIX, |
637 | | /// The current world matrix, inverted & transposed |
638 | | ACT_INVERSE_TRANSPOSE_WORLD_MATRIX, |
639 | | |
640 | | /// An array of bone matrices, each represented as only a 3x4 matrix (3 rows of |
641 | | /// 4columns) usually for doing hardware skinning. |
642 | | /// You should make enough entries available in your vertex program for the number of |
643 | | /// bones in use, i.e. an array of numBones*3 float4’s. |
644 | | ACT_BONE_MATRIX_ARRAY_3x4, |
645 | | ACT_WORLD_MATRIX_ARRAY_3x4 = ACT_BONE_MATRIX_ARRAY_3x4, |
646 | | /// The current array of bone matrices, used for blending |
647 | | ACT_BONE_MATRIX_ARRAY, |
648 | | ACT_WORLD_MATRIX_ARRAY = ACT_BONE_MATRIX_ARRAY, |
649 | | /// The current array of bone matrices transformed to an array of dual quaternions, |
650 | | /// represented as a 2x4 matrix |
651 | | ACT_BONE_DUALQUATERNION_ARRAY_2x4, |
652 | | ACT_WORLD_DUALQUATERNION_ARRAY_2x4 = ACT_BONE_DUALQUATERNION_ARRAY_2x4, |
653 | | /// The scale and shear components of the current array of bone matrices |
654 | | ACT_BONE_SCALE_SHEAR_MATRIX_ARRAY_3x4, |
655 | | ACT_WORLD_SCALE_SHEAR_MATRIX_ARRAY_3x4 = ACT_BONE_SCALE_SHEAR_MATRIX_ARRAY_3x4, |
656 | | |
657 | | /// The current view matrix |
658 | | ACT_VIEW_MATRIX, |
659 | | /// The current view matrix, inverted |
660 | | ACT_INVERSE_VIEW_MATRIX, |
661 | | /** Provides transpose of view matrix. |
662 | | */ |
663 | | ACT_TRANSPOSE_VIEW_MATRIX, |
664 | | /** Provides inverse transpose of view matrix. |
665 | | */ |
666 | | ACT_INVERSE_TRANSPOSE_VIEW_MATRIX, |
667 | | |
668 | | /// The current projection matrix |
669 | | ACT_PROJECTION_MATRIX, |
670 | | /** Provides inverse of projection matrix. |
671 | | */ |
672 | | ACT_INVERSE_PROJECTION_MATRIX, |
673 | | /** Provides transpose of projection matrix. |
674 | | */ |
675 | | ACT_TRANSPOSE_PROJECTION_MATRIX, |
676 | | /** Provides inverse transpose of projection matrix. |
677 | | */ |
678 | | ACT_INVERSE_TRANSPOSE_PROJECTION_MATRIX, |
679 | | |
680 | | /// The current view & projection matrices concatenated |
681 | | ACT_VIEWPROJ_MATRIX, |
682 | | /** Provides inverse of concatenated view and projection matrices. |
683 | | */ |
684 | | ACT_INVERSE_VIEWPROJ_MATRIX, |
685 | | /** Provides transpose of concatenated view and projection matrices. |
686 | | */ |
687 | | ACT_TRANSPOSE_VIEWPROJ_MATRIX, |
688 | | /** Provides inverse transpose of concatenated view and projection matrices. |
689 | | */ |
690 | | ACT_INVERSE_TRANSPOSE_VIEWPROJ_MATRIX, |
691 | | |
692 | | /// The current world & view matrices concatenated |
693 | | ACT_WORLDVIEW_MATRIX, |
694 | | /// The current world & view matrices concatenated, then inverted |
695 | | ACT_INVERSE_WORLDVIEW_MATRIX, |
696 | | /** Provides transpose of concatenated world and view matrices. |
697 | | */ |
698 | | ACT_TRANSPOSE_WORLDVIEW_MATRIX, |
699 | | /// The current world & view matrices concatenated, then inverted & transposed |
700 | | ACT_INVERSE_TRANSPOSE_WORLDVIEW_MATRIX, |
701 | | /** Provides inverse transpose of the upper 3x3 of the worldview matrix. |
702 | | Equivalent to @c gl_NormalMatrix. |
703 | | */ |
704 | | ACT_NORMAL_MATRIX, |
705 | | |
706 | | /// The current world, view & projection matrices concatenated |
707 | | ACT_WORLDVIEWPROJ_MATRIX, |
708 | | /** Provides inverse of concatenated world, view and projection matrices. |
709 | | */ |
710 | | ACT_INVERSE_WORLDVIEWPROJ_MATRIX, |
711 | | /** Provides transpose of concatenated world, view and projection matrices. |
712 | | */ |
713 | | ACT_TRANSPOSE_WORLDVIEWPROJ_MATRIX, |
714 | | /** Provides inverse transpose of concatenated world, view and projection |
715 | | matrices. |
716 | | */ |
717 | | ACT_INVERSE_TRANSPOSE_WORLDVIEWPROJ_MATRIX, |
718 | | /// For layered rendering: The current world, view & projection matrices concatenated |
719 | | ACT_WORLDVIEWPROJ_MATRIX_ARRAY, |
720 | | |
721 | | // render target related values |
722 | | /** -1 if requires texture flipping, +1 otherwise. It's useful when you bypassed |
723 | | projection matrix transform, still able use this value to adjust transformed y |
724 | | position. |
725 | | */ |
726 | | ACT_RENDER_TARGET_FLIPPING, |
727 | | |
728 | | /** -1 if the winding has been inverted, +1 otherwise. |
729 | | * e.g. for reflections |
730 | | */ |
731 | | ACT_VERTEX_WINDING, |
732 | | |
733 | | /// Fog colour |
734 | | ACT_FOG_COLOUR, |
735 | | /// Fog params: `(density, linear start, linear end, 1/(end-start))` |
736 | | ACT_FOG_PARAMS, |
737 | | |
738 | | /// Surface ambient colour, as set in Pass::setAmbient |
739 | | ACT_SURFACE_AMBIENT_COLOUR, |
740 | | /// Surface diffuse colour, as set in Pass::setDiffuse |
741 | | ACT_SURFACE_DIFFUSE_COLOUR, |
742 | | /// Surface specular colour, as set in Pass::setSpecular |
743 | | ACT_SURFACE_SPECULAR_COLOUR, |
744 | | /// Surface emissive colour, as set in Pass::setSelfIllumination |
745 | | ACT_SURFACE_EMISSIVE_COLOUR, |
746 | | /// Surface shininess, as set in Pass::setShininess |
747 | | ACT_SURFACE_SHININESS, |
748 | | /// Surface alpha rejection value, not as set in @ref Pass::setAlphaRejectValue, but a |
749 | | /// floating number between 0.0f and 1.0f instead (255.0f / |
750 | | /// @ref Pass::getAlphaRejectValue()) |
751 | | ACT_SURFACE_ALPHA_REJECTION_VALUE, |
752 | | |
753 | | /// The number of active light sources |
754 | | ACT_LIGHT_COUNT, |
755 | | |
756 | | /// The ambient light colour set in the scene |
757 | | ACT_AMBIENT_LIGHT_COLOUR, |
758 | | |
759 | | /// Light diffuse colour (index determined by setAutoConstant call). |
760 | | /// this requires an index in the ’extra_params’ field, and relates to the ’nth’ closest |
761 | | /// light which could affect this object |
762 | | /// (i.e. 0 refers to the closest light - note that directional lights are always first |
763 | | /// in the list and always present). |
764 | | /// NB if there are no lights this close, then the parameter will be set to black. |
765 | | ACT_LIGHT_DIFFUSE_COLOUR, |
766 | | /// Light specular colour (index determined by setAutoConstant call) |
767 | | ACT_LIGHT_SPECULAR_COLOUR, |
768 | | /** Light attenuation parameters. |
769 | | * Packed as `(range, constant, linear, quadric)`. |
770 | | * For area lights this contains the height half-vector `(x, y, z, 0)` of the light in viewspace. |
771 | | */ |
772 | | ACT_LIGHT_ATTENUATION, |
773 | | /** Spotlight parameters. |
774 | | Packed as `(innerFactor, outerFactor, falloff, spotType)` |
775 | | innerFactor and outerFactor are cos(angle/2) |
776 | | The spotType parameter is 0.0f for non-spotlights, 1.0f for spotlights and 2.0f for |
777 | | area spotlights. |
778 | | For area lights this contains the width half-vector `(x, y, z, 2)` of the light in viewspace. |
779 | | Also for non-spotlights the inner and outer factors are 1 and 0 respectively |
780 | | */ |
781 | | ACT_SPOTLIGHT_PARAMS, |
782 | | /** A light position in world space (index determined by setAutoConstant call). |
783 | | This requires an index in the ’extra_params’ field, and relates to the ’nth’ closest |
784 | | light which could affect this object (i.e. 0 refers to the closest light). |
785 | | NB if there are no lights this close, then the parameter will be set to all zeroes. |
786 | | Note that this property will work with all kinds of lights, even directional lights, |
787 | | since the parameter is set as a 4D vector. |
788 | | Point lights will be `(pos.x, pos.y, pos.z, 1.0f)` whilst directional lights will be |
789 | | `(-dir.x, -dir.y, -dir.z, 0.0f)`. |
790 | | Operations like dot products will work consistently on both. |
791 | | */ |
792 | | ACT_LIGHT_POSITION, |
793 | | /// A light position in object space (index determined by setAutoConstant call) |
794 | | ACT_LIGHT_POSITION_OBJECT_SPACE, |
795 | | /// A light position in view space (index determined by setAutoConstant call) |
796 | | ACT_LIGHT_POSITION_VIEW_SPACE, |
797 | | /// A light direction in world space (index determined by setAutoConstant call) |
798 | | /// @deprecated this property only works on directional lights, and we recommend that |
799 | | /// you use light_position instead since that returns a generic 4D vector. |
800 | | ACT_LIGHT_DIRECTION, |
801 | | /// A light direction in object space (index determined by setAutoConstant call) |
802 | | ACT_LIGHT_DIRECTION_OBJECT_SPACE, |
803 | | /// A light direction in view space (index determined by setAutoConstant call) |
804 | | ACT_LIGHT_DIRECTION_VIEW_SPACE, |
805 | | /** The distance of the light from the center of the object |
806 | | a useful approximation as an alternative to per-vertex distance |
807 | | calculations. |
808 | | */ |
809 | | ACT_LIGHT_DISTANCE_OBJECT_SPACE, |
810 | | /** Light power level, a single scalar as set in Light::setPowerScale (index determined |
811 | | by setAutoConstant call) */ |
812 | | ACT_LIGHT_POWER_SCALE, |
813 | | /// Light diffuse colour pre-scaled by Light::setPowerScale (index determined by |
814 | | /// setAutoConstant call) |
815 | | ACT_LIGHT_DIFFUSE_COLOUR_POWER_SCALED, |
816 | | /// Light specular colour pre-scaled by Light::setPowerScale (index determined by |
817 | | /// setAutoConstant call) |
818 | | ACT_LIGHT_SPECULAR_COLOUR_POWER_SCALED, |
819 | | /// Array of light diffuse colours (count set by extra param) |
820 | | ACT_LIGHT_DIFFUSE_COLOUR_ARRAY, |
821 | | /// Array of light specular colours (count set by extra param) |
822 | | ACT_LIGHT_SPECULAR_COLOUR_ARRAY, |
823 | | /// Array of light diffuse colours scaled by light power (count set by extra param) |
824 | | ACT_LIGHT_DIFFUSE_COLOUR_POWER_SCALED_ARRAY, |
825 | | /// Array of light specular colours scaled by light power (count set by extra param) |
826 | | ACT_LIGHT_SPECULAR_COLOUR_POWER_SCALED_ARRAY, |
827 | | /// Array of light attenuation parameters. |
828 | | /// @copydetails #ACT_LIGHT_ATTENUATION (count set by extra param) |
829 | | ACT_LIGHT_ATTENUATION_ARRAY, |
830 | | /// Array of light positions in world space (count set by extra param) |
831 | | ACT_LIGHT_POSITION_ARRAY, |
832 | | /// Array of light positions in object space (count set by extra param) |
833 | | ACT_LIGHT_POSITION_OBJECT_SPACE_ARRAY, |
834 | | /// Array of light positions in view space (count set by extra param) |
835 | | ACT_LIGHT_POSITION_VIEW_SPACE_ARRAY, |
836 | | /// Array of light directions in world space (count set by extra param) |
837 | | ACT_LIGHT_DIRECTION_ARRAY, |
838 | | /// Array of light directions in object space (count set by extra param) |
839 | | ACT_LIGHT_DIRECTION_OBJECT_SPACE_ARRAY, |
840 | | /// Array of light directions in view space (count set by extra param) |
841 | | ACT_LIGHT_DIRECTION_VIEW_SPACE_ARRAY, |
842 | | /** Array of distances of the lights from the center of the object |
843 | | a useful approximation as an alternative to per-vertex distance |
844 | | calculations. (count set by extra param) |
845 | | */ |
846 | | ACT_LIGHT_DISTANCE_OBJECT_SPACE_ARRAY, |
847 | | /** Array of light power levels, a single scalar as set in Light::setPowerScale |
848 | | (count set by extra param) |
849 | | */ |
850 | | ACT_LIGHT_POWER_SCALE_ARRAY, |
851 | | /** Spotlight parameters array |
852 | | * @copydetails #ACT_SPOTLIGHT_PARAMS |
853 | | * (count set by extra param) |
854 | | */ |
855 | | ACT_SPOTLIGHT_PARAMS_ARRAY, |
856 | | |
857 | | /** The derived ambient light colour, with 'r', 'g', 'b' components filled with |
858 | | product of surface ambient colour and ambient light colour, respectively, |
859 | | and 'a' component filled with surface diffuse alpha component. |
860 | | */ |
861 | | ACT_DERIVED_AMBIENT_LIGHT_COLOUR, |
862 | | /** The derived scene colour, with 'r', 'g' and 'b' components filled with sum |
863 | | of derived ambient light colour and surface emissive colour, respectively, |
864 | | and 'a' component filled with surface diffuse alpha component. |
865 | | */ |
866 | | ACT_DERIVED_SCENE_COLOUR, |
867 | | |
868 | | /** The derived light diffuse colour (index determined by setAutoConstant call), |
869 | | with 'r', 'g' and 'b' components filled with product of surface diffuse colour, |
870 | | light power scale and light diffuse colour, respectively, and 'a' component filled |
871 | | with surface |
872 | | diffuse alpha component. |
873 | | */ |
874 | | ACT_DERIVED_LIGHT_DIFFUSE_COLOUR, |
875 | | /** The derived light specular colour (index determined by setAutoConstant call), |
876 | | with 'r', 'g' and 'b' components filled with product of surface specular colour |
877 | | and light specular colour, respectively, and 'a' component filled with surface |
878 | | specular alpha component. |
879 | | */ |
880 | | ACT_DERIVED_LIGHT_SPECULAR_COLOUR, |
881 | | |
882 | | /// Array of derived light diffuse colours (count set by extra param) |
883 | | ACT_DERIVED_LIGHT_DIFFUSE_COLOUR_ARRAY, |
884 | | /// Array of derived light specular colours (count set by extra param) |
885 | | ACT_DERIVED_LIGHT_SPECULAR_COLOUR_ARRAY, |
886 | | /** The absolute light number of a local light index. Each pass may have |
887 | | a number of lights passed to it, and each of these lights will have |
888 | | an index in the overall light list, which will differ from the local |
889 | | light index due to factors like setStartLight and setIteratePerLight. |
890 | | This binding provides the global light index for a local index. |
891 | | */ |
892 | | ACT_LIGHT_NUMBER, |
893 | | /// Returns (int) 1 if the given light casts shadows, 0 otherwise (index set in extra |
894 | | /// param) |
895 | | ACT_LIGHT_CASTS_SHADOWS, |
896 | | /// Returns (int) 1 if the given light casts shadows, 0 otherwise (index set in extra |
897 | | /// param) |
898 | | ACT_LIGHT_CASTS_SHADOWS_ARRAY, |
899 | | |
900 | | /** The distance a shadow volume should be extruded when using |
901 | | finite extrusion programs. |
902 | | */ |
903 | | ACT_SHADOW_EXTRUSION_DISTANCE, |
904 | | /// The current camera's position in world space |
905 | | ACT_CAMERA_POSITION, |
906 | | /// The current camera's position in object space |
907 | | ACT_CAMERA_POSITION_OBJECT_SPACE, |
908 | | /// The current camera's position in world space even when camera relative rendering is enabled |
909 | | ACT_CAMERA_RELATIVE_POSITION, |
910 | | |
911 | | /** The view/projection matrix of the assigned texture projection frustum. |
912 | | Applicable to vertex programs which have been specified as the ’shadow receiver’ vertex |
913 | | program alternative, or where a texture unit is marked as content_type shadow; this |
914 | | provides details of the view/projection matrix for the current shadow projector. The |
915 | | optional ’extra_params’ entry specifies which light the projector refers to (for the |
916 | | case of content_type shadow where more than one shadow texture may be present in a |
917 | | single pass), where 0 is the default and refers to the first light referenced in this |
918 | | pass. |
919 | | */ |
920 | | ACT_TEXTURE_VIEWPROJ_MATRIX, |
921 | | /// Array of view/projection matrices of the first n texture projection frustums |
922 | | ACT_TEXTURE_VIEWPROJ_MATRIX_ARRAY, |
923 | | /** The view/projection matrix of the assigned texture projection frustum, |
924 | | combined with the current world matrix |
925 | | */ |
926 | | ACT_TEXTURE_WORLDVIEWPROJ_MATRIX, |
927 | | /// Array of world/view/projection matrices of the first n texture projection frustums |
928 | | ACT_TEXTURE_WORLDVIEWPROJ_MATRIX_ARRAY, |
929 | | /// The view/projection matrix of a given spotlight |
930 | | ACT_SPOTLIGHT_VIEWPROJ_MATRIX, |
931 | | /// Array of view/projection matrix of a given spotlight |
932 | | ACT_SPOTLIGHT_VIEWPROJ_MATRIX_ARRAY, |
933 | | /** The view/projection matrix of a given spotlight projection frustum, |
934 | | combined with the current world matrix |
935 | | */ |
936 | | ACT_SPOTLIGHT_WORLDVIEWPROJ_MATRIX, |
937 | | /** An array of the view/projection matrix of a given spotlight projection frustum, |
938 | | combined with the current world matrix |
939 | | */ |
940 | | ACT_SPOTLIGHT_WORLDVIEWPROJ_MATRIX_ARRAY, |
941 | | /** A custom parameter which will come from the renderable, using 'data' as the |
942 | | identifier |
943 | | |
944 | | This allows you to map a custom parameter on an individual Renderable (see |
945 | | Renderable::setCustomParameter) to a parameter on a GPU program. It requires that you |
946 | | complete the ’extra_params’ field with the index that was used in the |
947 | | Renderable::setCustomParameter call, and this will ensure that whenever this Renderable |
948 | | is used, it will have it’s custom parameter mapped in. It’s very important that this |
949 | | parameter has been defined on all Renderables that are assigned the material that |
950 | | contains this automatic mapping, otherwise the process will fail. |
951 | | */ |
952 | | ACT_CUSTOM, |
953 | | /** provides current elapsed time |
954 | | */ |
955 | | ACT_TIME, |
956 | | /** Single float value, which repeats itself based on given as |
957 | | parameter "cycle time". |
958 | | */ |
959 | | ACT_TIME_0_X, |
960 | | /// Cosine of "Time0_X". |
961 | | ACT_COSTIME_0_X, |
962 | | /// Sine of "Time0_X". |
963 | | ACT_SINTIME_0_X, |
964 | | /// Tangent of "Time0_X". |
965 | | ACT_TANTIME_0_X, |
966 | | /** Vector of "Time0_X", "SinTime0_X", "CosTime0_X", |
967 | | "TanTime0_X". |
968 | | */ |
969 | | ACT_TIME_0_X_PACKED, |
970 | | /** Single float value, which represents scaled time value [0..1], |
971 | | which repeats itself based on given as parameter "cycle time". |
972 | | */ |
973 | | ACT_TIME_0_1, |
974 | | /// Cosine of "Time0_1". |
975 | | ACT_COSTIME_0_1, |
976 | | /// Sine of "Time0_1". |
977 | | ACT_SINTIME_0_1, |
978 | | /// Tangent of "Time0_1". |
979 | | ACT_TANTIME_0_1, |
980 | | /** Vector of "Time0_1", "SinTime0_1", "CosTime0_1", |
981 | | "TanTime0_1". |
982 | | */ |
983 | | ACT_TIME_0_1_PACKED, |
984 | | /** Single float value, which represents scaled time value [0..2*Pi], |
985 | | which repeats itself based on given as parameter "cycle time". |
986 | | */ |
987 | | ACT_TIME_0_2PI, |
988 | | /// Cosine of "Time0_2PI". |
989 | | ACT_COSTIME_0_2PI, |
990 | | /// Sine of "Time0_2PI". |
991 | | ACT_SINTIME_0_2PI, |
992 | | /// Tangent of "Time0_2PI". |
993 | | ACT_TANTIME_0_2PI, |
994 | | /** Vector of "Time0_2PI", "SinTime0_2PI", "CosTime0_2PI", |
995 | | "TanTime0_2PI". |
996 | | */ |
997 | | ACT_TIME_0_2PI_PACKED, |
998 | | /// provides the scaled frame time, returned as a floating point value. |
999 | | ACT_FRAME_TIME, |
1000 | | /// provides the calculated frames per second, returned as a floating point value. |
1001 | | ACT_FPS, |
1002 | | // viewport-related values |
1003 | | /** Current viewport width (in pixels) as floating point value. |
1004 | | */ |
1005 | | ACT_VIEWPORT_WIDTH, |
1006 | | /** Current viewport height (in pixels) as floating point value. |
1007 | | */ |
1008 | | ACT_VIEWPORT_HEIGHT, |
1009 | | /** This variable represents `1/ViewportWidth`. |
1010 | | */ |
1011 | | ACT_INVERSE_VIEWPORT_WIDTH, |
1012 | | /** This variable represents `1/ViewportHeight`. |
1013 | | */ |
1014 | | ACT_INVERSE_VIEWPORT_HEIGHT, |
1015 | | /** Viewport dimensions. |
1016 | | Packed as `(ViewportWidth, ViewportHeight, 1/ViewportWidth, 1/ViewportHeight)` |
1017 | | */ |
1018 | | ACT_VIEWPORT_SIZE, |
1019 | | |
1020 | | // view parameters |
1021 | | /** This variable provides the view direction vector (world space). |
1022 | | */ |
1023 | | ACT_VIEW_DIRECTION, |
1024 | | /** This variable provides the view side vector (world space). |
1025 | | */ |
1026 | | ACT_VIEW_SIDE_VECTOR, |
1027 | | /** This variable provides the view up vector (world space). |
1028 | | */ |
1029 | | ACT_VIEW_UP_VECTOR, |
1030 | | /** This variable provides the field of view as a floating point value. |
1031 | | */ |
1032 | | ACT_FOV, |
1033 | | /** This variable provides the near clip distance as a floating point value. |
1034 | | */ |
1035 | | ACT_NEAR_CLIP_DISTANCE, |
1036 | | /** This variable provides the far clip distance as a floating point value. |
1037 | | */ |
1038 | | ACT_FAR_CLIP_DISTANCE, |
1039 | | |
1040 | | /** provides the pass index number within the technique |
1041 | | of the active material. |
1042 | | */ |
1043 | | ACT_PASS_NUMBER, |
1044 | | |
1045 | | /** provides the current iteration number of the pass. The iteration |
1046 | | number is the number of times the current render operation has |
1047 | | been drawn for the active pass. |
1048 | | */ |
1049 | | ACT_PASS_ITERATION_NUMBER, |
1050 | | |
1051 | | /** Provides a parametric animation value [0..1], only available |
1052 | | where the renderable specifically implements it. |
1053 | | |
1054 | | For morph animation, sets the parametric value |
1055 | | (0..1) representing the distance between the first position keyframe (bound to |
1056 | | positions) and the second position keyframe (bound to the first free texture |
1057 | | coordinate) so that the vertex program can interpolate between them. For pose |
1058 | | animation, indicates a group of up to 4 parametric weight values applying to a |
1059 | | sequence of up to 4 poses (each one bound to x, y, z and w of the constant), one for |
1060 | | each pose. The original positions are held in the usual position buffer, and the |
1061 | | offsets to take those positions to the pose where weight == 1.0 are in the first ’n’ |
1062 | | free texture coordinates; ’n’ being determined by the value passed to |
1063 | | includes_pose_animation. If more than 4 simultaneous poses are required, then you’ll |
1064 | | need more than 1 shader constant to hold the parametric values, in which case you |
1065 | | should use this binding more than once, referencing a different constant entry; the |
1066 | | second one will contain the parametrics for poses 5-8, the third for poses 9-12, and |
1067 | | so on. |
1068 | | */ |
1069 | | ACT_ANIMATION_PARAMETRIC, |
1070 | | |
1071 | | /** Provides the texel offsets required by this rendersystem to map |
1072 | | texels to pixels. Packed as |
1073 | | `(absoluteHorizontalOffset, absoluteVerticalOffset, horizontalOffset / viewportWidth, verticalOffset / viewportHeight)` |
1074 | | */ |
1075 | | ACT_TEXEL_OFFSETS, |
1076 | | |
1077 | | /** Provides information about the depth range of the scene as viewed |
1078 | | from the current camera. |
1079 | | Passed as `(minDepth, maxDepth, depthRange, 1 / depthRange)` |
1080 | | */ |
1081 | | ACT_SCENE_DEPTH_RANGE, |
1082 | | |
1083 | | /** Provides information about the depth range of the scene as viewed |
1084 | | from a given shadow camera. Requires an index parameter which maps |
1085 | | to a light index relative to the current light list. |
1086 | | Passed as `(minDepth, maxDepth, depthRange, 1 / depthRange)` |
1087 | | */ |
1088 | | ACT_SHADOW_SCENE_DEPTH_RANGE, |
1089 | | |
1090 | | /** Provides an array of information about the depth range of the scene as viewed |
1091 | | from a given shadow camera. Requires an index parameter which maps |
1092 | | to a light index relative to the current light list. |
1093 | | Passed as `(minDepth, maxDepth, depthRange, 1 / depthRange)` |
1094 | | */ |
1095 | | ACT_SHADOW_SCENE_DEPTH_RANGE_ARRAY, |
1096 | | |
1097 | | /** Provides the fixed shadow colour as configured via SceneManager::setShadowColour; |
1098 | | useful for integrated modulative shadows. |
1099 | | */ |
1100 | | ACT_SHADOW_COLOUR, |
1101 | | /** Provides texture size of the texture unit (index determined by setAutoConstant |
1102 | | call). Packed as `(width, height, depth, numMipMaps)` |
1103 | | */ |
1104 | | ACT_TEXTURE_SIZE, |
1105 | | /** Provides inverse texture size of the texture unit (index determined by |
1106 | | setAutoConstant |
1107 | | call). Packed as `(1 / width, 1 / height, 1 / depth, 1 / numMipMaps)` |
1108 | | */ |
1109 | | ACT_INVERSE_TEXTURE_SIZE, |
1110 | | /** Provides packed texture size of the texture unit (index determined by |
1111 | | setAutoConstant |
1112 | | call). Packed as `(width, height, 1 / width, 1 / height)` |
1113 | | */ |
1114 | | ACT_PACKED_TEXTURE_SIZE, |
1115 | | |
1116 | | /** Provides the current transform matrix of the texture unit (index determined by |
1117 | | setAutoConstant |
1118 | | call), as seen by the fixed-function pipeline. |
1119 | | |
1120 | | This requires an index in the ’extra_params’ field, and relates to the ’nth’ texture |
1121 | | unit of the pass in question. |
1122 | | NB if the given index exceeds the number of texture units available for this pass, |
1123 | | then the parameter will be set to Matrix4::IDENTITY. |
1124 | | */ |
1125 | | ACT_TEXTURE_MATRIX, |
1126 | | |
1127 | | /** Provides the position of the LOD camera in world space, allowing you |
1128 | | to perform separate LOD calculations in shaders independent of the rendering |
1129 | | camera. If there is no separate LOD camera then this is the real camera |
1130 | | position. See Camera::setLodCamera. |
1131 | | */ |
1132 | | ACT_LOD_CAMERA_POSITION, |
1133 | | /** Provides the position of the LOD camera in object space, allowing you |
1134 | | to perform separate LOD calculations in shaders independent of the rendering |
1135 | | camera. If there is no separate LOD camera then this is the real camera |
1136 | | position. See Camera::setLodCamera. |
1137 | | */ |
1138 | | ACT_LOD_CAMERA_POSITION_OBJECT_SPACE, |
1139 | | /** Binds custom per-light constants to the shaders. */ |
1140 | | ACT_LIGHT_CUSTOM, |
1141 | | /// Point attenuation params. |
1142 | | /// Packed as `(size, constant, linear, quadratic)` |
1143 | | ACT_POINT_PARAMS, |
1144 | | /// the LOD index as selected by the active LodStrategy |
1145 | | ACT_MATERIAL_LOD_INDEX, |
1146 | | }; |
1147 | | |
1148 | | /** Defines the type of the extra data item used by the auto constant. |
1149 | | |
1150 | | */ |
1151 | | enum ACDataType { |
1152 | | /// no data is required |
1153 | | ACDT_NONE, |
1154 | | /// the auto constant requires data of type int |
1155 | | ACDT_INT, |
1156 | | /// the auto constant requires data of type float |
1157 | | ACDT_REAL |
1158 | | }; |
1159 | | |
1160 | | /** Defines the base element type of the auto constant |
1161 | | */ |
1162 | | enum ElementType { |
1163 | | ET_INT = BCT_INT, |
1164 | | // float |
1165 | | ET_REAL = BCT_FLOAT |
1166 | | }; |
1167 | | |
1168 | | /** Structure defining an auto constant that's available for use in |
1169 | | a parameters object. |
1170 | | */ |
1171 | | struct AutoConstantDefinition |
1172 | | { |
1173 | | AutoConstantType acType; |
1174 | | String name; |
1175 | | size_t elementCount; |
1176 | | /// The type of the constant in the program |
1177 | | ElementType elementType; |
1178 | | /// The type of any extra data |
1179 | | ACDataType dataType; |
1180 | | |
1181 | | AutoConstantDefinition(AutoConstantType _acType, const String& _name, |
1182 | | size_t _elementCount, ElementType _elementType, |
1183 | | ACDataType _dataType) |
1184 | | :acType(_acType), name(_name), elementCount(_elementCount), |
1185 | | elementType(_elementType), dataType(_dataType) |
1186 | 0 | { |
1187 | 0 |
|
1188 | 0 | } |
1189 | | }; |
1190 | | |
1191 | | /** Structure recording the use of an automatic parameter. */ |
1192 | | class AutoConstantEntry |
1193 | | { |
1194 | | public: |
1195 | | /// The target (physical) constant index |
1196 | | size_t physicalIndex; |
1197 | | /// The type of parameter |
1198 | | AutoConstantType paramType; |
1199 | | /// Additional information to go with the parameter |
1200 | | union{ |
1201 | | uint32 data; |
1202 | | float fData; |
1203 | | }; |
1204 | | /// The variability of this parameter (see GpuParamVariability) |
1205 | | uint16 variability; |
1206 | | /** The number of elements per individual entry in this constant |
1207 | | Used in case people used packed elements smaller than 4 (e.g. GLSL) |
1208 | | and bind an auto which is 4-element packed to it */ |
1209 | | uint8 elementCount; |
1210 | | |
1211 | | AutoConstantEntry(AutoConstantType theType, size_t theIndex, uint32 theData, |
1212 | | uint16 theVariability, uint8 theElemCount = 4) |
1213 | | : physicalIndex(theIndex), paramType(theType), |
1214 | 0 | data(theData), variability(theVariability), elementCount(theElemCount) {} |
1215 | | |
1216 | | AutoConstantEntry(AutoConstantType theType, size_t theIndex, float theData, |
1217 | | uint16 theVariability, uint8 theElemCount = 4) |
1218 | | : physicalIndex(theIndex), paramType(theType), |
1219 | 0 | fData(theData), variability(theVariability), elementCount(theElemCount) {} |
1220 | | |
1221 | | }; |
1222 | | // Auto parameter storage |
1223 | | typedef std::vector<AutoConstantEntry> AutoConstantList; |
1224 | | |
1225 | | typedef std::vector<GpuSharedParametersUsage> GpuSharedParamUsageList; |
1226 | | private: |
1227 | | static AutoConstantDefinition AutoConstantDictionary[]; |
1228 | | |
1229 | | /// Packed list of constants (physical indexing) |
1230 | | ConstantList mConstants; |
1231 | | |
1232 | | /// Sampler handles (logical indexing) |
1233 | | std::vector<int> mRegisters; |
1234 | | |
1235 | | /** Logical index to physical index map - for low-level programs |
1236 | | or high-level programs which pass params this way. */ |
1237 | | GpuLogicalBufferStructPtr mLogicalToPhysical; |
1238 | | |
1239 | | /** Gets the physical buffer index associated with a logical int constant index. |
1240 | | */ |
1241 | | GpuLogicalIndexUse* getConstantLogicalIndexUse(size_t logicalIndex, size_t requestedSize, |
1242 | | uint16 variability, BaseConstantType type); |
1243 | | |
1244 | | /// Mapping from parameter names to def - high-level programs are expected to populate this |
1245 | | GpuNamedConstantsPtr mNamedConstants; |
1246 | | /// List of automatically updated parameters |
1247 | | AutoConstantList mAutoConstants; |
1248 | | /// The combined variability masks of all parameters |
1249 | | uint16 mCombinedVariability; |
1250 | | /// Do we need to transpose matrices? |
1251 | | bool mTransposeMatrices; |
1252 | | /// flag to indicate if names not found will be ignored |
1253 | | bool mIgnoreMissingParams; |
1254 | | /// physical index for active pass iteration parameter real constant entry; |
1255 | | size_t mActivePassIterationIndex; |
1256 | | |
1257 | | bool mUseLinearColours; |
1258 | | |
1259 | | /// Return the variability for an auto constant |
1260 | | static uint16 deriveVariability(AutoConstantType act); |
1261 | | |
1262 | | void copySharedParamSetUsage(const GpuSharedParamUsageList& srcList); |
1263 | | |
1264 | | GpuSharedParamUsageList mSharedParamSets; |
1265 | | |
1266 | | template <typename T> void _setNamedConstant(const String& name, const T* val, size_t count); |
1267 | | |
1268 | | public: |
1269 | | GpuProgramParameters(); |
1270 | | ~GpuProgramParameters(); |
1271 | | |
1272 | | /// Copy constructor |
1273 | | GpuProgramParameters(const GpuProgramParameters& oth); |
1274 | | /// Operator = overload |
1275 | | GpuProgramParameters& operator=(const GpuProgramParameters& oth); |
1276 | | |
1277 | | /** Internal method for providing a link to a name->definition map for parameters. */ |
1278 | | void _setNamedConstants(const GpuNamedConstantsPtr& constantmap); |
1279 | | |
1280 | | /** Internal method for providing a link to a logical index->physical index map for |
1281 | | * parameters. */ |
1282 | | void _setLogicalIndexes(const GpuLogicalBufferStructPtr& indexMap); |
1283 | | |
1284 | | /// Does this parameter set include named parameters? |
1285 | 0 | bool hasNamedParameters() const { return mNamedConstants.get() != 0; } |
1286 | | /** Does this parameter set include logically indexed parameters? |
1287 | | @note Not mutually exclusive with hasNamedParameters since some high-level |
1288 | | programs still use logical indexes to set the parameters on the |
1289 | | rendersystem. |
1290 | | */ |
1291 | 0 | bool hasLogicalIndexedParameters() const { return mLogicalToPhysical.get() != 0; } |
1292 | | |
1293 | | /// Convert colour parameters from gamma to linear space when setting them. |
1294 | | /// This is useful when you have your materials defined in gamma space but your |
1295 | | /// rendering is in linear space. |
1296 | 0 | void setUseLinearColours(bool enable) { mUseLinearColours = enable; } |
1297 | | |
1298 | | /// @name Set constant by logical index |
1299 | | /// @{ |
1300 | | /** Sets a 4-element floating-point parameter to the program. |
1301 | | @param index The logical constant index at which to place the parameter |
1302 | | (each constant is a 4D float) |
1303 | | @param vec The value to set |
1304 | | */ |
1305 | | void setConstant(size_t index, const Vector4& vec); |
1306 | | /** Sets a single floating-point parameter to the program. |
1307 | | @note This is actually equivalent to calling |
1308 | | setConstant(index Vector4(val, 0, 0, 0)) since all constants are 4D. |
1309 | | @param index The logical constant index at which to place the parameter (each constant is |
1310 | | a 4D float) |
1311 | | @param val The value to set |
1312 | | */ |
1313 | | void setConstant(size_t index, Real val); |
1314 | | /** Sets a 4-element floating-point parameter to the program via Vector3. |
1315 | | @param index The logical constant index at which to place the parameter (each constant is |
1316 | | a 4D float). |
1317 | | Note that since you're passing a Vector3, the last element of the 4-element |
1318 | | value will be set to 1 (a homogeneous vector) |
1319 | | @param vec The value to set |
1320 | | */ |
1321 | | void setConstant(size_t index, const Vector3& vec); |
1322 | | /** Sets a 4-element floating-point parameter to the program via Vector2. |
1323 | | @param index The logical constant index at which to place the parameter (each constant is |
1324 | | a 4D float). |
1325 | | Note that since you're passing a Vector2, the last 2 elements of the 4-element |
1326 | | value will be set to 1 (a homogeneous vector) |
1327 | | @param vec The value to set |
1328 | | */ |
1329 | | void setConstant(size_t index, const Vector2& vec); |
1330 | | /** Sets a Matrix4 parameter to the program. |
1331 | | @param index The logical constant index at which to place the parameter (each constant is |
1332 | | a 4D float). |
1333 | | NB since a Matrix4 is 16 floats long, this parameter will take up 4 indexes. |
1334 | | @param m The value to set |
1335 | | */ |
1336 | | void setConstant(size_t index, const Matrix4& m); |
1337 | | /** Sets a list of Matrix4 parameters to the program. |
1338 | | @param index The logical constant index at which to start placing the parameter (each constant is |
1339 | | a 4D float). |
1340 | | NB since a Matrix4 is 16 floats long, so each entry will take up 4 indexes. |
1341 | | @param m Pointer to an array of matrices to set |
1342 | | @param numEntries Number of Matrix4 entries |
1343 | | */ |
1344 | | void setConstant(size_t index, const Matrix4* m, size_t numEntries); |
1345 | | /** Sets a ColourValue parameter to the program. |
1346 | | @param index The logical constant index at which to place the parameter (each constant is |
1347 | | a 4D float) |
1348 | | @param colour The value to set |
1349 | | */ |
1350 | | void setConstant(size_t index, const ColourValue& colour); |
1351 | | /** Sets a multiple value constant floating-point parameter to the program. |
1352 | | @param index The logical constant index at which to start placing parameters (each constant is |
1353 | | a 4D float) |
1354 | | @param val Pointer to the values to write, must contain 4*count floats |
1355 | | @param count The number of groups of 4 floats to write |
1356 | | */ |
1357 | | void setConstant(size_t index, const float *val, size_t count); |
1358 | | /** Sets a multiple value constant floating-point parameter to the program. |
1359 | | @param index The logical constant index at which to start placing parameters (each constant is |
1360 | | a 4D float) |
1361 | | @param val Pointer to the values to write, must contain 4*count floats |
1362 | | @param count The number of groups of 4 floats to write |
1363 | | */ |
1364 | | void setConstant(size_t index, const double *val, size_t count); |
1365 | | /** Sets a multiple value constant integer parameter to the program. |
1366 | | |
1367 | | Different types of GPU programs support different types of constant parameters. |
1368 | | For example, it's relatively common to find that vertex programs only support |
1369 | | floating point constants, and that fragment programs only support integer (fixed point) |
1370 | | parameters. This can vary depending on the program version supported by the |
1371 | | graphics card being used. You should consult the documentation for the type of |
1372 | | low level program you are using, or alternatively use the methods |
1373 | | provided on RenderSystemCapabilities to determine the options. |
1374 | | @param index The logical constant index at which to place the parameter (each constant is |
1375 | | a 4D integer) |
1376 | | @param val Pointer to the values to write, must contain 4*count ints |
1377 | | @param count The number of groups of 4 ints to write |
1378 | | */ |
1379 | | void setConstant(size_t index, const int *val, size_t count); |
1380 | | /** Sets a multiple value constant unsigned integer parameter to the program. |
1381 | | |
1382 | | Different types of GPU programs support different types of constant parameters. |
1383 | | For example, it's relatively common to find that vertex programs only support |
1384 | | floating point constants, and that fragment programs only support integer (fixed point) |
1385 | | parameters. This can vary depending on the program version supported by the |
1386 | | graphics card being used. You should consult the documentation for the type of |
1387 | | low level program you are using, or alternatively use the methods |
1388 | | provided on RenderSystemCapabilities to determine the options. |
1389 | | @param index The logical constant index at which to place the parameter (each constant is |
1390 | | a 4D integer) |
1391 | | @param val Pointer to the values to write, must contain 4*count ints |
1392 | | @param count The number of groups of 4 ints to write |
1393 | | */ |
1394 | | void setConstant(size_t index, const uint *val, size_t count); |
1395 | | /// @} |
1396 | | |
1397 | | /** @name Set constant by physical index |
1398 | | You can use these methods if you have already derived the physical |
1399 | | constant buffer location, for a slight speed improvement over using |
1400 | | the named / logical index versions. |
1401 | | */ |
1402 | | /// @{ |
1403 | | /** Write a series of values into the underlying |
1404 | | constant buffer at the given physical index. |
1405 | | @param physicalIndex The buffer position to start writing |
1406 | | @param val Pointer to a list of values to write |
1407 | | @param count The number of floats to write |
1408 | | */ |
1409 | | template<typename T> |
1410 | | void _writeRawConstants(size_t physicalIndex, const T* val, size_t count) |
1411 | 0 | { |
1412 | 0 | assert(physicalIndex + sizeof(T) * count <= mConstants.size()); |
1413 | 0 | memcpy(&mConstants[physicalIndex], val, sizeof(T) * count); |
1414 | 0 | } Unexecuted instantiation: void Ogre::GpuProgramParameters::_writeRawConstants<float>(unsigned long, float const*, unsigned long) Unexecuted instantiation: void Ogre::GpuProgramParameters::_writeRawConstants<int>(unsigned long, int const*, unsigned long) |
1415 | | /// @overload |
1416 | | void _writeRawConstants(size_t physicalIndex, const double* val, size_t count); |
1417 | | /// write values into register storage |
1418 | | void _writeRegisters(size_t index, const int* val, size_t count); |
1419 | | /** Write a Vector parameter to the program directly to |
1420 | | the underlying constants buffer. |
1421 | | @param physicalIndex The physical buffer index at which to place the parameter |
1422 | | @param vec The value to set |
1423 | | @param count The number of floats to write; if for example |
1424 | | the uniform constant 'slot' is smaller than a Vector4 |
1425 | | */ |
1426 | | template <int dims, typename T> |
1427 | | void _writeRawConstant(size_t physicalIndex, const Vector<dims, T>& vec, size_t count = dims) |
1428 | 0 | { |
1429 | 0 | _writeRawConstants(physicalIndex, vec.ptr(), std::min(count, (size_t)dims)); |
1430 | 0 | } Unexecuted instantiation: void Ogre::GpuProgramParameters::_writeRawConstant<3, float>(unsigned long, Ogre::Vector<3, float> const&, unsigned long) Unexecuted instantiation: void Ogre::GpuProgramParameters::_writeRawConstant<4, float>(unsigned long, Ogre::Vector<4, float> const&, unsigned long) |
1431 | | /** Write a single parameter to the program. |
1432 | | @param physicalIndex The physical buffer index at which to place the parameter |
1433 | | @param val The value to set |
1434 | | */ |
1435 | | template<typename T> |
1436 | | void _writeRawConstant(size_t physicalIndex, T val) |
1437 | 0 | { |
1438 | 0 | _writeRawConstants(physicalIndex, &val, 1); |
1439 | 0 | } Unexecuted instantiation: void Ogre::GpuProgramParameters::_writeRawConstant<int>(unsigned long, int) Unexecuted instantiation: void Ogre::GpuProgramParameters::_writeRawConstant<float>(unsigned long, float) |
1440 | | /** Write a Matrix4 parameter to the program. |
1441 | | @param physicalIndex The physical buffer index at which to place the parameter |
1442 | | @param m The value to set |
1443 | | @param elementCount actual element count used with shader |
1444 | | */ |
1445 | | void _writeRawConstant(size_t physicalIndex, const Matrix4& m, size_t elementCount); |
1446 | | /// @overload |
1447 | | void _writeRawConstant(size_t physicalIndex, const Matrix3& m, size_t elementCount); |
1448 | | /** Write a list of Matrix4 parameters to the program. |
1449 | | @param physicalIndex The physical buffer index at which to place the parameter |
1450 | | @param m The value to set |
1451 | | @param numEntries Number of Matrix4 entries |
1452 | | */ |
1453 | | void _writeRawConstant(size_t physicalIndex, const TransformBaseReal* m, size_t numEntries); |
1454 | | /** Write a ColourValue parameter to the program. |
1455 | | @param physicalIndex The physical buffer index at which to place the parameter |
1456 | | @param colour The value to set |
1457 | | @param count The number of floats to write; if for example |
1458 | | the uniform constant 'slot' is smaller than a Vector4 |
1459 | | */ |
1460 | | void _writeRawConstant(size_t physicalIndex, const ColourValue& colour, |
1461 | | size_t count = 4); |
1462 | | /// @} |
1463 | | |
1464 | | /** Read a series of floating point values from the underlying float |
1465 | | constant buffer at the given physical index. |
1466 | | @param physicalIndex The buffer position to start reading |
1467 | | @param count The number of floats to read |
1468 | | @param dest Pointer to a buffer to receive the values |
1469 | | */ |
1470 | | void _readRawConstants(size_t physicalIndex, size_t count, float* dest); |
1471 | | /** Read a series of integer values from the underlying integer |
1472 | | constant buffer at the given physical index. |
1473 | | @param physicalIndex The buffer position to start reading |
1474 | | @param count The number of ints to read |
1475 | | @param dest Pointer to a buffer to receive the values |
1476 | | */ |
1477 | | void _readRawConstants(size_t physicalIndex, size_t count, int* dest); |
1478 | | |
1479 | | /// @deprecated use getConstantDefinitions() |
1480 | | OGRE_DEPRECATED GpuConstantDefinitionIterator getConstantDefinitionIterator(void) const; |
1481 | | |
1482 | | /** Get a specific GpuConstantDefinition for a named parameter. |
1483 | | @note |
1484 | | Only available if this parameters object has named parameters. |
1485 | | */ |
1486 | | const GpuConstantDefinition& getConstantDefinition(const String& name) const; |
1487 | | |
1488 | | /** Get the full list of GpuConstantDefinition instances. |
1489 | | @note |
1490 | | Only available if this parameters object has named parameters. |
1491 | | */ |
1492 | | const GpuNamedConstants& getConstantDefinitions() const; |
1493 | | |
1494 | | /** Get the current list of mappings from low-level logical param indexes |
1495 | | to physical buffer locations in the float buffer. |
1496 | | @note |
1497 | | Only applicable to low-level programs. |
1498 | | */ |
1499 | 0 | const GpuLogicalBufferStructPtr& getLogicalBufferStruct() const { return mLogicalToPhysical; } |
1500 | | |
1501 | | /** Retrieves the logical index relating to a physical index in the |
1502 | | buffer, for programs which support that (low-level programs and |
1503 | | high-level programs which use logical parameter indexes). |
1504 | | @return std::numeric_limits<size_t>::max() if not found |
1505 | | */ |
1506 | | size_t getLogicalIndexForPhysicalIndex(size_t physicalIndex); |
1507 | | /// Get a reference to the list of constants |
1508 | 0 | const ConstantList& getConstantList() const { return mConstants; } |
1509 | | /// Get a pointer to the 'nth' item in the float buffer |
1510 | 0 | float* getFloatPointer(size_t pos) { return (float*)&mConstants[pos]; } |
1511 | | /// Get a pointer to the 'nth' item in the float buffer |
1512 | 0 | const float* getFloatPointer(size_t pos) const { return (const float*)&mConstants[pos]; } |
1513 | | /// Get a pointer to the 'nth' item in the double buffer |
1514 | 0 | double* getDoublePointer(size_t pos) { return (double*)&mConstants[pos]; } |
1515 | | /// Get a pointer to the 'nth' item in the double buffer |
1516 | 0 | const double* getDoublePointer(size_t pos) const { return (const double*)&mConstants[pos]; } |
1517 | | /// Get a pointer to the 'nth' item in the int buffer |
1518 | 0 | int* getIntPointer(size_t pos) { return (int*)&mConstants[pos]; } |
1519 | | /// Get a pointer to the 'nth' item in the int buffer |
1520 | 0 | const int* getIntPointer(size_t pos) const { return (const int*)&mConstants[pos]; } |
1521 | | /// Get a pointer to the 'nth' item in the uint buffer |
1522 | 0 | uint* getUnsignedIntPointer(size_t pos) { return (uint*)&mConstants[pos]; } |
1523 | | /// Get a pointer to the 'nth' item in the uint buffer |
1524 | 0 | const uint* getUnsignedIntPointer(size_t pos) const { return (const uint*)&mConstants[pos]; } |
1525 | | |
1526 | | /// get a pointer to register storage |
1527 | 0 | int* getRegPointer(size_t pos) { return &mRegisters[pos]; } |
1528 | | /// @overload |
1529 | 0 | const int* getRegPointer(size_t pos) const { return &mRegisters[pos]; } |
1530 | | |
1531 | | /// @name Automatically derived constants |
1532 | | /// @{ |
1533 | | |
1534 | | /// Get a reference to the list of auto constant bindings |
1535 | 0 | const AutoConstantList& getAutoConstantList() const { return mAutoConstants; } |
1536 | | |
1537 | | /** Sets up a constant which will automatically be updated by the system. |
1538 | | |
1539 | | Vertex and fragment programs often need parameters which are to do with the |
1540 | | current render state, or particular values which may very well change over time, |
1541 | | and often between objects which are being rendered. This feature allows you |
1542 | | to set up a certain number of predefined parameter mappings that are kept up to |
1543 | | date for you. |
1544 | | @param index The location in the constant list to place this updated constant every time |
1545 | | it is changed. Note that because of the nature of the types, we know how big the |
1546 | | parameter details will be so you don't need to set that like you do for manual constants. |
1547 | | @param acType The type of automatic constant to set |
1548 | | @param extraInfo If the constant type needs more information (like a light index or array size) put it here. |
1549 | | */ |
1550 | | void setAutoConstant(size_t index, AutoConstantType acType, uint32 extraInfo = 0); |
1551 | | /// @overload |
1552 | | void setAutoConstantReal(size_t index, AutoConstantType acType, float rData); |
1553 | | /// @overload |
1554 | | void setAutoConstant(size_t index, AutoConstantType acType, uint16 extraInfo1, uint16 extraInfo2) |
1555 | 0 | { |
1556 | 0 | setAutoConstant(index, acType, (uint32)extraInfo1 | ((uint32)extraInfo2) << 16); |
1557 | 0 | } |
1558 | | |
1559 | | /** As setAutoConstant, but sets up the auto constant directly against a |
1560 | | physical buffer index. |
1561 | | */ |
1562 | | void _setRawAutoConstant(size_t physicalIndex, AutoConstantType acType, uint32 extraInfo, |
1563 | | uint16 variability, uint8 elementSize = 4); |
1564 | | /** As setAutoConstantReal, but sets up the auto constant directly against a |
1565 | | physical buffer index. |
1566 | | */ |
1567 | | void _setRawAutoConstantReal(size_t physicalIndex, AutoConstantType acType, float rData, |
1568 | | uint16 variability, uint8 elementSize = 4); |
1569 | | |
1570 | | |
1571 | | /** Unbind an auto constant so that the constant is manually controlled again. */ |
1572 | | void clearAutoConstant(size_t index); |
1573 | | |
1574 | | /// @deprecated use ACT_TIME directly |
1575 | | OGRE_DEPRECATED void setConstantFromTime(size_t index, Real factor) |
1576 | 0 | { |
1577 | 0 | setAutoConstantReal(index, ACT_TIME, factor); |
1578 | 0 | } |
1579 | | |
1580 | | /** Clears all the existing automatic constants. */ |
1581 | | void clearAutoConstants(void); |
1582 | | |
1583 | | /** Gets the automatic constant bindings currently in place. */ |
1584 | 0 | const AutoConstantList& getAutoConstants() const { |
1585 | 0 | return mAutoConstants; |
1586 | 0 | } |
1587 | | |
1588 | | /// Gets the number of int constants that have been set |
1589 | 0 | size_t getAutoConstantCount(void) const { return mAutoConstants.size(); } |
1590 | | /** Gets a specific Auto Constant entry if index is in valid range |
1591 | | otherwise returns a NULL |
1592 | | @param index which entry is to be retrieved |
1593 | | */ |
1594 | | AutoConstantEntry* getAutoConstantEntry(const size_t index); |
1595 | | /** Returns true if this instance has any automatic constants. */ |
1596 | 0 | bool hasAutoConstants(void) const { return !(mAutoConstants.empty()); } |
1597 | | /** Finds an auto constant that's affecting a given logical parameter |
1598 | | index for floating-point values. |
1599 | | @note Only applicable for low-level programs. |
1600 | | */ |
1601 | | const AutoConstantEntry* findFloatAutoConstantEntry(size_t logicalIndex); |
1602 | | /** Finds an auto constant that's affecting a given named parameter index. |
1603 | | @note Only applicable to high-level programs. |
1604 | | */ |
1605 | | const AutoConstantEntry* findAutoConstantEntry(const String& paramName) const; |
1606 | | /** Finds an auto constant that's affecting a given physical position in |
1607 | | the floating-point buffer |
1608 | | */ |
1609 | | const AutoConstantEntry* _findRawAutoConstantEntryFloat(size_t physicalIndex) const; |
1610 | | /** Sets up a constant which will automatically be updated by the system. |
1611 | | |
1612 | | Vertex and fragment programs often need parameters which are to do with the |
1613 | | current render state, or particular values which may very well change over time, |
1614 | | and often between objects which are being rendered. This feature allows you |
1615 | | to set up a certain number of predefined parameter mappings that are kept up to |
1616 | | date for you. |
1617 | | @note |
1618 | | This named option will only work if you are using a parameters object created |
1619 | | from a high-level program (HighLevelGpuProgram). |
1620 | | @param name The name of the parameter |
1621 | | @param acType The type of automatic constant to set |
1622 | | @param extraInfo If the constant type needs more information (like a light index) put it here. |
1623 | | */ |
1624 | | void setNamedAutoConstant(const String& name, AutoConstantType acType, uint32 extraInfo = 0); |
1625 | | /// @overload |
1626 | | void setNamedAutoConstantReal(const String& name, AutoConstantType acType, Real rData); |
1627 | | /// @overload |
1628 | | void setNamedAutoConstant(const String& name, AutoConstantType acType, uint16 extraInfo1, uint16 extraInfo2) |
1629 | 0 | { |
1630 | 0 | setNamedAutoConstant(name, acType, (uint32)extraInfo1 | ((uint32)extraInfo2) << 16); |
1631 | 0 | } |
1632 | | |
1633 | | /// @deprecated use ACT_TIME directly |
1634 | | void setNamedConstantFromTime(const String& name, Real factor) |
1635 | 0 | { |
1636 | 0 | setNamedAutoConstantReal(name, ACT_TIME, factor); |
1637 | 0 | } |
1638 | | |
1639 | | /** Unbind an auto constant so that the constant is manually controlled again. */ |
1640 | | void clearNamedAutoConstant(const String& name); |
1641 | | /// @} |
1642 | | |
1643 | | /** Update automatic parameters. |
1644 | | @param source The source of the parameters |
1645 | | @param variabilityMask A mask of GpuParamVariability which identifies which autos will need updating |
1646 | | */ |
1647 | | void _updateAutoParams(const AutoParamDataSource* source, uint16 variabilityMask); |
1648 | | |
1649 | | /** Tells the program whether to ignore missing parameters or not. |
1650 | | */ |
1651 | 0 | void setIgnoreMissingParams(bool state) { mIgnoreMissingParams = state; } |
1652 | | |
1653 | | /// @name Set constant by name |
1654 | | /// @{ |
1655 | | /** Sets a single value constant parameter to the program. |
1656 | | |
1657 | | Different types of GPU programs support different types of constant parameters. |
1658 | | For example, it's relatively common to find that vertex programs only support |
1659 | | floating point constants, and that fragment programs only support integer (fixed point) |
1660 | | parameters. This can vary depending on the program version supported by the |
1661 | | graphics card being used. You should consult the documentation for the type of |
1662 | | low level program you are using, or alternatively use the methods |
1663 | | provided on RenderSystemCapabilities to determine the options. |
1664 | | |
1665 | | Another possible limitation is that some systems only allow constants to be set |
1666 | | on certain boundaries, e.g. in sets of 4 values for example. Again, see |
1667 | | RenderSystemCapabilities for full details. |
1668 | | @note |
1669 | | This named option will only work if you are using a parameters object created |
1670 | | from a high-level program (HighLevelGpuProgram). |
1671 | | @param name The name of the parameter |
1672 | | @param val The value to set |
1673 | | */ |
1674 | | void setNamedConstant(const String& name, float val); |
1675 | | /// @overload |
1676 | | void setNamedConstant(const String& name, int val); |
1677 | | /// @overload |
1678 | | void setNamedConstant(const String& name, uint val); |
1679 | | /// @overload |
1680 | | void setNamedConstant(const String& name, const Vector4& val); |
1681 | | /// @overload |
1682 | | void setNamedConstant(const String& name, const Vector3& val); |
1683 | | /// @overload |
1684 | | void setNamedConstant(const String& name, const Vector2& val); |
1685 | | /// @overload |
1686 | | void setNamedConstant(const String& name, const Matrix4& val); |
1687 | | /// @overload |
1688 | | void setNamedConstant(const String& name, const ColourValue& colour); |
1689 | | /** Sets a list of Matrix4 parameters to the program. |
1690 | | @param name The name of the parameter; this must be the first index of an array, |
1691 | | for examples 'matrices[0]' |
1692 | | NB since a Matrix4 is 16 floats long, so each entry will take up 4 indexes. |
1693 | | @param m Pointer to an array of matrices to set |
1694 | | @param numEntries Number of Matrix4 entries |
1695 | | */ |
1696 | | void setNamedConstant(const String& name, const Matrix4* m, size_t numEntries); |
1697 | | /** Sets a multiple value constant parameter to the program. |
1698 | | |
1699 | | Some systems only allow constants to be set on certain boundaries, |
1700 | | e.g. in sets of 4 values for example. The 'multiple' parameter allows |
1701 | | you to control that although you should only change it if you know |
1702 | | your chosen language supports that (at the time of writing, only |
1703 | | GLSL allows constants which are not a multiple of 4). |
1704 | | @note |
1705 | | This named option will only work if you are using a parameters object created |
1706 | | from a high-level program (HighLevelGpuProgram). |
1707 | | @param name The name of the parameter |
1708 | | @param val Pointer to the values to write |
1709 | | @param count The number of 'multiples' of floats to write |
1710 | | @param multiple The number of raw entries in each element to write, |
1711 | | the default is 4 so count = 1 would write 4 floats. |
1712 | | */ |
1713 | | void setNamedConstant(const String& name, const float *val, size_t count, |
1714 | | size_t multiple = 4); |
1715 | | /// @overload |
1716 | | void setNamedConstant(const String& name, const double *val, size_t count, |
1717 | | size_t multiple = 4); |
1718 | | /// @overload |
1719 | | void setNamedConstant(const String& name, const int *val, size_t count, |
1720 | | size_t multiple = 4); |
1721 | | /// @overload |
1722 | | void setNamedConstant(const String& name, const uint *val, size_t count, |
1723 | | size_t multiple = 4); |
1724 | | /// @} |
1725 | | /** Find a constant definition for a named parameter. |
1726 | | |
1727 | | This method returns null if the named parameter did not exist, unlike |
1728 | | getConstantDefinition which is more strict; unless you set the |
1729 | | last parameter to true. |
1730 | | @param name The name to look up |
1731 | | @param throwExceptionIfMissing If set to true, failure to find an entry |
1732 | | will throw an exception. |
1733 | | */ |
1734 | | const GpuConstantDefinition* _findNamedConstantDefinition( |
1735 | | const String& name, bool throwExceptionIfMissing = false) const; |
1736 | | /** Gets the physical buffer index associated with a logical float constant index. |
1737 | | @note Only applicable to low-level programs. |
1738 | | @param logicalIndex The logical parameter index |
1739 | | @param requestedSize The requested size - pass 0 to ignore missing entries |
1740 | | and return std::numeric_limits<size_t>::max() |
1741 | | @param variability |
1742 | | @param type |
1743 | | */ |
1744 | | size_t _getConstantPhysicalIndex(size_t logicalIndex, size_t requestedSize, uint16 variability, BaseConstantType type); |
1745 | | /** Sets whether or not we need to transpose the matrices passed in from the rest of OGRE. |
1746 | | |
1747 | | D3D uses transposed matrices compared to GL and OGRE; this is not important when you |
1748 | | use programs which are written to process row-major matrices, such as those generated |
1749 | | by Cg, but if you use a program written to D3D's matrix layout you will need to enable |
1750 | | this flag. |
1751 | | */ |
1752 | 0 | void setTransposeMatrices(bool val) { mTransposeMatrices = val; } |
1753 | | /// Gets whether or not matrices are to be transposed when set |
1754 | 0 | bool getTransposeMatrices(void) const { return mTransposeMatrices; } |
1755 | | |
1756 | | /** Copies the values of all constants (including auto constants) from another |
1757 | | GpuProgramParameters object. |
1758 | | @note This copes the internal storage of the paarameters object and therefore |
1759 | | can only be used for parameters objects created from the same GpuProgram. |
1760 | | To merge parameters that match from different programs, use copyMatchingNamedConstantsFrom. |
1761 | | */ |
1762 | | void copyConstantsFrom(const GpuProgramParameters& source); |
1763 | | |
1764 | | /** Copies the values of all matching named constants (including auto constants) from |
1765 | | another GpuProgramParameters object. |
1766 | | |
1767 | | This method iterates over the named constants in another parameters object |
1768 | | and copies across the values where they match. This method is safe to |
1769 | | use when the 2 parameters objects came from different programs, but only |
1770 | | works for named parameters. |
1771 | | */ |
1772 | | void copyMatchingNamedConstantsFrom(const GpuProgramParameters& source); |
1773 | | |
1774 | | /** gets the auto constant definition associated with name if found else returns NULL |
1775 | | @param name The name of the auto constant |
1776 | | */ |
1777 | | static const AutoConstantDefinition* getAutoConstantDefinition(const String& name); |
1778 | | /** gets the auto constant definition by auto constant type. |
1779 | | @param type The auto constant type |
1780 | | */ |
1781 | | static const AutoConstantDefinition* getAutoConstantDefinition(AutoConstantType type); |
1782 | | /** Returns the number of auto constant definitions |
1783 | | */ |
1784 | | static size_t getNumAutoConstantDefinitions(void); |
1785 | | |
1786 | | |
1787 | | /** increments the multipass number entry by 1 if it exists |
1788 | | */ |
1789 | | void incPassIterationNumber(void); |
1790 | | /// @deprecated query by GPV_PASS_ITERATION_NUMBER instead |
1791 | | OGRE_DEPRECATED bool hasPassIterationNumber() const |
1792 | 0 | { return mActivePassIterationIndex != (std::numeric_limits<size_t>::max)(); } |
1793 | | /// @deprecated query by GPV_PASS_ITERATION_NUMBER instead |
1794 | | OGRE_DEPRECATED size_t getPassIterationNumberIndex() const |
1795 | 0 | { return mActivePassIterationIndex; } |
1796 | | |
1797 | | /// @name Shared Parameters |
1798 | | /// @{ |
1799 | | /** Use a set of shared parameters in this parameters object. |
1800 | | |
1801 | | Allows you to use a set of shared parameters to automatically update |
1802 | | this parameter set. |
1803 | | */ |
1804 | | void addSharedParameters(GpuSharedParametersPtr sharedParams); |
1805 | | |
1806 | | /** Use a set of shared parameters in this parameters object. |
1807 | | |
1808 | | Allows you to use a set of shared parameters to automatically update |
1809 | | this parameter set. |
1810 | | @param sharedParamsName The name of a shared parameter set as defined in |
1811 | | GpuProgramManager |
1812 | | */ |
1813 | | void addSharedParameters(const String& sharedParamsName); |
1814 | | |
1815 | | /** Returns whether this parameter set is using the named shared parameter set. */ |
1816 | | bool isUsingSharedParameters(const String& sharedParamsName) const; |
1817 | | |
1818 | | /** Stop using the named shared parameter set. */ |
1819 | | void removeSharedParameters(const String& sharedParamsName); |
1820 | | |
1821 | | /** Stop using all shared parameter sets. */ |
1822 | | void removeAllSharedParameters(); |
1823 | | |
1824 | | /** Get the list of shared parameter sets. */ |
1825 | | const GpuSharedParamUsageList& getSharedParameters() const; |
1826 | | |
1827 | | /** Update the parameters by copying the data from the shared |
1828 | | parameters. |
1829 | | @note This method may not actually be called if the RenderSystem |
1830 | | supports using shared parameters directly in their own shared buffer; in |
1831 | | which case the values should not be copied out of the shared area |
1832 | | into the individual parameter set, but bound separately. |
1833 | | */ |
1834 | | void _copySharedParams(); |
1835 | | |
1836 | | /** Update the HardwareBuffer based backing of referenced shared parameters |
1837 | | * |
1838 | | * falls back to _copySharedParams() if a shared parameter is not hardware backed |
1839 | | */ |
1840 | | void _updateSharedParams(); |
1841 | | /// @} |
1842 | | |
1843 | | size_t calculateSize(void) const; |
1844 | | }; |
1845 | | |
1846 | | /** @} */ |
1847 | | /** @} */ |
1848 | | } |
1849 | | |
1850 | | #include "OgreHeaderSuffix.h" |
1851 | | |
1852 | | #endif |