Fix nonsemantic debuginfo line attribution for cooperative matrix
* Generate debuginfo for coopmat types, treating them as an opaque composite. Restore the debug source location after calling convertGlslangToSpvType, fixes the line info in this unit test * Add a cooperative matrix test case, based on the shader from https://github.com/jeffbolznv/vk_cooperative_matrix_perf/blob/master/shaders/shmem.comp
This commit is contained in:
parent
46ef757e04
commit
ca04c2a16a
9 changed files with 797 additions and 18 deletions
|
|
@ -2858,9 +2858,16 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
|||
// SPIR-V, for an out parameter
|
||||
std::vector<spv::Id> temporaryLvalues; // temporaries to pass, as proxies for complexLValues
|
||||
|
||||
auto resultType = [&invertedType, &node, this](){ return invertedType != spv::NoType ?
|
||||
invertedType :
|
||||
convertGlslangToSpvType(node->getType()); };
|
||||
auto resultType = [&invertedType, &node, this](){
|
||||
if (invertedType != spv::NoType) {
|
||||
return invertedType;
|
||||
} else {
|
||||
auto ret = convertGlslangToSpvType(node->getType());
|
||||
// convertGlslangToSpvType may clobber the debug location, reset it
|
||||
builder.setDebugSourceLocation(node->getLoc().line, node->getLoc().getFilename());
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
// try texturing
|
||||
result = createImageTextureFunctionCall(node);
|
||||
|
|
|
|||
|
|
@ -439,6 +439,43 @@ Id Builder::makeCooperativeMatrixTypeKHR(Id component, Id scope, Id rows, Id col
|
|||
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
|
||||
module.mapInstruction(type);
|
||||
|
||||
if (emitNonSemanticShaderDebugInfo)
|
||||
{
|
||||
// Find a name for one of the parameters. It can either come from debuginfo for another
|
||||
// type, or an OpName from a constant.
|
||||
auto const findName = [&](Id id) {
|
||||
Id id2 = debugId[id];
|
||||
for (auto &t : groupedDebugTypes[NonSemanticShaderDebugInfo100DebugTypeBasic]) {
|
||||
if (t->getResultId() == id2) {
|
||||
for (auto &s : strings) {
|
||||
if (s->getResultId() == t->getIdOperand(2)) {
|
||||
return s->getNameString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto &t : names) {
|
||||
if (t->getIdOperand(0) == id) {
|
||||
return t->getNameString();
|
||||
}
|
||||
}
|
||||
return "unknown";
|
||||
};
|
||||
std::string debugName = "coopmat<";
|
||||
debugName += std::string(findName(component)) + ", ";
|
||||
if (isConstantScalar(scope)) {
|
||||
debugName += std::string("gl_Scope") + std::string(spv::ScopeToString((spv::Scope)getConstantScalar(scope))) + ", ";
|
||||
} else {
|
||||
debugName += std::string(findName(scope)) + ", ";
|
||||
}
|
||||
debugName += std::string(findName(rows)) + ", ";
|
||||
debugName += std::string(findName(cols)) + ">";
|
||||
// There's no nonsemantic debug info instruction for cooperative matrix types,
|
||||
// use opaque composite instead.
|
||||
auto const debugResultId = makeCompositeDebugType({}, debugName.c_str(), NonSemanticShaderDebugInfo100Structure, true);
|
||||
debugId[type->getResultId()] = debugResultId;
|
||||
}
|
||||
|
||||
return type->getResultId();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#define SpvBuilder_H
|
||||
|
||||
#include "Logger.h"
|
||||
#define SPV_ENABLE_UTILITY_CODE
|
||||
#include "spirv.hpp"
|
||||
#include "spvIR.h"
|
||||
namespace spv {
|
||||
|
|
|
|||
|
|
@ -2772,6 +2772,20 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) {
|
|||
case OpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break;
|
||||
}
|
||||
}
|
||||
|
||||
inline const char* ScopeToString(Scope value) {
|
||||
switch (value) {
|
||||
case ScopeCrossDevice: return "CrossDevice";
|
||||
case ScopeDevice: return "Device";
|
||||
case ScopeWorkgroup: return "Workgroup";
|
||||
case ScopeSubgroup: return "Subgroup";
|
||||
case ScopeInvocation: return "Invocation";
|
||||
case ScopeQueueFamily: return "QueueFamily";
|
||||
case ScopeShaderCallKHR: return "ShaderCallKHR";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SPV_ENABLE_UTILITY_CODE */
|
||||
|
||||
// Overload bitwise operators for mask bit combining
|
||||
|
|
|
|||
|
|
@ -189,6 +189,15 @@ public:
|
|||
out.push_back(operands[op]);
|
||||
}
|
||||
|
||||
const char *getNameString() const {
|
||||
if (opCode == OpString) {
|
||||
return (const char *)&operands[0];
|
||||
} else {
|
||||
assert(opCode == OpName);
|
||||
return (const char *)&operands[1];
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
Instruction(const Instruction&);
|
||||
Id resultId;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue