CmCgProgram.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #include "CmCgProgram.h"
  25. #include "CmGpuProgramManager.h"
  26. #include "CmHighLevelGpuProgramManager.h"
  27. #include "CmDebug.h"
  28. #include "CmException.h"
  29. #include "CmCgProgramRTTI.h"
  30. namespace CamelotEngine {
  31. void checkForCgError(const String& ogreMethod, const String& errorTextPrefix, CGcontext context)
  32. {
  33. CGerror error = cgGetError();
  34. if (error != CG_NO_ERROR)
  35. {
  36. String msg = errorTextPrefix + cgGetErrorString(error);
  37. if (error == CG_COMPILER_ERROR)
  38. {
  39. // Get listing with full compile errors
  40. msg = msg + "\n" + cgGetLastListing(context);
  41. }
  42. CM_EXCEPT(InternalErrorException, msg);
  43. }
  44. }
  45. //-----------------------------------------------------------------------
  46. void CgProgram::selectProfile(void)
  47. {
  48. mSelectedProfile.clear();
  49. mSelectedCgProfile = CG_PROFILE_UNKNOWN;
  50. mSelectedProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
  51. GpuProgramManager& gpuMgr = GpuProgramManager::instance();
  52. if (gpuMgr.isSyntaxSupported(mSelectedProfile))
  53. {
  54. mSelectedCgProfile = cgGetProfile(mSelectedProfile.c_str());
  55. // Check for errors
  56. checkForCgError("CgProgram::selectProfile",
  57. "Unable to find CG profile enum for program.", mCgContext);
  58. }
  59. else
  60. mSelectedProfile.clear();
  61. }
  62. //-----------------------------------------------------------------------
  63. void CgProgram::buildArgs(void)
  64. {
  65. vector<String>::type args;
  66. if (!mCompileArgs.empty())
  67. args = StringUtil::split(mCompileArgs);
  68. vector<String>::type::const_iterator i;
  69. if (mSelectedCgProfile == CG_PROFILE_VS_1_1)
  70. {
  71. // Need the 'dcls' argument whenever we use this profile
  72. // otherwise compilation of the assembler will fail
  73. bool dclsFound = false;
  74. for (i = args.begin(); i != args.end(); ++i)
  75. {
  76. if (*i == "dcls")
  77. {
  78. dclsFound = true;
  79. break;
  80. }
  81. }
  82. if (!dclsFound)
  83. {
  84. args.push_back("-profileopts");
  85. args.push_back("dcls");
  86. }
  87. }
  88. // Now split args into that god-awful char** that Cg insists on
  89. freeCgArgs();
  90. mCgArguments = (char**)malloc(sizeof(char*) * (args.size() + 1));
  91. int index = 0;
  92. for (i = args.begin(); i != args.end(); ++i, ++index)
  93. {
  94. mCgArguments[index] = (char*)malloc(sizeof(char) * (i->length() + 1));
  95. strcpy(mCgArguments[index], i->c_str());
  96. }
  97. // Null terminate list
  98. mCgArguments[index] = 0;
  99. }
  100. //-----------------------------------------------------------------------
  101. void CgProgram::freeCgArgs(void)
  102. {
  103. if (mCgArguments)
  104. {
  105. size_t index = 0;
  106. char* current = mCgArguments[index];
  107. while (current)
  108. {
  109. free(current);
  110. mCgArguments[index] = 0;
  111. current = mCgArguments[++index];
  112. }
  113. free(mCgArguments);
  114. mCgArguments = 0;
  115. }
  116. }
  117. //-----------------------------------------------------------------------
  118. void CgProgram::loadFromSource(void)
  119. {
  120. // Create Cg Program
  121. selectProfile();
  122. if (mSelectedCgProfile == CG_PROFILE_UNKNOWN)
  123. {
  124. gDebug().log("Attempted to load Cg program but no supported "
  125. "profile was found.", "RenderSystem");
  126. return;
  127. }
  128. buildArgs();
  129. // TODO PORT - This doesn't load includes
  130. // deal with includes
  131. String sourceToUse = mSource;
  132. //String sourceToUse = resolveCgIncludes(mSource, this, mFilename);
  133. mCgProgram = cgCreateProgram(mCgContext, CG_SOURCE, sourceToUse.c_str(),
  134. mSelectedCgProfile, mEntryPoint.c_str(), const_cast<const char**>(mCgArguments));
  135. // Test
  136. //LogManager::getSingleton().logMessage(cgGetProgramString(mCgProgram, CG_COMPILED_PROGRAM));
  137. // Check for errors
  138. checkForCgError("CgProgram::loadFromSource",
  139. "Unable to compile Cg program", mCgContext);
  140. // ignore any previous error
  141. if (mSelectedCgProfile != CG_PROFILE_UNKNOWN && !mCompileError)
  142. {
  143. if (mSelectedCgProfile == CG_PROFILE_VS_4_0 || mSelectedCgProfile == CG_PROFILE_PS_4_0)
  144. {
  145. String hlslSourceFromCg = cgGetProgramString(mCgProgram, CG_COMPILED_PROGRAM);
  146. // Create a high-level program, give it the same name as us
  147. HighLevelGpuProgramPtr vp =
  148. HighLevelGpuProgramManager::instance().create(
  149. hlslSourceFromCg, "main", "hlsl", mType, mProfile);
  150. vp->initialize();
  151. mAssemblerProgram = vp;
  152. }
  153. else
  154. {
  155. String shaderAssemblerCode = cgGetProgramString(mCgProgram, CG_COMPILED_PROGRAM);
  156. // Create a low-level program, give it the same name as us
  157. mAssemblerProgram =
  158. GpuProgramManager::instance().createProgram(
  159. shaderAssemblerCode, "", mSelectedProfile,
  160. mType,
  161. GPP_NONE);
  162. }
  163. // Shader params need to be forwarded to low level implementation
  164. mAssemblerProgram->setAdjacencyInfoRequired(isAdjacencyInfoRequired());
  165. }
  166. }
  167. //-----------------------------------------------------------------------
  168. void CgProgram::unload_internal(void)
  169. {
  170. // Unload Cg Program
  171. // Lowlevel program will get unloaded elsewhere
  172. if (mCgProgram)
  173. {
  174. cgDestroyProgram(mCgProgram);
  175. checkForCgError("CgProgram::unloadImpl",
  176. "Error while unloading Cg program",
  177. mCgContext);
  178. mCgProgram = 0;
  179. }
  180. HighLevelGpuProgram::unload_internal();
  181. }
  182. //-----------------------------------------------------------------------
  183. void CgProgram::buildConstantDefinitions() const
  184. {
  185. // Derive parameter names from Cg
  186. //createParameterMappingStructures(true);
  187. if (!mCgProgram)
  188. return;
  189. recurseParams(cgGetFirstParameter(mCgProgram, CG_PROGRAM));
  190. recurseParams(cgGetFirstParameter(mCgProgram, CG_GLOBAL));
  191. }
  192. //---------------------------------------------------------------------
  193. void CgProgram::recurseParams(CGparameter parameter, UINT32 contextArraySize) const
  194. {
  195. //while (parameter != 0)
  196. // {
  197. // // Look for parameters
  198. // // Don't bother enumerating unused parameters, especially since they will
  199. // // be optimised out and therefore not in the indexed versions
  200. // CGtype paramType = cgGetParameterType(parameter);
  201. // if (cgGetParameterVariability(parameter) == CG_UNIFORM &&
  202. // paramType != CG_SAMPLERRECT &&
  203. // cgGetParameterDirection(parameter) != CG_OUT &&
  204. // cgIsParameterReferenced(parameter))
  205. // {
  206. // int arraySize;
  207. // switch(paramType)
  208. // {
  209. // case CG_STRUCT:
  210. // recurseParams(cgGetFirstStructParameter(parameter));
  211. // break;
  212. // case CG_ARRAY:
  213. // // Support only 1-dimensional arrays
  214. // arraySize = cgGetArraySize(parameter, 0);
  215. // recurseParams(cgGetArrayParameter(parameter, 0), (size_t)arraySize);
  216. // break;
  217. // default:
  218. // // Normal path (leaf)
  219. // String paramName = cgGetParameterName(parameter);
  220. // UINT32 logicalIndex = (UINT32)cgGetParameterResourceIndex(parameter);
  221. // // Get the parameter resource, to calculate the physical index
  222. // CGresource res = cgGetParameterResource(parameter);
  223. // bool isRegisterCombiner = false;
  224. // UINT32 regCombinerPhysicalIndex = 0;
  225. // switch (res)
  226. // {
  227. // case CG_COMBINER_STAGE_CONST0:
  228. // // register combiner, const 0
  229. // // the index relates to the texture stage; store this as (stage * 2) + 0
  230. // regCombinerPhysicalIndex = logicalIndex * 2;
  231. // isRegisterCombiner = true;
  232. // break;
  233. // case CG_COMBINER_STAGE_CONST1:
  234. // // register combiner, const 1
  235. // // the index relates to the texture stage; store this as (stage * 2) + 1
  236. // regCombinerPhysicalIndex = (logicalIndex * 2) + 1;
  237. // isRegisterCombiner = true;
  238. // break;
  239. // default:
  240. // // normal constant
  241. // break;
  242. // }
  243. // // Trim the '[0]' suffix if it exists, we will add our own indexing later
  244. // if (StringUtil::endsWith(paramName, "[0]", false))
  245. // {
  246. // paramName.erase(paramName.size() - 3);
  247. // }
  248. // GpuConstantDefinition def;
  249. // def.arraySize = contextArraySize;
  250. // mapTypeAndElementSize(paramType, isRegisterCombiner, def);
  251. // if (def.constType == GCT_UNKNOWN)
  252. // {
  253. // gDebug().log("Problem parsing the following Cg Uniform: '" + paramName + "'", "RenderSystem");
  254. // // next uniform
  255. // parameter = cgGetNextParameter(parameter);
  256. // continue;
  257. // }
  258. // if (isRegisterCombiner)
  259. // {
  260. // def.physicalIndex = regCombinerPhysicalIndex;
  261. // }
  262. // else
  263. // {
  264. // // base position on existing buffer contents
  265. // if(def.isSampler())
  266. // {
  267. // def.physicalIndex = mSamplerLogicalToPhysical->bufferSize;
  268. // }
  269. // else
  270. // {
  271. // if (def.isFloat())
  272. // {
  273. // def.physicalIndex = mFloatLogicalToPhysical->bufferSize;
  274. // }
  275. // else
  276. // {
  277. // def.physicalIndex = mIntLogicalToPhysical->bufferSize;
  278. // }
  279. // }
  280. // }
  281. // def.logicalIndex = logicalIndex;
  282. // mConstantDefs->map.insert(GpuConstantDefinitionMap::value_type(paramName, def));
  283. // // Record logical / physical mapping
  284. // if(def.isSampler())
  285. // {
  286. // mSamplerLogicalToPhysical->map.insert(
  287. // GpuLogicalIndexUseMap::value_type(logicalIndex,
  288. // GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
  289. // mSamplerLogicalToPhysical->bufferSize += def.arraySize;
  290. // mConstantDefs->samplerCount = mSamplerLogicalToPhysical->bufferSize;
  291. // mTextureLogicalToPhysical->map.insert(
  292. // GpuLogicalIndexUseMap::value_type(logicalIndex,
  293. // GpuLogicalIndexUse(def.physicalIndex, def.arraySize, GPV_GLOBAL)));
  294. // mTextureLogicalToPhysical->bufferSize += def.arraySize;
  295. // mConstantDefs->textureCount = mTextureLogicalToPhysical->bufferSize;
  296. // }
  297. // else
  298. // {
  299. // if (def.isFloat())
  300. // {
  301. // mFloatLogicalToPhysical->map.insert(
  302. // GpuLogicalIndexUseMap::value_type(logicalIndex,
  303. // GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
  304. // mFloatLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
  305. // mConstantDefs->floatBufferSize = mFloatLogicalToPhysical->bufferSize;
  306. // }
  307. // else
  308. // {
  309. // mIntLogicalToPhysical->map.insert(
  310. // GpuLogicalIndexUseMap::value_type(logicalIndex,
  311. // GpuLogicalIndexUse(def.physicalIndex, def.arraySize * def.elementSize, GPV_GLOBAL)));
  312. // mIntLogicalToPhysical->bufferSize += def.arraySize * def.elementSize;
  313. // mConstantDefs->intBufferSize = mIntLogicalToPhysical->bufferSize;
  314. // }
  315. // }
  316. // // Deal with array indexing
  317. // mConstantDefs->generateConstantDefinitionArrayEntries(paramName, def);
  318. // break;
  319. //
  320. // }
  321. //
  322. // }
  323. // // Get next
  324. // parameter = cgGetNextParameter(parameter);
  325. // }
  326. }
  327. //-----------------------------------------------------------------------
  328. void CgProgram::mapTypeAndElementSize(CGtype cgType, bool isRegisterCombiner,
  329. GpuConstantDefinition& def) const
  330. {
  331. if (isRegisterCombiner)
  332. {
  333. // register combiners are the only single-float entries in our buffer
  334. def.constType = GCT_FLOAT1;
  335. def.elementSize = 1;
  336. }
  337. else
  338. {
  339. switch(cgType)
  340. {
  341. case CG_SAMPLER1D:
  342. def.constType = GCT_SAMPLER1D;
  343. break;
  344. case CG_SAMPLER2D:
  345. def.constType = GCT_SAMPLER2D;
  346. break;
  347. case CG_SAMPLER3D:
  348. def.constType = GCT_SAMPLER3D;
  349. break;
  350. case CG_SAMPLERCUBE:
  351. def.constType = GCT_SAMPLERCUBE;
  352. break;
  353. case CG_FLOAT:
  354. case CG_FLOAT1:
  355. case CG_HALF:
  356. case CG_HALF1:
  357. def.constType = GCT_FLOAT1;
  358. break;
  359. case CG_FLOAT2:
  360. case CG_HALF2:
  361. def.constType = GCT_FLOAT2;
  362. break;
  363. case CG_FLOAT3:
  364. case CG_HALF3:
  365. def.constType = GCT_FLOAT3;
  366. break;
  367. case CG_FLOAT4:
  368. case CG_HALF4:
  369. def.constType = GCT_FLOAT4;
  370. break;
  371. case CG_FLOAT2x2:
  372. case CG_HALF2x2:
  373. def.constType = GCT_MATRIX_2X2;
  374. break;
  375. case CG_FLOAT2x3:
  376. case CG_HALF2x3:
  377. def.constType = GCT_MATRIX_2X3;
  378. break;
  379. case CG_FLOAT2x4:
  380. case CG_HALF2x4:
  381. def.constType = GCT_MATRIX_2X4;
  382. break;
  383. case CG_FLOAT3x2:
  384. case CG_HALF3x2:
  385. def.constType = GCT_MATRIX_3X2;
  386. break;
  387. case CG_FLOAT3x3:
  388. case CG_HALF3x3:
  389. def.constType = GCT_MATRIX_3X3;
  390. break;
  391. case CG_FLOAT3x4:
  392. case CG_HALF3x4:
  393. def.constType = GCT_MATRIX_3X4;
  394. break;
  395. case CG_FLOAT4x2:
  396. case CG_HALF4x2:
  397. def.constType = GCT_MATRIX_4X2;
  398. break;
  399. case CG_FLOAT4x3:
  400. case CG_HALF4x3:
  401. def.constType = GCT_MATRIX_4X3;
  402. break;
  403. case CG_FLOAT4x4:
  404. case CG_HALF4x4:
  405. def.constType = GCT_MATRIX_4X4;
  406. break;
  407. case CG_INT:
  408. case CG_INT1:
  409. def.constType = GCT_INT1;
  410. break;
  411. case CG_INT2:
  412. def.constType = GCT_INT2;
  413. break;
  414. case CG_INT3:
  415. def.constType = GCT_INT3;
  416. break;
  417. case CG_INT4:
  418. def.constType = GCT_INT4;
  419. break;
  420. default:
  421. def.constType = GCT_UNKNOWN;
  422. break;
  423. }
  424. // Cg pads
  425. def.elementSize = GpuConstantDefinition::getElementSize(def.constType, true);
  426. }
  427. }
  428. //-----------------------------------------------------------------------
  429. CgProgram::CgProgram(CGcontext context, const String& source, const String& entryPoint, const String& language,
  430. GpuProgramType gptype, GpuProgramProfile profile, bool isAdjacencyInfoRequired)
  431. : HighLevelGpuProgram(source, entryPoint, language, gptype, profile, isAdjacencyInfoRequired),
  432. mCgContext(context), mCgProgram(0),
  433. mSelectedCgProfile(CG_PROFILE_UNKNOWN), mCgArguments(0)
  434. {
  435. }
  436. //-----------------------------------------------------------------------
  437. CgProgram::~CgProgram()
  438. {
  439. freeCgArgs();
  440. unload_internal();
  441. }
  442. //-----------------------------------------------------------------------
  443. bool CgProgram::isSupported(void) const
  444. {
  445. if (mCompileError || !isRequiredCapabilitiesSupported())
  446. return false;
  447. String selectedProfile = GpuProgramManager::instance().gpuProgProfileToRSSpecificProfile(mProfile);
  448. if (GpuProgramManager::instance().isSyntaxSupported(selectedProfile))
  449. return true;
  450. return false;
  451. }
  452. //-----------------------------------------------------------------------
  453. String CgProgram::resolveCgIncludes(const String& inSource, Resource* resourceBeingLoaded, const String& fileName)
  454. {
  455. String outSource;
  456. // TODO PORT - Includes are not handled ATM
  457. // output will be at least this big
  458. //outSource.reserve(inSource.length());
  459. //size_t startMarker = 0;
  460. //size_t i = inSource.find("#include");
  461. //while (i != String::npos)
  462. //{
  463. // size_t includePos = i;
  464. // size_t afterIncludePos = includePos + 8;
  465. // size_t newLineBefore = inSource.rfind("\n", includePos);
  466. // // check we're not in a comment
  467. // size_t lineCommentIt = inSource.rfind("//", includePos);
  468. // if (lineCommentIt != String::npos)
  469. // {
  470. // if (newLineBefore == String::npos || lineCommentIt > newLineBefore)
  471. // {
  472. // // commented
  473. // i = inSource.find("#include", afterIncludePos);
  474. // continue;
  475. // }
  476. // }
  477. // size_t blockCommentIt = inSource.rfind("/*", includePos);
  478. // if (blockCommentIt != String::npos)
  479. // {
  480. // size_t closeCommentIt = inSource.rfind("*/", includePos);
  481. // if (closeCommentIt == String::npos || closeCommentIt < blockCommentIt)
  482. // {
  483. // // commented
  484. // i = inSource.find("#include", afterIncludePos);
  485. // continue;
  486. // }
  487. // }
  488. // // find following newline (or EOF)
  489. // size_t newLineAfter = inSource.find("\n", afterIncludePos);
  490. // // find include file string container
  491. // String endDelimeter = "\"";
  492. // size_t startIt = inSource.find("\"", afterIncludePos);
  493. // if (startIt == String::npos || startIt > newLineAfter)
  494. // {
  495. // // try <>
  496. // startIt = inSource.find("<", afterIncludePos);
  497. // if (startIt == String::npos || startIt > newLineAfter)
  498. // {
  499. // CM_EXCEPT(InternalErrorException,
  500. // "Badly formed #include directive (expected \" or <) in file "
  501. // + fileName + ": " + inSource.substr(includePos, newLineAfter-includePos));
  502. // }
  503. // else
  504. // {
  505. // endDelimeter = ">";
  506. // }
  507. // }
  508. // size_t endIt = inSource.find(endDelimeter, startIt+1);
  509. // if (endIt == String::npos || endIt <= startIt)
  510. // {
  511. // CM_EXCEPT(InternalErrorException,
  512. // "Badly formed #include directive (expected " + endDelimeter + ") in file "
  513. // + fileName + ": " + inSource.substr(includePos, newLineAfter-includePos));
  514. // }
  515. // // extract filename
  516. // String filename(inSource.substr(startIt+1, endIt-startIt-1));
  517. // // open included file
  518. // DataStreamPtr resource = ResourceGroupManager::getSingleton().
  519. // openResource(filename, resourceBeingLoaded->getGroup(), true, resourceBeingLoaded);
  520. // // replace entire include directive line
  521. // // copy up to just before include
  522. // if (newLineBefore != String::npos && newLineBefore >= startMarker)
  523. // outSource.append(inSource.substr(startMarker, newLineBefore-startMarker+1));
  524. // size_t lineCount = 0;
  525. // size_t lineCountPos = 0;
  526. //
  527. // // Count the line number of #include statement
  528. // lineCountPos = outSource.find('\n');
  529. // while(lineCountPos != String::npos)
  530. // {
  531. // lineCountPos = outSource.find('\n', lineCountPos+1);
  532. // lineCount++;
  533. // }
  534. // // Add #line to the start of the included file to correct the line count
  535. // outSource.append("#line 1 \"" + filename + "\"\n");
  536. // outSource.append(resource->getAsString());
  537. // // Add #line to the end of the included file to correct the line count
  538. // outSource.append("\n#line " + toString(lineCount) +
  539. // "\"" + fileName + "\"\n");
  540. // startMarker = newLineAfter;
  541. // if (startMarker != String::npos)
  542. // i = inSource.find("#include", startMarker);
  543. // else
  544. // i = String::npos;
  545. //}
  546. //// copy any remaining characters
  547. //outSource.append(inSource.substr(startMarker));
  548. return outSource;
  549. }
  550. //-----------------------------------------------------------------------
  551. const String& CgProgram::getLanguage(void) const
  552. {
  553. static const String language = "cg";
  554. return language;
  555. }
  556. /************************************************************************/
  557. /* SERIALIZATION */
  558. /************************************************************************/
  559. RTTITypeBase* CgProgram::getRTTIStatic()
  560. {
  561. return CgProgramRTTI::instance();
  562. }
  563. RTTITypeBase* CgProgram::getRTTI() const
  564. {
  565. return CgProgram::getRTTIStatic();
  566. }
  567. }