authorgravatar for subocashell@gmail.comSubo2002 <subocashell@gmail.com> 2026-08-24 17:49:49+01:00
committergravatar for subocashell@gmail.comSubo2002 <subocashell@gmail.com> 2026-08-24 17:49:49+01:00
log4ddb82ec2cdc9e68fdc6b938cb0c95d7a7342bb1
tree99ddb42b8324d503eda1d9e278754d6e5bd247d9
parent40ebd816226f5bd74f52399cda6d1c845e4e4c26

Added missing local workgroup sizes to spirv_mesh's SpirvMeshOptions and

associated decorations

5 files changed, 20 insertions(+), 4 deletions(-)

lib/std/lang.zig+3
......@@ -545,6 +545,9 @@ pub const CallingConvention = union(enum(u8)) {
545545 stage_output: StageOutput = .output_triangles,
546546 max_primitives: u32 = 1,
547547 max_vertices: u32 = 3,
548 x: u32,
549 y: u32,
550 z: u32,
548551 };
549552
550553 /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies.
src/InternPool.zig+9-3
......@@ -5186,7 +5186,7 @@ pub const Tag = enum(u8) {
51865186 param_comptime_bits: ?[]u32,
51875187 param_noalias_bits: ?[]u32,
51885188 spirv_kernel_options: ?extern struct { x: u32, y: u32, z: u32 },
5189 spirv_mesh_options: ?extern struct { max_primitives: u32, max_vertices: u32 },
5189 spirv_mesh_options: ?extern struct { max_primitives: u32, max_vertices: u32, x: u32, y: u32, z: u32 },
51905190 param_types: []Index,
51915191 },
51925192 .config = .{
......@@ -9104,6 +9104,9 @@ pub fn getFuncType(
91049104 .spirv_mesh => |mesh| extra.appendSliceAssumeCapacity(.{&.{
91059105 mesh.max_primitives,
91069106 mesh.max_vertices,
9107 mesh.x,
9108 mesh.y,
9109 mesh.z,
91079110 }}),
91089111 else => {},
91099112 };
......@@ -12591,10 +12594,10 @@ const PackedCallingConvention = packed struct(u18) {
1259112594 };
1259212595 }
1259312596
12594 fn extraLen(cc: PackedCallingConvention) u2 {
12597 fn extraLen(cc: PackedCallingConvention) u3 {
1259512598 return switch (cc.tag) {
1259612599 .spirv_kernel, .spirv_task => 3,
12597 .spirv_mesh => 2,
12600 .spirv_mesh => 5,
1259812601 else => 0,
1259912602 };
1260012603 }
......@@ -12650,6 +12653,9 @@ const PackedCallingConvention = packed struct(u18) {
1265012653 .stage_output = @fromBackingInt(@intCast(cc.extra)),
1265112654 .max_primitives = trailing[0],
1265212655 .max_vertices = trailing[1],
12656 .x = trailing[2],
12657 .y = trailing[3],
12658 .z = trailing[4],
1265312659 },
1265412660 else => comptime unreachable,
1265512661 },
src/Sema.zig+3
......@@ -8777,6 +8777,9 @@ fn checkReturnTypeAndCallConv(
87778777 if (mesh.max_vertices == 0 or mesh.max_primitives == 0) {
87788778 return sema.fail(block, callconv_src, "mesh shader 'max_vertices' and 'max_primitives' must be at least 1", .{});
87798779 }
8780 if (mesh.x == 0 or mesh.y == 0 or mesh.z == 0) {
8781 return sema.fail(block, callconv_src, "mesh shader workgroup dimensions must be at least 1", .{});
8782 }
87808783 if (!target.cpu.has(.spirv, .mesh_shading_ext)) {
87818784 return sema.fail(block, callconv_src, "calling convention '{t}' requires the 'mesh_shading_ext' feature", .{@"callconv"});
87828785 }
src/link/SpirV.zig+4
......@@ -757,6 +757,10 @@ fn emitEntryPoints(
757757 .entry_point = final_id,
758758 .mode = .{ .output_primitives_ext = .{ .primitive_count = mesh.max_primitives } },
759759 });
760 try execution_modes_section.emit(gpa, .OpExecutionMode, .{
761 .entry_point = final_id,
762 .mode = .{ .local_size = .{ .x_size = mesh.x, .y_size = mesh.y, .z_size = mesh.z } },
763 });
760764 try execution_modes_section.emit(gpa, .OpExecutionMode, .{
761765 .entry_point = final_id,
762766 .mode = switch (mesh.stage_output) {
test/cases/callconv_spirv.zig+1-1
......@@ -2,7 +2,7 @@ export fn vert() callconv(.spirv_vertex) void {}
22export fn frag() callconv(.{ .spirv_fragment = .{ .depth_assumption = .greater } }) void {}
33export fn comp() callconv(.{ .spirv_kernel = .{ .x = 8, .y = 8, .z = 1 } }) void {}
44export fn task() callconv(.{ .spirv_task = .{ .x = 1, .y = 1, .z = 1 } }) void {}
5export fn mesh() callconv(.{ .spirv_mesh = .{ .stage_output = .output_lines, .max_primitives = 1, .max_vertices = 2 } }) void {}
5export fn mesh() callconv(.{ .spirv_mesh = .{ .stage_output = .output_lines, .max_primitives = 1, .max_vertices = 2, .x = 1, .y = 1, .z = 1 } }) void {}
66
77// compile
88// output_mode=Obj