| 1 | const Buffer = extern struct { value: u32 }; |
| 2 | const Sampler = @SpirvType(.sampler); |
| 3 | const RuntimeArray = @SpirvType(.{ .runtime_array = u32 }); |
| 4 | const SamplerRuntimeArray = @SpirvType(.{ .runtime_array = Sampler }); |
| 5 | const BufferRuntimeArray = @SpirvType(.{ .runtime_array = Buffer }); |
| 6 | |
| 7 | const a = @extern(*addrspace(.input) const RuntimeArray, .{ .name = "a" }); |
| 8 | const b = @extern(*addrspace(.uniform) const RuntimeArray, .{ .name = "b" }); |
| 9 | const c = @extern(*addrspace(.storage_buffer) const RuntimeArray, .{ .name = "c" }); |
| 10 | const d = @extern(*addrspace(.constant) const RuntimeArray, .{ .name = "d" }); |
| 11 | const e = @extern(*addrspace(.constant) const SamplerRuntimeArray, .{ |
| 12 | .name = "samplers", |
| 13 | .decoration = .{ .descriptor = .{ .set = 0, .binding = 0 } }, |
| 14 | }); |
| 15 | const f = @extern(*addrspace(.storage_buffer) [4]Buffer, .{ |
| 16 | .name = "sized_buffers", |
| 17 | .decoration = .{ .descriptor = .{ .set = 0, .binding = 1 } }, |
| 18 | }); |
| 19 | const g = @extern(*addrspace(.storage_buffer) BufferRuntimeArray, .{ |
| 20 | .name = "buffers", |
| 21 | .decoration = .{ .descriptor = .{ .set = 0, .binding = 2 } }, |
| 22 | }); |
| 23 | |
| 24 | comptime { |
| 25 | _ = a; |
| 26 | } |
| 27 | comptime { |
| 28 | _ = b; |
| 29 | } |
| 30 | comptime { |
| 31 | _ = c; |
| 32 | } |
| 33 | |
| 34 | export 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 |