summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-05-06 00:27:00 +0000
committerGitHub <noreply@github.com>2025-05-05 17:27:00 -0700
commit6907ea5c8f83712f40fbc7713de4f4bb656c6c35 (patch)
treeda8b9ce1154eeb96f5155095b6e78154e34c6872 /source
parent50d9781b7387b0f7f56d19c72afcf390cca72b72 (diff)
Add a new capability hlsl_2018 that avoid using select/and/or (#7003)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-capabilities.capdef5
-rw-r--r--source/slang/slang-emit-hlsl.cpp6
2 files changed, 11 insertions, 0 deletions
diff --git a/source/slang/slang-capabilities.capdef b/source/slang/slang-capabilities.capdef
index 8f6aa254c..b50519a72 100644
--- a/source/slang/slang-capabilities.capdef
+++ b/source/slang/slang-capabilities.capdef
@@ -219,6 +219,11 @@ def _sm_6_9 : _sm_6_8;
/// [Version]
def hlsl_nvapi : hlsl;
+
+/// Represet HLSL compatibility support.
+/// [Version]
+def hlsl_2018 : _sm_5_1;
+
/// Represents capabilities required for DXIL Library compilation.
/// [Version]
alias dxil_lib = _sm_6_3;
diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp
index 2d963866d..3813cf9cb 100644
--- a/source/slang/slang-emit-hlsl.cpp
+++ b/source/slang/slang-emit-hlsl.cpp
@@ -826,6 +826,9 @@ bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
auto targetProfile = getTargetProgram()->getOptionSet().getProfile();
if (targetProfile.getVersion() < ProfileVersion::DX_6_0)
return false;
+ auto targetCaps = getTargetReq()->getTargetCaps();
+ if (targetCaps.implies(CapabilityAtom::hlsl_2018))
+ return false;
if (as<IRBasicType>(inst->getDataType()))
return false;
@@ -851,6 +854,9 @@ bool HLSLSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOu
auto targetProfile = getTargetProgram()->getOptionSet().getProfile();
if (targetProfile.getVersion() < ProfileVersion::DX_6_0)
return false;
+ auto targetCaps = getTargetReq()->getTargetCaps();
+ if (targetCaps.implies(CapabilityAtom::hlsl_2018))
+ return false;
if (as<IRBasicType>(inst->getDataType()))
return false;