1const Buffer = extern struct { value: u32 };
2const Sampler = @SpirvType(.sampler);
3const RuntimeArray = @SpirvType(.{ .runtime_array = u32 });
4const SamplerRuntimeArray = @SpirvType(.{ .runtime_array = Sampler });
5const BufferRuntimeArray = @SpirvType(.{ .runtime_array = Buffer });
6
7const a = @extern(*addrspace(.input) const RuntimeArray, .{ .name = "a" });
8const b = @extern(*addrspace(.uniform) const RuntimeArray, .{ .name = "b" });
9const c = @extern(*addrspace(.storage_buffer) const RuntimeArray, .{ .name = "c" });
10const d = @extern(*addrspace(.constant) const RuntimeArray, .{ .name = "d" });
11const e = @extern(*addrspace(.constant) const SamplerRuntimeArray, .{
12 .name = "samplers",
13 .decoration = .{ .descriptor = .{ .set = 0, .binding = 0 } },
14});
15const f = @extern(*addrspace(.storage_buffer) [4]Buffer, .{
16 .name = "sized_buffers",
17 .decoration = .{ .descriptor = .{ .set = 0, .binding = 1 } },
18});
19const g = @extern(*addrspace(.storage_buffer) BufferRuntimeArray, .{
20 .name = "buffers",
21 .decoration = .{ .descriptor = .{ .set = 0, .binding = 2 } },
22});
23
24comptime {
25 _ = a;
26}
27comptime {
28 _ = b;
29}
30comptime {
31 _ = c;
32}
33
34export fn main() callconv(.{ .spirv_fragment = .{} }) void {
35 _ = &d[0];
36 _ = &e[0];
37 f[0].value = 1;
38 g[0].value = 2;
39}
40
41// error
42// backend=selfhosted
43// target=spirv32-vulkan
44// cpu_features=baseline+runtime_descriptor_array
45//
46// :7:19: error: SPIR-V runtime array is not allowed in the 'input' address space
47// :8:19: error: extern in 'uniform' address space must be a single-item pointer to a struct
48// :9:19: error: extern in 'storage_buffer' address space must be a single-item pointer to a struct
49// :10:19: error: extern in 'constant' address space must point to an opaque SPIR-V type, or to an array of one