summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-lower-generic-type.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-09-02 12:21:28 -0700
committerGitHub <noreply@github.com>2020-09-02 12:21:28 -0700
commita2a7c4d988b2b7126130d9dcbe4ec94e1ce8424b (patch)
tree5e9559abd79b9e2f7d4f22f65a77daaaae3eed16 /source/slang/slang-ir-lower-generic-type.cpp
parent7f567df6937b33c653c424af3abb20d32eb80561 (diff)
Allow unspecialized existential shader parameters (dynamic dispatch). (#1529)
* Allow unspecialized existential shader parameters (dynamic dispatch). * Fixes. * Fixes * disable cuda test
Diffstat (limited to 'source/slang/slang-ir-lower-generic-type.cpp')
-rw-r--r--source/slang/slang-ir-lower-generic-type.cpp30
1 files changed, 27 insertions, 3 deletions
diff --git a/source/slang/slang-ir-lower-generic-type.cpp b/source/slang/slang-ir-lower-generic-type.cpp
index 0b0973274..caf0f82bf 100644
--- a/source/slang/slang-ir-lower-generic-type.cpp
+++ b/source/slang/slang-ir-lower-generic-type.cpp
@@ -10,13 +10,22 @@ namespace Slang
{
// This is a subpass of generics lowering IR transformation.
// This pass lowers all generic/polymorphic types into IRAnyValueType.
- struct GenericVarLoweringContext
+ struct GenericTypeLoweringContext
{
SharedGenericsLoweringContext* sharedContext;
void processInst(IRInst* inst)
{
- // If inst is a type itself, keep its type.
+ // Ensure public struct types has RTTI object defined.
+ if (as<IRStructType>(inst))
+ {
+ if (inst->findDecoration<IRPublicDecoration>())
+ {
+ sharedContext->maybeEmitRTTIObject(inst);
+ }
+ }
+
+ // Don't modify type insts themselves.
if (as<IRType>(inst))
return;
@@ -28,6 +37,21 @@ namespace Slang
auto newType = sharedContext->lowerType(builder, inst->getFullType());
if (newType != inst->getFullType())
inst->setFullType((IRType*)newType);
+
+ switch (inst->op)
+ {
+ default:
+ break;
+ case kIROp_StructField:
+ {
+ // Translate the struct field type.
+ auto structField = static_cast<IRStructField*>(inst);
+ auto loweredFieldType =
+ sharedContext->lowerType(builder, structField->getFieldType());
+ structField->setOperand(1, loweredFieldType);
+ }
+ break;
+ }
}
void processModule()
@@ -62,7 +86,7 @@ namespace Slang
void lowerGenericType(SharedGenericsLoweringContext* sharedContext)
{
- GenericVarLoweringContext context;
+ GenericTypeLoweringContext context;
context.sharedContext = sharedContext;
context.processModule();
}