diff options
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 8b0012f1d..66e75a282 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -1666,6 +1666,12 @@ HLSLToVulkanLayoutOptions* TargetRequest::getHLSLToVulkanLayoutOptions() return hlslToVulkanOptions.get(); } +void TargetRequest::setTargetCaps(CapabilitySet capSet) +{ + cookedCapabilities = capSet; + +} + CapabilitySet TargetRequest::getTargetCaps() { if(!cookedCapabilities.isEmpty()) @@ -1691,6 +1697,11 @@ CapabilitySet TargetRequest::getTargetCaps() // are available where can be directly encoded on the declarations. List<CapabilityName> atoms; + + // If the user specified a explicit profile, we should pull + // a corresponding atom representing the target version from the profile. + CapabilitySet profileCaps = CapabilitySet(optionSet.getProfile().getCapabilityName()); + bool isGLSLTarget = false; switch(getTarget()) { @@ -1704,7 +1715,40 @@ CapabilitySet TargetRequest::getTargetCaps() case CodeGenTarget::SPIRVAssembly: if (getOptionSet().shouldEmitSPIRVDirectly()) { - atoms.add(CapabilityName::spirv_1_5); + // Default to SPIRV 1.5 if the user has not specified a target version. + bool hasTargetVersionAtom = false; + if (!profileCaps.isEmpty()) + { + profileCaps.join(CapabilitySet(CapabilityName::spirv_1_0)); + for (auto profileCapAtomSet : profileCaps.getAtomSets()) + { + for (auto atom : profileCapAtomSet) + { + if (isTargetVersionAtom((CapabilityName)atom)) + { + atoms.add((CapabilityName)atom); + hasTargetVersionAtom = true; + } + } + } + } + if (!hasTargetVersionAtom) + { + atoms.add(CapabilityName::spirv_1_5); + } + // If the user specified any SPIR-V extensions in the profile, + // pull them in. + for (auto profileCapAtomSet : profileCaps.getAtomSets()) + { + for (auto atom : profileCapAtomSet) + { + if (isSpirvExtensionAtom((CapabilityName)atom)) + { + atoms.add((CapabilityName)atom); + hasTargetVersionAtom = true; + } + } + } } else { @@ -1752,9 +1796,7 @@ CapabilitySet TargetRequest::getTargetCaps() CapabilitySet targetCap = CapabilitySet(atoms); - CapabilitySet latestSpirvCapSet = CapabilitySet(CapabilityName::spirv_latest); - auto latestSpirvCapSetElements = latestSpirvCapSet.getAtomSets()->getElements<CapabilityAtom>(); - CapabilityName latestSpirvAtom = (CapabilityName)latestSpirvCapSetElements[latestSpirvCapSetElements.getCount()-2]; //-1 gets shader stage + CapabilityName latestSpirvAtom = getLatestSpirvAtom(); for (auto atomVal : optionSet.getArray(CompilerOptionName::Capability)) { |
