spirv: generate *void as pointer to opaque

This commit is contained in:
Robin Voetter 2023-10-08 02:06:47 +02:00
parent fe51ff9fc1
commit ae3efab226
No known key found for this signature in database
2 changed files with 14 additions and 8 deletions

View File

@ -1187,7 +1187,17 @@ const DeclGen = struct {
log.debug("resolveType: ty = {}", .{ty.fmt(mod)});
const target = self.getTarget();
switch (ty.zigTypeTag(mod)) {
.Void, .NoReturn => return try self.spv.resolve(.void_type),
.NoReturn => {
assert(repr == .direct);
return try self.spv.resolve(.void_type);
},
.Void => switch (repr) {
.direct => return try self.spv.resolve(.void_type),
// Pointers to void
.indirect => return try self.spv.resolve(.{ .opaque_type = .{
.name = try self.spv.resolveString("void"),
} }),
},
.Bool => switch (repr) {
.direct => return try self.spv.resolve(.bool_type),
.indirect => return try self.intType(.unsigned, 1),
@ -1439,11 +1449,9 @@ const DeclGen = struct {
return ty_ref;
},
.Opaque => {
return try self.spv.resolve(.{
.opaque_type = .{
.name = .none, // TODO
},
});
return try self.spv.resolve(.{ .opaque_type = .{
.name = .none, // TODO
} });
},
.Null,

View File

@ -270,8 +270,6 @@ test "implicit cast from *[N]T to [*c]T" {
}
test "*usize to *void" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var i = @as(usize, 0);
var v = @as(*void, @ptrCast(&i));
v.* = {};