CmCgProgram.cpp 20 KB

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