#include "slang-ir-legalize-mesh-outputs.h" #include "slang-ir-clone.h" #include "slang-ir-insts.h" #include "slang-ir.h" namespace Slang { void legalizeMeshOutputTypes(IRModule* module) { IRBuilder builder(module); for (auto inst : module->getGlobalInsts()) { if (auto meshOutput = as(inst)) { auto elemType = meshOutput->getElementType(); auto maxCount = meshOutput->getMaxElementCount(); auto arrayType = builder.getArrayType(elemType, maxCount); IROp decorationOp = as(meshOutput) ? kIROp_VerticesDecoration : as(meshOutput) ? kIROp_IndicesDecoration : as(meshOutput) ? kIROp_PrimitivesDecoration : (SLANG_UNREACHABLE("Missing case for IRMeshOutputType"), IROp(0)); // Ensure that all params are marked up as vertices/indices/primitives traverseUsers( meshOutput, [&](IRParam* i) { builder.addMeshOutputDecoration(decorationOp, i, maxCount); }); meshOutput->replaceUsesWith(arrayType); } } } } // namespace Slang