| author | |
| committer | |
| log | ac7bf53d9486d6c9a079a818dc87891551eaeac1 |
| tree | c23c684d2e395f5447a5afc80d708a33f3cf999d |
| parent | 93905c89057e9d7020aa2e6130bde7cd91ac4484 |
fixes compilation of attached test case2 files changed, 29 insertions(+), 2 deletions(-)
src/Type.zig+2-2| ... | @@ -1019,8 +1019,8 @@ pub fn abiAlignment(ty: Type, zcu: *const Zcu) Alignment { | ... | @@ -1019,8 +1019,8 @@ pub fn abiAlignment(ty: Type, zcu: *const Zcu) Alignment { |
| 1019 | .c_longdouble => cTypeAlign(target, .longdouble), | 1019 | .c_longdouble => cTypeAlign(target, .longdouble), |
| 1020 | 1020 | ||
| 1021 | .f16 => .@"2", | 1021 | .f16 => .@"2", |
| 1022 | .f32 => cTypeAlign(target, .float), | 1022 | .f32 => if (target.os.tag == .opengl) .@"4" else cTypeAlign(target, .float), |
| 1023 | .f64 => switch (target.cTypeBitSize(.double)) { | 1023 | .f64 => if (target.os.tag == .opengl) .@"8" else switch (target.cTypeBitSize(.double)) { |
| 1024 | 64 => cTypeAlign(target, .double), | 1024 | 64 => cTypeAlign(target, .double), |
| 1025 | else => .@"8", | 1025 | else => .@"8", |
| 1026 | }, | 1026 | }, |
test/cases/storage_buffer_opengl.zig created+27| ... | @@ -0,0 +1,27 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | const RuntimeArray = @SpirvType(.{ .runtime_array = @Vector(4, f32) }); | ||
| 4 | const Buffer = extern struct { | ||
| 5 | data: RuntimeArray, | ||
| 6 | }; | ||
| 7 | |||
| 8 | const output = @extern(*addrspace(.storage_buffer) Buffer, .{ | ||
| 9 | .name = "output", | ||
| 10 | .decoration = .{ .descriptor = .{ .set = 0, .binding = 0 } }, | ||
| 11 | }); | ||
| 12 | |||
| 13 | const num_segments = 20; | ||
| 14 | |||
| 15 | export fn main() callconv(.{ .spirv_kernel = .{ .x = 1, .y = 1, .z = 1 } }) void { | ||
| 16 | const val = std.spirv.global_invocation_id[0]; | ||
| 17 | if (val > num_segments) return; | ||
| 18 | var val_f: f32 = @floatFromInt(val); | ||
| 19 | val_f /= num_segments; | ||
| 20 | output.data[val] = .{ val_f, val_f, 0, 1 }; | ||
| 21 | } | ||
| 22 | |||
| 23 | // compile | ||
| 24 | // output_mode=Obj | ||
| 25 | // backend=auto | ||
| 26 | // target=spirv32-opengl | ||
| 27 | // emit_bin=true | ||