From aa03cea0da38b2950e6f8694dc8b1405352eda66 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 5 May 2022 12:30:10 -0400 Subject: Output SPIR-V lifetimes (#2221) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP tracking liveness. * Skeleton around adding liveness instructions. * Calling into liveness tracking logic. Adds live start to var insts. * Liveness macros have initial output. * Looking at different initialization scenarios. * Some discussion around liveness. * WIP for working out liveness end. * WIP Updated liveness using use lists. * Is now adding liveness information * Some small fixes. * WIP around liveness. * Seems to output liveness correctly for current scenario. * Tidy up liveness code. * Update comment arounds liveness to current status. * Small fixes to liveness test. * Add support for call in liveness analysis. * Improve liveness example with array access. * Small updates to comments. * Disable liveness test because inconsistencies with output on CI system. * First pass support for GLSL SPIR-V liveness support. * Add the SPIRVOpDecoration. * Fix signature for OpLivenessStop. * Simplified by having a Kind type. * Fix some issues brought up in PR. * Rename liveness instructions. * Merge with var-lifetime. Small improvements. * Improvements to the documentation/naming in GLSL liveness pass. Add comment around possible improvements to the liveness pass. --- source/slang/slang-emit-glsl.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source/slang/slang-emit-glsl.cpp') diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index 3b39c1cb1..5b2ae6d19 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -1831,6 +1831,40 @@ void GLSLSourceEmitter::emitVectorTypeNameImpl(IRType* elementType, IRIntegerVal } } +void GLSLSourceEmitter::emitTypeImpl(IRType* type, const StringSliceLoc* nameAndLoc) +{ + if (auto refType = as(type)) + { + m_writer->emit("spirv_by_reference "); + type = refType->getValueType(); + } + return Super::emitTypeImpl(type, nameAndLoc); +} + +void GLSLSourceEmitter::emitParamTypeImpl(IRType* type, String const& name) +{ + if (auto refType = as(type)) + { + // + m_writer->emit("spirv_by_reference "); + type = refType->getValueType(); + } + Super::emitParamTypeImpl(type, name); +} + +void GLSLSourceEmitter::emitFuncDecorationImpl(IRDecoration* decoration) +{ + if (decoration->getOp() == kIROp_SPIRVOpDecoration) + { + m_writer->emit("spirv_instruction(id = "); + emitSimpleValue(decoration->getOperand(0)); + m_writer->emit(")\n"); + } + else + { + Super::emitFuncDecorationImpl(decoration); + } +} void GLSLSourceEmitter::emitSimpleTypeImpl(IRType* type) { -- cgit v1.2.3