2 // Copyright (C) 2014-2015 LunarG, Inc.
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
10 // Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
13 // Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
18 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19 // contributors may be used to endorse or promote products derived
20 // from this software without specific prior written permission.
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 // POSSIBILITY OF SUCH DAMAGE.
36 // Disassembler for SPIR-V.
48 #include "disassemble.h"
53 // Include C-based headers that don't have a namespace
54 #include "GLSL.std.450.h"
55 #include "GLSL.ext.AMD.h"
56 #include "GLSL.ext.NV.h"
57 #include "GLSL.ext.ARM.h"
58 #include "NonSemanticShaderDebugInfo100.h"
59 #include "GLSL.ext.QCOM.h"
62 const char* GlslStd450DebugNames[spv::GLSLstd450Count];
66 static const char* GLSLextAMDGetDebugNames(const char*, unsigned);
67 static const char* GLSLextNVGetDebugNames(const char*, unsigned);
68 static const char* NonSemanticShaderDebugInfo100GetDebugNames(unsigned);
70 static void Kill(std::ostream& out, const char* message)
72 out << std::endl << "Disassembly failed: " << message << std::endl;
76 // used to identify the extended instruction library imported when printing
82 NonSemanticDebugPrintfExtInst,
83 NonSemanticShaderDebugInfo100
86 // Container class for a single instance of a SPIR-V stream, with methods for disassembly.
89 SpirvStream(std::ostream& out, const std::vector<unsigned int>& stream) : out(out), stream(stream), word(0), nextNestedControl(0) { }
90 virtual ~SpirvStream() { }
93 void processInstructions();
96 SpirvStream(const SpirvStream&);
97 SpirvStream& operator=(const SpirvStream&);
98 Op getOpCode(int id) const { return idInstruction[id] ? (Op)(stream[idInstruction[id]] & OpCodeMask) : OpNop; }
102 void formatId(Id id, std::stringstream&);
103 void outputResultId(Id id);
104 void outputTypeId(Id id);
105 void outputId(Id id);
106 void outputMask(OperandClass operandClass, unsigned mask);
107 void disassembleImmediates(int numOperands);
108 void disassembleIds(int numOperands);
109 std::pair<int, std::string> decodeString();
110 int disassembleString();
111 void disassembleInstruction(Id resultId, Id typeId, Op opCode, int numOperands);
114 std::ostream& out; // where to write the disassembly
115 const std::vector<unsigned int>& stream; // the actual word stream
116 int size; // the size of the word stream
117 int word; // the next word of the stream to read
119 // map each <id> to the instruction that created it
121 std::vector<unsigned int> idInstruction; // the word offset into the stream where the instruction for result [id] starts; 0 if not yet seen (forward reference or function parameter)
123 std::vector<std::string> idDescriptor; // the best text string known for explaining the <id>
128 // stack of structured-merge points
129 std::stack<Id> nestedControl;
130 Id nextNestedControl; // need a slight delay for when we are nested
133 void SpirvStream::validate()
135 size = (int)stream.size();
137 Kill(out, "stream is too short");
140 if (stream[word++] != MagicNumber) {
141 out << "Bad magic number";
146 out << "// Module Version " << std::hex << stream[word++] << std::endl;
148 // Generator's magic number
149 out << "// Generated by (magic number): " << std::hex << stream[word++] << std::dec << std::endl;
152 bound = stream[word++];
153 idInstruction.resize(bound);
154 idDescriptor.resize(bound);
155 out << "// Id's are bound by " << bound << std::endl;
158 // Reserved schema, must be 0 for now
159 schema = stream[word++];
161 Kill(out, "bad schema, must be 0");
164 // Loop over all the instructions, in order, processing each.
165 // Boiler plate for each is handled here directly, the rest is dispatched.
166 void SpirvStream::processInstructions()
169 while (word < size) {
170 int instructionStart = word;
172 // Instruction wordCount and opcode
173 unsigned int firstWord = stream[word];
174 unsigned wordCount = firstWord >> WordCountShift;
175 Op opCode = (Op)(firstWord & OpCodeMask);
176 int nextInst = word + wordCount;
179 // Presence of full instruction
181 Kill(out, "stream instruction terminated too early");
183 // Base for computing number of operands; will be updated as more is learned
184 unsigned numOperands = wordCount - 1;
188 if (InstructionDesc[opCode].hasType()) {
189 typeId = stream[word++];
195 if (InstructionDesc[opCode].hasResult()) {
196 resultId = stream[word++];
199 // save instruction for future reference
200 idInstruction[resultId] = instructionStart;
203 outputResultId(resultId);
204 outputTypeId(typeId);
207 // Hand off the Op and all its operands
208 disassembleInstruction(resultId, typeId, opCode, numOperands);
209 if (word != nextInst) {
210 out << " ERROR, incorrect number of operands consumed. At " << word << " instead of " << nextInst << " instruction start was " << instructionStart;
217 void SpirvStream::outputIndent()
219 for (int i = 0; i < (int)nestedControl.size(); ++i)
223 void SpirvStream::formatId(Id id, std::stringstream& idStream)
226 // On instructions with no IDs, this is called with "0", which does not
227 // have to be within ID bounds on null shaders.
229 Kill(out, "Bad <id>");
232 if (idDescriptor[id].size() > 0)
233 idStream << "(" << idDescriptor[id] << ")";
237 void SpirvStream::outputResultId(Id id)
239 const int width = 16;
240 std::stringstream idStream;
241 formatId(id, idStream);
242 out << std::setw(width) << std::right << idStream.str();
248 if (nestedControl.size() && id == nestedControl.top())
252 void SpirvStream::outputTypeId(Id id)
254 const int width = 12;
255 std::stringstream idStream;
256 formatId(id, idStream);
257 out << std::setw(width) << std::right << idStream.str() << " ";
260 void SpirvStream::outputId(Id id)
263 Kill(out, "Bad <id>");
266 if (idDescriptor[id].size() > 0)
267 out << "(" << idDescriptor[id] << ")";
270 void SpirvStream::outputMask(OperandClass operandClass, unsigned mask)
275 for (int m = 0; m < OperandClassParams[operandClass].ceiling; ++m) {
277 out << OperandClassParams[operandClass].getName(m) << " ";
282 void SpirvStream::disassembleImmediates(int numOperands)
284 for (int i = 0; i < numOperands; ++i) {
285 out << stream[word++];
286 if (i < numOperands - 1)
291 void SpirvStream::disassembleIds(int numOperands)
293 for (int i = 0; i < numOperands; ++i) {
294 outputId(stream[word++]);
295 if (i < numOperands - 1)
300 // decode string from words at current position (non-consuming)
301 std::pair<int, std::string> SpirvStream::decodeString()
309 unsigned int content = stream[wordPos];
310 for (int charCount = 0; charCount < 4; ++charCount) {
322 return std::make_pair(wordPos - word, res);
325 // return the number of operands consumed by the string
326 int SpirvStream::disassembleString()
330 std::pair<int, std::string> decoderes = decodeString();
332 out << decoderes.second;
335 word += decoderes.first;
337 return decoderes.first;
340 void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, int numOperands)
342 // Process the opcode
344 out << (OpcodeString(opCode) + 2); // leave out the "Op"
346 if (opCode == OpLoopMerge || opCode == OpSelectionMerge)
347 nextNestedControl = stream[word];
348 else if (opCode == OpBranchConditional || opCode == OpSwitch) {
349 if (nextNestedControl) {
350 nestedControl.push(nextNestedControl);
351 nextNestedControl = 0;
353 } else if (opCode == OpExtInstImport) {
354 idDescriptor[resultId] = decodeString().second;
357 if (resultId != 0 && idDescriptor[resultId].size() == 0) {
360 switch (stream[word]) {
361 case 8: idDescriptor[resultId] = "int8_t"; break;
362 case 16: idDescriptor[resultId] = "int16_t"; break;
363 default: assert(0); // fallthrough
364 case 32: idDescriptor[resultId] = "int"; break;
365 case 64: idDescriptor[resultId] = "int64_t"; break;
369 switch (stream[word]) {
370 case 16: idDescriptor[resultId] = "float16_t"; break;
371 default: assert(0); // fallthrough
372 case 32: idDescriptor[resultId] = "float"; break;
373 case 64: idDescriptor[resultId] = "float64_t"; break;
377 idDescriptor[resultId] = "bool";
380 idDescriptor[resultId] = "struct";
383 idDescriptor[resultId] = "ptr";
386 if (idDescriptor[stream[word]].size() > 0) {
387 idDescriptor[resultId].append(idDescriptor[stream[word]].begin(), idDescriptor[stream[word]].begin() + 1);
388 if (strstr(idDescriptor[stream[word]].c_str(), "8")) {
389 idDescriptor[resultId].append("8");
391 if (strstr(idDescriptor[stream[word]].c_str(), "16")) {
392 idDescriptor[resultId].append("16");
394 if (strstr(idDescriptor[stream[word]].c_str(), "64")) {
395 idDescriptor[resultId].append("64");
398 idDescriptor[resultId].append("vec");
399 switch (stream[word + 1]) {
400 case 2: idDescriptor[resultId].append("2"); break;
401 case 3: idDescriptor[resultId].append("3"); break;
402 case 4: idDescriptor[resultId].append("4"); break;
403 case 8: idDescriptor[resultId].append("8"); break;
404 case 16: idDescriptor[resultId].append("16"); break;
405 case 32: idDescriptor[resultId].append("32"); break;
415 // Process the operands. Note, a new context-dependent set could be
416 // swapped in mid-traversal.
418 // Handle images specially, so can put out helpful strings.
419 if (opCode == OpTypeImage) {
422 out << " " << DimensionString((Dim)stream[word++]);
423 out << (stream[word++] != 0 ? " depth" : "");
424 out << (stream[word++] != 0 ? " array" : "");
425 out << (stream[word++] != 0 ? " multi-sampled" : "");
426 switch (stream[word++]) {
427 case 0: out << " runtime"; break;
428 case 1: out << " sampled"; break;
429 case 2: out << " nonsampled"; break;
431 out << " format:" << ImageFormatString((ImageFormat)stream[word++]);
433 if (numOperands == 8) {
434 out << " " << AccessQualifierString(stream[word++]);
439 // Handle all the parameterized operands
440 for (int op = 0; op < InstructionDesc[opCode].operands.getNum() && numOperands > 0; ++op) {
442 OperandClass operandClass = InstructionDesc[opCode].operands.getClass(op);
443 switch (operandClass) {
446 case OperandMemorySemantics:
449 // Get names for printing "(XXX)" for readability, *after* this id
450 if (opCode == OpName)
451 idDescriptor[stream[word - 1]] = decodeString().second;
453 case OperandVariableIds:
454 disassembleIds(numOperands);
456 case OperandImageOperands:
457 outputMask(OperandImageOperands, stream[word++]);
459 disassembleIds(numOperands);
461 case OperandOptionalLiteral:
462 case OperandVariableLiterals:
463 if ((opCode == OpDecorate && stream[word - 1] == DecorationBuiltIn) ||
464 (opCode == OpMemberDecorate && stream[word - 1] == DecorationBuiltIn)) {
465 out << BuiltInString(stream[word++]);
469 disassembleImmediates(numOperands);
471 case OperandVariableIdLiteral:
472 while (numOperands > 0) {
480 disassembleImmediates(1);
484 case OperandVariableLiteralId:
485 while (numOperands > 0) {
491 disassembleImmediates(1);
497 case OperandLiteralNumber:
498 disassembleImmediates(1);
500 if (opCode == OpExtInst) {
501 ExtInstSet extInstSet = GLSL450Inst;
502 const char* name = idDescriptor[stream[word - 2]].c_str();
503 if (strcmp("OpenCL.std", name) == 0) {
504 extInstSet = OpenCLExtInst;
505 } else if (strcmp("OpenCL.DebugInfo.100", name) == 0) {
506 extInstSet = OpenCLExtInst;
507 } else if (strcmp("NonSemantic.DebugPrintf", name) == 0) {
508 extInstSet = NonSemanticDebugPrintfExtInst;
509 } else if (strcmp("NonSemantic.Shader.DebugInfo.100", name) == 0) {
510 extInstSet = NonSemanticShaderDebugInfo100;
511 } else if (strcmp(spv::E_SPV_AMD_shader_ballot, name) == 0 ||
512 strcmp(spv::E_SPV_AMD_shader_trinary_minmax, name) == 0 ||
513 strcmp(spv::E_SPV_AMD_shader_explicit_vertex_parameter, name) == 0 ||
514 strcmp(spv::E_SPV_AMD_gcn_shader, name) == 0) {
515 extInstSet = GLSLextAMDInst;
516 } else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 ||
517 strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 ||
518 strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 ||
519 strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
520 strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0 ||
521 strcmp(spv::E_SPV_NV_mesh_shader, name) == 0) {
522 extInstSet = GLSLextNVInst;
524 unsigned entrypoint = stream[word - 1];
525 if (extInstSet == GLSL450Inst) {
526 if (entrypoint < GLSLstd450Count) {
527 out << "(" << GlslStd450DebugNames[entrypoint] << ")";
529 } else if (extInstSet == GLSLextAMDInst) {
530 out << "(" << GLSLextAMDGetDebugNames(name, entrypoint) << ")";
532 else if (extInstSet == GLSLextNVInst) {
533 out << "(" << GLSLextNVGetDebugNames(name, entrypoint) << ")";
534 } else if (extInstSet == NonSemanticDebugPrintfExtInst) {
535 out << "(DebugPrintf)";
536 } else if (extInstSet == NonSemanticShaderDebugInfo100) {
537 out << "(" << NonSemanticShaderDebugInfo100GetDebugNames(entrypoint) << ")";
541 case OperandOptionalLiteralString:
542 case OperandLiteralString:
543 numOperands -= disassembleString();
545 case OperandVariableLiteralStrings:
546 while (numOperands > 0)
547 numOperands -= disassembleString();
549 case OperandMemoryAccess:
550 outputMask(OperandMemoryAccess, stream[word++]);
552 // Aligned is the only memory access operand that uses an immediate
553 // value, and it is also the first operand that uses a value at all.
554 if (stream[word-1] & MemoryAccessAlignedMask) {
555 disassembleImmediates(1);
560 disassembleIds(numOperands);
563 assert(operandClass >= OperandSource && operandClass < OperandOpcode);
565 if (OperandClassParams[operandClass].bitmask)
566 outputMask(operandClass, stream[word++]);
568 out << OperandClassParams[operandClass].getName(stream[word++]);
578 static void GLSLstd450GetDebugNames(const char** names)
580 for (int i = 0; i < GLSLstd450Count; ++i)
581 names[i] = "Unknown";
583 names[GLSLstd450Round] = "Round";
584 names[GLSLstd450RoundEven] = "RoundEven";
585 names[GLSLstd450Trunc] = "Trunc";
586 names[GLSLstd450FAbs] = "FAbs";
587 names[GLSLstd450SAbs] = "SAbs";
588 names[GLSLstd450FSign] = "FSign";
589 names[GLSLstd450SSign] = "SSign";
590 names[GLSLstd450Floor] = "Floor";
591 names[GLSLstd450Ceil] = "Ceil";
592 names[GLSLstd450Fract] = "Fract";
593 names[GLSLstd450Radians] = "Radians";
594 names[GLSLstd450Degrees] = "Degrees";
595 names[GLSLstd450Sin] = "Sin";
596 names[GLSLstd450Cos] = "Cos";
597 names[GLSLstd450Tan] = "Tan";
598 names[GLSLstd450Asin] = "Asin";
599 names[GLSLstd450Acos] = "Acos";
600 names[GLSLstd450Atan] = "Atan";
601 names[GLSLstd450Sinh] = "Sinh";
602 names[GLSLstd450Cosh] = "Cosh";
603 names[GLSLstd450Tanh] = "Tanh";
604 names[GLSLstd450Asinh] = "Asinh";
605 names[GLSLstd450Acosh] = "Acosh";
606 names[GLSLstd450Atanh] = "Atanh";
607 names[GLSLstd450Atan2] = "Atan2";
608 names[GLSLstd450Pow] = "Pow";
609 names[GLSLstd450Exp] = "Exp";
610 names[GLSLstd450Log] = "Log";
611 names[GLSLstd450Exp2] = "Exp2";
612 names[GLSLstd450Log2] = "Log2";
613 names[GLSLstd450Sqrt] = "Sqrt";
614 names[GLSLstd450InverseSqrt] = "InverseSqrt";
615 names[GLSLstd450Determinant] = "Determinant";
616 names[GLSLstd450MatrixInverse] = "MatrixInverse";
617 names[GLSLstd450Modf] = "Modf";
618 names[GLSLstd450ModfStruct] = "ModfStruct";
619 names[GLSLstd450FMin] = "FMin";
620 names[GLSLstd450SMin] = "SMin";
621 names[GLSLstd450UMin] = "UMin";
622 names[GLSLstd450FMax] = "FMax";
623 names[GLSLstd450SMax] = "SMax";
624 names[GLSLstd450UMax] = "UMax";
625 names[GLSLstd450FClamp] = "FClamp";
626 names[GLSLstd450SClamp] = "SClamp";
627 names[GLSLstd450UClamp] = "UClamp";
628 names[GLSLstd450FMix] = "FMix";
629 names[GLSLstd450Step] = "Step";
630 names[GLSLstd450SmoothStep] = "SmoothStep";
631 names[GLSLstd450Fma] = "Fma";
632 names[GLSLstd450Frexp] = "Frexp";
633 names[GLSLstd450FrexpStruct] = "FrexpStruct";
634 names[GLSLstd450Ldexp] = "Ldexp";
635 names[GLSLstd450PackSnorm4x8] = "PackSnorm4x8";
636 names[GLSLstd450PackUnorm4x8] = "PackUnorm4x8";
637 names[GLSLstd450PackSnorm2x16] = "PackSnorm2x16";
638 names[GLSLstd450PackUnorm2x16] = "PackUnorm2x16";
639 names[GLSLstd450PackHalf2x16] = "PackHalf2x16";
640 names[GLSLstd450PackDouble2x32] = "PackDouble2x32";
641 names[GLSLstd450UnpackSnorm2x16] = "UnpackSnorm2x16";
642 names[GLSLstd450UnpackUnorm2x16] = "UnpackUnorm2x16";
643 names[GLSLstd450UnpackHalf2x16] = "UnpackHalf2x16";
644 names[GLSLstd450UnpackSnorm4x8] = "UnpackSnorm4x8";
645 names[GLSLstd450UnpackUnorm4x8] = "UnpackUnorm4x8";
646 names[GLSLstd450UnpackDouble2x32] = "UnpackDouble2x32";
647 names[GLSLstd450Length] = "Length";
648 names[GLSLstd450Distance] = "Distance";
649 names[GLSLstd450Cross] = "Cross";
650 names[GLSLstd450Normalize] = "Normalize";
651 names[GLSLstd450FaceForward] = "FaceForward";
652 names[GLSLstd450Reflect] = "Reflect";
653 names[GLSLstd450Refract] = "Refract";
654 names[GLSLstd450FindILsb] = "FindILsb";
655 names[GLSLstd450FindSMsb] = "FindSMsb";
656 names[GLSLstd450FindUMsb] = "FindUMsb";
657 names[GLSLstd450InterpolateAtCentroid] = "InterpolateAtCentroid";
658 names[GLSLstd450InterpolateAtSample] = "InterpolateAtSample";
659 names[GLSLstd450InterpolateAtOffset] = "InterpolateAtOffset";
660 names[GLSLstd450NMin] = "NMin";
661 names[GLSLstd450NMax] = "NMax";
662 names[GLSLstd450NClamp] = "NClamp";
665 static const char* GLSLextAMDGetDebugNames(const char* name, unsigned entrypoint)
667 if (strcmp(name, spv::E_SPV_AMD_shader_ballot) == 0) {
668 switch (entrypoint) {
669 case SwizzleInvocationsAMD: return "SwizzleInvocationsAMD";
670 case SwizzleInvocationsMaskedAMD: return "SwizzleInvocationsMaskedAMD";
671 case WriteInvocationAMD: return "WriteInvocationAMD";
672 case MbcntAMD: return "MbcntAMD";
673 default: return "Bad";
675 } else if (strcmp(name, spv::E_SPV_AMD_shader_trinary_minmax) == 0) {
676 switch (entrypoint) {
677 case FMin3AMD: return "FMin3AMD";
678 case UMin3AMD: return "UMin3AMD";
679 case SMin3AMD: return "SMin3AMD";
680 case FMax3AMD: return "FMax3AMD";
681 case UMax3AMD: return "UMax3AMD";
682 case SMax3AMD: return "SMax3AMD";
683 case FMid3AMD: return "FMid3AMD";
684 case UMid3AMD: return "UMid3AMD";
685 case SMid3AMD: return "SMid3AMD";
686 default: return "Bad";
688 } else if (strcmp(name, spv::E_SPV_AMD_shader_explicit_vertex_parameter) == 0) {
689 switch (entrypoint) {
690 case InterpolateAtVertexAMD: return "InterpolateAtVertexAMD";
691 default: return "Bad";
694 else if (strcmp(name, spv::E_SPV_AMD_gcn_shader) == 0) {
695 switch (entrypoint) {
696 case CubeFaceIndexAMD: return "CubeFaceIndexAMD";
697 case CubeFaceCoordAMD: return "CubeFaceCoordAMD";
698 case TimeAMD: return "TimeAMD";
707 static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
709 if (strcmp(name, spv::E_SPV_NV_sample_mask_override_coverage) == 0 ||
710 strcmp(name, spv::E_SPV_NV_geometry_shader_passthrough) == 0 ||
711 strcmp(name, spv::E_ARB_shader_viewport_layer_array) == 0 ||
712 strcmp(name, spv::E_SPV_NV_viewport_array2) == 0 ||
713 strcmp(name, spv::E_SPV_NVX_multiview_per_view_attributes) == 0 ||
714 strcmp(name, spv::E_SPV_NV_fragment_shader_barycentric) == 0 ||
715 strcmp(name, spv::E_SPV_NV_mesh_shader) == 0 ||
716 strcmp(name, spv::E_SPV_NV_shader_image_footprint) == 0) {
717 switch (entrypoint) {
719 case BuiltInViewportMaskNV: return "ViewportMaskNV";
720 case BuiltInSecondaryPositionNV: return "SecondaryPositionNV";
721 case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
722 case BuiltInPositionPerViewNV: return "PositionPerViewNV";
723 case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
724 case BuiltInBaryCoordNV: return "BaryCoordNV";
725 case BuiltInBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
726 case BuiltInTaskCountNV: return "TaskCountNV";
727 case BuiltInPrimitiveCountNV: return "PrimitiveCountNV";
728 case BuiltInPrimitiveIndicesNV: return "PrimitiveIndicesNV";
729 case BuiltInClipDistancePerViewNV: return "ClipDistancePerViewNV";
730 case BuiltInCullDistancePerViewNV: return "CullDistancePerViewNV";
731 case BuiltInLayerPerViewNV: return "LayerPerViewNV";
732 case BuiltInMeshViewCountNV: return "MeshViewCountNV";
733 case BuiltInMeshViewIndicesNV: return "MeshViewIndicesNV";
736 case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
737 case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
738 case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
739 case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
740 case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
741 case CapabilityMeshShadingNV: return "MeshShadingNV";
742 case CapabilityImageFootprintNV: return "ImageFootprintNV";
743 case CapabilitySampleMaskOverrideCoverageNV:return "SampleMaskOverrideCoverageNV";
746 case DecorationOverrideCoverageNV: return "OverrideCoverageNV";
747 case DecorationPassthroughNV: return "PassthroughNV";
748 case DecorationViewportRelativeNV: return "ViewportRelativeNV";
749 case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
750 case DecorationPerVertexNV: return "PerVertexNV";
751 case DecorationPerPrimitiveNV: return "PerPrimitiveNV";
752 case DecorationPerViewNV: return "PerViewNV";
753 case DecorationPerTaskNV: return "PerTaskNV";
755 default: return "Bad";
761 static const char* NonSemanticShaderDebugInfo100GetDebugNames(unsigned entrypoint)
763 switch (entrypoint) {
764 case NonSemanticShaderDebugInfo100DebugInfoNone: return "DebugInfoNone";
765 case NonSemanticShaderDebugInfo100DebugCompilationUnit: return "DebugCompilationUnit";
766 case NonSemanticShaderDebugInfo100DebugTypeBasic: return "DebugTypeBasic";
767 case NonSemanticShaderDebugInfo100DebugTypePointer: return "DebugTypePointer";
768 case NonSemanticShaderDebugInfo100DebugTypeQualifier: return "DebugTypeQualifier";
769 case NonSemanticShaderDebugInfo100DebugTypeArray: return "DebugTypeArray";
770 case NonSemanticShaderDebugInfo100DebugTypeVector: return "DebugTypeVector";
771 case NonSemanticShaderDebugInfo100DebugTypedef: return "DebugTypedef";
772 case NonSemanticShaderDebugInfo100DebugTypeFunction: return "DebugTypeFunction";
773 case NonSemanticShaderDebugInfo100DebugTypeEnum: return "DebugTypeEnum";
774 case NonSemanticShaderDebugInfo100DebugTypeComposite: return "DebugTypeComposite";
775 case NonSemanticShaderDebugInfo100DebugTypeMember: return "DebugTypeMember";
776 case NonSemanticShaderDebugInfo100DebugTypeInheritance: return "DebugTypeInheritance";
777 case NonSemanticShaderDebugInfo100DebugTypePtrToMember: return "DebugTypePtrToMember";
778 case NonSemanticShaderDebugInfo100DebugTypeTemplate: return "DebugTypeTemplate";
779 case NonSemanticShaderDebugInfo100DebugTypeTemplateParameter: return "DebugTypeTemplateParameter";
780 case NonSemanticShaderDebugInfo100DebugTypeTemplateTemplateParameter: return "DebugTypeTemplateTemplateParameter";
781 case NonSemanticShaderDebugInfo100DebugTypeTemplateParameterPack: return "DebugTypeTemplateParameterPack";
782 case NonSemanticShaderDebugInfo100DebugGlobalVariable: return "DebugGlobalVariable";
783 case NonSemanticShaderDebugInfo100DebugFunctionDeclaration: return "DebugFunctionDeclaration";
784 case NonSemanticShaderDebugInfo100DebugFunction: return "DebugFunction";
785 case NonSemanticShaderDebugInfo100DebugLexicalBlock: return "DebugLexicalBlock";
786 case NonSemanticShaderDebugInfo100DebugLexicalBlockDiscriminator: return "DebugLexicalBlockDiscriminator";
787 case NonSemanticShaderDebugInfo100DebugScope: return "DebugScope";
788 case NonSemanticShaderDebugInfo100DebugNoScope: return "DebugNoScope";
789 case NonSemanticShaderDebugInfo100DebugInlinedAt: return "DebugInlinedAt";
790 case NonSemanticShaderDebugInfo100DebugLocalVariable: return "DebugLocalVariable";
791 case NonSemanticShaderDebugInfo100DebugInlinedVariable: return "DebugInlinedVariable";
792 case NonSemanticShaderDebugInfo100DebugDeclare: return "DebugDeclare";
793 case NonSemanticShaderDebugInfo100DebugValue: return "DebugValue";
794 case NonSemanticShaderDebugInfo100DebugOperation: return "DebugOperation";
795 case NonSemanticShaderDebugInfo100DebugExpression: return "DebugExpression";
796 case NonSemanticShaderDebugInfo100DebugMacroDef: return "DebugMacroDef";
797 case NonSemanticShaderDebugInfo100DebugMacroUndef: return "DebugMacroUndef";
798 case NonSemanticShaderDebugInfo100DebugImportedEntity: return "DebugImportedEntity";
799 case NonSemanticShaderDebugInfo100DebugSource: return "DebugSource";
800 case NonSemanticShaderDebugInfo100DebugFunctionDefinition: return "DebugFunctionDefinition";
801 case NonSemanticShaderDebugInfo100DebugSourceContinued: return "DebugSourceContinued";
802 case NonSemanticShaderDebugInfo100DebugLine: return "DebugLine";
803 case NonSemanticShaderDebugInfo100DebugNoLine: return "DebugNoLine";
804 case NonSemanticShaderDebugInfo100DebugBuildIdentifier: return "DebugBuildIdentifier";
805 case NonSemanticShaderDebugInfo100DebugStoragePath: return "DebugStoragePath";
806 case NonSemanticShaderDebugInfo100DebugEntryPoint: return "DebugEntryPoint";
807 case NonSemanticShaderDebugInfo100DebugTypeMatrix: return "DebugTypeMatrix";
808 default: return "Bad";
814 void Disassemble(std::ostream& out, const std::vector<unsigned int>& stream)
816 SpirvStream SpirvStream(out, stream);
818 GLSLstd450GetDebugNames(GlslStd450DebugNames);
819 SpirvStream.validate();
820 SpirvStream.processInstructions();
823 }; // end namespace spv