diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-04-26 15:46:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-26 15:46:24 -0400 |
| commit | e1940e53c0f76e91a2616693b261beb9190015be (patch) | |
| tree | 2ef14f1e81eb1cf0b003cf93102afdbd542f4750 /source | |
| parent | a1739e87b5fb90b0a39c583f8d2468f851869c9f (diff) | |
For C-like targets, emit resource declarations before other globals (#2843)
* For C-like targets, emit resource declarations before other globals
* Remove unused tests
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index c122c13f2..34467d25d 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -3771,6 +3771,18 @@ void CLikeSourceEmitter::computeEmitActions(IRModule* module, List<EmitAction>& for(auto inst : module->getGlobalInsts()) { + // Emit all resource-typed objects first. This is to avoid an odd scenario in HLSL + // where not using a resource type in a resource definition before the same type + // is used for a function parameter causes HLSL to complain about an 'incomplete type' + // + if ( isResourceType(inst->getDataType()) ) + { + ensureGlobalInst(&ctx, inst, EmitAction::Level::Definition); + } + } + + for(auto inst : module->getGlobalInsts()) + { if( as<IRType>(inst) ) { // Don't emit a type unless it is actually used or is marked public. @@ -3778,6 +3790,10 @@ void CLikeSourceEmitter::computeEmitActions(IRModule* module, List<EmitAction>& continue; } + // Skip resource types in this pass. + if ( isResourceType(inst->getDataType()) ) + continue; + ensureGlobalInst(&ctx, inst, EmitAction::Level::Definition); } } |
