From 8f962894fd38edb47d782d303ac9ff87b3a3bb6a Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 4 Sep 2020 10:18:44 -0700 Subject: Allow mixing unspecialized and specialized existential parameters. (#1533) * Allow mixing unspecialized and specialized existential parameters. * Fixes. --- source/slang/slang-lower-to-ir.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index ee5338236..424358d3c 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1420,10 +1420,14 @@ struct ValLoweringVisitor : ValVisitorcreateWitnessTableEntry(irWitnessTable, irReqKey, irSatisfyingVal); } - return LoweredValInfo::simple(irWitnessTable); } + LoweredValInfo visitDynamicSubtypeWitness(DynamicSubtypeWitness * /*val*/) + { + return LoweredValInfo::simple(nullptr); + } + LoweredValInfo visitThisTypeSubtypeWitness(ThisTypeSubtypeWitness* val) { SLANG_UNUSED(val); @@ -7859,6 +7863,8 @@ struct SpecializedComponentTypeIRGenContext : ComponentTypeVisitor IRInst* irParam = getSimpleVal(context, ensureDecl(context, shaderParam.paramDeclRef)); List irSlotArgs; + // Tracks if there are any type args that is not an IRDynamicType. + bool hasConcreteTypeArg = false; for( Index jj = 0; jj < specializationArgCount; ++jj ) { auto& specializationArg = specializationInfo->existentialArgs[existentialArgOffset++]; @@ -7866,14 +7872,21 @@ struct SpecializedComponentTypeIRGenContext : ComponentTypeVisitor auto irType = lowerSimpleVal(context, specializationArg.val); auto irWitness = lowerSimpleVal(context, specializationArg.witness); + if (irType->op != kIROp_DynamicType) + hasConcreteTypeArg = true; + irSlotArgs.add(irType); irSlotArgs.add(irWitness); } - - builder->addBindExistentialSlotsDecoration( - irParam, - irSlotArgs.getCount(), - irSlotArgs.getBuffer()); + // Only insert a `BindExistentialSlots` decoration when there are at least + // one non-dynamic type argument. + if (hasConcreteTypeArg) + { + builder->addBindExistentialSlotsDecoration( + irParam, + irSlotArgs.getCount(), + irSlotArgs.getBuffer()); + } } } } -- cgit v1.2.3