| 511 | }; |
| 512 | |
| 513 | void PTShaderLibrary::initialize() |
| 514 | { |
| 515 | |
| 516 | // Create a static block from the precomplied main entry point DXIL. |
| 517 | _pDefaultShaderDXIL.Attach(new StaticBlob(g_sMainEntryPointsDXIL.data(), |
| 518 | g_sMainEntryPointsDXIL.size() * sizeof(g_sMainEntryPointsDXIL[0]))); |
| 519 | |
| 520 | // Create a string for the default shader options (remove the first line which is added by |
| 521 | // minify script) |
| 522 | _defaultOptions = CommonShaders::g_sOptions; |
| 523 | _defaultOptions.erase(0, _defaultOptions.find("\n") + 1); |
| 524 | |
| 525 | // Always use runtime compiled evaluateMaterialForShader. |
| 526 | // TODO: Use pre-compiled default version when only default shader is used in scene. |
| 527 | _options.set("RUNTIME_COMPILE_EVALUATE_MATERIAL_FUNCTION", 1); |
| 528 | |
| 529 | _optionsSource = _options.toHLSL(); |
| 530 | |
| 531 | // Create an emptry array of Slang transpilers. |
| 532 | _transpilerArray = {}; |
| 533 | |
| 534 | // Clear the source and built ins vector. Not strictly needed, but this function could be called |
| 535 | // repeatedly in the future. |
| 536 | _compiledShaders.clear(); |
| 537 | _builtInMaterialNames = {}; |
| 538 | |
| 539 | // Create source code for the default shader, containg the main entry points used for all |
| 540 | // shaders.. |
| 541 | MaterialShaderSource defaultMaterialSource("Default", CommonShaders::g_sMainEntryPoints); |
| 542 | |
| 543 | // Add the shared entry points to the default shader's definitions source. |
| 544 | |
| 545 | // Create the material definition for default shader. |
| 546 | _builtInMaterialDefinitions[defaultMaterialSource.uniqueId] = |
| 547 | make_shared<MaterialDefinition>(defaultMaterialSource, |
| 548 | MaterialBase::StandardSurfaceDefaults, MaterialBase::updateBuiltInMaterial, false); |
| 549 | |
| 550 | // Create shader from the definition. |
| 551 | MaterialShaderDefinition shaderDef; |
| 552 | _builtInMaterialDefinitions[defaultMaterialSource.uniqueId]->getShaderDefinition(shaderDef); |
| 553 | MaterialShaderPtr pDefaultShader = _shaderLibrary.acquire(shaderDef); |
| 554 | |
| 555 | // Ensure the instance hit entry point is compiled for default shader. |
| 556 | pDefaultShader->incrementRefCount(EntryPointTypes::kInitializeMaterialExport); |
| 557 | |
| 558 | // Add default shader to the built-in array. |
| 559 | _builtInMaterialNames.push_back(defaultMaterialSource.uniqueId); |
| 560 | _builtInShaders[defaultMaterialSource.uniqueId] = |
| 561 | pDefaultShader; // Stores strong reference to the built-in's shader. |
| 562 | } |
| 563 | |
| 564 | bool PTShaderLibrary::setOption(const string& name, int value) |
| 565 | { |
nothing calls this directly
no test coverage detected