1const Block = extern struct { x: u32 };
2const RuntimeArray = @SpirvType(.{ .runtime_array = u32 });
3
4extern var implicit_addrspace: u32;
5
6const many = @extern([*]addrspace(.storage_buffer) u32, .{
7 .name = "many",
8 .decoration = .{ .descriptor = .{ .set = 0, .binding = 0 } },
9});
10const push_array = @extern(*addrspace(.push_constant) const [4]Block, .{ .name = "push_array" });
11const plain_constant = @extern(*addrspace(.constant) const Block, .{
12 .name = "plain_constant",
13 .decoration = .{ .descriptor = .{ .set = 0, .binding = 1 } },
14});
15const runtime_array = @extern(*addrspace(.storage_buffer) RuntimeArray, .{
16 .name = "runtime_array",
17 .decoration = .{ .descriptor = .{ .set = 0, .binding = 2 } },
18});
19
20comptime {
21 _ = implicit_addrspace;
22}
23comptime {
24 _ = many;
25}
26comptime {
27 _ = push_array;
28}
29comptime {
30 _ = plain_constant;
31}
32comptime {
33 _ = runtime_array;
34}
35
36// error
37// backend=selfhosted
38// target=spirv32-vulkan
39//
40// :4:32: error: SPIR-V extern variables require an explicit address space
41// :6:22: error: extern in 'storage_buffer' address space must be a single-item pointer to a struct
42// :10:28: error: extern in 'push_constant' address space must be a single-item pointer to a struct
43// :11:32: error: extern in 'constant' address space must point to an opaque SPIR-V type, or to an array of one
44// :15:31: error: extern symbol cannot have type '*addrspace(.storage_buffer) @SpirvType(.runtime_array, u32)'
45// :15:31: note: pointer element type '@SpirvType(.runtime_array, u32)' is not extern compatible
46// :15:31: note: SPIR-V runtime arrays must be the last field of an extern struct
47// :15:31: note: consider enabling the 'runtime_descriptor_array' feature to use the runtime array as the extern pointee