summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2025-01-08 00:25:32 -0600
committerGitHub <noreply@github.com>2025-01-07 22:25:32 -0800
commit1a56f58fdd0c704e6dc0fad0f0ec33a25a35e60b (patch)
treea44cdcd19379df09bdd4a8e585652e718f402ac6 /source
parent7e278c3ad6eaedbce1d6b6babecbe32f1764b269 (diff)
Check whether array element is fully specialized (#6000)
* Check whether array element is fully specialized close #5776 When we start specialize a "specialize" IR, we should make sure all the elements are fully specialized, but we miss checking the elements of an array. This change will check the it. * add test * add all wrapper types into the check * add utility function to check if the type is wrapper type --------- Co-authored-by: zhangkai <zhangkai@zhangkais-MacBook-Pro.local> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-specialize.cpp6
-rw-r--r--source/slang/slang-ir-util.cpp25
-rw-r--r--source/slang/slang-ir-util.h2
3 files changed, 33 insertions, 0 deletions
diff --git a/source/slang/slang-ir-specialize.cpp b/source/slang/slang-ir-specialize.cpp
index 2757538a6..50dfa2c6a 100644
--- a/source/slang/slang-ir-specialize.cpp
+++ b/source/slang/slang-ir-specialize.cpp
@@ -125,6 +125,12 @@ struct SpecializationContext
}
}
+ if (isWrapperType(inst))
+ {
+ // For all the wrapper type, we need to make sure the operands are fully specialized.
+ return areAllOperandsFullySpecialized(inst);
+ }
+
// The default case is that a global value is always specialized.
if (inst->getParent() == module->getModuleInst())
{
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index 7788a50d5..c753600a7 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -277,6 +277,31 @@ bool isSimpleHLSLDataType(IRInst* inst)
return true;
}
+bool isWrapperType(IRInst* inst)
+{
+ switch (inst->getOp())
+ {
+ case kIROp_ArrayType:
+ case kIROp_TextureType:
+ case kIROp_VectorType:
+ case kIROp_MatrixType:
+ case kIROp_PtrType:
+ case kIROp_RefType:
+ case kIROp_ConstRefType:
+ case kIROp_HLSLStructuredBufferType:
+ case kIROp_HLSLRWStructuredBufferType:
+ case kIROp_HLSLRasterizerOrderedStructuredBufferType:
+ case kIROp_HLSLAppendStructuredBufferType:
+ case kIROp_HLSLConsumeStructuredBufferType:
+ case kIROp_TupleType:
+ case kIROp_OptionalType:
+ case kIROp_TypePack:
+ return true;
+ default:
+ return false;
+ }
+}
+
SourceLoc findFirstUseLoc(IRInst* inst)
{
for (auto use = inst->firstUse; use; use = use->nextUse)
diff --git a/source/slang/slang-ir-util.h b/source/slang/slang-ir-util.h
index 9a712ba96..e23aeb618 100644
--- a/source/slang/slang-ir-util.h
+++ b/source/slang/slang-ir-util.h
@@ -104,6 +104,8 @@ bool isSimpleDataType(IRType* type);
bool isSimpleHLSLDataType(IRInst* inst);
+bool isWrapperType(IRInst* inst);
+
SourceLoc findFirstUseLoc(IRInst* inst);
inline bool isChildInstOf(IRInst* inst, IRInst* parent)