MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / setupFunctionDebugInfo

Method setupFunctionDebugInfo

SPIRV/SpvBuilder.cpp:2736–2785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2734}
2735
2736void Builder::setupFunctionDebugInfo(Function* function, const char* name, const std::vector<Id>& paramTypes,
2737 const std::vector<char const*>& paramNames)
2738{
2739
2740 if (!emitNonSemanticShaderDebugInfo)
2741 return;
2742
2743 Id nameId = getStringId(unmangleFunctionName(name));
2744 Id funcTypeId = function->getFuncTypeId();
2745 assert(getDebugType(funcTypeId) != NoType);
2746 Id funcId = function->getId();
2747
2748 assert(funcId != 0);
2749
2750 // Make the debug function instruction
2751 Id debugFuncId = makeDebugFunction(function, nameId, funcTypeId);
2752 debugFuncIdLookup[funcId] = debugFuncId;
2753 currentDebugScopeId.push(debugFuncId);
2754
2755 // DebugScope and DebugLine for parameter DebugDeclares
2756 assert(paramTypes.size() == paramNames.size());
2757 if ((int)paramTypes.size() > 0) {
2758 Id firstParamId = function->getParamId(0);
2759
2760 for (size_t p = 0; p < paramTypes.size(); ++p) {
2761 bool passByRef = false;
2762 Id paramTypeId = paramTypes[p];
2763
2764 // For pointer-typed parameters, they are actually passed by reference and we need unwrap the pointer to get the actual parameter type.
2765 if (isPointerType(paramTypeId) || isArrayType(paramTypeId)) {
2766 passByRef = true;
2767 paramTypeId = getContainedTypeId(paramTypeId);
2768 }
2769
2770 auto const& paramName = paramNames[p];
2771 auto const debugLocalVariableId = createDebugLocalVariable(getDebugType(paramTypeId), paramName, p + 1);
2772 auto const paramId = static_cast<Id>(firstParamId + p);
2773
2774 if (passByRef) {
2775 makeDebugDeclare(debugLocalVariableId, paramId);
2776 } else {
2777 makeDebugValue(debugLocalVariableId, paramId);
2778 }
2779 }
2780 }
2781
2782 // Clear debug scope stack
2783 if (emitNonSemanticShaderDebugInfo)
2784 currentDebugScopeId.pop();
2785}
2786
2787Id Builder::makeDebugFunction([[maybe_unused]] Function* function, Id nameId, Id funcTypeId)
2788{

Callers 1

makeFunctionsMethod · 0.80

Calls 6

getFuncTypeIdMethod · 0.80
getParamIdMethod · 0.80
getIdMethod · 0.45
pushMethod · 0.45
sizeMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected