summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2025-08-26 10:48:49 -0700
committerGitHub <noreply@github.com>2025-08-26 17:48:49 +0000
commitb36659eca38be716bee43c01c6584bda5f91166a (patch)
treea7e309179242dd9976b50f6ca6d198eb687f138f /source/slang
parent70d70c1d315a91ed414892fb70974026082bcc99 (diff)
Fix `shouldEmitSPIRVDirectly` (#8019)
Fixes: #8018 Changes: * Do not emit true for `shouldEmitSPIRVDirectly` with a GLSL target
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-ir-lower-buffer-element-type.cpp5
-rw-r--r--source/slang/slang-ir-util.h6
-rw-r--r--source/slang/slang-target-program.h2
-rw-r--r--source/slang/slang-target.h3
-rw-r--r--source/slang/slang-type-layout.cpp5
5 files changed, 13 insertions, 8 deletions
diff --git a/source/slang/slang-ir-lower-buffer-element-type.cpp b/source/slang/slang-ir-lower-buffer-element-type.cpp
index 2f40c6cf9..056ee6244 100644
--- a/source/slang/slang-ir-lower-buffer-element-type.cpp
+++ b/source/slang/slang-ir-lower-buffer-element-type.cpp
@@ -666,7 +666,10 @@ struct LoweredElementTypeContext
// For spirv backend, we always want to lower all array types, even if the element type
// comes out the same. This is because different layout rules may have different array
// stride requirements.
- if (!target->shouldEmitSPIRVDirectly())
+ //
+ // Additionally, `buffer` blocks do not work correctly unless lowered when targeting
+ // GLSL.
+ if (!isKhronosTarget(target->getTargetReq()))
{
// For non-spirv target, we skip lowering this type if all field types are
// unchanged.
diff --git a/source/slang/slang-ir-util.h b/source/slang/slang-ir-util.h
index 77c464b1f..b7aafea56 100644
--- a/source/slang/slang-ir-util.h
+++ b/source/slang/slang-ir-util.h
@@ -373,12 +373,6 @@ void verifyComputeDerivativeGroupModifiers(
bool linearAttr,
IRNumThreadsDecoration* numThreadsDecor);
-
-inline bool isSPIRV(CodeGenTarget codeGenTarget)
-{
- return codeGenTarget == CodeGenTarget::SPIRV || codeGenTarget == CodeGenTarget::SPIRVAssembly;
-}
-
int getIRVectorElementSize(IRType* type);
IRType* getIRVectorBaseType(IRType* type);
diff --git a/source/slang/slang-target-program.h b/source/slang/slang-target-program.h
index 57a9c46fb..44fc36604 100644
--- a/source/slang/slang-target-program.h
+++ b/source/slang/slang-target-program.h
@@ -108,7 +108,7 @@ public:
bool shouldEmitSPIRVDirectly()
{
- return isKhronosTarget(m_targetReq) && getOptionSet().shouldEmitSPIRVDirectly();
+ return isSPIRV(m_targetReq->getTarget()) && getOptionSet().shouldEmitSPIRVDirectly();
}
private:
diff --git a/source/slang/slang-target.h b/source/slang/slang-target.h
index 6ac52657f..8fa1f83f6 100644
--- a/source/slang/slang-target.h
+++ b/source/slang/slang-target.h
@@ -70,6 +70,9 @@ bool isMetalTarget(TargetRequest* targetReq);
bool isKhronosTarget(TargetRequest* targetReq);
bool isKhronosTarget(CodeGenTarget target);
+/// Are we generating code where SPIRV is the target?
+bool isSPIRV(CodeGenTarget codeGenTarget);
+
/// Are we generating code for a CUDA API (CUDA / OptiX)?
bool isCUDATarget(TargetRequest* targetReq);
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 3e2560755..efd41bd86 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -2669,6 +2669,11 @@ bool isKhronosTarget(TargetRequest* targetReq)
return isKhronosTarget(targetReq->getTarget());
}
+bool isSPIRV(CodeGenTarget codeGenTarget)
+{
+ return codeGenTarget == CodeGenTarget::SPIRV || codeGenTarget == CodeGenTarget::SPIRVAssembly;
+}
+
bool isCPUTarget(TargetRequest* targetReq)
{
return ArtifactDescUtil::isCpuLikeTarget(