Skip to content

Commit c7c97ad

Browse files
author
Tim Foley
authored
Basic IR support for static const globals (shader-slang#404)
* Basic IR support for `static const` globals Our strategy for lowering global *variables* can fall back to putting their initialization into a function, but that isn't really appropriate for global constants (it also isn't appropriate for arrays, but we'll need to deal with that seaprately). This change adds a distinct case for global constants (rather than treating them as variables), and forces the emission logic to always emit them as a single expression. Doing this makes assumptions about how the IR for these constants gets emitted (and what optimziations might do to it). In order to make things work, I had to switch the handling of initializer-list expressions to not be lowered via temporaries and mutation (since that isn't a good fit for reverting to a single expression). I've added a single test case to ensure that this works in the simplest scenario. My next priority will be to see if this unblocks my work in Falcor. * Fixup: bug fixes
1 parent 112caca commit c7c97ad

11 files changed

+415
-114
lines changed

source/slang/bytecode.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,15 @@ BytecodeGenerationPtr<BCSymbol> generateBytecodeSymbolForInst(
918918
break;
919919

920920
case kIROp_global_var:
921+
case kIROp_global_constant:
921922
{
922923
auto bcVar = allocate<BCSymbol>(context);
923924

924925
bcVar->op = inst->op;
925926
bcVar->typeID = getTypeID(context, inst->type);
926927

928+
// TODO: actually need to intialize with body instructions
929+
927930
return bcVar;
928931
}
929932
break;

0 commit comments

Comments
 (0)