summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-specialize-resources.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/source/slang/slang-ir-specialize-resources.cpp b/source/slang/slang-ir-specialize-resources.cpp
index f72ca6b38..60439abeb 100644
--- a/source/slang/slang-ir-specialize-resources.cpp
+++ b/source/slang/slang-ir-specialize-resources.cpp
@@ -171,6 +171,27 @@ struct ResourceParameterSpecializationContext
return anySpecializableParam;
}
+ // Returns true if `type` is an `IRStructType` with array-typed fields.
+ bool isStructTypeWithArray(IRType* type)
+ {
+ if (auto structType = as<IRStructType>(type))
+ {
+ for (auto field : structType->getFields())
+ {
+ if (auto arrayType = as<IRArrayType>(field->getFieldType()))
+ {
+ return true;
+ }
+ if (auto subStructType = as<IRStructType>(field->getFieldType()))
+ {
+ if (isStructTypeWithArray(subStructType))
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
// Of course, now we need to back-fill the predicates that
// the above function used to evaluate prameters and arguments.
@@ -209,6 +230,8 @@ struct ResourceParameterSpecializationContext
return true;
if(as<IRByteAddressBufferTypeBase>(type))
return true;
+ if (isStructTypeWithArray(type))
+ return true;
}
// For now, we will not treat any other parameters as
@@ -257,7 +280,7 @@ struct ResourceParameterSpecializationContext
// of the indexing operation is also
// suitable for specialization.
//
- if( arg->op == kIROp_getElement )
+ if( arg->op == kIROp_getElement || arg->op == kIROp_Load )
{
auto base = arg->getOperand(0);
@@ -565,6 +588,11 @@ struct ResourceParameterSpecializationContext
//
ioInfo.newArgs.add(oldIndex);
}
+ else if (oldArg->op == kIROp_Load)
+ {
+ auto oldBase = oldArg->getOperand(0);
+ getCallInfoForArg(ioInfo, oldBase);
+ }
else
{
// If we fail to match any of the cases above
@@ -718,6 +746,10 @@ struct ResourceParameterSpecializationContext
return newVal;
}
+ else if (oldArg->op == kIROp_Load)
+ {
+ return getSpecializedValueForArg(ioInfo, oldArg->getOperand(0));
+ }
else
{
// If we don't match one of the above cases,