| ... | ... | @@ -425,10 +425,21 @@ pub fn finalize(module: *Module, gpa: Allocator) ![]Word { |
| 425 | 425 | }, |
| 426 | 426 | }; |
| 427 | 427 | |
| 428 | const zig_version = @import("builtin").zig_version; |
| 429 | const zig_spirv_compiler_version = comptime (zig_version.major << 12) | (zig_version.minor << 7) | zig_version.patch; |
| 430 | |
| 431 | // A SPIR-V Generator Magic Number is a 32 bit word: The high order 16 |
| 432 | // bits are a tool ID, which should be unique across all SPIR-V |
| 433 | // generators. The low order 16 bits are reserved for use as a tool |
| 434 | // version number, or any other purpose the tool supplier chooses. |
| 435 | // Only the tool IDs are reserved with Khronos. |
| 436 | // See https://github.com/KhronosGroup/SPIRV-Headers/blob/f2e4bd213104fe323a01e935df56557328d37ac8/include/spirv/spir-v.xml#L17C5-L21C54 |
| 437 | const generator_id: u32 = (spec.zig_generator_id << 16) | zig_spirv_compiler_version; |
| 438 | |
| 428 | 439 | const header = [_]Word{ |
| 429 | 440 | spec.magic_number, |
| 430 | 441 | version.toWord(), |
| 431 | | spec.zig_generator_id, |
| 442 | generator_id, |
| 432 | 443 | module.idBound(), |
| 433 | 444 | 0, // Schema (currently reserved for future use) |
| 434 | 445 | }; |
| ... | ... | @@ -437,7 +448,7 @@ pub fn finalize(module: *Module, gpa: Allocator) ![]Word { |
| 437 | 448 | defer source.deinit(module.gpa); |
| 438 | 449 | try module.sections.debug_strings.emit(module.gpa, .OpSource, .{ |
| 439 | 450 | .source_language = .zig, |
| 440 | | .version = 0, |
| 451 | .version = zig_spirv_compiler_version, |
| 441 | 452 | // We cannot emit these because the Khronos translator does not parse this instruction |
| 442 | 453 | // correctly. |
| 443 | 454 | // See https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2188 |