| author | |
| committer | |
| log | 4d2e831300f1f32da5d51ccc4ab7be48d8f6b9f5 |
| tree | e90746eeb5d384dc8001d33699479fb0beee9939 |
| parent | e2669015901e52069a9fdc82bb44e21119dcceab |
3 files changed, 18 insertions(+), 45 deletions(-)
src/Sema.zig+5-5| ... | @@ -22732,6 +22732,8 @@ fn checkLogicalPtrCast( | ... | @@ -22732,6 +22732,8 @@ fn checkLogicalPtrCast( |
| 22732 | const zcu = pt.zcu; | 22732 | const zcu = pt.zcu; |
| 22733 | const src_info = operand_ty.ptrInfo(zcu); | 22733 | const src_info = operand_ty.ptrInfo(zcu); |
| 22734 | const dest_info = dest_ty.ptrInfo(zcu); | 22734 | const dest_info = dest_ty.ptrInfo(zcu); |
| 22735 | const src_child: Type = .fromInterned(src_info.child); | ||
| 22736 | const dest_child: Type = .fromInterned(dest_info.child); | ||
| 22735 | 22737 | ||
| 22736 | if (block.isComptime() or block.is_typeof) return; | 22738 | if (block.isComptime() or block.is_typeof) return; |
| 22737 | switch (zcu.getTarget().os.tag) { | 22739 | switch (zcu.getTarget().os.tag) { |
| ... | @@ -22739,8 +22741,9 @@ fn checkLogicalPtrCast( | ... | @@ -22739,8 +22741,9 @@ fn checkLogicalPtrCast( |
| 22739 | else => return, | 22741 | else => return, |
| 22740 | } | 22742 | } |
| 22741 | if (src_info.flags.address_space == .physical_storage_buffer) return; | 22743 | if (src_info.flags.address_space == .physical_storage_buffer) return; |
| 22744 | if (!dest_child.hasRuntimeBits(zcu)) return; | ||
| 22742 | 22745 | ||
| 22743 | var cur: Type = .fromInterned(src_info.child); | 22746 | var cur = src_child; |
| 22744 | while (cur.toIntern() != dest_info.child) { | 22747 | while (cur.toIntern() != dest_info.child) { |
| 22745 | cur = switch (cur.zigTypeTag(zcu)) { | 22748 | cur = switch (cur.zigTypeTag(zcu)) { |
| 22746 | .array, .vector => cur.childType(zcu), | 22749 | .array, .vector => cur.childType(zcu), |
| ... | @@ -22755,10 +22758,7 @@ fn checkLogicalPtrCast( | ... | @@ -22755,10 +22758,7 @@ fn checkLogicalPtrCast( |
| 22755 | } orelse return sema.failWithOwnedErrorMsg(block, msg: { | 22758 | } orelse return sema.failWithOwnedErrorMsg(block, msg: { |
| 22756 | const msg = try sema.errMsg(src, "cannot cast pointer '{f}' to '{f}'", .{ operand_ty.fmt(pt), dest_ty.fmt(pt) }); | 22759 | const msg = try sema.errMsg(src, "cannot cast pointer '{f}' to '{f}'", .{ operand_ty.fmt(pt), dest_ty.fmt(pt) }); |
| 22757 | errdefer msg.destroy(sema.gpa); | 22760 | errdefer msg.destroy(sema.gpa); |
| 22758 | try sema.errNote(src, msg, "'{f}' must appear at offset 0 inside '{f}'", .{ | 22761 | try sema.errNote(src, msg, "'{f}' must appear at offset 0 inside '{f}'", .{ dest_child.fmt(pt), src_child.fmt(pt) }); |
| 22759 | Type.fromInterned(dest_info.child).fmt(pt), | ||
| 22760 | Type.fromInterned(src_info.child).fmt(pt), | ||
| 22761 | }); | ||
| 22762 | break :msg msg; | 22762 | break :msg msg; |
| 22763 | }); | 22763 | }); |
| 22764 | } | 22764 | } |
src/codegen/spirv/CodeGen.zig+3-16| ... | @@ -1975,13 +1975,8 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1975,13 +1975,8 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1975 | 1975 | ||
| 1976 | const nav_ty_id = try cg.resolveType(nav_ty, .indirect); | 1976 | const nav_ty_id = try cg.resolveType(nav_ty, .indirect); |
| 1977 | const decl_ptr_ty_id = try cg.ptrType(nav_ty_id, storage_class); | 1977 | const decl_ptr_ty_id = try cg.ptrType(nav_ty_id, storage_class); |
| 1978 | switch (nav_ty.zigTypeTag(zcu)) { | 1978 | if (cg.needsLayout(nav.resolved.?.@"addrspace", nav_ty)) { |
| 1979 | .@"struct", .@"union" => { | 1979 | try cg.block_var_ids.put(gpa, spv_decl.result_id, {}); |
| 1980 | if (cg.needsLayout(nav.resolved.?.@"addrspace", nav_ty)) { | ||
| 1981 | try cg.block_var_ids.put(gpa, spv_decl.result_id, {}); | ||
| 1982 | } | ||
| 1983 | }, | ||
| 1984 | else => {}, | ||
| 1985 | } | 1980 | } |
| 1986 | if (decl_ptr_ty_id == ty_id) return spv_decl.result_id; | 1981 | if (decl_ptr_ty_id == ty_id) return spv_decl.result_id; |
| 1987 | switch (target.os.tag) { | 1982 | switch (target.os.tag) { |
| ... | @@ -6764,16 +6759,8 @@ fn ptrElemPtr(cg: *CodeGen, ptr_ty: Type, ptr_id: Id, index_id: Id) !Id { | ... | @@ -6764,16 +6759,8 @@ fn ptrElemPtr(cg: *CodeGen, ptr_ty: Type, ptr_id: Id, index_id: Id) !Id { |
| 6764 | const zcu = cg.zcu; | 6759 | const zcu = cg.zcu; |
| 6765 | // Construct new pointer type for the resulting pointer | 6760 | // Construct new pointer type for the resulting pointer |
| 6766 | const as = ptr_ty.ptrAddressSpace(zcu); | 6761 | const as = ptr_ty.ptrAddressSpace(zcu); |
| 6767 | const child_ty = ptr_ty.childType(zcu); | ||
| 6768 | const is_single_ptr = ptr_ty.isSinglePointer(zcu); | 6762 | const is_single_ptr = ptr_ty.isSinglePointer(zcu); |
| 6769 | const elem_is_block = switch (as) { | 6763 | const elem_is_block = cg.block_var_ids.contains(ptr_id); |
| 6770 | .uniform, .storage_buffer => switch (child_ty.zigTypeTag(cg.zcu)) { | ||
| 6771 | .array => is_single_ptr, | ||
| 6772 | .spirv => is_single_ptr and child_ty.isSpirvRuntimeArray(cg.zcu), | ||
| 6773 | else => false, | ||
| 6774 | }, | ||
| 6775 | else => false, | ||
| 6776 | }; | ||
| 6777 | const elem_ty_id = try cg.pointeeType(as, ptr_ty.indexableElem(zcu), elem_is_block); | 6764 | const elem_ty_id = try cg.pointeeType(as, ptr_ty.indexableElem(zcu), elem_is_block); |
| 6778 | const elem_ptr_ty_id = try cg.ptrType(elem_ty_id, cg.storageClass(as)); | 6765 | const elem_ptr_ty_id = try cg.ptrType(elem_ty_id, cg.storageClass(as)); |
| 6779 | if (is_single_ptr) { | 6766 | if (is_single_ptr) { |
test/cases/compile_errors/callconv_spirv_invalid_options.zig+10-24| ... | @@ -1,29 +1,15 @@ | ... | @@ -1,29 +1,15 @@ |
| 1 | const F1 = fn () callconv(.{ .spirv_kernel = .{ .x = 0, .y = 1, .z = 1 } }) void; | 1 | export fn a() callconv(.{ .spirv_kernel = .{ .x = 0, .y = 1, .z = 1 } }) void {} |
| 2 | const F2 = fn () callconv(.{ .spirv_task = .{ .x = 1, .y = 0, .z = 1 } }) void; | 2 | export fn b() callconv(.{ .spirv_task = .{ .x = 1, .y = 0, .z = 1 } }) void {} |
| 3 | const F3 = fn () callconv(.{ .spirv_mesh = .{ .max_vertices = 0 } }) void; | 3 | export fn c() callconv(.{ .spirv_mesh = .{ .max_vertices = 0, .x = 1, .y = 1, .z = 1 } }) void {} |
| 4 | const F4 = fn () callconv(.{ .spirv_fragment = .{ .pixel_centered_integer = true } }) void; | 4 | export fn d() callconv(.{ .spirv_mesh = .{ .x = 1, .y = 1, .z = 0 } }) void {} |
| 5 | export fn entry1() void { | 5 | export fn e() callconv(.{ .spirv_fragment = .{ .pixel_centered_integer = true } }) void {} |
| 6 | const a: F1 = undefined; | ||
| 7 | _ = a; | ||
| 8 | } | ||
| 9 | export fn entry2() void { | ||
| 10 | const a: F2 = undefined; | ||
| 11 | _ = a; | ||
| 12 | } | ||
| 13 | export fn entry3() void { | ||
| 14 | const a: F3 = undefined; | ||
| 15 | _ = a; | ||
| 16 | } | ||
| 17 | export fn entry4() void { | ||
| 18 | const a: F4 = undefined; | ||
| 19 | _ = a; | ||
| 20 | } | ||
| 21 | 6 | ||
| 22 | // error | 7 | // error |
| 23 | // backend=selfhosted | 8 | // backend=selfhosted |
| 24 | // target=spirv32-vulkan | 9 | // target=spirv32-vulkan |
| 25 | // | 10 | // |
| 26 | // :1:28: error: kernel workgroup dimensions must be at least 1 | 11 | // :1:25: error: kernel workgroup dimensions must be at least 1 |
| 27 | // :2:28: error: kernel workgroup dimensions must be at least 1 | 12 | // :2:25: error: kernel workgroup dimensions must be at least 1 |
| 28 | // :3:28: error: mesh shader 'max_vertices' and 'max_primitives' must be at least 1 | 13 | // :3:25: error: mesh shader 'max_vertices' and 'max_primitives' must be at least 1 |
| 29 | // :4:28: error: 'pixel_centered_integer' is not supported on this target | 14 | // :4:25: error: mesh shader workgroup dimensions must be at least 1 |
| 15 | // :5:25: error: 'pixel_centered_integer' is not supported on this target |