summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-c-like.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
-rw-r--r--source/slang/slang-emit-c-like.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 7840dc450..a31c16505 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -1344,6 +1344,30 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
}
}
+ // If this is a call to a ResourceType's member function, don't fold for readability.
+ if (auto call = as<IRCall>(inst))
+ {
+ auto callee = getResolvedInstForDecorations(call->getCallee());
+ if (callee->findDecoration<IRTargetIntrinsicDecoration>())
+ {
+ auto funcType = as<IRFuncType>(callee->getDataType());
+ if (funcType)
+ {
+ if (funcType->getParamCount() > 0)
+ {
+ auto firstParamType = funcType->getParamType(0);
+ if (as<IRResourceTypeBase>(firstParamType))
+ return false;
+ if (as<IRHLSLStructuredBufferTypeBase>(firstParamType))
+ return false;
+ if (as<IRUntypedBufferResourceType>(firstParamType))
+ return false;
+ if (as<IRSamplerStateTypeBase>(firstParamType))
+ return false;
+ }
+ }
+ }
+ }
// We'd like to figure out if it is safe to fold our instruction into `user`
// First, let's make sure they are in the same block/parent: