| ... | @@ -81,6 +81,9 @@ const Tag = enum { | ... | @@ -81,6 +81,9 @@ const Tag = enum { |
| 81 | /// have member names trailing. | 81 | /// have member names trailing. |
| 82 | /// data is payload to SimpleStructType | 82 | /// data is payload to SimpleStructType |
| 83 | type_struct_simple_with_member_names, | 83 | type_struct_simple_with_member_names, |
| | 84 | /// Opaque type. |
| | 85 | /// data is name string. |
| | 86 | type_opaque, |
| 84 | | 87 | |
| 85 | // -- Values | 88 | // -- Values |
| 86 | /// Value of type u8 | 89 | /// Value of type u8 |
| ... | @@ -235,6 +238,7 @@ pub const Key = union(enum) { | ... | @@ -235,6 +238,7 @@ pub const Key = union(enum) { |
| 235 | function_type: FunctionType, | 238 | function_type: FunctionType, |
| 236 | ptr_type: PointerType, | 239 | ptr_type: PointerType, |
| 237 | struct_type: StructType, | 240 | struct_type: StructType, |
| | 241 | opaque_type: OpaqueType, |
| 238 | | 242 | |
| 239 | // -- values | 243 | // -- values |
| 240 | int: Int, | 244 | int: Int, |
| ... | @@ -289,6 +293,10 @@ pub const Key = union(enum) { | ... | @@ -289,6 +293,10 @@ pub const Key = union(enum) { |
| 289 | } | 293 | } |
| 290 | }; | 294 | }; |
| 291 | | 295 | |
| | 296 | pub const OpaqueType = struct { |
| | 297 | name: String = .none, |
| | 298 | }; |
| | 299 | |
| 292 | pub const Int = struct { | 300 | pub const Int = struct { |
| 293 | /// The type: any bitness integer. | 301 | /// The type: any bitness integer. |
| 294 | ty: Ref, | 302 | ty: Ref, |
| ... | @@ -539,6 +547,13 @@ fn emit( | ... | @@ -539,6 +547,13 @@ fn emit( |
| 539 | } | 547 | } |
| 540 | // TODO: Decorations? | 548 | // TODO: Decorations? |
| 541 | }, | 549 | }, |
| | 550 | .opaque_type => |opaque_type| { |
| | 551 | const name = if (self.getString(opaque_type.name)) |name| name else ""; |
| | 552 | try section.emit(spv.gpa, .OpTypeOpaque, .{ |
| | 553 | .id_result = result_id, |
| | 554 | .literal_string = name, |
| | 555 | }); |
| | 556 | }, |
| 542 | .int => |int| { | 557 | .int => |int| { |
| 543 | const int_type = self.lookup(int.ty).int_type; | 558 | const int_type = self.lookup(int.ty).int_type; |
| 544 | const ty_id = self.resultId(int.ty); | 559 | const ty_id = self.resultId(int.ty); |
| ... | @@ -697,6 +712,11 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref { | ... | @@ -697,6 +712,11 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref { |
| 697 | }; | 712 | }; |
| 698 | } | 713 | } |
| 699 | }, | 714 | }, |
| | 715 | .opaque_type => |opaque_type| Item{ |
| | 716 | .tag = .type_opaque, |
| | 717 | .result_id = result_id, |
| | 718 | .data = @intFromEnum(opaque_type.name), |
| | 719 | }, |
| 700 | .int => |int| blk: { | 720 | .int => |int| blk: { |
| 701 | const int_type = self.lookup(int.ty).int_type; | 721 | const int_type = self.lookup(int.ty).int_type; |
| 702 | if (int_type.signedness == .unsigned and int_type.bits == 8) { | 722 | if (int_type.signedness == .unsigned and int_type.bits == 8) { |
| ... | @@ -874,6 +894,11 @@ pub fn lookup(self: *const Self, ref: Ref) Key { | ... | @@ -874,6 +894,11 @@ pub fn lookup(self: *const Self, ref: Ref) Key { |
| 874 | }, | 894 | }, |
| 875 | }; | 895 | }; |
| 876 | }, | 896 | }, |
| | 897 | .type_opaque => .{ |
| | 898 | .opaque_type = .{ |
| | 899 | .name = @as(String, @enumFromInt(data)), |
| | 900 | }, |
| | 901 | }, |
| 877 | .float16 => .{ .float = .{ | 902 | .float16 => .{ .float = .{ |
| 878 | .ty = self.get(.{ .float_type = .{ .bits = 16 } }), | 903 | .ty = self.get(.{ .float_type = .{ .bits = 16 } }), |
| 879 | .value = .{ .float16 = @as(f16, @bitCast(@as(u16, @intCast(data)))) }, | 904 | .value = .{ .float16 = @as(f16, @bitCast(@as(u16, @intCast(data)))) }, |