| ... | ... | @@ -81,6 +81,9 @@ const Tag = enum { |
| 81 | 81 | /// have member names trailing. |
| 82 | 82 | /// data is payload to SimpleStructType |
| 83 | 83 | type_struct_simple_with_member_names, |
| 84 | /// Opaque type. |
| 85 | /// data is name string. |
| 86 | type_opaque, |
| 84 | 87 | |
| 85 | 88 | // -- Values |
| 86 | 89 | /// Value of type u8 |
| ... | ... | @@ -235,6 +238,7 @@ pub const Key = union(enum) { |
| 235 | 238 | function_type: FunctionType, |
| 236 | 239 | ptr_type: PointerType, |
| 237 | 240 | struct_type: StructType, |
| 241 | opaque_type: OpaqueType, |
| 238 | 242 | |
| 239 | 243 | // -- values |
| 240 | 244 | int: Int, |
| ... | ... | @@ -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 | 300 | pub const Int = struct { |
| 293 | 301 | /// The type: any bitness integer. |
| 294 | 302 | ty: Ref, |
| ... | ... | @@ -539,6 +547,13 @@ fn emit( |
| 539 | 547 | } |
| 540 | 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 | 557 | .int => |int| { |
| 543 | 558 | const int_type = self.lookup(int.ty).int_type; |
| 544 | 559 | const ty_id = self.resultId(int.ty); |
| ... | ... | @@ -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 | 720 | .int => |int| blk: { |
| 701 | 721 | const int_type = self.lookup(int.ty).int_type; |
| 702 | 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 | 894 | }, |
| 875 | 895 | }; |
| 876 | 896 | }, |
| 897 | .type_opaque => .{ |
| 898 | .opaque_type = .{ |
| 899 | .name = @as(String, @enumFromInt(data)), |
| 900 | }, |
| 901 | }, |
| 877 | 902 | .float16 => .{ .float = .{ |
| 878 | 903 | .ty = self.get(.{ .float_type = .{ .bits = 16 } }), |
| 879 | 904 | .value = .{ .float16 = @as(f16, @bitCast(@as(u16, @intCast(data)))) }, |