upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorettehn <141814824+ettehn@users.noreply.github.com>2026-11-24 11:02:23 +0800
committerettehn <141814824+ettehn@users.noreply.github.com>2026-11-24 11:28:30 +0800
commitf8a88299e1dfd09195e129a1d14970e2b532ef2b (patch)
tree5938ae2bf4a64083bebccae8da44c44724448bf8 /tools
parentd478a92d4d7eae1d7b512cb4553ddc4fbc300e85 (diff)
Support named SPIR-V shader debug instructions
Carry forward old Leonida PR #4744 for BUILD-SPIRV-DEBUGINFO.
Diffstat (limited to 'tools')
-rw-r--r--tools/spirv_asm.py6
-rw-r--r--tools/spirv_asm_tables.py48
2 files changed, 52 insertions, 2 deletions
diff --git a/tools/spirv_asm.py b/tools/spirv_asm.py
index 49d0809e1..e32dd83af 100644
--- a/tools/spirv_asm.py
+++ b/tools/spirv_asm.py
@@ -30,7 +30,8 @@ if _HERE not in sys.path:
30 sys.path.insert(0, _HERE) 30 sys.path.insert(0, _HERE)
31 31
32from spirv_asm_tables import ( # noqa: E402 32from spirv_asm_tables import ( # noqa: E402
33 BIT_ENUMS, GLSL_STD_450, INSTRUCTIONS, NONSEMANTIC_DEBUGPRINTF, VALUE_ENUMS, 33 BIT_ENUMS, GLSL_STD_450, INSTRUCTIONS, NONSEMANTIC_DEBUGPRINTF,
34 NONSEMANTIC_SHADER_DEBUGINFO_100, VALUE_ENUMS,
34) 35)
35 36
36SPIRV_MAGIC = 0x07230203 37SPIRV_MAGIC = 0x07230203
@@ -54,6 +55,7 @@ TARGET_ENV_VERSION = {
54_ID_KINDS = frozenset(("IdRef", "IdResult", "IdResultType", "IdScope", "IdMemorySemantics")) 55_ID_KINDS = frozenset(("IdRef", "IdResult", "IdResultType", "IdScope", "IdMemorySemantics"))
55_ID_RE = re.compile(r"%[A-Za-z0-9_]+") 56_ID_RE = re.compile(r"%[A-Za-z0-9_]+")
56_EXT_SETS = { 57_EXT_SETS = {
58 "NonSemantic.Shader.DebugInfo.100": NONSEMANTIC_SHADER_DEBUGINFO_100,
57 "GLSL.std.450": GLSL_STD_450, 59 "GLSL.std.450": GLSL_STD_450,
58 "NonSemantic.DebugPrintf": NONSEMANTIC_DEBUGPRINTF, # spirv-dis writes its instruction by name 60 "NonSemantic.DebugPrintf": NONSEMANTIC_DEBUGPRINTF, # spirv-dis writes its instruction by name
59} 61}
@@ -638,7 +640,7 @@ def _assemble(instructions, version: int, track_switch_types: bool) -> bytes:
638 640
639 cur_ext_table = None 641 cur_ext_table = None
640 switch_type = None # (width, signed) of the OpSwitch selector's integer type 642 switch_type = None # (width, signed) of the OpSwitch selector's integer type
641 if opname == "OpExtInst" and arg_idx < len(toks): 643 if opname in ("OpExtInst", "OpExtInstWithForwardRefsKHR") and arg_idx < len(toks):
642 cur_ext_table = ext_imports.get(get_id(toks[arg_idx], lineno)) 644 cur_ext_table = ext_imports.get(get_id(toks[arg_idx], lineno))
643 elif opname == "OpSwitch" and arg_idx < len(toks): 645 elif opname == "OpSwitch" and arg_idx < len(toks):
644 sel_id = get_id(toks[arg_idx], lineno) 646 sel_id = get_id(toks[arg_idx], lineno)
diff --git a/tools/spirv_asm_tables.py b/tools/spirv_asm_tables.py
index a58311c14..7714d734f 100644
--- a/tools/spirv_asm_tables.py
+++ b/tools/spirv_asm_tables.py
@@ -1111,3 +1111,51 @@ GLSL_STD_450 = {
1111NONSEMANTIC_DEBUGPRINTF = { 1111NONSEMANTIC_DEBUGPRINTF = {
1112 'DebugPrintf': 1, 1112 'DebugPrintf': 1,
1113} 1113}
1114
1115# extinst.nonsemantic.shader.debuginfo.100.grammar.json (SPIRV-Headers).
1116NONSEMANTIC_SHADER_DEBUGINFO_100 = {
1117 'DebugBuildIdentifier': 105,
1118 'DebugCompilationUnit': 1,
1119 'DebugDeclare': 28,
1120 'DebugEntryPoint': 107,
1121 'DebugExpression': 31,
1122 'DebugFunction': 20,
1123 'DebugFunctionDeclaration': 19,
1124 'DebugFunctionDefinition': 101,
1125 'DebugGlobalVariable': 18,
1126 'DebugImportedEntity': 34,
1127 'DebugInfoNone': 0,
1128 'DebugInlinedAt': 25,
1129 'DebugInlinedVariable': 27,
1130 'DebugLexicalBlock': 21,
1131 'DebugLexicalBlockDiscriminator': 22,
1132 'DebugLine': 103,
1133 'DebugLocalVariable': 26,
1134 'DebugMacroDef': 32,
1135 'DebugMacroUndef': 33,
1136 'DebugNoLine': 104,
1137 'DebugNoScope': 24,
1138 'DebugOperation': 30,
1139 'DebugScope': 23,
1140 'DebugSource': 35,
1141 'DebugSourceContinued': 102,
1142 'DebugStoragePath': 106,
1143 'DebugTypeArray': 5,
1144 'DebugTypeBasic': 2,
1145 'DebugTypeComposite': 10,
1146 'DebugTypedef': 7,
1147 'DebugTypeEnum': 9,
1148 'DebugTypeFunction': 8,
1149 'DebugTypeInheritance': 12,
1150 'DebugTypeMatrix': 108,
1151 'DebugTypeMember': 11,
1152 'DebugTypePointer': 3,
1153 'DebugTypePtrToMember': 13,
1154 'DebugTypeQualifier': 4,
1155 'DebugTypeTemplate': 14,
1156 'DebugTypeTemplateParameter': 15,
1157 'DebugTypeTemplateParameterPack': 17,
1158 'DebugTypeTemplateTemplateParameter': 16,
1159 'DebugTypeVector': 6,
1160 'DebugValue': 29,
1161}