authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-01 12:49:51-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-02-01 12:49:51-08:00
log102d9542203e52839156cb61efdfca8403a379a9
tree72daf0d9a1ac3680f2f1fbc6447a120dde9b52ee
parent06b29c854656a1f9320ee16024b1c3a6b78180a5
parent1055344673a87af39f2288bae069ec9403e6086d
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #7827 from Snektron/spirv-setup

Stage 2: SPIR-V setup

13 files changed, 2258 insertions(+), 8 deletions(-)

lib/std/target.zig+35
......@@ -57,6 +57,9 @@ pub const Target = struct {
5757 wasi,
5858 emscripten,
5959 uefi,
60 opencl,
61 glsl450,
62 vulkan,
6063 other,
6164
6265 pub fn isDarwin(tag: Tag) bool {
......@@ -248,6 +251,9 @@ pub const Target = struct {
248251 .wasi,
249252 .emscripten,
250253 .uefi,
254 .opencl, // TODO: OpenCL versions
255 .glsl450, // TODO: GLSL versions
256 .vulkan,
251257 .other,
252258 => return .{ .none = {} },
253259
......@@ -403,6 +409,9 @@ pub const Target = struct {
403409 .wasi,
404410 .emscripten,
405411 .uefi,
412 .opencl,
413 .glsl450,
414 .vulkan,
406415 .other,
407416 => false,
408417 };
......@@ -421,6 +430,7 @@ pub const Target = struct {
421430 pub const powerpc = @import("target/powerpc.zig");
422431 pub const riscv = @import("target/riscv.zig");
423432 pub const sparc = @import("target/sparc.zig");
433 pub const spirv = @import("target/spirv.zig");
424434 pub const systemz = @import("target/systemz.zig");
425435 pub const wasm = @import("target/wasm.zig");
426436 pub const x86 = @import("target/x86.zig");
......@@ -493,6 +503,10 @@ pub const Target = struct {
493503 .wasi,
494504 .emscripten,
495505 => return .musl,
506 .opencl, // TODO: SPIR-V ABIs with Linkage capability
507 .glsl450,
508 .vulkan,
509 => return .none,
496510 }
497511 }
498512
......@@ -528,6 +542,7 @@ pub const Target = struct {
528542 macho,
529543 wasm,
530544 c,
545 spirv,
531546 hex,
532547 raw,
533548 };
......@@ -744,6 +759,8 @@ pub const Target = struct {
744759 // Stage1 currently assumes that architectures above this comment
745760 // map one-to-one with the ZigLLVM_ArchType enum.
746761 spu_2,
762 spirv32,
763 spirv64,
747764
748765 pub fn isARM(arch: Arch) bool {
749766 return switch (arch) {
......@@ -857,6 +874,8 @@ pub const Target = struct {
857874 .s390x => ._S390,
858875 .ve => ._NONE,
859876 .spu_2 => ._SPU_2,
877 .spirv32 => ._NONE,
878 .spirv64 => ._NONE,
860879 };
861880 }
862881
......@@ -914,6 +933,8 @@ pub const Target = struct {
914933 .s390x => .Unknown,
915934 .ve => .Unknown,
916935 .spu_2 => .Unknown,
936 .spirv32 => .Unknown,
937 .spirv64 => .Unknown,
917938 };
918939 }
919940
......@@ -957,6 +978,9 @@ pub const Target = struct {
957978 .shave,
958979 .ve,
959980 .spu_2,
981 // GPU bitness is opaque. For now, assume little endian.
982 .spirv32,
983 .spirv64,
960984 => .Little,
961985
962986 .arc,
......@@ -1012,6 +1036,7 @@ pub const Target = struct {
10121036 .wasm32,
10131037 .renderscript32,
10141038 .aarch64_32,
1039 .spirv32,
10151040 => return 32,
10161041
10171042 .aarch64,
......@@ -1035,6 +1060,7 @@ pub const Target = struct {
10351060 .sparcv9,
10361061 .s390x,
10371062 .ve,
1063 .spirv64,
10381064 => return 64,
10391065 }
10401066 }
......@@ -1057,6 +1083,7 @@ pub const Target = struct {
10571083 .i386, .x86_64 => "x86",
10581084 .nvptx, .nvptx64 => "nvptx",
10591085 .wasm32, .wasm64 => "wasm",
1086 .spirv32, .spirv64 => "spir-v",
10601087 else => @tagName(arch),
10611088 };
10621089 }
......@@ -1347,6 +1374,9 @@ pub const Target = struct {
13471374 .uefi,
13481375 .windows,
13491376 .emscripten,
1377 .opencl,
1378 .glsl450,
1379 .vulkan,
13501380 .other,
13511381 => return false,
13521382 else => return true,
......@@ -1482,6 +1512,8 @@ pub const Target = struct {
14821512 .nvptx64,
14831513 .spu_2,
14841514 .avr,
1515 .spirv32,
1516 .spirv64,
14851517 => return result,
14861518
14871519 // TODO go over each item in this list and either move it to the above list, or
......@@ -1524,6 +1556,9 @@ pub const Target = struct {
15241556 .windows,
15251557 .emscripten,
15261558 .wasi,
1559 .opencl,
1560 .glsl450,
1561 .vulkan,
15271562 .other,
15281563 => return result,
15291564
lib/std/zig.zig+1
......@@ -141,6 +141,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro
141141 .Lib => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}),
142142 },
143143 .c => return std.fmt.allocPrint(allocator, "{s}.c", .{root_name}),
144 .spirv => return std.fmt.allocPrint(allocator, "{s}.spv", .{root_name}),
144145 .hex => return std.fmt.allocPrint(allocator, "{s}.ihex", .{root_name}),
145146 .raw => return std.fmt.allocPrint(allocator, "{s}.bin", .{root_name}),
146147 }
lib/std/zig/cross_target.zig+6
......@@ -130,6 +130,9 @@ pub const CrossTarget = struct {
130130 .wasi,
131131 .emscripten,
132132 .uefi,
133 .opencl,
134 .glsl450,
135 .vulkan,
133136 .other,
134137 => {
135138 self.os_version_min = .{ .none = {} };
......@@ -730,6 +733,9 @@ pub const CrossTarget = struct {
730733 .wasi,
731734 .emscripten,
732735 .uefi,
736 .opencl,
737 .glsl450,
738 .vulkan,
733739 .other,
734740 => return error.InvalidOperatingSystemVersion,
735741
src/Module.zig+4-1
......@@ -1673,7 +1673,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
16731673 // in `Decl` to notice that the line number did not change.
16741674 self.comp.work_queue.writeItemAssumeCapacity(.{ .update_line_number = decl });
16751675 },
1676 .c, .wasm => {},
1676 .c, .wasm, .spirv => {},
16771677 }
16781678 }
16791679 } else {
......@@ -1906,6 +1906,7 @@ fn allocateNewDecl(
19061906 .macho => .{ .macho = link.File.MachO.TextBlock.empty },
19071907 .c => .{ .c = link.File.C.DeclBlock.empty },
19081908 .wasm => .{ .wasm = {} },
1909 .spirv => .{ .spirv = {} },
19091910 },
19101911 .fn_link = switch (mod.comp.bin_file.tag) {
19111912 .coff => .{ .coff = {} },
......@@ -1913,6 +1914,7 @@ fn allocateNewDecl(
19131914 .macho => .{ .macho = link.File.MachO.SrcFn.empty },
19141915 .c => .{ .c = link.File.C.FnBlock.empty },
19151916 .wasm => .{ .wasm = null },
1917 .spirv => .{ .spirv = .{} },
19161918 },
19171919 .generation = 0,
19181920 .is_pub = false,
......@@ -2010,6 +2012,7 @@ pub fn analyzeExport(
20102012 .macho => .{ .macho = link.File.MachO.Export{} },
20112013 .c => .{ .c = {} },
20122014 .wasm => .{ .wasm = {} },
2015 .spirv => .{ .spirv = {} },
20132016 },
20142017 .owner_decl = owner_decl,
20152018 .exported_decl = exported_decl,
src/codegen/llvm.zig+5
......@@ -69,6 +69,8 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 {
6969 .renderscript64 => "renderscript64",
7070 .ve => "ve",
7171 .spu_2 => return error.LLVMBackendDoesNotSupportSPUMarkII,
72 .spirv32 => return error.LLVMBackendDoesNotSupportSPIRV,
73 .spirv64 => return error.LLVMBackendDoesNotSupportSPIRV,
7274 };
7375 // TODO Add a sub-arch for some architectures depending on CPU features.
7476
......@@ -109,6 +111,9 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 {
109111 .wasi => "wasi",
110112 .emscripten => "emscripten",
111113 .uefi => "windows",
114 .opencl => return error.LLVMBackendDoesNotSupportOpenCL,
115 .glsl450 => return error.LLVMBackendDoesNotSupportGLSL450,
116 .vulkan => return error.LLVMBackendDoesNotSupportVulkan,
112117 .other => "unknown",
113118 };
114119
src/codegen/spirv.zig created+51
......@@ -0,0 +1,51 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3
4const spec = @import("spirv/spec.zig");
5const Module = @import("../Module.zig");
6const Decl = Module.Decl;
7
8pub fn writeInstruction(code: *std.ArrayList(u32), instr: spec.Opcode, args: []const u32) !void {
9 const word_count = @intCast(u32, args.len + 1);
10 try code.append((word_count << 16) | @enumToInt(instr));
11 try code.appendSlice(args);
12}
13
14pub const SPIRVModule = struct {
15 next_id: u32 = 0,
16 free_id_list: std.ArrayList(u32),
17
18 pub fn init(allocator: *Allocator) SPIRVModule {
19 return .{
20 .free_id_list = std.ArrayList(u32).init(allocator),
21 };
22 }
23
24 pub fn deinit(self: *SPIRVModule) void {
25 self.free_id_list.deinit();
26 }
27
28 pub fn allocId(self: *SPIRVModule) u32 {
29 if (self.free_id_list.popOrNull()) |id| return id;
30
31 defer self.next_id += 1;
32 return self.next_id;
33 }
34
35 pub fn freeId(self: *SPIRVModule, id: u32) void {
36 if (id + 1 == self.next_id) {
37 self.next_id -= 1;
38 } else {
39 // If no more memory to append the id to the free list, just ignore it.
40 self.free_id_list.append(id) catch {};
41 }
42 }
43
44 pub fn idBound(self: *SPIRVModule) u32 {
45 return self.next_id;
46 }
47
48 pub fn genDecl(self: SPIRVModule, id: u32, code: *std.ArrayList(u32), decl: *Decl) !void {
49
50 }
51};
src/codegen/spirv/spec.zig created+1645
......@@ -0,0 +1,1645 @@
1// Copyright (c) 2014-2020 The Khronos Group Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and/or associated documentation files (the "Materials"),
5// to deal in the Materials without restriction, including without limitation
6// the rights to use, copy, modify, merge, publish, distribute, sublicense,
7// and/or sell copies of the Materials, and to permit persons to whom the
8// Materials are furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Materials.
12//
13// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
14// STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
15// HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
16//
17// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
23// IN THE MATERIALS.
24const Version = @import("builtin").Version;
25pub const version = Version{ .major = 1, .minor = 5, .patch = 4 };
26pub const magic_number: u32 = 0x07230203;
27pub const Opcode = extern enum(u16) {
28 OpNop = 0,
29 OpUndef = 1,
30 OpSourceContinued = 2,
31 OpSource = 3,
32 OpSourceExtension = 4,
33 OpName = 5,
34 OpMemberName = 6,
35 OpString = 7,
36 OpLine = 8,
37 OpExtension = 10,
38 OpExtInstImport = 11,
39 OpExtInst = 12,
40 OpMemoryModel = 14,
41 OpEntryPoint = 15,
42 OpExecutionMode = 16,
43 OpCapability = 17,
44 OpTypeVoid = 19,
45 OpTypeBool = 20,
46 OpTypeInt = 21,
47 OpTypeFloat = 22,
48 OpTypeVector = 23,
49 OpTypeMatrix = 24,
50 OpTypeImage = 25,
51 OpTypeSampler = 26,
52 OpTypeSampledImage = 27,
53 OpTypeArray = 28,
54 OpTypeRuntimeArray = 29,
55 OpTypeStruct = 30,
56 OpTypeOpaque = 31,
57 OpTypePointer = 32,
58 OpTypeFunction = 33,
59 OpTypeEvent = 34,
60 OpTypeDeviceEvent = 35,
61 OpTypeReserveId = 36,
62 OpTypeQueue = 37,
63 OpTypePipe = 38,
64 OpTypeForwardPointer = 39,
65 OpConstantTrue = 41,
66 OpConstantFalse = 42,
67 OpConstant = 43,
68 OpConstantComposite = 44,
69 OpConstantSampler = 45,
70 OpConstantNull = 46,
71 OpSpecConstantTrue = 48,
72 OpSpecConstantFalse = 49,
73 OpSpecConstant = 50,
74 OpSpecConstantComposite = 51,
75 OpSpecConstantOp = 52,
76 OpFunction = 54,
77 OpFunctionParameter = 55,
78 OpFunctionEnd = 56,
79 OpFunctionCall = 57,
80 OpVariable = 59,
81 OpImageTexelPointer = 60,
82 OpLoad = 61,
83 OpStore = 62,
84 OpCopyMemory = 63,
85 OpCopyMemorySized = 64,
86 OpAccessChain = 65,
87 OpInBoundsAccessChain = 66,
88 OpPtrAccessChain = 67,
89 OpArrayLength = 68,
90 OpGenericPtrMemSemantics = 69,
91 OpInBoundsPtrAccessChain = 70,
92 OpDecorate = 71,
93 OpMemberDecorate = 72,
94 OpDecorationGroup = 73,
95 OpGroupDecorate = 74,
96 OpGroupMemberDecorate = 75,
97 OpVectorExtractDynamic = 77,
98 OpVectorInsertDynamic = 78,
99 OpVectorShuffle = 79,
100 OpCompositeConstruct = 80,
101 OpCompositeExtract = 81,
102 OpCompositeInsert = 82,
103 OpCopyObject = 83,
104 OpTranspose = 84,
105 OpSampledImage = 86,
106 OpImageSampleImplicitLod = 87,
107 OpImageSampleExplicitLod = 88,
108 OpImageSampleDrefImplicitLod = 89,
109 OpImageSampleDrefExplicitLod = 90,
110 OpImageSampleProjImplicitLod = 91,
111 OpImageSampleProjExplicitLod = 92,
112 OpImageSampleProjDrefImplicitLod = 93,
113 OpImageSampleProjDrefExplicitLod = 94,
114 OpImageFetch = 95,
115 OpImageGather = 96,
116 OpImageDrefGather = 97,
117 OpImageRead = 98,
118 OpImageWrite = 99,
119 OpImage = 100,
120 OpImageQueryFormat = 101,
121 OpImageQueryOrder = 102,
122 OpImageQuerySizeLod = 103,
123 OpImageQuerySize = 104,
124 OpImageQueryLod = 105,
125 OpImageQueryLevels = 106,
126 OpImageQuerySamples = 107,
127 OpConvertFToU = 109,
128 OpConvertFToS = 110,
129 OpConvertSToF = 111,
130 OpConvertUToF = 112,
131 OpUConvert = 113,
132 OpSConvert = 114,
133 OpFConvert = 115,
134 OpQuantizeToF16 = 116,
135 OpConvertPtrToU = 117,
136 OpSatConvertSToU = 118,
137 OpSatConvertUToS = 119,
138 OpConvertUToPtr = 120,
139 OpPtrCastToGeneric = 121,
140 OpGenericCastToPtr = 122,
141 OpGenericCastToPtrExplicit = 123,
142 OpBitcast = 124,
143 OpSNegate = 126,
144 OpFNegate = 127,
145 OpIAdd = 128,
146 OpFAdd = 129,
147 OpISub = 130,
148 OpFSub = 131,
149 OpIMul = 132,
150 OpFMul = 133,
151 OpUDiv = 134,
152 OpSDiv = 135,
153 OpFDiv = 136,
154 OpUMod = 137,
155 OpSRem = 138,
156 OpSMod = 139,
157 OpFRem = 140,
158 OpFMod = 141,
159 OpVectorTimesScalar = 142,
160 OpMatrixTimesScalar = 143,
161 OpVectorTimesMatrix = 144,
162 OpMatrixTimesVector = 145,
163 OpMatrixTimesMatrix = 146,
164 OpOuterProduct = 147,
165 OpDot = 148,
166 OpIAddCarry = 149,
167 OpISubBorrow = 150,
168 OpUMulExtended = 151,
169 OpSMulExtended = 152,
170 OpAny = 154,
171 OpAll = 155,
172 OpIsNan = 156,
173 OpIsInf = 157,
174 OpIsFinite = 158,
175 OpIsNormal = 159,
176 OpSignBitSet = 160,
177 OpLessOrGreater = 161,
178 OpOrdered = 162,
179 OpUnordered = 163,
180 OpLogicalEqual = 164,
181 OpLogicalNotEqual = 165,
182 OpLogicalOr = 166,
183 OpLogicalAnd = 167,
184 OpLogicalNot = 168,
185 OpSelect = 169,
186 OpIEqual = 170,
187 OpINotEqual = 171,
188 OpUGreaterThan = 172,
189 OpSGreaterThan = 173,
190 OpUGreaterThanEqual = 174,
191 OpSGreaterThanEqual = 175,
192 OpULessThan = 176,
193 OpSLessThan = 177,
194 OpULessThanEqual = 178,
195 OpSLessThanEqual = 179,
196 OpFOrdEqual = 180,
197 OpFUnordEqual = 181,
198 OpFOrdNotEqual = 182,
199 OpFUnordNotEqual = 183,
200 OpFOrdLessThan = 184,
201 OpFUnordLessThan = 185,
202 OpFOrdGreaterThan = 186,
203 OpFUnordGreaterThan = 187,
204 OpFOrdLessThanEqual = 188,
205 OpFUnordLessThanEqual = 189,
206 OpFOrdGreaterThanEqual = 190,
207 OpFUnordGreaterThanEqual = 191,
208 OpShiftRightLogical = 194,
209 OpShiftRightArithmetic = 195,
210 OpShiftLeftLogical = 196,
211 OpBitwiseOr = 197,
212 OpBitwiseXor = 198,
213 OpBitwiseAnd = 199,
214 OpNot = 200,
215 OpBitFieldInsert = 201,
216 OpBitFieldSExtract = 202,
217 OpBitFieldUExtract = 203,
218 OpBitReverse = 204,
219 OpBitCount = 205,
220 OpDPdx = 207,
221 OpDPdy = 208,
222 OpFwidth = 209,
223 OpDPdxFine = 210,
224 OpDPdyFine = 211,
225 OpFwidthFine = 212,
226 OpDPdxCoarse = 213,
227 OpDPdyCoarse = 214,
228 OpFwidthCoarse = 215,
229 OpEmitVertex = 218,
230 OpEndPrimitive = 219,
231 OpEmitStreamVertex = 220,
232 OpEndStreamPrimitive = 221,
233 OpControlBarrier = 224,
234 OpMemoryBarrier = 225,
235 OpAtomicLoad = 227,
236 OpAtomicStore = 228,
237 OpAtomicExchange = 229,
238 OpAtomicCompareExchange = 230,
239 OpAtomicCompareExchangeWeak = 231,
240 OpAtomicIIncrement = 232,
241 OpAtomicIDecrement = 233,
242 OpAtomicIAdd = 234,
243 OpAtomicISub = 235,
244 OpAtomicSMin = 236,
245 OpAtomicUMin = 237,
246 OpAtomicSMax = 238,
247 OpAtomicUMax = 239,
248 OpAtomicAnd = 240,
249 OpAtomicOr = 241,
250 OpAtomicXor = 242,
251 OpPhi = 245,
252 OpLoopMerge = 246,
253 OpSelectionMerge = 247,
254 OpLabel = 248,
255 OpBranch = 249,
256 OpBranchConditional = 250,
257 OpSwitch = 251,
258 OpKill = 252,
259 OpReturn = 253,
260 OpReturnValue = 254,
261 OpUnreachable = 255,
262 OpLifetimeStart = 256,
263 OpLifetimeStop = 257,
264 OpGroupAsyncCopy = 259,
265 OpGroupWaitEvents = 260,
266 OpGroupAll = 261,
267 OpGroupAny = 262,
268 OpGroupBroadcast = 263,
269 OpGroupIAdd = 264,
270 OpGroupFAdd = 265,
271 OpGroupFMin = 266,
272 OpGroupUMin = 267,
273 OpGroupSMin = 268,
274 OpGroupFMax = 269,
275 OpGroupUMax = 270,
276 OpGroupSMax = 271,
277 OpReadPipe = 274,
278 OpWritePipe = 275,
279 OpReservedReadPipe = 276,
280 OpReservedWritePipe = 277,
281 OpReserveReadPipePackets = 278,
282 OpReserveWritePipePackets = 279,
283 OpCommitReadPipe = 280,
284 OpCommitWritePipe = 281,
285 OpIsValidReserveId = 282,
286 OpGetNumPipePackets = 283,
287 OpGetMaxPipePackets = 284,
288 OpGroupReserveReadPipePackets = 285,
289 OpGroupReserveWritePipePackets = 286,
290 OpGroupCommitReadPipe = 287,
291 OpGroupCommitWritePipe = 288,
292 OpEnqueueMarker = 291,
293 OpEnqueueKernel = 292,
294 OpGetKernelNDrangeSubGroupCount = 293,
295 OpGetKernelNDrangeMaxSubGroupSize = 294,
296 OpGetKernelWorkGroupSize = 295,
297 OpGetKernelPreferredWorkGroupSizeMultiple = 296,
298 OpRetainEvent = 297,
299 OpReleaseEvent = 298,
300 OpCreateUserEvent = 299,
301 OpIsValidEvent = 300,
302 OpSetUserEventStatus = 301,
303 OpCaptureEventProfilingInfo = 302,
304 OpGetDefaultQueue = 303,
305 OpBuildNDRange = 304,
306 OpImageSparseSampleImplicitLod = 305,
307 OpImageSparseSampleExplicitLod = 306,
308 OpImageSparseSampleDrefImplicitLod = 307,
309 OpImageSparseSampleDrefExplicitLod = 308,
310 OpImageSparseSampleProjImplicitLod = 309,
311 OpImageSparseSampleProjExplicitLod = 310,
312 OpImageSparseSampleProjDrefImplicitLod = 311,
313 OpImageSparseSampleProjDrefExplicitLod = 312,
314 OpImageSparseFetch = 313,
315 OpImageSparseGather = 314,
316 OpImageSparseDrefGather = 315,
317 OpImageSparseTexelsResident = 316,
318 OpNoLine = 317,
319 OpAtomicFlagTestAndSet = 318,
320 OpAtomicFlagClear = 319,
321 OpImageSparseRead = 320,
322 OpSizeOf = 321,
323 OpTypePipeStorage = 322,
324 OpConstantPipeStorage = 323,
325 OpCreatePipeFromPipeStorage = 324,
326 OpGetKernelLocalSizeForSubgroupCount = 325,
327 OpGetKernelMaxNumSubgroups = 326,
328 OpTypeNamedBarrier = 327,
329 OpNamedBarrierInitialize = 328,
330 OpMemoryNamedBarrier = 329,
331 OpModuleProcessed = 330,
332 OpExecutionModeId = 331,
333 OpDecorateId = 332,
334 OpGroupNonUniformElect = 333,
335 OpGroupNonUniformAll = 334,
336 OpGroupNonUniformAny = 335,
337 OpGroupNonUniformAllEqual = 336,
338 OpGroupNonUniformBroadcast = 337,
339 OpGroupNonUniformBroadcastFirst = 338,
340 OpGroupNonUniformBallot = 339,
341 OpGroupNonUniformInverseBallot = 340,
342 OpGroupNonUniformBallotBitExtract = 341,
343 OpGroupNonUniformBallotBitCount = 342,
344 OpGroupNonUniformBallotFindLSB = 343,
345 OpGroupNonUniformBallotFindMSB = 344,
346 OpGroupNonUniformShuffle = 345,
347 OpGroupNonUniformShuffleXor = 346,
348 OpGroupNonUniformShuffleUp = 347,
349 OpGroupNonUniformShuffleDown = 348,
350 OpGroupNonUniformIAdd = 349,
351 OpGroupNonUniformFAdd = 350,
352 OpGroupNonUniformIMul = 351,
353 OpGroupNonUniformFMul = 352,
354 OpGroupNonUniformSMin = 353,
355 OpGroupNonUniformUMin = 354,
356 OpGroupNonUniformFMin = 355,
357 OpGroupNonUniformSMax = 356,
358 OpGroupNonUniformUMax = 357,
359 OpGroupNonUniformFMax = 358,
360 OpGroupNonUniformBitwiseAnd = 359,
361 OpGroupNonUniformBitwiseOr = 360,
362 OpGroupNonUniformBitwiseXor = 361,
363 OpGroupNonUniformLogicalAnd = 362,
364 OpGroupNonUniformLogicalOr = 363,
365 OpGroupNonUniformLogicalXor = 364,
366 OpGroupNonUniformQuadBroadcast = 365,
367 OpGroupNonUniformQuadSwap = 366,
368 OpCopyLogical = 400,
369 OpPtrEqual = 401,
370 OpPtrNotEqual = 402,
371 OpPtrDiff = 403,
372 OpTerminateInvocation = 4416,
373 OpSubgroupBallotKHR = 4421,
374 OpSubgroupFirstInvocationKHR = 4422,
375 OpSubgroupAllKHR = 4428,
376 OpSubgroupAnyKHR = 4429,
377 OpSubgroupAllEqualKHR = 4430,
378 OpSubgroupReadInvocationKHR = 4432,
379 OpTraceRayKHR = 4445,
380 OpExecuteCallableKHR = 4446,
381 OpConvertUToAccelerationStructureKHR = 4447,
382 OpIgnoreIntersectionKHR = 4448,
383 OpTerminateRayKHR = 4449,
384 OpTypeRayQueryKHR = 4472,
385 OpRayQueryInitializeKHR = 4473,
386 OpRayQueryTerminateKHR = 4474,
387 OpRayQueryGenerateIntersectionKHR = 4475,
388 OpRayQueryConfirmIntersectionKHR = 4476,
389 OpRayQueryProceedKHR = 4477,
390 OpRayQueryGetIntersectionTypeKHR = 4479,
391 OpGroupIAddNonUniformAMD = 5000,
392 OpGroupFAddNonUniformAMD = 5001,
393 OpGroupFMinNonUniformAMD = 5002,
394 OpGroupUMinNonUniformAMD = 5003,
395 OpGroupSMinNonUniformAMD = 5004,
396 OpGroupFMaxNonUniformAMD = 5005,
397 OpGroupUMaxNonUniformAMD = 5006,
398 OpGroupSMaxNonUniformAMD = 5007,
399 OpFragmentMaskFetchAMD = 5011,
400 OpFragmentFetchAMD = 5012,
401 OpReadClockKHR = 5056,
402 OpImageSampleFootprintNV = 5283,
403 OpGroupNonUniformPartitionNV = 5296,
404 OpWritePackedPrimitiveIndices4x8NV = 5299,
405 OpReportIntersectionNV = 5334,
406 OpReportIntersectionKHR = 5334,
407 OpIgnoreIntersectionNV = 5335,
408 OpTerminateRayNV = 5336,
409 OpTraceNV = 5337,
410 OpTypeAccelerationStructureNV = 5341,
411 OpTypeAccelerationStructureKHR = 5341,
412 OpExecuteCallableNV = 5344,
413 OpTypeCooperativeMatrixNV = 5358,
414 OpCooperativeMatrixLoadNV = 5359,
415 OpCooperativeMatrixStoreNV = 5360,
416 OpCooperativeMatrixMulAddNV = 5361,
417 OpCooperativeMatrixLengthNV = 5362,
418 OpBeginInvocationInterlockEXT = 5364,
419 OpEndInvocationInterlockEXT = 5365,
420 OpDemoteToHelperInvocationEXT = 5380,
421 OpIsHelperInvocationEXT = 5381,
422 OpSubgroupShuffleINTEL = 5571,
423 OpSubgroupShuffleDownINTEL = 5572,
424 OpSubgroupShuffleUpINTEL = 5573,
425 OpSubgroupShuffleXorINTEL = 5574,
426 OpSubgroupBlockReadINTEL = 5575,
427 OpSubgroupBlockWriteINTEL = 5576,
428 OpSubgroupImageBlockReadINTEL = 5577,
429 OpSubgroupImageBlockWriteINTEL = 5578,
430 OpSubgroupImageMediaBlockReadINTEL = 5580,
431 OpSubgroupImageMediaBlockWriteINTEL = 5581,
432 OpUCountLeadingZerosINTEL = 5585,
433 OpUCountTrailingZerosINTEL = 5586,
434 OpAbsISubINTEL = 5587,
435 OpAbsUSubINTEL = 5588,
436 OpIAddSatINTEL = 5589,
437 OpUAddSatINTEL = 5590,
438 OpIAverageINTEL = 5591,
439 OpUAverageINTEL = 5592,
440 OpIAverageRoundedINTEL = 5593,
441 OpUAverageRoundedINTEL = 5594,
442 OpISubSatINTEL = 5595,
443 OpUSubSatINTEL = 5596,
444 OpIMul32x16INTEL = 5597,
445 OpUMul32x16INTEL = 5598,
446 OpFunctionPointerINTEL = 5600,
447 OpFunctionPointerCallINTEL = 5601,
448 OpDecorateString = 5632,
449 OpDecorateStringGOOGLE = 5632,
450 OpMemberDecorateString = 5633,
451 OpMemberDecorateStringGOOGLE = 5633,
452 OpVmeImageINTEL = 5699,
453 OpTypeVmeImageINTEL = 5700,
454 OpTypeAvcImePayloadINTEL = 5701,
455 OpTypeAvcRefPayloadINTEL = 5702,
456 OpTypeAvcSicPayloadINTEL = 5703,
457 OpTypeAvcMcePayloadINTEL = 5704,
458 OpTypeAvcMceResultINTEL = 5705,
459 OpTypeAvcImeResultINTEL = 5706,
460 OpTypeAvcImeResultSingleReferenceStreamoutINTEL = 5707,
461 OpTypeAvcImeResultDualReferenceStreamoutINTEL = 5708,
462 OpTypeAvcImeSingleReferenceStreaminINTEL = 5709,
463 OpTypeAvcImeDualReferenceStreaminINTEL = 5710,
464 OpTypeAvcRefResultINTEL = 5711,
465 OpTypeAvcSicResultINTEL = 5712,
466 OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL = 5713,
467 OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL = 5714,
468 OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL = 5715,
469 OpSubgroupAvcMceSetInterShapePenaltyINTEL = 5716,
470 OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL = 5717,
471 OpSubgroupAvcMceSetInterDirectionPenaltyINTEL = 5718,
472 OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL = 5719,
473 OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL = 5720,
474 OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL = 5721,
475 OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL = 5722,
476 OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL = 5723,
477 OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL = 5724,
478 OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL = 5725,
479 OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL = 5726,
480 OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL = 5727,
481 OpSubgroupAvcMceSetAcOnlyHaarINTEL = 5728,
482 OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL = 5729,
483 OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL = 5730,
484 OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL = 5731,
485 OpSubgroupAvcMceConvertToImePayloadINTEL = 5732,
486 OpSubgroupAvcMceConvertToImeResultINTEL = 5733,
487 OpSubgroupAvcMceConvertToRefPayloadINTEL = 5734,
488 OpSubgroupAvcMceConvertToRefResultINTEL = 5735,
489 OpSubgroupAvcMceConvertToSicPayloadINTEL = 5736,
490 OpSubgroupAvcMceConvertToSicResultINTEL = 5737,
491 OpSubgroupAvcMceGetMotionVectorsINTEL = 5738,
492 OpSubgroupAvcMceGetInterDistortionsINTEL = 5739,
493 OpSubgroupAvcMceGetBestInterDistortionsINTEL = 5740,
494 OpSubgroupAvcMceGetInterMajorShapeINTEL = 5741,
495 OpSubgroupAvcMceGetInterMinorShapeINTEL = 5742,
496 OpSubgroupAvcMceGetInterDirectionsINTEL = 5743,
497 OpSubgroupAvcMceGetInterMotionVectorCountINTEL = 5744,
498 OpSubgroupAvcMceGetInterReferenceIdsINTEL = 5745,
499 OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL = 5746,
500 OpSubgroupAvcImeInitializeINTEL = 5747,
501 OpSubgroupAvcImeSetSingleReferenceINTEL = 5748,
502 OpSubgroupAvcImeSetDualReferenceINTEL = 5749,
503 OpSubgroupAvcImeRefWindowSizeINTEL = 5750,
504 OpSubgroupAvcImeAdjustRefOffsetINTEL = 5751,
505 OpSubgroupAvcImeConvertToMcePayloadINTEL = 5752,
506 OpSubgroupAvcImeSetMaxMotionVectorCountINTEL = 5753,
507 OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL = 5754,
508 OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL = 5755,
509 OpSubgroupAvcImeSetWeightedSadINTEL = 5756,
510 OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL = 5757,
511 OpSubgroupAvcImeEvaluateWithDualReferenceINTEL = 5758,
512 OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL = 5759,
513 OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL = 5760,
514 OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL = 5761,
515 OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL = 5762,
516 OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL = 5763,
517 OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL = 5764,
518 OpSubgroupAvcImeConvertToMceResultINTEL = 5765,
519 OpSubgroupAvcImeGetSingleReferenceStreaminINTEL = 5766,
520 OpSubgroupAvcImeGetDualReferenceStreaminINTEL = 5767,
521 OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL = 5768,
522 OpSubgroupAvcImeStripDualReferenceStreamoutINTEL = 5769,
523 OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL = 5770,
524 OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL = 5771,
525 OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL = 5772,
526 OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL = 5773,
527 OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL = 5774,
528 OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL = 5775,
529 OpSubgroupAvcImeGetBorderReachedINTEL = 5776,
530 OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL = 5777,
531 OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL = 5778,
532 OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL = 5779,
533 OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL = 5780,
534 OpSubgroupAvcFmeInitializeINTEL = 5781,
535 OpSubgroupAvcBmeInitializeINTEL = 5782,
536 OpSubgroupAvcRefConvertToMcePayloadINTEL = 5783,
537 OpSubgroupAvcRefSetBidirectionalMixDisableINTEL = 5784,
538 OpSubgroupAvcRefSetBilinearFilterEnableINTEL = 5785,
539 OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL = 5786,
540 OpSubgroupAvcRefEvaluateWithDualReferenceINTEL = 5787,
541 OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL = 5788,
542 OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL = 5789,
543 OpSubgroupAvcRefConvertToMceResultINTEL = 5790,
544 OpSubgroupAvcSicInitializeINTEL = 5791,
545 OpSubgroupAvcSicConfigureSkcINTEL = 5792,
546 OpSubgroupAvcSicConfigureIpeLumaINTEL = 5793,
547 OpSubgroupAvcSicConfigureIpeLumaChromaINTEL = 5794,
548 OpSubgroupAvcSicGetMotionVectorMaskINTEL = 5795,
549 OpSubgroupAvcSicConvertToMcePayloadINTEL = 5796,
550 OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL = 5797,
551 OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL = 5798,
552 OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL = 5799,
553 OpSubgroupAvcSicSetBilinearFilterEnableINTEL = 5800,
554 OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL = 5801,
555 OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL = 5802,
556 OpSubgroupAvcSicEvaluateIpeINTEL = 5803,
557 OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL = 5804,
558 OpSubgroupAvcSicEvaluateWithDualReferenceINTEL = 5805,
559 OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL = 5806,
560 OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL = 5807,
561 OpSubgroupAvcSicConvertToMceResultINTEL = 5808,
562 OpSubgroupAvcSicGetIpeLumaShapeINTEL = 5809,
563 OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL = 5810,
564 OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL = 5811,
565 OpSubgroupAvcSicGetPackedIpeLumaModesINTEL = 5812,
566 OpSubgroupAvcSicGetIpeChromaModeINTEL = 5813,
567 OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL = 5814,
568 OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL = 5815,
569 OpSubgroupAvcSicGetInterRawSadsINTEL = 5816,
570 OpLoopControlINTEL = 5887,
571 OpReadPipeBlockingINTEL = 5946,
572 OpWritePipeBlockingINTEL = 5947,
573 OpFPGARegINTEL = 5949,
574 OpRayQueryGetRayTMinKHR = 6016,
575 OpRayQueryGetRayFlagsKHR = 6017,
576 OpRayQueryGetIntersectionTKHR = 6018,
577 OpRayQueryGetIntersectionInstanceCustomIndexKHR = 6019,
578 OpRayQueryGetIntersectionInstanceIdKHR = 6020,
579 OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR = 6021,
580 OpRayQueryGetIntersectionGeometryIndexKHR = 6022,
581 OpRayQueryGetIntersectionPrimitiveIndexKHR = 6023,
582 OpRayQueryGetIntersectionBarycentricsKHR = 6024,
583 OpRayQueryGetIntersectionFrontFaceKHR = 6025,
584 OpRayQueryGetIntersectionCandidateAABBOpaqueKHR = 6026,
585 OpRayQueryGetIntersectionObjectRayDirectionKHR = 6027,
586 OpRayQueryGetIntersectionObjectRayOriginKHR = 6028,
587 OpRayQueryGetWorldRayDirectionKHR = 6029,
588 OpRayQueryGetWorldRayOriginKHR = 6030,
589 OpRayQueryGetIntersectionObjectToWorldKHR = 6031,
590 OpRayQueryGetIntersectionWorldToObjectKHR = 6032,
591 OpAtomicFAddEXT = 6035,
592 _,
593};
594pub const ImageOperands = packed struct {
595 Bias: bool align(@alignOf(u32)) = false,
596 Lod: bool = false,
597 Grad: bool = false,
598 ConstOffset: bool = false,
599 Offset: bool = false,
600 ConstOffsets: bool = false,
601 Sample: bool = false,
602 MinLod: bool = false,
603 MakeTexelAvailable: bool = false,
604 MakeTexelVisible: bool = false,
605 NonPrivateTexel: bool = false,
606 VolatileTexel: bool = false,
607 SignExtend: bool = false,
608 ZeroExtend: bool = false,
609 _reserved_bit_14: bool = false,
610 _reserved_bit_15: bool = false,
611 _reserved_bit_16: bool = false,
612 _reserved_bit_17: bool = false,
613 _reserved_bit_18: bool = false,
614 _reserved_bit_19: bool = false,
615 _reserved_bit_20: bool = false,
616 _reserved_bit_21: bool = false,
617 _reserved_bit_22: bool = false,
618 _reserved_bit_23: bool = false,
619 _reserved_bit_24: bool = false,
620 _reserved_bit_25: bool = false,
621 _reserved_bit_26: bool = false,
622 _reserved_bit_27: bool = false,
623 _reserved_bit_28: bool = false,
624 _reserved_bit_29: bool = false,
625 _reserved_bit_30: bool = false,
626 _reserved_bit_31: bool = false,
627};
628pub const FPFastMathMode = packed struct {
629 NotNaN: bool align(@alignOf(u32)) = false,
630 NotInf: bool = false,
631 NSZ: bool = false,
632 AllowRecip: bool = false,
633 Fast: bool = false,
634 _reserved_bit_5: bool = false,
635 _reserved_bit_6: bool = false,
636 _reserved_bit_7: bool = false,
637 _reserved_bit_8: bool = false,
638 _reserved_bit_9: bool = false,
639 _reserved_bit_10: bool = false,
640 _reserved_bit_11: bool = false,
641 _reserved_bit_12: bool = false,
642 _reserved_bit_13: bool = false,
643 _reserved_bit_14: bool = false,
644 _reserved_bit_15: bool = false,
645 _reserved_bit_16: bool = false,
646 _reserved_bit_17: bool = false,
647 _reserved_bit_18: bool = false,
648 _reserved_bit_19: bool = false,
649 _reserved_bit_20: bool = false,
650 _reserved_bit_21: bool = false,
651 _reserved_bit_22: bool = false,
652 _reserved_bit_23: bool = false,
653 _reserved_bit_24: bool = false,
654 _reserved_bit_25: bool = false,
655 _reserved_bit_26: bool = false,
656 _reserved_bit_27: bool = false,
657 _reserved_bit_28: bool = false,
658 _reserved_bit_29: bool = false,
659 _reserved_bit_30: bool = false,
660 _reserved_bit_31: bool = false,
661};
662pub const SelectionControl = packed struct {
663 Flatten: bool align(@alignOf(u32)) = false,
664 DontFlatten: bool = false,
665 _reserved_bit_2: bool = false,
666 _reserved_bit_3: bool = false,
667 _reserved_bit_4: bool = false,
668 _reserved_bit_5: bool = false,
669 _reserved_bit_6: bool = false,
670 _reserved_bit_7: bool = false,
671 _reserved_bit_8: bool = false,
672 _reserved_bit_9: bool = false,
673 _reserved_bit_10: bool = false,
674 _reserved_bit_11: bool = false,
675 _reserved_bit_12: bool = false,
676 _reserved_bit_13: bool = false,
677 _reserved_bit_14: bool = false,
678 _reserved_bit_15: bool = false,
679 _reserved_bit_16: bool = false,
680 _reserved_bit_17: bool = false,
681 _reserved_bit_18: bool = false,
682 _reserved_bit_19: bool = false,
683 _reserved_bit_20: bool = false,
684 _reserved_bit_21: bool = false,
685 _reserved_bit_22: bool = false,
686 _reserved_bit_23: bool = false,
687 _reserved_bit_24: bool = false,
688 _reserved_bit_25: bool = false,
689 _reserved_bit_26: bool = false,
690 _reserved_bit_27: bool = false,
691 _reserved_bit_28: bool = false,
692 _reserved_bit_29: bool = false,
693 _reserved_bit_30: bool = false,
694 _reserved_bit_31: bool = false,
695};
696pub const LoopControl = packed struct {
697 Unroll: bool align(@alignOf(u32)) = false,
698 DontUnroll: bool = false,
699 DependencyInfinite: bool = false,
700 DependencyLength: bool = false,
701 MinIterations: bool = false,
702 MaxIterations: bool = false,
703 IterationMultiple: bool = false,
704 PeelCount: bool = false,
705 PartialCount: bool = false,
706 _reserved_bit_9: bool = false,
707 _reserved_bit_10: bool = false,
708 _reserved_bit_11: bool = false,
709 _reserved_bit_12: bool = false,
710 _reserved_bit_13: bool = false,
711 _reserved_bit_14: bool = false,
712 _reserved_bit_15: bool = false,
713 InitiationIntervalINTEL: bool = false,
714 MaxConcurrencyINTEL: bool = false,
715 DependencyArrayINTEL: bool = false,
716 PipelineEnableINTEL: bool = false,
717 LoopCoalesceINTEL: bool = false,
718 MaxInterleavingINTEL: bool = false,
719 SpeculatedIterationsINTEL: bool = false,
720 _reserved_bit_23: bool = false,
721 _reserved_bit_24: bool = false,
722 _reserved_bit_25: bool = false,
723 _reserved_bit_26: bool = false,
724 _reserved_bit_27: bool = false,
725 _reserved_bit_28: bool = false,
726 _reserved_bit_29: bool = false,
727 _reserved_bit_30: bool = false,
728 _reserved_bit_31: bool = false,
729};
730pub const FunctionControl = packed struct {
731 Inline: bool align(@alignOf(u32)) = false,
732 DontInline: bool = false,
733 Pure: bool = false,
734 Const: bool = false,
735 _reserved_bit_4: bool = false,
736 _reserved_bit_5: bool = false,
737 _reserved_bit_6: bool = false,
738 _reserved_bit_7: bool = false,
739 _reserved_bit_8: bool = false,
740 _reserved_bit_9: bool = false,
741 _reserved_bit_10: bool = false,
742 _reserved_bit_11: bool = false,
743 _reserved_bit_12: bool = false,
744 _reserved_bit_13: bool = false,
745 _reserved_bit_14: bool = false,
746 _reserved_bit_15: bool = false,
747 _reserved_bit_16: bool = false,
748 _reserved_bit_17: bool = false,
749 _reserved_bit_18: bool = false,
750 _reserved_bit_19: bool = false,
751 _reserved_bit_20: bool = false,
752 _reserved_bit_21: bool = false,
753 _reserved_bit_22: bool = false,
754 _reserved_bit_23: bool = false,
755 _reserved_bit_24: bool = false,
756 _reserved_bit_25: bool = false,
757 _reserved_bit_26: bool = false,
758 _reserved_bit_27: bool = false,
759 _reserved_bit_28: bool = false,
760 _reserved_bit_29: bool = false,
761 _reserved_bit_30: bool = false,
762 _reserved_bit_31: bool = false,
763};
764pub const MemorySemantics = packed struct {
765 _reserved_bit_0: bool align(@alignOf(u32)) = false,
766 Acquire: bool = false,
767 Release: bool = false,
768 AcquireRelease: bool = false,
769 SequentiallyConsistent: bool = false,
770 _reserved_bit_5: bool = false,
771 UniformMemory: bool = false,
772 SubgroupMemory: bool = false,
773 WorkgroupMemory: bool = false,
774 CrossWorkgroupMemory: bool = false,
775 AtomicCounterMemory: bool = false,
776 ImageMemory: bool = false,
777 OutputMemory: bool = false,
778 MakeAvailable: bool = false,
779 MakeVisible: bool = false,
780 Volatile: bool = false,
781 _reserved_bit_16: bool = false,
782 _reserved_bit_17: bool = false,
783 _reserved_bit_18: bool = false,
784 _reserved_bit_19: bool = false,
785 _reserved_bit_20: bool = false,
786 _reserved_bit_21: bool = false,
787 _reserved_bit_22: bool = false,
788 _reserved_bit_23: bool = false,
789 _reserved_bit_24: bool = false,
790 _reserved_bit_25: bool = false,
791 _reserved_bit_26: bool = false,
792 _reserved_bit_27: bool = false,
793 _reserved_bit_28: bool = false,
794 _reserved_bit_29: bool = false,
795 _reserved_bit_30: bool = false,
796 _reserved_bit_31: bool = false,
797};
798pub const MemoryAccess = packed struct {
799 Volatile: bool align(@alignOf(u32)) = false,
800 Aligned: bool = false,
801 Nontemporal: bool = false,
802 MakePointerAvailable: bool = false,
803 MakePointerVisible: bool = false,
804 NonPrivatePointer: bool = false,
805 _reserved_bit_6: bool = false,
806 _reserved_bit_7: bool = false,
807 _reserved_bit_8: bool = false,
808 _reserved_bit_9: bool = false,
809 _reserved_bit_10: bool = false,
810 _reserved_bit_11: bool = false,
811 _reserved_bit_12: bool = false,
812 _reserved_bit_13: bool = false,
813 _reserved_bit_14: bool = false,
814 _reserved_bit_15: bool = false,
815 _reserved_bit_16: bool = false,
816 _reserved_bit_17: bool = false,
817 _reserved_bit_18: bool = false,
818 _reserved_bit_19: bool = false,
819 _reserved_bit_20: bool = false,
820 _reserved_bit_21: bool = false,
821 _reserved_bit_22: bool = false,
822 _reserved_bit_23: bool = false,
823 _reserved_bit_24: bool = false,
824 _reserved_bit_25: bool = false,
825 _reserved_bit_26: bool = false,
826 _reserved_bit_27: bool = false,
827 _reserved_bit_28: bool = false,
828 _reserved_bit_29: bool = false,
829 _reserved_bit_30: bool = false,
830 _reserved_bit_31: bool = false,
831};
832pub const KernelProfilingInfo = packed struct {
833 CmdExecTime: bool align(@alignOf(u32)) = false,
834 _reserved_bit_1: bool = false,
835 _reserved_bit_2: bool = false,
836 _reserved_bit_3: bool = false,
837 _reserved_bit_4: bool = false,
838 _reserved_bit_5: bool = false,
839 _reserved_bit_6: bool = false,
840 _reserved_bit_7: bool = false,
841 _reserved_bit_8: bool = false,
842 _reserved_bit_9: bool = false,
843 _reserved_bit_10: bool = false,
844 _reserved_bit_11: bool = false,
845 _reserved_bit_12: bool = false,
846 _reserved_bit_13: bool = false,
847 _reserved_bit_14: bool = false,
848 _reserved_bit_15: bool = false,
849 _reserved_bit_16: bool = false,
850 _reserved_bit_17: bool = false,
851 _reserved_bit_18: bool = false,
852 _reserved_bit_19: bool = false,
853 _reserved_bit_20: bool = false,
854 _reserved_bit_21: bool = false,
855 _reserved_bit_22: bool = false,
856 _reserved_bit_23: bool = false,
857 _reserved_bit_24: bool = false,
858 _reserved_bit_25: bool = false,
859 _reserved_bit_26: bool = false,
860 _reserved_bit_27: bool = false,
861 _reserved_bit_28: bool = false,
862 _reserved_bit_29: bool = false,
863 _reserved_bit_30: bool = false,
864 _reserved_bit_31: bool = false,
865};
866pub const RayFlags = packed struct {
867 OpaqueKHR: bool align(@alignOf(u32)) = false,
868 NoOpaqueKHR: bool = false,
869 TerminateOnFirstHitKHR: bool = false,
870 SkipClosestHitShaderKHR: bool = false,
871 CullBackFacingTrianglesKHR: bool = false,
872 CullFrontFacingTrianglesKHR: bool = false,
873 CullOpaqueKHR: bool = false,
874 CullNoOpaqueKHR: bool = false,
875 SkipTrianglesKHR: bool = false,
876 SkipAABBsKHR: bool = false,
877 _reserved_bit_10: bool = false,
878 _reserved_bit_11: bool = false,
879 _reserved_bit_12: bool = false,
880 _reserved_bit_13: bool = false,
881 _reserved_bit_14: bool = false,
882 _reserved_bit_15: bool = false,
883 _reserved_bit_16: bool = false,
884 _reserved_bit_17: bool = false,
885 _reserved_bit_18: bool = false,
886 _reserved_bit_19: bool = false,
887 _reserved_bit_20: bool = false,
888 _reserved_bit_21: bool = false,
889 _reserved_bit_22: bool = false,
890 _reserved_bit_23: bool = false,
891 _reserved_bit_24: bool = false,
892 _reserved_bit_25: bool = false,
893 _reserved_bit_26: bool = false,
894 _reserved_bit_27: bool = false,
895 _reserved_bit_28: bool = false,
896 _reserved_bit_29: bool = false,
897 _reserved_bit_30: bool = false,
898 _reserved_bit_31: bool = false,
899};
900pub const FragmentShadingRate = packed struct {
901 Vertical2Pixels: bool align(@alignOf(u32)) = false,
902 Vertical4Pixels: bool = false,
903 Horizontal2Pixels: bool = false,
904 Horizontal4Pixels: bool = false,
905 _reserved_bit_4: bool = false,
906 _reserved_bit_5: bool = false,
907 _reserved_bit_6: bool = false,
908 _reserved_bit_7: bool = false,
909 _reserved_bit_8: bool = false,
910 _reserved_bit_9: bool = false,
911 _reserved_bit_10: bool = false,
912 _reserved_bit_11: bool = false,
913 _reserved_bit_12: bool = false,
914 _reserved_bit_13: bool = false,
915 _reserved_bit_14: bool = false,
916 _reserved_bit_15: bool = false,
917 _reserved_bit_16: bool = false,
918 _reserved_bit_17: bool = false,
919 _reserved_bit_18: bool = false,
920 _reserved_bit_19: bool = false,
921 _reserved_bit_20: bool = false,
922 _reserved_bit_21: bool = false,
923 _reserved_bit_22: bool = false,
924 _reserved_bit_23: bool = false,
925 _reserved_bit_24: bool = false,
926 _reserved_bit_25: bool = false,
927 _reserved_bit_26: bool = false,
928 _reserved_bit_27: bool = false,
929 _reserved_bit_28: bool = false,
930 _reserved_bit_29: bool = false,
931 _reserved_bit_30: bool = false,
932 _reserved_bit_31: bool = false,
933};
934pub const SourceLanguage = extern enum(u32) {
935 Unknown = 0,
936 ESSL = 1,
937 GLSL = 2,
938 OpenCL_C = 3,
939 OpenCL_CPP = 4,
940 HLSL = 5,
941 _,
942};
943pub const ExecutionModel = extern enum(u32) {
944 Vertex = 0,
945 TessellationControl = 1,
946 TessellationEvaluation = 2,
947 Geometry = 3,
948 Fragment = 4,
949 GLCompute = 5,
950 Kernel = 6,
951 TaskNV = 5267,
952 MeshNV = 5268,
953 RayGenerationNV = 5313,
954 RayGenerationKHR = 5313,
955 IntersectionNV = 5314,
956 IntersectionKHR = 5314,
957 AnyHitNV = 5315,
958 AnyHitKHR = 5315,
959 ClosestHitNV = 5316,
960 ClosestHitKHR = 5316,
961 MissNV = 5317,
962 MissKHR = 5317,
963 CallableNV = 5318,
964 CallableKHR = 5318,
965 _,
966};
967pub const AddressingModel = extern enum(u32) {
968 Logical = 0,
969 Physical32 = 1,
970 Physical64 = 2,
971 PhysicalStorageBuffer64 = 5348,
972 PhysicalStorageBuffer64EXT = 5348,
973 _,
974};
975pub const MemoryModel = extern enum(u32) {
976 Simple = 0,
977 GLSL450 = 1,
978 OpenCL = 2,
979 Vulkan = 3,
980 VulkanKHR = 3,
981 _,
982};
983pub const ExecutionMode = extern enum(u32) {
984 Invocations = 0,
985 SpacingEqual = 1,
986 SpacingFractionalEven = 2,
987 SpacingFractionalOdd = 3,
988 VertexOrderCw = 4,
989 VertexOrderCcw = 5,
990 PixelCenterInteger = 6,
991 OriginUpperLeft = 7,
992 OriginLowerLeft = 8,
993 EarlyFragmentTests = 9,
994 PointMode = 10,
995 Xfb = 11,
996 DepthReplacing = 12,
997 DepthGreater = 14,
998 DepthLess = 15,
999 DepthUnchanged = 16,
1000 LocalSize = 17,
1001 LocalSizeHint = 18,
1002 InputPoints = 19,
1003 InputLines = 20,
1004 InputLinesAdjacency = 21,
1005 Triangles = 22,
1006 InputTrianglesAdjacency = 23,
1007 Quads = 24,
1008 Isolines = 25,
1009 OutputVertices = 26,
1010 OutputPoints = 27,
1011 OutputLineStrip = 28,
1012 OutputTriangleStrip = 29,
1013 VecTypeHint = 30,
1014 ContractionOff = 31,
1015 Initializer = 33,
1016 Finalizer = 34,
1017 SubgroupSize = 35,
1018 SubgroupsPerWorkgroup = 36,
1019 SubgroupsPerWorkgroupId = 37,
1020 LocalSizeId = 38,
1021 LocalSizeHintId = 39,
1022 PostDepthCoverage = 4446,
1023 DenormPreserve = 4459,
1024 DenormFlushToZero = 4460,
1025 SignedZeroInfNanPreserve = 4461,
1026 RoundingModeRTE = 4462,
1027 RoundingModeRTZ = 4463,
1028 StencilRefReplacingEXT = 5027,
1029 OutputLinesNV = 5269,
1030 OutputPrimitivesNV = 5270,
1031 DerivativeGroupQuadsNV = 5289,
1032 DerivativeGroupLinearNV = 5290,
1033 OutputTrianglesNV = 5298,
1034 PixelInterlockOrderedEXT = 5366,
1035 PixelInterlockUnorderedEXT = 5367,
1036 SampleInterlockOrderedEXT = 5368,
1037 SampleInterlockUnorderedEXT = 5369,
1038 ShadingRateInterlockOrderedEXT = 5370,
1039 ShadingRateInterlockUnorderedEXT = 5371,
1040 MaxWorkgroupSizeINTEL = 5893,
1041 MaxWorkDimINTEL = 5894,
1042 NoGlobalOffsetINTEL = 5895,
1043 NumSIMDWorkitemsINTEL = 5896,
1044 _,
1045};
1046pub const StorageClass = extern enum(u32) {
1047 UniformConstant = 0,
1048 Input = 1,
1049 Uniform = 2,
1050 Output = 3,
1051 Workgroup = 4,
1052 CrossWorkgroup = 5,
1053 Private = 6,
1054 Function = 7,
1055 Generic = 8,
1056 PushConstant = 9,
1057 AtomicCounter = 10,
1058 Image = 11,
1059 StorageBuffer = 12,
1060 CallableDataNV = 5328,
1061 CallableDataKHR = 5328,
1062 IncomingCallableDataNV = 5329,
1063 IncomingCallableDataKHR = 5329,
1064 RayPayloadNV = 5338,
1065 RayPayloadKHR = 5338,
1066 HitAttributeNV = 5339,
1067 HitAttributeKHR = 5339,
1068 IncomingRayPayloadNV = 5342,
1069 IncomingRayPayloadKHR = 5342,
1070 ShaderRecordBufferNV = 5343,
1071 ShaderRecordBufferKHR = 5343,
1072 PhysicalStorageBuffer = 5349,
1073 PhysicalStorageBufferEXT = 5349,
1074 CodeSectionINTEL = 5605,
1075 _,
1076};
1077pub const Dim = extern enum(u32) {
1078 @"1D" = 0,
1079 @"2D" = 1,
1080 @"3D" = 2,
1081 Cube = 3,
1082 Rect = 4,
1083 Buffer = 5,
1084 SubpassData = 6,
1085 _,
1086};
1087pub const SamplerAddressingMode = extern enum(u32) {
1088 None = 0,
1089 ClampToEdge = 1,
1090 Clamp = 2,
1091 Repeat = 3,
1092 RepeatMirrored = 4,
1093 _,
1094};
1095pub const SamplerFilterMode = extern enum(u32) {
1096 Nearest = 0,
1097 Linear = 1,
1098 _,
1099};
1100pub const ImageFormat = extern enum(u32) {
1101 Unknown = 0,
1102 Rgba32f = 1,
1103 Rgba16f = 2,
1104 R32f = 3,
1105 Rgba8 = 4,
1106 Rgba8Snorm = 5,
1107 Rg32f = 6,
1108 Rg16f = 7,
1109 R11fG11fB10f = 8,
1110 R16f = 9,
1111 Rgba16 = 10,
1112 Rgb10A2 = 11,
1113 Rg16 = 12,
1114 Rg8 = 13,
1115 R16 = 14,
1116 R8 = 15,
1117 Rgba16Snorm = 16,
1118 Rg16Snorm = 17,
1119 Rg8Snorm = 18,
1120 R16Snorm = 19,
1121 R8Snorm = 20,
1122 Rgba32i = 21,
1123 Rgba16i = 22,
1124 Rgba8i = 23,
1125 R32i = 24,
1126 Rg32i = 25,
1127 Rg16i = 26,
1128 Rg8i = 27,
1129 R16i = 28,
1130 R8i = 29,
1131 Rgba32ui = 30,
1132 Rgba16ui = 31,
1133 Rgba8ui = 32,
1134 R32ui = 33,
1135 Rgb10a2ui = 34,
1136 Rg32ui = 35,
1137 Rg16ui = 36,
1138 Rg8ui = 37,
1139 R16ui = 38,
1140 R8ui = 39,
1141 R64ui = 40,
1142 R64i = 41,
1143 _,
1144};
1145pub const ImageChannelOrder = extern enum(u32) {
1146 R = 0,
1147 A = 1,
1148 RG = 2,
1149 RA = 3,
1150 RGB = 4,
1151 RGBA = 5,
1152 BGRA = 6,
1153 ARGB = 7,
1154 Intensity = 8,
1155 Luminance = 9,
1156 Rx = 10,
1157 RGx = 11,
1158 RGBx = 12,
1159 Depth = 13,
1160 DepthStencil = 14,
1161 sRGB = 15,
1162 sRGBx = 16,
1163 sRGBA = 17,
1164 sBGRA = 18,
1165 ABGR = 19,
1166 _,
1167};
1168pub const ImageChannelDataType = extern enum(u32) {
1169 SnormInt8 = 0,
1170 SnormInt16 = 1,
1171 UnormInt8 = 2,
1172 UnormInt16 = 3,
1173 UnormShort565 = 4,
1174 UnormShort555 = 5,
1175 UnormInt101010 = 6,
1176 SignedInt8 = 7,
1177 SignedInt16 = 8,
1178 SignedInt32 = 9,
1179 UnsignedInt8 = 10,
1180 UnsignedInt16 = 11,
1181 UnsignedInt32 = 12,
1182 HalfFloat = 13,
1183 Float = 14,
1184 UnormInt24 = 15,
1185 UnormInt101010_2 = 16,
1186 _,
1187};
1188pub const FPRoundingMode = extern enum(u32) {
1189 RTE = 0,
1190 RTZ = 1,
1191 RTP = 2,
1192 RTN = 3,
1193 _,
1194};
1195pub const LinkageType = extern enum(u32) {
1196 Export = 0,
1197 Import = 1,
1198 _,
1199};
1200pub const AccessQualifier = extern enum(u32) {
1201 ReadOnly = 0,
1202 WriteOnly = 1,
1203 ReadWrite = 2,
1204 _,
1205};
1206pub const FunctionParameterAttribute = extern enum(u32) {
1207 Zext = 0,
1208 Sext = 1,
1209 ByVal = 2,
1210 Sret = 3,
1211 NoAlias = 4,
1212 NoCapture = 5,
1213 NoWrite = 6,
1214 NoReadWrite = 7,
1215 _,
1216};
1217pub const Decoration = extern enum(u32) {
1218 RelaxedPrecision = 0,
1219 SpecId = 1,
1220 Block = 2,
1221 BufferBlock = 3,
1222 RowMajor = 4,
1223 ColMajor = 5,
1224 ArrayStride = 6,
1225 MatrixStride = 7,
1226 GLSLShared = 8,
1227 GLSLPacked = 9,
1228 CPacked = 10,
1229 BuiltIn = 11,
1230 NoPerspective = 13,
1231 Flat = 14,
1232 Patch = 15,
1233 Centroid = 16,
1234 Sample = 17,
1235 Invariant = 18,
1236 Restrict = 19,
1237 Aliased = 20,
1238 Volatile = 21,
1239 Constant = 22,
1240 Coherent = 23,
1241 NonWritable = 24,
1242 NonReadable = 25,
1243 Uniform = 26,
1244 UniformId = 27,
1245 SaturatedConversion = 28,
1246 Stream = 29,
1247 Location = 30,
1248 Component = 31,
1249 Index = 32,
1250 Binding = 33,
1251 DescriptorSet = 34,
1252 Offset = 35,
1253 XfbBuffer = 36,
1254 XfbStride = 37,
1255 FuncParamAttr = 38,
1256 FPRoundingMode = 39,
1257 FPFastMathMode = 40,
1258 LinkageAttributes = 41,
1259 NoContraction = 42,
1260 InputAttachmentIndex = 43,
1261 Alignment = 44,
1262 MaxByteOffset = 45,
1263 AlignmentId = 46,
1264 MaxByteOffsetId = 47,
1265 NoSignedWrap = 4469,
1266 NoUnsignedWrap = 4470,
1267 ExplicitInterpAMD = 4999,
1268 OverrideCoverageNV = 5248,
1269 PassthroughNV = 5250,
1270 ViewportRelativeNV = 5252,
1271 SecondaryViewportRelativeNV = 5256,
1272 PerPrimitiveNV = 5271,
1273 PerViewNV = 5272,
1274 PerTaskNV = 5273,
1275 PerVertexNV = 5285,
1276 NonUniform = 5300,
1277 NonUniformEXT = 5300,
1278 RestrictPointer = 5355,
1279 RestrictPointerEXT = 5355,
1280 AliasedPointer = 5356,
1281 AliasedPointerEXT = 5356,
1282 ReferencedIndirectlyINTEL = 5602,
1283 CounterBuffer = 5634,
1284 HlslCounterBufferGOOGLE = 5634,
1285 UserSemantic = 5635,
1286 HlslSemanticGOOGLE = 5635,
1287 UserTypeGOOGLE = 5636,
1288 RegisterINTEL = 5825,
1289 MemoryINTEL = 5826,
1290 NumbanksINTEL = 5827,
1291 BankwidthINTEL = 5828,
1292 MaxPrivateCopiesINTEL = 5829,
1293 SinglepumpINTEL = 5830,
1294 DoublepumpINTEL = 5831,
1295 MaxReplicatesINTEL = 5832,
1296 SimpleDualPortINTEL = 5833,
1297 MergeINTEL = 5834,
1298 BankBitsINTEL = 5835,
1299 ForcePow2DepthINTEL = 5836,
1300 _,
1301};
1302pub const BuiltIn = extern enum(u32) {
1303 Position = 0,
1304 PointSize = 1,
1305 ClipDistance = 3,
1306 CullDistance = 4,
1307 VertexId = 5,
1308 InstanceId = 6,
1309 PrimitiveId = 7,
1310 InvocationId = 8,
1311 Layer = 9,
1312 ViewportIndex = 10,
1313 TessLevelOuter = 11,
1314 TessLevelInner = 12,
1315 TessCoord = 13,
1316 PatchVertices = 14,
1317 FragCoord = 15,
1318 PointCoord = 16,
1319 FrontFacing = 17,
1320 SampleId = 18,
1321 SamplePosition = 19,
1322 SampleMask = 20,
1323 FragDepth = 22,
1324 HelperInvocation = 23,
1325 NumWorkgroups = 24,
1326 WorkgroupSize = 25,
1327 WorkgroupId = 26,
1328 LocalInvocationId = 27,
1329 GlobalInvocationId = 28,
1330 LocalInvocationIndex = 29,
1331 WorkDim = 30,
1332 GlobalSize = 31,
1333 EnqueuedWorkgroupSize = 32,
1334 GlobalOffset = 33,
1335 GlobalLinearId = 34,
1336 SubgroupSize = 36,
1337 SubgroupMaxSize = 37,
1338 NumSubgroups = 38,
1339 NumEnqueuedSubgroups = 39,
1340 SubgroupId = 40,
1341 SubgroupLocalInvocationId = 41,
1342 VertexIndex = 42,
1343 InstanceIndex = 43,
1344 SubgroupEqMask = 4416,
1345 SubgroupGeMask = 4417,
1346 SubgroupGtMask = 4418,
1347 SubgroupLeMask = 4419,
1348 SubgroupLtMask = 4420,
1349 SubgroupEqMaskKHR = 4416,
1350 SubgroupGeMaskKHR = 4417,
1351 SubgroupGtMaskKHR = 4418,
1352 SubgroupLeMaskKHR = 4419,
1353 SubgroupLtMaskKHR = 4420,
1354 BaseVertex = 4424,
1355 BaseInstance = 4425,
1356 DrawIndex = 4426,
1357 PrimitiveShadingRateKHR = 4432,
1358 DeviceIndex = 4438,
1359 ViewIndex = 4440,
1360 ShadingRateKHR = 4444,
1361 BaryCoordNoPerspAMD = 4992,
1362 BaryCoordNoPerspCentroidAMD = 4993,
1363 BaryCoordNoPerspSampleAMD = 4994,
1364 BaryCoordSmoothAMD = 4995,
1365 BaryCoordSmoothCentroidAMD = 4996,
1366 BaryCoordSmoothSampleAMD = 4997,
1367 BaryCoordPullModelAMD = 4998,
1368 FragStencilRefEXT = 5014,
1369 ViewportMaskNV = 5253,
1370 SecondaryPositionNV = 5257,
1371 SecondaryViewportMaskNV = 5258,
1372 PositionPerViewNV = 5261,
1373 ViewportMaskPerViewNV = 5262,
1374 FullyCoveredEXT = 5264,
1375 TaskCountNV = 5274,
1376 PrimitiveCountNV = 5275,
1377 PrimitiveIndicesNV = 5276,
1378 ClipDistancePerViewNV = 5277,
1379 CullDistancePerViewNV = 5278,
1380 LayerPerViewNV = 5279,
1381 MeshViewCountNV = 5280,
1382 MeshViewIndicesNV = 5281,
1383 BaryCoordNV = 5286,
1384 BaryCoordNoPerspNV = 5287,
1385 FragSizeEXT = 5292,
1386 FragmentSizeNV = 5292,
1387 FragInvocationCountEXT = 5293,
1388 InvocationsPerPixelNV = 5293,
1389 LaunchIdNV = 5319,
1390 LaunchIdKHR = 5319,
1391 LaunchSizeNV = 5320,
1392 LaunchSizeKHR = 5320,
1393 WorldRayOriginNV = 5321,
1394 WorldRayOriginKHR = 5321,
1395 WorldRayDirectionNV = 5322,
1396 WorldRayDirectionKHR = 5322,
1397 ObjectRayOriginNV = 5323,
1398 ObjectRayOriginKHR = 5323,
1399 ObjectRayDirectionNV = 5324,
1400 ObjectRayDirectionKHR = 5324,
1401 RayTminNV = 5325,
1402 RayTminKHR = 5325,
1403 RayTmaxNV = 5326,
1404 RayTmaxKHR = 5326,
1405 InstanceCustomIndexNV = 5327,
1406 InstanceCustomIndexKHR = 5327,
1407 ObjectToWorldNV = 5330,
1408 ObjectToWorldKHR = 5330,
1409 WorldToObjectNV = 5331,
1410 WorldToObjectKHR = 5331,
1411 HitTNV = 5332,
1412 HitKindNV = 5333,
1413 HitKindKHR = 5333,
1414 IncomingRayFlagsNV = 5351,
1415 IncomingRayFlagsKHR = 5351,
1416 RayGeometryIndexKHR = 5352,
1417 WarpsPerSMNV = 5374,
1418 SMCountNV = 5375,
1419 WarpIDNV = 5376,
1420 SMIDNV = 5377,
1421 _,
1422};
1423pub const Scope = extern enum(u32) {
1424 CrossDevice = 0,
1425 Device = 1,
1426 Workgroup = 2,
1427 Subgroup = 3,
1428 Invocation = 4,
1429 QueueFamily = 5,
1430 QueueFamilyKHR = 5,
1431 ShaderCallKHR = 6,
1432 _,
1433};
1434pub const GroupOperation = extern enum(u32) {
1435 Reduce = 0,
1436 InclusiveScan = 1,
1437 ExclusiveScan = 2,
1438 ClusteredReduce = 3,
1439 PartitionedReduceNV = 6,
1440 PartitionedInclusiveScanNV = 7,
1441 PartitionedExclusiveScanNV = 8,
1442 _,
1443};
1444pub const KernelEnqueueFlags = extern enum(u32) {
1445 NoWait = 0,
1446 WaitKernel = 1,
1447 WaitWorkGroup = 2,
1448 _,
1449};
1450pub const Capability = extern enum(u32) {
1451 Matrix = 0,
1452 Shader = 1,
1453 Geometry = 2,
1454 Tessellation = 3,
1455 Addresses = 4,
1456 Linkage = 5,
1457 Kernel = 6,
1458 Vector16 = 7,
1459 Float16Buffer = 8,
1460 Float16 = 9,
1461 Float64 = 10,
1462 Int64 = 11,
1463 Int64Atomics = 12,
1464 ImageBasic = 13,
1465 ImageReadWrite = 14,
1466 ImageMipmap = 15,
1467 Pipes = 17,
1468 Groups = 18,
1469 DeviceEnqueue = 19,
1470 LiteralSampler = 20,
1471 AtomicStorage = 21,
1472 Int16 = 22,
1473 TessellationPointSize = 23,
1474 GeometryPointSize = 24,
1475 ImageGatherExtended = 25,
1476 StorageImageMultisample = 27,
1477 UniformBufferArrayDynamicIndexing = 28,
1478 SampledImageArrayDynamicIndexing = 29,
1479 StorageBufferArrayDynamicIndexing = 30,
1480 StorageImageArrayDynamicIndexing = 31,
1481 ClipDistance = 32,
1482 CullDistance = 33,
1483 ImageCubeArray = 34,
1484 SampleRateShading = 35,
1485 ImageRect = 36,
1486 SampledRect = 37,
1487 GenericPointer = 38,
1488 Int8 = 39,
1489 InputAttachment = 40,
1490 SparseResidency = 41,
1491 MinLod = 42,
1492 Sampled1D = 43,
1493 Image1D = 44,
1494 SampledCubeArray = 45,
1495 SampledBuffer = 46,
1496 ImageBuffer = 47,
1497 ImageMSArray = 48,
1498 StorageImageExtendedFormats = 49,
1499 ImageQuery = 50,
1500 DerivativeControl = 51,
1501 InterpolationFunction = 52,
1502 TransformFeedback = 53,
1503 GeometryStreams = 54,
1504 StorageImageReadWithoutFormat = 55,
1505 StorageImageWriteWithoutFormat = 56,
1506 MultiViewport = 57,
1507 SubgroupDispatch = 58,
1508 NamedBarrier = 59,
1509 PipeStorage = 60,
1510 GroupNonUniform = 61,
1511 GroupNonUniformVote = 62,
1512 GroupNonUniformArithmetic = 63,
1513 GroupNonUniformBallot = 64,
1514 GroupNonUniformShuffle = 65,
1515 GroupNonUniformShuffleRelative = 66,
1516 GroupNonUniformClustered = 67,
1517 GroupNonUniformQuad = 68,
1518 ShaderLayer = 69,
1519 ShaderViewportIndex = 70,
1520 FragmentShadingRateKHR = 4422,
1521 SubgroupBallotKHR = 4423,
1522 DrawParameters = 4427,
1523 SubgroupVoteKHR = 4431,
1524 StorageBuffer16BitAccess = 4433,
1525 StorageUniformBufferBlock16 = 4433,
1526 UniformAndStorageBuffer16BitAccess = 4434,
1527 StorageUniform16 = 4434,
1528 StoragePushConstant16 = 4435,
1529 StorageInputOutput16 = 4436,
1530 DeviceGroup = 4437,
1531 MultiView = 4439,
1532 VariablePointersStorageBuffer = 4441,
1533 VariablePointers = 4442,
1534 AtomicStorageOps = 4445,
1535 SampleMaskPostDepthCoverage = 4447,
1536 StorageBuffer8BitAccess = 4448,
1537 UniformAndStorageBuffer8BitAccess = 4449,
1538 StoragePushConstant8 = 4450,
1539 DenormPreserve = 4464,
1540 DenormFlushToZero = 4465,
1541 SignedZeroInfNanPreserve = 4466,
1542 RoundingModeRTE = 4467,
1543 RoundingModeRTZ = 4468,
1544 RayQueryProvisionalKHR = 4471,
1545 RayQueryKHR = 4472,
1546 RayTraversalPrimitiveCullingKHR = 4478,
1547 RayTracingKHR = 4479,
1548 Float16ImageAMD = 5008,
1549 ImageGatherBiasLodAMD = 5009,
1550 FragmentMaskAMD = 5010,
1551 StencilExportEXT = 5013,
1552 ImageReadWriteLodAMD = 5015,
1553 Int64ImageEXT = 5016,
1554 ShaderClockKHR = 5055,
1555 SampleMaskOverrideCoverageNV = 5249,
1556 GeometryShaderPassthroughNV = 5251,
1557 ShaderViewportIndexLayerEXT = 5254,
1558 ShaderViewportIndexLayerNV = 5254,
1559 ShaderViewportMaskNV = 5255,
1560 ShaderStereoViewNV = 5259,
1561 PerViewAttributesNV = 5260,
1562 FragmentFullyCoveredEXT = 5265,
1563 MeshShadingNV = 5266,
1564 ImageFootprintNV = 5282,
1565 FragmentBarycentricNV = 5284,
1566 ComputeDerivativeGroupQuadsNV = 5288,
1567 FragmentDensityEXT = 5291,
1568 ShadingRateNV = 5291,
1569 GroupNonUniformPartitionedNV = 5297,
1570 ShaderNonUniform = 5301,
1571 ShaderNonUniformEXT = 5301,
1572 RuntimeDescriptorArray = 5302,
1573 RuntimeDescriptorArrayEXT = 5302,
1574 InputAttachmentArrayDynamicIndexing = 5303,
1575 InputAttachmentArrayDynamicIndexingEXT = 5303,
1576 UniformTexelBufferArrayDynamicIndexing = 5304,
1577 UniformTexelBufferArrayDynamicIndexingEXT = 5304,
1578 StorageTexelBufferArrayDynamicIndexing = 5305,
1579 StorageTexelBufferArrayDynamicIndexingEXT = 5305,
1580 UniformBufferArrayNonUniformIndexing = 5306,
1581 UniformBufferArrayNonUniformIndexingEXT = 5306,
1582 SampledImageArrayNonUniformIndexing = 5307,
1583 SampledImageArrayNonUniformIndexingEXT = 5307,
1584 StorageBufferArrayNonUniformIndexing = 5308,
1585 StorageBufferArrayNonUniformIndexingEXT = 5308,
1586 StorageImageArrayNonUniformIndexing = 5309,
1587 StorageImageArrayNonUniformIndexingEXT = 5309,
1588 InputAttachmentArrayNonUniformIndexing = 5310,
1589 InputAttachmentArrayNonUniformIndexingEXT = 5310,
1590 UniformTexelBufferArrayNonUniformIndexing = 5311,
1591 UniformTexelBufferArrayNonUniformIndexingEXT = 5311,
1592 StorageTexelBufferArrayNonUniformIndexing = 5312,
1593 StorageTexelBufferArrayNonUniformIndexingEXT = 5312,
1594 RayTracingNV = 5340,
1595 VulkanMemoryModel = 5345,
1596 VulkanMemoryModelKHR = 5345,
1597 VulkanMemoryModelDeviceScope = 5346,
1598 VulkanMemoryModelDeviceScopeKHR = 5346,
1599 PhysicalStorageBufferAddresses = 5347,
1600 PhysicalStorageBufferAddressesEXT = 5347,
1601 ComputeDerivativeGroupLinearNV = 5350,
1602 RayTracingProvisionalKHR = 5353,
1603 CooperativeMatrixNV = 5357,
1604 FragmentShaderSampleInterlockEXT = 5363,
1605 FragmentShaderShadingRateInterlockEXT = 5372,
1606 ShaderSMBuiltinsNV = 5373,
1607 FragmentShaderPixelInterlockEXT = 5378,
1608 DemoteToHelperInvocationEXT = 5379,
1609 SubgroupShuffleINTEL = 5568,
1610 SubgroupBufferBlockIOINTEL = 5569,
1611 SubgroupImageBlockIOINTEL = 5570,
1612 SubgroupImageMediaBlockIOINTEL = 5579,
1613 IntegerFunctions2INTEL = 5584,
1614 FunctionPointersINTEL = 5603,
1615 IndirectReferencesINTEL = 5604,
1616 SubgroupAvcMotionEstimationINTEL = 5696,
1617 SubgroupAvcMotionEstimationIntraINTEL = 5697,
1618 SubgroupAvcMotionEstimationChromaINTEL = 5698,
1619 FPGAMemoryAttributesINTEL = 5824,
1620 UnstructuredLoopControlsINTEL = 5886,
1621 FPGALoopControlsINTEL = 5888,
1622 KernelAttributesINTEL = 5892,
1623 FPGAKernelAttributesINTEL = 5897,
1624 BlockingPipesINTEL = 5945,
1625 FPGARegINTEL = 5948,
1626 AtomicFloat32AddEXT = 6033,
1627 AtomicFloat64AddEXT = 6034,
1628 _,
1629};
1630pub const RayQueryIntersection = extern enum(u32) {
1631 RayQueryCandidateIntersectionKHR = 0,
1632 RayQueryCommittedIntersectionKHR = 1,
1633 _,
1634};
1635pub const RayQueryCommittedIntersectionType = extern enum(u32) {
1636 RayQueryCommittedIntersectionNoneKHR = 0,
1637 RayQueryCommittedIntersectionTriangleKHR = 1,
1638 RayQueryCommittedIntersectionGeneratedKHR = 2,
1639 _,
1640};
1641pub const RayQueryCandidateIntersectionType = extern enum(u32) {
1642 RayQueryCandidateIntersectionTriangleKHR = 0,
1643 RayQueryCandidateIntersectionAABBKHR = 1,
1644 _,
1645};
src/link.zig+24-5
......@@ -139,6 +139,7 @@ pub const File = struct {
139139 macho: MachO.TextBlock,
140140 c: C.DeclBlock,
141141 wasm: void,
142 spirv: void,
142143 };
143144
144145 pub const LinkFn = union {
......@@ -147,6 +148,7 @@ pub const File = struct {
147148 macho: MachO.SrcFn,
148149 c: C.FnBlock,
149150 wasm: ?Wasm.FnData,
151 spirv: SpirV.FnData,
150152 };
151153
152154 pub const Export = union {
......@@ -155,6 +157,7 @@ pub const File = struct {
155157 macho: MachO.Export,
156158 c: void,
157159 wasm: void,
160 spirv: void,
158161 };
159162
160163 /// For DWARF .debug_info.
......@@ -183,6 +186,7 @@ pub const File = struct {
183186 .macho => &(try MachO.createEmpty(allocator, options)).base,
184187 .wasm => &(try Wasm.createEmpty(allocator, options)).base,
185188 .c => unreachable, // Reported error earlier.
189 .spirv => &(try SpirV.createEmpty(allocator, options)).base,
186190 .hex => return error.HexObjectFormatUnimplemented,
187191 .raw => return error.RawObjectFormatUnimplemented,
188192 };
......@@ -198,6 +202,7 @@ pub const File = struct {
198202 .macho => &(try MachO.createEmpty(allocator, options)).base,
199203 .wasm => &(try Wasm.createEmpty(allocator, options)).base,
200204 .c => unreachable, // Reported error earlier.
205 .spirv => &(try SpirV.createEmpty(allocator, options)).base,
201206 .hex => return error.HexObjectFormatUnimplemented,
202207 .raw => return error.RawObjectFormatUnimplemented,
203208 };
......@@ -213,6 +218,7 @@ pub const File = struct {
213218 .macho => &(try MachO.openPath(allocator, sub_path, options)).base,
214219 .wasm => &(try Wasm.openPath(allocator, sub_path, options)).base,
215220 .c => &(try C.openPath(allocator, sub_path, options)).base,
221 .spirv => &(try SpirV.openPath(allocator, sub_path, options)).base,
216222 .hex => return error.HexObjectFormatUnimplemented,
217223 .raw => return error.RawObjectFormatUnimplemented,
218224 };
......@@ -242,7 +248,7 @@ pub const File = struct {
242248 .mode = determineMode(base.options),
243249 });
244250 },
245 .c, .wasm => {},
251 .c, .wasm, .spirv => {},
246252 }
247253 }
248254
......@@ -287,7 +293,7 @@ pub const File = struct {
287293 f.close();
288294 base.file = null;
289295 },
290 .c, .wasm => {},
296 .c, .wasm, .spirv => {},
291297 }
292298 }
293299
......@@ -300,6 +306,7 @@ pub const File = struct {
300306 .macho => return @fieldParentPtr(MachO, "base", base).updateDecl(module, decl),
301307 .c => return @fieldParentPtr(C, "base", base).updateDecl(module, decl),
302308 .wasm => return @fieldParentPtr(Wasm, "base", base).updateDecl(module, decl),
309 .spirv => return @fieldParentPtr(SpirV, "base", base).updateDecl(module, decl),
303310 }
304311 }
305312
......@@ -309,7 +316,7 @@ pub const File = struct {
309316 .elf => return @fieldParentPtr(Elf, "base", base).updateDeclLineNumber(module, decl),
310317 .macho => return @fieldParentPtr(MachO, "base", base).updateDeclLineNumber(module, decl),
311318 .c => return @fieldParentPtr(C, "base", base).updateDeclLineNumber(module, decl),
312 .wasm => {},
319 .wasm, .spirv => {},
313320 }
314321 }
315322
......@@ -321,7 +328,7 @@ pub const File = struct {
321328 .elf => return @fieldParentPtr(Elf, "base", base).allocateDeclIndexes(decl),
322329 .macho => return @fieldParentPtr(MachO, "base", base).allocateDeclIndexes(decl),
323330 .c => return @fieldParentPtr(C, "base", base).allocateDeclIndexes(decl),
324 .wasm => {},
331 .wasm, .spirv => {},
325332 }
326333 }
327334
......@@ -368,6 +375,11 @@ pub const File = struct {
368375 parent.deinit();
369376 base.allocator.destroy(parent);
370377 },
378 .spirv => {
379 const parent = @fieldParentPtr(SpirV, "base", base);
380 parent.deinit();
381 base.allocator.destroy(parent);
382 },
371383 }
372384 }
373385
......@@ -401,6 +413,7 @@ pub const File = struct {
401413 .macho => return @fieldParentPtr(MachO, "base", base).flush(comp),
402414 .c => return @fieldParentPtr(C, "base", base).flush(comp),
403415 .wasm => return @fieldParentPtr(Wasm, "base", base).flush(comp),
416 .spirv => return @fieldParentPtr(SpirV, "base", base).flush(comp),
404417 }
405418 }
406419
......@@ -413,6 +426,7 @@ pub const File = struct {
413426 .macho => return @fieldParentPtr(MachO, "base", base).flushModule(comp),
414427 .c => return @fieldParentPtr(C, "base", base).flushModule(comp),
415428 .wasm => return @fieldParentPtr(Wasm, "base", base).flushModule(comp),
429 .spirv => return @fieldParentPtr(SpirV, "base", base).flushModule(comp),
416430 }
417431 }
418432
......@@ -424,6 +438,7 @@ pub const File = struct {
424438 .macho => @fieldParentPtr(MachO, "base", base).freeDecl(decl),
425439 .c => @fieldParentPtr(C, "base", base).freeDecl(decl),
426440 .wasm => @fieldParentPtr(Wasm, "base", base).freeDecl(decl),
441 .spirv => @fieldParentPtr(SpirV, "base", base).freeDecl(decl),
427442 }
428443 }
429444
......@@ -433,7 +448,7 @@ pub const File = struct {
433448 .elf => return @fieldParentPtr(Elf, "base", base).error_flags,
434449 .macho => return @fieldParentPtr(MachO, "base", base).error_flags,
435450 .c => return .{ .no_entry_point_found = false },
436 .wasm => return ErrorFlags{},
451 .wasm, .spirv => return ErrorFlags{},
437452 }
438453 }
439454
......@@ -451,6 +466,7 @@ pub const File = struct {
451466 .macho => return @fieldParentPtr(MachO, "base", base).updateDeclExports(module, decl, exports),
452467 .c => return @fieldParentPtr(C, "base", base).updateDeclExports(module, decl, exports),
453468 .wasm => return @fieldParentPtr(Wasm, "base", base).updateDeclExports(module, decl, exports),
469 .spirv => return @fieldParentPtr(SpirV, "base", base).updateDeclExports(module, decl, exports),
454470 }
455471 }
456472
......@@ -461,6 +477,7 @@ pub const File = struct {
461477 .macho => return @fieldParentPtr(MachO, "base", base).getDeclVAddr(decl),
462478 .c => unreachable,
463479 .wasm => unreachable,
480 .spirv => unreachable,
464481 }
465482 }
466483
......@@ -601,6 +618,7 @@ pub const File = struct {
601618 macho,
602619 c,
603620 wasm,
621 spirv,
604622 };
605623
606624 pub const ErrorFlags = struct {
......@@ -611,6 +629,7 @@ pub const File = struct {
611629 pub const Coff = @import("link/Coff.zig");
612630 pub const Elf = @import("link/Elf.zig");
613631 pub const MachO = @import("link/MachO.zig");
632 pub const SpirV = @import("link/SpirV.zig");
614633 pub const Wasm = @import("link/Wasm.zig");
615634};
616635
src/link/SpirV.zig created+234
......@@ -0,0 +1,234 @@
1const SpirV = @This();
2
3const std = @import("std");
4const Allocator = std.mem.Allocator;
5const assert = std.debug.assert;
6
7const Module = @import("../Module.zig");
8const Compilation = @import("../Compilation.zig");
9const link = @import("../link.zig");
10const codegen = @import("../codegen/spirv.zig");
11const trace = @import("../tracy.zig").trace;
12const build_options = @import("build_options");
13const spec = @import("../codegen/spirv/spec.zig");
14
15//! SPIR-V Spec documentation: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html
16//! According to above documentation, a SPIR-V module has the following logical layout:
17//! Header.
18//! OpCapability instructions.
19//! OpExtension instructions.
20//! OpExtInstImport instructions.
21//! A single OpMemoryModel instruction.
22//! All entry points, declared with OpEntryPoint instructions.
23//! All execution-mode declarators; OpExecutionMode and OpExecutionModeId instructions.
24//! Debug instructions:
25//! - First, OpString, OpSourceExtension, OpSource, OpSourceContinued (no forward references).
26//! - OpName and OpMemberName instructions.
27//! - OpModuleProcessed instructions.
28//! All annotation (decoration) instructions.
29//! All type declaration instructions, constant instructions, global variable declarations, (preferrably) OpUndef instructions.
30//! All function declarations without a body (extern functions presumably).
31//! All regular functions.
32
33pub const FnData = struct {
34 id: ?u32 = null,
35 code: std.ArrayListUnmanaged(u32) = .{},
36};
37
38base: link.File,
39
40// TODO: Does this file need to support multiple independent modules?
41spirv_module: codegen.SPIRVModule,
42
43pub fn createEmpty(gpa: *Allocator, options: link.Options) !*SpirV {
44 const spirv = try gpa.create(SpirV);
45 spirv.* = .{
46 .base = .{
47 .tag = .spirv,
48 .options = options,
49 .file = null,
50 .allocator = gpa,
51 },
52 .spirv_module = codegen.SPIRVModule.init(gpa),
53 };
54
55 // TODO: Figure out where to put all of these
56 switch (options.target.cpu.arch) {
57 .spirv32, .spirv64 => {},
58 else => return error.TODOArchNotSupported,
59 }
60
61 switch (options.target.os.tag) {
62 .opencl, .glsl450, .vulkan => {},
63 else => return error.TODOOsNotSupported,
64 }
65
66 if (options.target.abi != .none) {
67 return error.TODOAbiNotSupported;
68 }
69
70 return spirv;
71}
72
73pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Options) !*SpirV {
74 assert(options.object_format == .spirv);
75
76 if (options.use_llvm) return error.LLVM_BackendIsTODO_ForSpirV; // TODO: LLVM Doesn't support SpirV at all.
77 if (options.use_lld) return error.LLD_LinkingIsTODO_ForSpirV; // TODO: LLD Doesn't support SpirV at all.
78
79 // TODO: read the file and keep vaild parts instead of truncating
80 const file = try options.emit.?.directory.handle.createFile(sub_path, .{ .truncate = true, .read = true });
81 errdefer file.close();
82
83 const spirv = try createEmpty(allocator, options);
84 errdefer spirv.base.destroy();
85
86 spirv.base.file = file;
87 return spirv;
88}
89
90pub fn deinit(self: *SpirV) void {
91 self.spirv_module.deinit();
92}
93
94pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void {
95 const tracy = trace(@src());
96 defer tracy.end();
97
98 const fn_data = &decl.fn_link.spirv;
99 if (fn_data.id == null) {
100 fn_data.id = self.spirv_module.allocId();
101 }
102
103 var managed_code = fn_data.code.toManaged(self.base.allocator);
104 managed_code.items.len = 0;
105
106 try self.spirv_module.genDecl(fn_data.id.?, &managed_code, decl);
107 fn_data.code = managed_code.toUnmanaged();
108
109 // Free excess allocated memory for this Decl.
110 fn_data.code.shrinkAndFree(self.base.allocator, fn_data.code.items.len);
111}
112
113pub fn updateDeclExports(
114 self: *SpirV,
115 module: *Module,
116 decl: *const Module.Decl,
117 exports: []const *Module.Export,
118) !void {}
119
120pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void {
121 var fn_data = decl.fn_link.spirv;
122 fn_data.code.deinit(self.base.allocator);
123 if (fn_data.id) |id| self.spirv_module.freeId(id);
124 decl.fn_link.spirv = undefined;
125}
126
127pub fn flush(self: *SpirV, comp: *Compilation) !void {
128 if (build_options.have_llvm and self.base.options.use_lld) {
129 return error.LLD_LinkingIsTODO_ForSpirV; // TODO: LLD Doesn't support SpirV at all.
130 } else {
131 return self.flushModule(comp);
132 }
133}
134
135pub fn flushModule(self: *SpirV, comp: *Compilation) !void {
136 const tracy = trace(@src());
137 defer tracy.end();
138
139 const module = self.base.options.module.?;
140 const target = comp.getTarget();
141
142 var binary = std.ArrayList(u32).init(self.base.allocator);
143 defer binary.deinit();
144
145 // Note: The order of adding sections to the final binary
146 // follows the SPIR-V logical module format!
147
148 try binary.appendSlice(&[_]u32{
149 spec.magic_number,
150 (spec.version.major << 16) | (spec.version.minor << 8),
151 0, // TODO: Register Zig compiler magic number.
152 self.spirv_module.idBound(),
153 0, // Schema (currently reserved for future use in the SPIR-V spec).
154 });
155
156 try writeCapabilities(&binary, target);
157 try writeMemoryModel(&binary, target);
158
159 // Collect list of buffers to write.
160 // SPIR-V files support both little and big endian words. The actual format is
161 // disambiguated by the magic number, and so theoretically we don't need to worry
162 // about endian-ness when writing the final binary.
163 var all_buffers = std.ArrayList(std.os.iovec_const).init(self.base.allocator);
164 defer all_buffers.deinit();
165
166 // Pre-allocate enough for the binary info + all functions
167 try all_buffers.ensureCapacity(module.decl_table.count() + 1);
168
169 all_buffers.appendAssumeCapacity(wordsToIovConst(binary.items));
170
171 for (module.decl_table.items()) |entry| {
172 const decl = entry.value;
173 switch (decl.typed_value) {
174 .most_recent => |tvm| {
175 const fn_data = &decl.fn_link.spirv;
176 all_buffers.appendAssumeCapacity(wordsToIovConst(fn_data.code.items));
177 },
178 .never_succeeded => continue,
179 }
180 }
181
182 var file_size: u64 = 0;
183 for (all_buffers.items) |iov| {
184 file_size += iov.iov_len;
185 }
186
187 const file = self.base.file.?;
188 try file.seekTo(0);
189 try file.setEndPos(file_size);
190 try file.pwritevAll(all_buffers.items, 0);
191}
192
193fn writeCapabilities(binary: *std.ArrayList(u32), target: std.Target) !void {
194 // TODO: Integrate with a hypothetical feature system
195 const cap: spec.Capability = switch (target.os.tag) {
196 .opencl => .Kernel,
197 .glsl450 => .Shader,
198 .vulkan => .VulkanMemoryModel,
199 else => unreachable, // TODO
200 };
201
202 try codegen.writeInstruction(binary, .OpCapability, &[_]u32{ @enumToInt(cap) });
203}
204
205fn writeMemoryModel(binary: *std.ArrayList(u32), target: std.Target) !void {
206 const addressing_model = switch (target.os.tag) {
207 .opencl => switch (target.cpu.arch) {
208 .spirv32 => spec.AddressingModel.Physical32,
209 .spirv64 => spec.AddressingModel.Physical64,
210 else => unreachable, // TODO
211 },
212 .glsl450, .vulkan => spec.AddressingModel.Logical,
213 else => unreachable, // TODO
214 };
215
216 const memory_model: spec.MemoryModel = switch (target.os.tag) {
217 .opencl => .OpenCL,
218 .glsl450 => .GLSL450,
219 .vulkan => .Vulkan,
220 else => unreachable,
221 };
222
223 try codegen.writeInstruction(binary, .OpMemoryModel, &[_]u32{
224 @enumToInt(addressing_model), @enumToInt(memory_model)
225 });
226}
227
228fn wordsToIovConst(words: []const u32) std.os.iovec_const {
229 const bytes = std.mem.sliceAsBytes(words);
230 return .{
231 .iov_base = bytes.ptr,
232 .iov_len = bytes.len,
233 };
234}
src/main.zig+3
......@@ -312,6 +312,7 @@ const usage_build_generic =
312312 \\ pe Portable Executable (Windows)
313313 \\ coff Common Object File Format (Windows)
314314 \\ macho macOS relocatables
315 \\ spirv Standard, Portable Intermediate Representation V (SPIR-V)
315316 \\ hex (planned) Intel IHEX
316317 \\ raw (planned) Dump machine code directly
317318 \\ -dirafter [dir] Add directory to AFTER include search path
......@@ -1588,6 +1589,8 @@ fn buildOutputType(
15881589 break :blk .hex;
15891590 } else if (mem.eql(u8, ofmt, "raw")) {
15901591 break :blk .raw;
1592 } else if (mem.eql(u8, ofmt, "spirv")) {
1593 break :blk .spirv;
15911594 } else {
15921595 fatal("unsupported object format: {s}", .{ofmt});
15931596 }
src/target.zig+2-2
......@@ -189,7 +189,7 @@ pub fn supportsStackProbing(target: std.Target) bool {
189189
190190pub fn osToLLVM(os_tag: std.Target.Os.Tag) llvm.OSType {
191191 return switch (os_tag) {
192 .freestanding, .other => .UnknownOS,
192 .freestanding, .other, .opencl, .glsl450, .vulkan => .UnknownOS,
193193 .windows, .uefi => .Win32,
194194 .ananas => .Ananas,
195195 .cloudabi => .CloudABI,
......@@ -280,7 +280,7 @@ pub fn archToLLVM(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {
280280 .renderscript32 => .renderscript32,
281281 .renderscript64 => .renderscript64,
282282 .ve => .ve,
283 .spu_2 => .UnknownArch,
283 .spu_2, .spirv32, .spirv64 => .UnknownArch,
284284 };
285285}
286286
src/type.zig+3
......@@ -3597,6 +3597,9 @@ pub const CType = enum {
35973597 .amdpal,
35983598 .hermit,
35993599 .hurd,
3600 .opencl,
3601 .glsl450,
3602 .vulkan,
36003603 => @panic("TODO specify the C integer and float type sizes for this OS"),
36013604 }
36023605 }
tools/gen_spirv_spec.zig created+245
......@@ -0,0 +1,245 @@
1const std = @import("std");
2const Writer = std.ArrayList(u8).Writer;
3
4//! See https://www.khronos.org/registry/spir-v/specs/unified1/MachineReadableGrammar.html
5//! and the files in https://github.com/KhronosGroup/SPIRV-Headers/blob/master/include/spirv/unified1/
6//! Note: Non-canonical casing in these structs used to match SPIR-V spec json.
7const Registry = union(enum) {
8 core: CoreRegistry,
9 extension: ExtensionRegistry,
10};
11
12const CoreRegistry = struct {
13 copyright: [][]const u8,
14 /// Hexadecimal representation of the magic number
15 magic_number: []const u8,
16 major_version: u32,
17 minor_version: u32,
18 revision: u32,
19 instruction_printing_class: []InstructionPrintingClass,
20 instructions: []Instruction,
21 operand_kinds: []OperandKind,
22};
23
24const ExtensionRegistry = struct {
25 copyright: [][]const u8,
26 version: u32,
27 revision: u32,
28 instructions: []Instruction,
29 operand_kinds: []OperandKind = &[_]OperandKind{},
30};
31
32const InstructionPrintingClass = struct {
33 tag: []const u8,
34 heading: ?[]const u8 = null,
35};
36
37const Instruction = struct {
38 opname: []const u8,
39 class: ?[]const u8 = null, // Note: Only available in the core registry.
40 opcode: u32,
41 operands: []Operand = &[_]Operand{},
42 capabilities: [][]const u8 = &[_][]const u8{},
43 extensions: [][]const u8 = &[_][]const u8{},
44 version: ?[]const u8 = null,
45
46 lastVersion: ?[]const u8 = null,
47};
48
49const Operand = struct {
50 kind: []const u8,
51 /// If this field is 'null', the operand is only expected once.
52 quantifier: ?Quantifier = null,
53 name: []const u8 = "",
54};
55
56const Quantifier = enum {
57 /// zero or once
58 @"?",
59 /// zero or more
60 @"*",
61};
62
63const OperandCategory = enum {
64 BitEnum,
65 ValueEnum,
66 Id,
67 Literal,
68 Composite,
69};
70
71const OperandKind = struct {
72 category: OperandCategory,
73 /// The name
74 kind: []const u8,
75 doc: ?[]const u8 = null,
76 enumerants: ?[]Enumerant = null,
77 bases: ?[]const []const u8 = null,
78};
79
80const Enumerant = struct {
81 enumerant: []const u8,
82 value: union(enum) {
83 bitflag: []const u8, // Hexadecimal representation of the value
84 int: u31,
85 },
86 capabilities: [][]const u8 = &[_][]const u8{},
87 /// Valid for .ValueEnum and .BitEnum
88 extensions: [][]const u8 = &[_][]const u8{},
89 /// `quantifier` will always be `null`.
90 parameters: []Operand = &[_]Operand{},
91 version: ?[]const u8 = null,
92 lastVersion: ?[]const u8 = null,
93};
94
95pub fn main() !void {
96 var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
97 defer arena.deinit();
98 const allocator = &arena.allocator;
99
100 const args = try std.process.argsAlloc(allocator);
101 if (args.len != 2) {
102 usageAndExit(std.io.getStdErr(), args[0], 1);
103 }
104
105 const spec_path = args[1];
106 const spec = try std.fs.cwd().readFileAlloc(allocator, spec_path, std.math.maxInt(usize));
107
108 var tokens = std.json.TokenStream.init(spec);
109 var registry = try std.json.parse(Registry, &tokens, .{.allocator = allocator});
110
111 var buf = std.ArrayList(u8).init(allocator);
112 defer buf.deinit();
113
114 try render(buf.writer(), registry);
115
116 const tree = try std.zig.parse(allocator, buf.items);
117 _ = try std.zig.render(allocator, std.io.getStdOut().writer(), tree);
118}
119
120fn render(writer: Writer, registry: Registry) !void {
121 switch (registry) {
122 .core => |core_reg| {
123 try renderCopyRight(writer, core_reg.copyright);
124 try writer.print(
125 \\const Version = @import("builtin").Version;
126 \\pub const version = Version{{.major = {}, .minor = {}, .patch = {}}};
127 \\pub const magic_number: u32 = {s};
128 \\
129 , .{ core_reg.major_version, core_reg.minor_version, core_reg.revision, core_reg.magic_number },
130 );
131 try renderOpcodes(writer, core_reg.instructions);
132 try renderOperandKinds(writer, core_reg.operand_kinds);
133 },
134 .extension => |ext_reg| {
135 try renderCopyRight(writer, ext_reg.copyright);
136 try writer.print(
137 \\const Version = @import("builtin").Version;
138 \\pub const version = Version{{.major = {}, .minor = 0, .patch = {}}};
139 \\
140 , .{ ext_reg.version, ext_reg.revision },
141 );
142 try renderOpcodes(writer, ext_reg.instructions);
143 try renderOperandKinds(writer, ext_reg.operand_kinds);
144 }
145 }
146}
147
148fn renderCopyRight(writer: Writer, copyright: []const []const u8) !void {
149 for (copyright) |line| {
150 try writer.print("// {s}\n", .{ line });
151 }
152}
153
154fn renderOpcodes(writer: Writer, instructions: []const Instruction) !void {
155 try writer.writeAll("pub const Opcode = extern enum(u16) {\n");
156 for (instructions) |instr| {
157 try writer.print("{} = {},\n", .{ std.zig.fmtId(instr.opname), instr.opcode });
158 }
159 try writer.writeAll("_,\n};\n");
160}
161
162fn renderOperandKinds(writer: Writer, kinds: []const OperandKind) !void {
163 for (kinds) |kind| {
164 switch (kind.category) {
165 .ValueEnum => try renderValueEnum(writer, kind),
166 .BitEnum => try renderBitEnum(writer, kind),
167 else => {},
168 }
169 }
170}
171
172fn renderValueEnum(writer: Writer, enumeration: OperandKind) !void {
173 try writer.print("pub const {s} = extern enum(u32) {{\n", .{ enumeration.kind });
174
175 const enumerants = enumeration.enumerants orelse return error.InvalidRegistry;
176 for (enumerants) |enumerant| {
177 if (enumerant.value != .int) return error.InvalidRegistry;
178
179 try writer.print("{} = {},\n", .{ std.zig.fmtId(enumerant.enumerant), enumerant.value.int });
180 }
181
182 try writer.writeAll("_,\n};\n");
183}
184
185fn renderBitEnum(writer: Writer, enumeration: OperandKind) !void {
186 try writer.print("pub const {s} = packed struct {{\n", .{ enumeration.kind });
187
188 var flags_by_bitpos = [_]?[]const u8{null} ** 32;
189 const enumerants = enumeration.enumerants orelse return error.InvalidRegistry;
190 for (enumerants) |enumerant| {
191 if (enumerant.value != .bitflag) return error.InvalidRegistry;
192 const value = try parseHexInt(enumerant.value.bitflag);
193 if (@popCount(u32, value) != 1) {
194 continue; // Skip combinations and 'none' items
195 }
196
197 var bitpos = std.math.log2_int(u32, value);
198 if (flags_by_bitpos[bitpos]) |*existing|{
199 // Keep the shortest
200 if (enumerant.enumerant.len < existing.len)
201 existing.* = enumerant.enumerant;
202 } else {
203 flags_by_bitpos[bitpos] = enumerant.enumerant;
204 }
205 }
206
207 for (flags_by_bitpos) |maybe_flag_name, bitpos| {
208 if (maybe_flag_name) |flag_name| {
209 try writer.writeAll(flag_name);
210 } else {
211 try writer.print("_reserved_bit_{}", .{bitpos});
212 }
213
214 try writer.writeAll(": bool ");
215 if (bitpos == 0) { // Force alignment to integer boundaries
216 try writer.writeAll("align(@alignOf(u32)) ");
217 }
218 try writer.writeAll("= false, ");
219 }
220
221 try writer.writeAll("};\n");
222}
223
224fn parseHexInt(text: []const u8) !u31 {
225 const prefix = "0x";
226 if (!std.mem.startsWith(u8, text, prefix))
227 return error.InvalidHexInt;
228 return try std.fmt.parseInt(u31, text[prefix.len ..], 16);
229}
230
231fn usageAndExit(file: std.fs.File, arg0: []const u8, code: u8) noreturn {
232 file.writer().print(
233 \\Usage: {s} <spirv json spec>
234 \\
235 \\Generates Zig bindings for a SPIR-V specification .json (either core or
236 \\extinst versions). The result, printed to stdout, should be used to update
237 \\files in src/codegen/spirv.
238 \\
239 \\The relevant specifications can be obtained from the SPIR-V registry:
240 \\https://github.com/KhronosGroup/SPIRV-Headers/blob/master/include/spirv/unified1/
241 \\
242 , .{arg0}
243 ) catch std.process.exit(1);
244 std.process.exit(code);
245}