diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-07-14 16:31:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-14 16:31:12 -0400 |
| commit | 2de296ca00c0e77526ae1a83b4fb3df30419f70b (patch) | |
| tree | 1aeac2f3d07890532ac0d359ca6bf2d1d010dbd8 /source/slang/slang.cpp | |
| parent | 68f80f0793cff96b1fc784059a76605888593cd8 (diff) | |
Allow setting of HLSLToVulkan options without having a target specified on the command line options. (#2989)
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 28227b39b..d8174190b 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -2911,7 +2911,7 @@ UInt Linkage::addTarget( Index result = targets.getCount(); targets.add(targetReq); - return (int) result; + return UInt(result); } void Linkage::loadParsedModule( @@ -4679,19 +4679,36 @@ void EndToEndCompileRequest::setCommandLineCompilerMode() m_isCommandLineCompile = true; } +void EndToEndCompileRequest::_completeTargetRequest(UInt targetIndex) +{ + auto linkage = getLinkage(); + + TargetRequest* targetRequest = linkage->targets[Index(targetIndex)]; + + // If we have vulkan layout options, and the target is khronos add the options + if (m_hlslToVulkanLayoutOptions && isKhronosTarget(targetRequest)) + { + targetRequest->setHLSLToVulkanLayoutOptions(m_hlslToVulkanLayoutOptions); + } + + // Set the current line directive + targetRequest->setLineDirectiveMode(m_lineDirectiveMode); +} + void EndToEndCompileRequest::setCodeGenTarget(SlangCompileTarget target) { auto linkage = getLinkage(); linkage->targets.clear(); - linkage->addTarget(CodeGenTarget(target)); - linkage->targets[0]->setLineDirectiveMode(m_lineDirectiveMode); + const auto targetIndex = linkage->addTarget(CodeGenTarget(target)); + SLANG_ASSERT(targetIndex == 0); + _completeTargetRequest(0); } int EndToEndCompileRequest::addCodeGenTarget(SlangCompileTarget target) { - int targetIndex = (int)getLinkage()->addTarget(CodeGenTarget(target)); - getLinkage()->targets[targetIndex]->setLineDirectiveMode(m_lineDirectiveMode); - return targetIndex; + const auto targetIndex = getLinkage()->addTarget(CodeGenTarget(target)); + _completeTargetRequest(targetIndex); + return int(targetIndex); } void EndToEndCompileRequest::setTargetProfile(int targetIndex, SlangProfileID profile) |
