OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGpuProgramParams.h
Go to the documentation of this file.
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 // Precompiler options
32 #include "OgrePrerequisites.h"
33 #include "OgreSharedPtr.h"
34 #include "OgreIteratorWrappers.h"
35 #include "OgreSerializer.h"
36 #include "OgreRenderOperation.h"
37 #include "OgreAny.h"
39 #include "OgreHeaderPrefix.h"
40 
41 namespace Ogre {
42 
55  {
77  GCT_INT1 = 22,
78  GCT_INT2 = 23,
79  GCT_INT3 = 24,
80  GCT_INT4 = 25,
96  };
97 
102  {
111 
112 
114  GPV_ALL = 0xFFFF
115 
116  };
117 
123  {
129  size_t logicalIndex;
132  size_t elementSize;
134  size_t arraySize;
137 
138  bool isFloat() const
139  {
140  return isFloat(constType);
141  }
142 
143  static bool isFloat(GpuConstantType c)
144  {
145  switch(c)
146  {
147  case GCT_INT1:
148  case GCT_INT2:
149  case GCT_INT3:
150  case GCT_INT4:
151  case GCT_SAMPLER1D:
152  case GCT_SAMPLER2D:
153  case GCT_SAMPLER2DARRAY:
154  case GCT_SAMPLER3D:
155  case GCT_SAMPLERCUBE:
156  case GCT_SAMPLER1DSHADOW:
157  case GCT_SAMPLER2DSHADOW:
158  return false;
159  default:
160  return true;
161  };
162 
163  }
164 
165  bool isDouble() const
166  {
167  return isDouble(constType);
168  }
169 
170  static bool isDouble(GpuConstantType c)
171  {
172  switch(c)
173  {
174  case GCT_INT1:
175  case GCT_INT2:
176  case GCT_INT3:
177  case GCT_INT4:
178  case GCT_FLOAT1:
179  case GCT_FLOAT2:
180  case GCT_FLOAT3:
181  case GCT_FLOAT4:
182  case GCT_SAMPLER1D:
183  case GCT_SAMPLER2D:
184  case GCT_SAMPLER2DARRAY:
185  case GCT_SAMPLER3D:
186  case GCT_SAMPLERCUBE:
187  case GCT_SAMPLER1DSHADOW:
188  case GCT_SAMPLER2DSHADOW:
189  return false;
190  default:
191  return true;
192  };
193 
194  }
195 
196  bool isSampler() const
197  {
198  return isSampler(constType);
199  }
200 
201  static bool isSampler(GpuConstantType c)
202  {
203  switch(c)
204  {
205  case GCT_SAMPLER1D:
206  case GCT_SAMPLER2D:
207  case GCT_SAMPLER2DARRAY:
208  case GCT_SAMPLER3D:
209  case GCT_SAMPLERCUBE:
210  case GCT_SAMPLER1DSHADOW:
211  case GCT_SAMPLER2DSHADOW:
212  return true;
213  default:
214  return false;
215  };
216 
217  }
218 
219  bool isSubroutine() const
220  {
221  return isSubroutine(constType);
222  }
223 
225  {
226  return c == GCT_SUBROUTINE;
227  }
228 
232  static size_t getElementSize(GpuConstantType ctype, bool padToMultiplesOf4)
233  {
234  if (padToMultiplesOf4)
235  {
236  switch(ctype)
237  {
238  case GCT_FLOAT1:
239  case GCT_INT1:
240  case GCT_SAMPLER1D:
241  case GCT_SAMPLER2D:
242  case GCT_SAMPLER2DARRAY:
243  case GCT_SAMPLER3D:
244  case GCT_SAMPLERCUBE:
245  case GCT_SAMPLER1DSHADOW:
246  case GCT_SAMPLER2DSHADOW:
247  case GCT_FLOAT2:
248  case GCT_INT2:
249  case GCT_FLOAT3:
250  case GCT_INT3:
251  case GCT_FLOAT4:
252  case GCT_INT4:
253  return 4;
254  case GCT_MATRIX_2X2:
255  case GCT_MATRIX_2X3:
256  case GCT_MATRIX_2X4:
257  case GCT_DOUBLE1:
258  case GCT_DOUBLE2:
259  case GCT_DOUBLE3:
260  case GCT_DOUBLE4:
261  return 8; // 2 float4s
262  case GCT_MATRIX_3X2:
263  case GCT_MATRIX_3X3:
264  case GCT_MATRIX_3X4:
265  return 12; // 3 float4s
266  case GCT_MATRIX_4X2:
267  case GCT_MATRIX_4X3:
268  case GCT_MATRIX_4X4:
272  return 16; // 4 float4s
276  return 24;
280  return 32;
281  default:
282  return 4;
283  };
284  }
285  else
286  {
287  switch(ctype)
288  {
289  case GCT_FLOAT1:
290  case GCT_DOUBLE1:
291  case GCT_INT1:
292  case GCT_SAMPLER1D:
293  case GCT_SAMPLER2D:
294  case GCT_SAMPLER2DARRAY:
295  case GCT_SAMPLER3D:
296  case GCT_SAMPLERCUBE:
297  case GCT_SAMPLER1DSHADOW:
298  case GCT_SAMPLER2DSHADOW:
299  return 1;
300  case GCT_FLOAT2:
301  case GCT_INT2:
302  case GCT_DOUBLE2:
303  return 2;
304  case GCT_FLOAT3:
305  case GCT_INT3:
306  case GCT_DOUBLE3:
307  return 3;
308  case GCT_FLOAT4:
309  case GCT_INT4:
310  case GCT_DOUBLE4:
311  return 4;
312  case GCT_MATRIX_2X2:
314  return 4;
315  case GCT_MATRIX_2X3:
316  case GCT_MATRIX_3X2:
319  return 6;
320  case GCT_MATRIX_2X4:
321  case GCT_MATRIX_4X2:
324  return 8;
325  case GCT_MATRIX_3X3:
327  return 9;
328  case GCT_MATRIX_3X4:
329  case GCT_MATRIX_4X3:
332  return 12;
333  case GCT_MATRIX_4X4:
335  return 16;
336  default:
337  return 4;
338  };
339 
340  }
341  }
342 
344  : constType(GCT_UNKNOWN)
345  , physicalIndex((std::numeric_limits<size_t>::max)())
346  , logicalIndex(0)
347  , elementSize(0)
348  , arraySize(1)
349  , variability(GPV_GLOBAL) {}
350  };
353 
356  {
365 
366  GpuNamedConstants() : floatBufferSize(0), doubleBufferSize(0), intBufferSize(0) {}
367 
379  void generateConstantDefinitionArrayEntries(const String& paramName,
380  const GpuConstantDefinition& baseDef);
381 
383  static bool getGenerateAllConstantDefinitionArrayEntries();
384 
391  static void setGenerateAllConstantDefinitionArrayEntries(bool generateAll);
392 
396  void save(const String& filename) const;
400  void load(DataStreamPtr& stream);
401 
402  size_t calculateSize(void) const;
403 
404  protected:
412  };
414 
417  {
418  public:
420  virtual ~GpuNamedConstantsSerializer();
421  void exportNamedConstants(const GpuNamedConstants* pConsts, const String& filename,
422  Endian endianMode = ENDIAN_NATIVE);
423  void exportNamedConstants(const GpuNamedConstants* pConsts, DataStreamPtr stream,
424  Endian endianMode = ENDIAN_NATIVE);
425  void importNamedConstants(DataStreamPtr& stream, GpuNamedConstants* pDest);
426  };
427 
432  {
436  size_t currentSize;
439 
441  : physicalIndex(99999), currentSize(0), variability(GPV_GLOBAL) {}
442  GpuLogicalIndexUse(size_t bufIdx, size_t curSz, uint16 v)
443  : physicalIndex(bufIdx), currentSize(curSz), variability(v) {}
444  };
448  {
449  OGRE_MUTEX(mutex);
450 
454  size_t bufferSize;
455  GpuLogicalBufferStruct() : bufferSize(0) {}
456  };
458 
474 
491  {
492  protected:
498 
499  // Optional data the rendersystem might want to store
501 
504 
506  unsigned long mVersion;
507 
508  public:
509  GpuSharedParameters(const String& name);
510  virtual ~GpuSharedParameters();
511 
513  const String& getName() { return mName; }
514 
522  void addConstantDefinition(const String& name, GpuConstantType constType, size_t arraySize = 1);
523 
526  void removeConstantDefinition(const String& name);
527 
530  void removeAllConstantDefinitions();
531 
535  unsigned long getVersion() const { return mVersion; }
536 
537  size_t calculateSize(void) const;
538 
544  void _markDirty();
546  size_t getFrameLastUpdated() const { return mFrameLastUpdated; }
547 
551  GpuConstantDefinitionIterator getConstantDefinitionIterator(void) const;
552 
555  const GpuConstantDefinition& getConstantDefinition(const String& name) const;
556 
559  const GpuNamedConstants& getConstantDefinitions() const;
560 
562  void setNamedConstant(const String& name, Real val);
564  void setNamedConstant(const String& name, int val);
566  void setNamedConstant(const String& name, const Vector4& vec);
568  void setNamedConstant(const String& name, const Vector3& vec);
570  void setNamedConstant(const String& name, const Vector2& vec);
572  void setNamedConstant(const String& name, const Matrix4& m);
574  void setNamedConstant(const String& name, const Matrix4* m, size_t numEntries);
576  void setNamedConstant(const String& name, const float *val, size_t count);
578  void setNamedConstant(const String& name, const double *val, size_t count);
580  void setNamedConstant(const String& name, const ColourValue& colour);
582  void setNamedConstant(const String& name, const int *val, size_t count);
583 
585  float* getFloatPointer(size_t pos) { _markDirty(); return &mFloatConstants[pos]; }
587  const float* getFloatPointer(size_t pos) const { return &mFloatConstants[pos]; }
589  double* getDoublePointer(size_t pos) { _markDirty(); return &mDoubleConstants[pos]; }
591  const double* getDoublePointer(size_t pos) const { return &mDoubleConstants[pos]; }
593  int* getIntPointer(size_t pos) { _markDirty(); return &mIntConstants[pos]; }
595  const int* getIntPointer(size_t pos) const { return &mIntConstants[pos]; }
596 
598  const FloatConstantList& getFloatConstantList() const { return mFloatConstants; }
600  const DoubleConstantList& getDoubleConstantList() const { return mDoubleConstants; }
602  const IntConstantList& getIntConstantList() const { return mIntConstants; }
603 
605  void _setRenderSystemData(const Any& data) const { mRenderSystemData = data; }
607  const Any& _getRenderSystemData() const { return mRenderSystemData; }
608 
609  };
610 
613 
614  class GpuProgramParameters;
615 
620  {
621  protected:
623  // Not a shared pointer since this is also parent
625  // list of physical mappings that we are going to bring in
627  {
630  };
632 
634 
635  // Optional data the rendersystem might want to store
637 
639  unsigned long mCopyDataVersion;
640 
641  void initCopyData();
642 
643 
644  public:
647  GpuProgramParameters* params);
648 
656  void _copySharedParamsToTargetParams();
657 
659  const String& getName() const { return mSharedParams->getName(); }
660 
661  GpuSharedParametersPtr getSharedParams() const { return mSharedParams; }
662  GpuProgramParameters* getTargetParams() const { return mParams; }
663 
665  void _setRenderSystemData(const Any& data) const { mRenderSystemData = data; }
667  const Any& _getRenderSystemData() const { return mRenderSystemData; }
668 
669 
670  };
671 
703  {
704  public:
709  {
720 
729 
742 
743 
758 
759 
774 
775 
787 
788 
803 
804 
806 
810 
814 
819 
820 
833 
834 
837 
838 
841 
915 
926 
939 
955 
956 
1041 
1061 
1063 
1087 
1092 
1098 
1099 
1104 
1111 
1117 
1124 
1131 
1148 
1153 
1168 
1169  ACT_UNKNOWN = 999
1170  };
1171 
1175  enum ACDataType {
1181  ACDT_REAL
1182  };
1183 
1188  ET_REAL
1189  };
1190 
1195  {
1203 
1205  size_t _elementCount, ElementType _elementType,
1206  ACDataType _dataType)
1207  :acType(_acType), name(_name), elementCount(_elementCount),
1208  elementType(_elementType), dataType(_dataType)
1209  {
1210 
1211  }
1212  };
1213 
1216  {
1217  public:
1227  union{
1228  size_t data;
1230  };
1233 
1234  AutoConstantEntry(AutoConstantType theType, size_t theIndex, size_t theData,
1235  uint16 theVariability, size_t theElemCount = 4)
1236  : paramType(theType), physicalIndex(theIndex), elementCount(theElemCount),
1237  data(theData), variability(theVariability) {}
1238 
1239  AutoConstantEntry(AutoConstantType theType, size_t theIndex, Real theData,
1240  uint16 theVariability, size_t theElemCount = 4)
1241  : paramType(theType), physicalIndex(theIndex), elementCount(theElemCount),
1242  fData(theData), variability(theVariability) {}
1243 
1244  };
1245  // Auto parameter storage
1247 
1249 
1250  // Map that store subroutines associated with slots
1251  typedef HashMap<unsigned int, String> SubroutineMap;
1252  typedef HashMap<unsigned int, String>::const_iterator SubroutineIterator;
1253 
1254  protected:
1256 
1257  static AutoConstantDefinition AutoConstantDictionary[];
1285 
1288  GpuLogicalIndexUse* _getFloatConstantLogicalIndexUse(size_t logicalIndex, size_t requestedSize, uint16 variability);
1291  GpuLogicalIndexUse* _getDoubleConstantLogicalIndexUse(size_t logicalIndex, size_t requestedSize, uint16 variability);
1294  GpuLogicalIndexUse* _getIntConstantLogicalIndexUse(size_t logicalIndex, size_t requestedSize, uint16 variability);
1295 
1297  uint16 deriveVariability(AutoConstantType act);
1298 
1299  void copySharedParamSetUsage(const GpuSharedParamUsageList& srcList);
1300 
1302 
1303  // Optional data the rendersystem might want to store
1305 
1306 
1307 
1308  public:
1311 
1315  GpuProgramParameters& operator=(const GpuProgramParameters& oth);
1316 
1318  void _setNamedConstants(const GpuNamedConstantsPtr& constantmap);
1319 
1321  void _setLogicalIndexes(const GpuLogicalBufferStructPtr& floatIndexMap, const GpuLogicalBufferStructPtr& doubleIndexMap,
1322  const GpuLogicalBufferStructPtr& intIndexMap);
1323 
1324 
1326  bool hasNamedParameters() const { return !mNamedConstants.isNull(); }
1332  bool hasLogicalIndexedParameters() const { return !mFloatLogicalToPhysical.isNull(); }
1333 
1339  void setConstant(size_t index, const Vector4& vec);
1347  void setConstant(size_t index, Real val);
1355  void setConstant(size_t index, const Vector3& vec);
1363  void setConstant(size_t index, const Vector2& vec);
1370  void setConstant(size_t index, const Matrix4& m);
1378  void setConstant(size_t index, const Matrix4* m, size_t numEntries);
1385  void setConstant(size_t index, const float *val, size_t count);
1392  void setConstant(size_t index, const double *val, size_t count);
1398  void setConstant(size_t index, const ColourValue& colour);
1399 
1414  void setConstant(size_t index, const int *val, size_t count);
1415 
1422  void _writeRawConstants(size_t physicalIndex, const float* val, size_t count);
1429  void _writeRawConstants(size_t physicalIndex, const double* val, size_t count);
1436  void _writeRawConstants(size_t physicalIndex, const int* val, size_t count);
1443  void _readRawConstants(size_t physicalIndex, size_t count, float* dest);
1450  void _readRawConstants(size_t physicalIndex, size_t count, int* dest);
1451 
1462  void _writeRawConstant(size_t physicalIndex, const Vector4& vec,
1463  size_t count = 4);
1471  void _writeRawConstant(size_t physicalIndex, Real val);
1479  void _writeRawConstant(size_t physicalIndex, Real val, size_t count);
1487  void _writeRawConstant(size_t physicalIndex, int val);
1495  void _writeRawConstant(size_t physicalIndex, const Vector3& vec);
1503  void _writeRawConstant(size_t physicalIndex, const Vector2& vec);
1512  void _writeRawConstant(size_t physicalIndex, const Matrix4& m, size_t elementCount);
1520  void _writeRawConstant(size_t physicalIndex, const Matrix4* m, size_t numEntries);
1530  void _writeRawConstant(size_t physicalIndex, const ColourValue& colour,
1531  size_t count = 4);
1532 
1533 
1539  GpuConstantDefinitionIterator getConstantDefinitionIterator(void) const;
1540 
1545  const GpuConstantDefinition& getConstantDefinition(const String& name) const;
1546 
1551  const GpuNamedConstants& getConstantDefinitions() const;
1552 
1558  const GpuLogicalBufferStructPtr& getFloatLogicalBufferStruct() const { return mFloatLogicalToPhysical; }
1559 
1565  size_t getFloatLogicalIndexForPhysicalIndex(size_t physicalIndex);
1576  const GpuLogicalBufferStructPtr& getDoubleLogicalBufferStruct() const { return mDoubleLogicalToPhysical; }
1577 
1583  size_t getDoubleLogicalIndexForPhysicalIndex(size_t physicalIndex);
1589  size_t getIntLogicalIndexForPhysicalIndex(size_t physicalIndex);
1590 
1596  const GpuLogicalBufferStructPtr& getIntLogicalBufferStruct() const { return mIntLogicalToPhysical; }
1598  const FloatConstantList& getFloatConstantList() const { return mFloatConstants; }
1600  float* getFloatPointer(size_t pos) { return &mFloatConstants[pos]; }
1602  const float* getFloatPointer(size_t pos) const { return &mFloatConstants[pos]; }
1604  const DoubleConstantList& getDoubleConstantList() const { return mDoubleConstants; }
1606  double* getDoublePointer(size_t pos) { return &mDoubleConstants[pos]; }
1608  const double* getDoublePointer(size_t pos) const { return &mDoubleConstants[pos]; }
1610  const IntConstantList& getIntConstantList() const { return mIntConstants; }
1612  int* getIntPointer(size_t pos) { return &mIntConstants[pos]; }
1614  const int* getIntPointer(size_t pos) const { return &mIntConstants[pos]; }
1616  const AutoConstantList& getAutoConstantList() const { return mAutoConstants; }
1617 
1631  void setAutoConstant(size_t index, AutoConstantType acType, size_t extraInfo = 0);
1632  void setAutoConstantReal(size_t index, AutoConstantType acType, Real rData);
1633 
1648  void setAutoConstant(size_t index, AutoConstantType acType, uint16 extraInfo1, uint16 extraInfo2);
1649 
1653  void _setRawAutoConstant(size_t physicalIndex, AutoConstantType acType, size_t extraInfo,
1654  uint16 variability, size_t elementSize = 4);
1658  void _setRawAutoConstantReal(size_t physicalIndex, AutoConstantType acType, Real rData,
1659  uint16 variability, size_t elementSize = 4);
1660 
1661 
1663  void clearAutoConstant(size_t index);
1664 
1669  void setConstantFromTime(size_t index, Real factor);
1670 
1672  void clearAutoConstants(void);
1675  AutoConstantIterator getAutoConstantIterator(void) const;
1677  size_t getAutoConstantCount(void) const { return mAutoConstants.size(); }
1682  AutoConstantEntry* getAutoConstantEntry(const size_t index);
1684  bool hasAutoConstants(void) const { return !(mAutoConstants.empty()); }
1689  const AutoConstantEntry* findFloatAutoConstantEntry(size_t logicalIndex);
1694  const AutoConstantEntry* findDoubleAutoConstantEntry(size_t logicalIndex);
1699  const AutoConstantEntry* findIntAutoConstantEntry(size_t logicalIndex);
1703  const AutoConstantEntry* findAutoConstantEntry(const String& paramName);
1707  const AutoConstantEntry* _findRawAutoConstantEntryFloat(size_t physicalIndex);
1711  const AutoConstantEntry* _findRawAutoConstantEntryDouble(size_t physicalIndex);
1715  const AutoConstantEntry* _findRawAutoConstantEntryInt(size_t physicalIndex);
1716 
1721  void _updateAutoParams(const AutoParamDataSource* source, uint16 variabilityMask);
1722 
1725  void setIgnoreMissingParams(bool state) { mIgnoreMissingParams = state; }
1726 
1746  void setNamedConstant(const String& name, Real val);
1766  void setNamedConstant(const String& name, int val);
1771  void setNamedConstant(const String& name, const Vector4& vec);
1779  void setNamedConstant(const String& name, const Vector3& vec);
1784  void setNamedConstant(const String& name, const Vector2& vec);
1789  void setNamedConstant(const String& name, const Matrix4& m);
1797  void setNamedConstant(const String& name, const Matrix4* m, size_t numEntries);
1814  void setNamedConstant(const String& name, const float *val, size_t count,
1815  size_t multiple = 4);
1832  void setNamedConstant(const String& name, const double *val, size_t count,
1833  size_t multiple = 4);
1838  void setNamedConstant(const String& name, const ColourValue& colour);
1839 
1856  void setNamedConstant(const String& name, const int *val, size_t count,
1857  size_t multiple = 4);
1858 
1873  void setNamedAutoConstant(const String& name, AutoConstantType acType, size_t extraInfo = 0);
1874  void setNamedAutoConstantReal(const String& name, AutoConstantType acType, Real rData);
1875 
1891  void setNamedAutoConstant(const String& name, AutoConstantType acType, uint16 extraInfo1, uint16 extraInfo2);
1892 
1900  void setNamedConstantFromTime(const String& name, Real factor);
1901 
1903  void clearNamedAutoConstant(const String& name);
1904 
1914  const GpuConstantDefinition* _findNamedConstantDefinition(
1915  const String& name, bool throwExceptionIfMissing = false) const;
1922  size_t _getFloatConstantPhysicalIndex(size_t logicalIndex, size_t requestedSize, uint16 variability);
1929  size_t _getDoubleConstantPhysicalIndex(size_t logicalIndex, size_t requestedSize, uint16 variability);
1936  size_t _getIntConstantPhysicalIndex(size_t logicalIndex, size_t requestedSize, uint16 variability);
1937 
1945  void setTransposeMatrices(bool val) { mTransposeMatrices = val; }
1947  bool getTransposeMatrices(void) const { return mTransposeMatrices; }
1948 
1955  void copyConstantsFrom(const GpuProgramParameters& source);
1956 
1965  void copyMatchingNamedConstantsFrom(const GpuProgramParameters& source);
1966 
1970  static const AutoConstantDefinition* getAutoConstantDefinition(const String& name);
1975  static const AutoConstantDefinition* getAutoConstantDefinition(const size_t idx);
1978  static size_t getNumAutoConstantDefinitions(void);
1979 
1980 
1983  void incPassIterationNumber(void);
1986  { return mActivePassIterationIndex != (std::numeric_limits<size_t>::max)(); }
1989  { return mActivePassIterationIndex; }
1990 
1991 
1997  void addSharedParameters(GpuSharedParametersPtr sharedParams);
1998 
2006  void addSharedParameters(const String& sharedParamsName);
2007 
2009  bool isUsingSharedParameters(const String& sharedParamsName) const;
2010 
2012  void removeSharedParameters(const String& sharedParamsName);
2013 
2015  void removeAllSharedParameters();
2016 
2018  const GpuSharedParamUsageList& getSharedParameters() const;
2019 
2021  void _setRenderSystemData(const Any& data) const { mRenderSystemData = data; }
2023  const Any& _getRenderSystemData() const { return mRenderSystemData; }
2024 
2032  void _copySharedParams();
2033 
2034  size_t calculateSize(void) const;
2035 
2038  void setNamedSubroutine(const String& subroutineSlot, const String& subroutine);
2039 
2042  void setSubroutine(size_t index, const String& subroutine);
2043 
2046  const SubroutineMap& getSubroutineMap() const { return mSubroutineMap; }
2047  };
2048 
2051 
2054 }
2055 
2056 #include "OgreHeaderSuffix.h"
2057 
2058 #endif
2059 
Array of light diffuse colours scaled by light power (count set by extra param)
The derived scene colour, with 'r', 'g' and 'b' components filled with sum of derived ambient light c...
The current view & projection matrices concatenated.
Sine of "Time0_1". Equivalent to RenderMonkey's "SinTime0_1".
double * getDoublePointer(size_t pos)
Get a pointer to the 'nth' item in the double buffer.
static bool isFloat(GpuConstantType c)
const double * getDoublePointer(size_t pos) const
Get a pointer to the 'nth' item in the double buffer.
size_t intBufferSize
Total size of the int buffer required.
An array of the view/projection matrix of a given spotlight projection frustum, combined with the cur...
uint16 mCombinedVariability
The combined variability masks of all parameters.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
GpuConstantDefinitionMap map
Map of parameter names to GpuConstantDefinition.
bool mIgnoreMissingParams
flag to indicate if names not found will be ignored
The ambient light colour set in the scene.
The current world matrix, inverted & transposed.
const Any & _getRenderSystemData() const
Internal method that the RenderSystem might use to store optional data.
unsigned long getVersion() const
Get the version number of this shared parameter set, can be used to identify when changes have occurr...
size_t elementSize
Number of raw buffer slots per element (some programs pack each array element to float4, some do not)
static size_t getElementSize(GpuConstantType ctype, bool padToMultiplesOf4)
Get the element size of a given type, including whether to pad the elements into multiples of 4 (e...
GpuLogicalIndexUse(size_t bufIdx, size_t curSz, uint16 v)
size_t mFrameLastUpdated
Not used when copying data, but might be useful to RS using shared buffers.
Structure recording the use of a physical buffer by a logical parameter index.
size_t mActivePassIterationIndex
physical index for active pass iteration parameter real constant entry;
HashMap< unsigned int, String >::const_iterator SubroutineIterator
float Real
Software floating point type.
This variable provides the view side vector (world space).
Array of light attenuation parameters, Vector4(range, constant, linear, quadric) (count set by extra ...
#define _OgreExport
Definition: OgrePlatform.h:260
const float * getFloatPointer(size_t pos) const
Get a pointer to the 'nth' item in the float buffer.
size_t elementCount
The number of elements per individual entry in this constant Used in case people used packed elements...
This variable represents 1.0/ViewportHeight.
Provides information about the depth range of the scene as viewed from the current camera...
Single float value, which represents scaled time value [0..1], which repeats itself based on given as...
Variant type that can hold Any other type.
Definition: OgreAny.h:56
Cosine of "Time0_1". Equivalent to RenderMonkey's "CosTime0_1".
size_t logicalIndex
Logical index - used to communicate this constant to the rendersystem.
A light position in object space (index determined by setAutoConstant call)
Array of view/projection matrices of the first n texture projection frustums.
HashMap< unsigned int, String > SubroutineMap
Provides transpose of concatenated view and projection matrices.
This variable provides the far clip distance as a floating point value.
size_t getAutoConstantCount(void) const
Gets the number of int constants that have been set.
#define OGRE_MUTEX(name)
Generic class for serialising data to / from binary stream-based files.
The current world & view matrices concatenated, then inverted & transposed.
Fog params: density, linear start, linear end, 1/(end-start)
Array of distances of the lights from the center of the object a useful approximation as an alternati...
Surface alpha rejection value, not as set in Pass::setAlphaRejectionValue, but a floating number betw...
The distance of the light from the center of the object a useful approximation as an alternative to p...
float * getFloatPointer(size_t pos)
Get a pointer to the 'nth' item in the float buffer.
GpuParamVariability
The variability of a GPU parameter, as derived from auto-params targeting it.
Array of derived light specular colours (count set by extra param)
Class representing colour.
A custom parameter which will come from the renderable, using 'data' as the identifier.
size_t floatBufferSize
Total size of the float buffer required.
IntConstantList mIntConstants
Packed list of integer constants (physical indexing)
Provides the fixed shadow colour as configured via SceneManager::setShadowColour; useful for integrat...
The view/projection matrix of the assigned texture projection frustum, combined with the current worl...
A light position in view space (index determined by setAutoConstant call)
The current camera's position in object space.
const SubroutineMap & getSubroutineMap() const
Get map with.
const Any & _getRenderSystemData() const
Internal method that the RenderSystem might use to store optional data.
Provides the position of the LOD camera in world space, allowing you to perform separate LOD calculat...
GpuLogicalIndexUseMap map
Map from logical index to physical buffer location.
vector< GpuSharedParametersUsage >::type GpuSharedParamUsageList
void setTransposeMatrices(bool val)
Sets whether or not we need to transpose the matrices passed in from the rest of OGRE.
AutoConstantType paramType
The type of parameter.
Array of light directions in world space (count set by extra param)
const GpuConstantDefinition * srcDefinition
SharedPtr< GpuProgramParameters > GpuProgramParametersSharedPtr
Shared pointer used to hold references to GpuProgramParameters instances.
Surface specular colour, as set in Pass::setSpecular.
Single float value, which repeats itself based on given as parameter "cycle time".
DoubleConstantList mDoubleConstants
Surface shininess, as set in Pass::setShininess.
Provides inverse of concatenated view and projection matrices.
A group of manually updated parameters that are shared between many parameter sets.
GpuSharedParametersPtr getSharedParams() const
The view/projection matrix of a given spotlight projection frustum, combined with the current world m...
static bool msGenerateAllConstantDefinitionArrayEntries
Indicates whether all array entries will be generated and added to the definitions map...
size_t physicalIndex
Physical start index in buffer (either float, double or int buffer)
AutoConstantList mAutoConstants
List of automatically updated parameters.
const GpuConstantDefinition * dstDefinition
bool getTransposeMatrices(void) const
Gets whether or not matrices are to be transposed when set.
void _setRenderSystemData(const Any &data) const
Internal method that the RenderSystem might use to store optional data.
This variable provides the view up vector (world space).
The distance a shadow volume should be extruded when using finite extrusion programs.
static bool isSubroutine(GpuConstantType c)
ACDataType
Defines the type of the extra data item used by the auto constant.
Provides texture size of the texture unit (index determined by setAutoConstant call).
A light position in world space (index determined by setAutoConstant call)
GpuSharedParametersPtr mSharedParams
GpuConstantType constType
Data type.
Provides an array of information about the depth range of the scene as viewed from a given shadow cam...
Surface ambient colour, as set in Pass::setAmbient.
const DoubleConstantList & getDoubleConstantList() const
Get a reference to the list of double constants.
uint16 variability
The variability of this parameter (see GpuParamVariability)
The derived light specular colour (index determined by setAutoConstant call), with 'r'...
Array of light specular colours scaled by light power (count set by extra param)
Returns (int) 1 if the given light casts shadows, 0 otherwise (index set in extra param) ...
bool mTransposeMatrices
Do we need to transpose matrices?
Sine of "Time0_2PI". Equivalent to RenderMonkey's "SinTime0_2PI".
The current array of world matrices, used for blending.
A light direction in object space (index determined by setAutoConstant call)
Provides inverse of concatenated world, view and projection matrices.
Structure recording the use of an automatic parameter.
Array of view/projection matrix of a given spotlight.
This variable provides the near clip distance as a floating point value.
GpuSharedParamUsageList mSharedParamSets
Provides the texel offsets required by this rendersystem to map texels to pixels. ...
provides the calculated frames per second, returned as a floating point value.
The view/projection matrix of the assigned texture projection frustum.
AutoConstantType
Defines the types of automatically updated values that may be bound to GpuProgram parameters...
Binds custom per-light constants to the shaders.
vector< AutoConstantEntry >::type AutoConstantList
The derived light diffuse colour (index determined by setAutoConstant call), with 'r'...
Array of light specular colours (count set by extra param)
bool hasNamedParameters() const
Does this parameter set include named parameters?
const DoubleConstantList & getDoubleConstantList() const
Get a reference to the list of double constants.
Array of light power levels, a single scalar as set in Light::setPowerScale (count set by extra param...
Cosine of "Time0_X". Equivalent to RenderMonkey's "CosTime0_X".
map< size_t, GpuLogicalIndexUse >::type GpuLogicalIndexUseMap
Vector of "Time0_X", "SinTime0_X", "CosTime0_X", "TanTime0_X".
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
provides the current iteration number of the pass.
size_t currentSize
Current physical size allocation.
Light power level, a single scalar as set in Light::setPowerScale (index determined by setAutoConstan...
size_t bufferSize
Shortcut to know the buffer size needs.
size_t doubleBufferSize
Total size of the double buffer required.
ConstVectorIterator< AutoConstantList > AutoConstantIterator
static bool isSampler(GpuConstantType c)
bool hasLogicalIndexedParameters() const
Does this parameter set include logically indexed parameters?
vector< CopyDataEntry >::type CopyDataList
size_t physicalIndex
Physical buffer index.
const AutoConstantList & getAutoConstantList() const
Get a reference to the list of auto constant bindings.
Structure defining an auto constant that's available for use in a parameters object.
GpuLogicalBufferStructPtr mIntLogicalToPhysical
Logical index to physical index map - for low-level programs or high-level programs which pass params...
Container struct to allow params to safely & update shared list of logical buffer assignments...
Struct collecting together the information for named constants.
Endian
The endianness of written files.
Concrete IteratorWrapper for const access to the underlying container.
static bool isDouble(GpuConstantType c)
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Collects together the program parameters used for a GpuProgram.
Tangent of "Time0_1". Equivalent to RenderMonkey's "TanTime0_1".
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
const IntConstantList & getIntConstantList() const
Get a reference to the list of int constants.
AutoConstantEntry(AutoConstantType theType, size_t theIndex, size_t theData, uint16 theVariability, size_t theElemCount=4)
SharedPtr< GpuNamedConstants > GpuNamedConstantsPtr
This variable represents 1.0/ViewportWidth.
const GpuLogicalBufferStructPtr & getDoubleLogicalBufferStruct() const
Retrieves the logical index relating to a physical index in the int buffer, for programs which suppor...
float * getFloatPointer(size_t pos)
Get a pointer to the 'nth' item in the float buffer.
uint16 variability
How this parameter varies (bitwise combination of GpuProgramVariability)
Surface emissive colour, as set in Pass::setSelfIllumination.
the auto constant requires data of type int
Full mask (16-bit)
Array of light diffuse colours (count set by extra param)
Provides transpose of concatenated world and view matrices.
The current array of world matrices transformed to an array of dual quaternions, represented as a 2x4...
The current world & view matrices concatenated, then inverted.
const String & getName()
Get the name of this shared parameter set.
The derived ambient light colour, with 'r', 'g', 'b' components filled with product of surface ambien...
The view/projection matrix of a given spotlight.
GpuProgramParameters * getTargetParams() const
uint16 variability
How the contents of this slot vary.
void setIgnoreMissingParams(bool state)
Tells the program whether to ignore missing parameters or not.
Array of light positions in world space (count set by extra param)
The scale and shear components of the current array of world matrices.
Light specular colour pre-scaled by Light::setPowerScale (index determined by setAutoConstant call) ...
Light diffuse colour pre-scaled by Light::setPowerScale (index determined by setAutoConstant call) ...
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
DoubleConstantList mDoubleConstants
Packed list of double-point constants (physical indexing)
Provides information about the depth range of the scene as viewed from a given shadow camera...
bool hasAutoConstants(void) const
Returns true if this instance has any automatic constants.
double * getDoublePointer(size_t pos)
Get a pointer to the 'nth' item in the double buffer.
Varies per object (based on an auto param usually), but not per light setup.
Light specular colour (index determined by setAutoConstant call)
void _setRenderSystemData(const Any &data) const
Internal method that the RenderSystem might use to store optional data.
void _setRenderSystemData(const Any &data) const
Internal method that the RenderSystem might use to store optional data.
Varies with pass iteration number.
-1 if the winding has been inverted (e.g.
This variable provides the field of view as a floating point value.
int * getIntPointer(size_t pos)
Get a pointer to the 'nth' item in the int buffer.
Surface diffuse colour, as set in Pass::setDiffuse.
Array of world/view/projection matrices of the first n texture projection frustums.
Light attenuation parameters, Vector4(range, constant, linear, quadric)
const GpuLogicalBufferStructPtr & getFloatLogicalBufferStruct() const
Get the current list of mappings from low-level logical param indexes to physical buffer locations in...
Cosine of "Time0_2PI". Equivalent to RenderMonkey's "CosTime0_2PI".
const float * getFloatPointer(size_t pos) const
Get a pointer to the 'nth' item in the float buffer.
Sine of "Time0_X". Equivalent to RenderMonkey's "SinTime0_X".
No variation except by manual setting - the default.
SharedPtr< GpuLogicalBufferStruct > GpuLogicalBufferStructPtr
Array of light directions in view space (count set by extra param)
const String & getName() const
Get the name of the shared parameter set.
unsigned long mCopyDataVersion
Version of shared params we based the copydata on.
Packed of "ViewportWidth", "ViewportHeight", "ViewportWidthInverse", "ViewportHeightInverse".
AutoConstantDefinition(AutoConstantType _acType, const String &_name, size_t _elementCount, ElementType _elementType, ACDataType _dataType)
map< String, GpuConstantDefinition >::type GpuConstantDefinitionMap
provides current elapsed time
Array of light positions in object space (count set by extra param)
size_t data
Concrete IteratorWrapper for const access to the underlying key-value container.
size_t arraySize
Length of array.
Single float value, which represents scaled time value [0..2*Pi], which repeats itself based on given...
A light direction in world space (index determined by setAutoConstant call)
provides the pass index number within the technique of the active materil.
Provides the position of the LOD camera in object space, allowing you to perform separate LOD calcula...
Provides the current transform matrix of the texture unit (index determined by setAutoConstant call)...
vector< int >::type IntConstantList
Definition of container that holds the current float constants.
Returns (int) 1 if the given light casts shadows, 0 otherwise (index set in extra param) ...
size_t getFrameLastUpdated() const
Get the frame in which this shared parameter set was last updated.
The current array of world matrices, as a 3x4 matrix, used for blending.
The number of active light sources (better than gl_MaxLights)
AutoConstantEntry(AutoConstantType theType, size_t theIndex, Real theData, uint16 theVariability, size_t theElemCount=4)
GpuNamedConstantsPtr mNamedConstants
Mapping from parameter names to def - high-level programs are expected to populate this...
Information about predefined program constants.
Vector of "Time0_1", "SinTime0_1", "CosTime0_1", "TanTime0_1".
_StringBase String
SharedPtr< GpuSharedParameters > GpuSharedParametersPtr
Shared pointer used to hold references to GpuProgramParameters instances.
Provides packed texture size of the texture unit (index determined by setAutoConstant call)...
size_t getPassIterationNumberIndex() const
Get the physical buffer index of the pass iteration number constant.
vector< float >::type FloatConstantList
Definition of container that holds the current float constants.
unsigned long mVersion
Version number of the definitions in this buffer.
ConstMapIterator< GpuConstantDefinitionMap > GpuConstantDefinitionIterator
ACDataType dataType
The type of any extra data.
unsigned short uint16
Definition: OgrePlatform.h:345
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
ElementType
Defines the base element type of the auto constant.
provides the scaled frame time, returned as a floating point value.
Provides a parametric animation value [0..1], only available where the renderable specifically implem...
int * getIntPointer(size_t pos)
Get a pointer to the 'nth' item in the int buffer.
GpuLogicalBufferStructPtr mFloatLogicalToPhysical
Logical index to physical index map - for low-level programs or high-level programs which pass params...
const FloatConstantList & getFloatConstantList() const
Get a reference to the list of float constants.
vector< double >::type DoubleConstantList
Definition of container that holds the current double constants.
bool hasPassIterationNumber() const
Does this parameters object have a pass iteration number constant?
Provides transpose of concatenated world, view and projection matrices.
Tangent of "Time0_2PI". Equivalent to RenderMonkey's "TanTime0_2PI".
Real fData
Array of light directions in object space (count set by extra param)
const IntConstantList & getIntConstantList() const
Get a reference to the list of int constants.
GpuLogicalBufferStructPtr mDoubleLogicalToPhysical
Logical index to physical index map - for low-level programs or high-level programs which pass params...
Tangent of "Time0_X". Equivalent to RenderMonkey's "TanTime0_X".
ElementType elementType
The type of the constant in the program.
const double * getDoublePointer(size_t pos) const
Get a pointer to the 'nth' item in the double buffer.
const FloatConstantList & getFloatConstantList() const
Get a reference to the list of float constants.
Array of light positions in view space (count set by extra param)
Light diffuse colour (index determined by setAutoConstant call)
size_t physicalIndex
The target (physical) constant index.
Spotlight parameters, Vector4(innerFactor, outerFactor, falloff, isSpot) innerFactor and outerFactor ...
Varies with light setup.
Provides inverse texture size of the texture unit (index determined by setAutoConstant call)...
This class records the usage of a set of shared parameters in a concrete set of GpuProgramParameters...
Provides inverse transpose of concatenated world, view and projection matrices.
A light direction in view space (index determined by setAutoConstant call)
The absolute light number of a local light index.
const int * getIntPointer(size_t pos) const
Get a pointer to the 'nth' item in the int buffer.
The current camera's position in world space.
The current world & view matrices concatenated.
Array of derived light diffuse colours (count set by extra param)
const Any & _getRenderSystemData() const
Internal method that the RenderSystem might use to store optional data.
This utility class is used to hold the information used to generate the matrices and other informatio...
Simple class for loading / saving GpuNamedConstants.
const int * getIntPointer(size_t pos) const
Get a pointer to the 'nth' item in the int buffer.
FloatConstantList mFloatConstants
Packed list of floating-point constants (physical indexing)
const GpuLogicalBufferStructPtr & getIntLogicalBufferStruct() const
Get the current list of mappings from low-level logical param indexes to physical buffer locations in...
Spotlight parameters array of Vector4(innerFactor, outerFactor, falloff, isSpot) innerFactor and oute...
Vector of "Time0_2PI", "SinTime0_2PI", "CosTime0_2PI", "TanTime0_2PI".
Current viewport height (in pixels) as floating point value.
Provides inverse transpose of concatenated view and projection matrices.