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)) {...@@ -545,6 +545,9 @@ pub const CallingConvention = union(enum(u8)) {
545 stage_output: StageOutput = .output_triangles,545 stage_output: StageOutput = .output_triangles,
546 max_primitives: u32 = 1,546 max_primitives: u32 = 1,
547 max_vertices: u32 = 3,547 max_vertices: u32 = 3,
548 x: u32,
549 y: u32,
550 z: u32,
548 };551 };
549552
550 /// Returns the array of `std.Target.Cpu.Arch` to which this `CallingConvention` applies.553 /// 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) {...@@ -5186,7 +5186,7 @@ pub const Tag = enum(u8) {
5186 param_comptime_bits: ?[]u32,5186 param_comptime_bits: ?[]u32,
5187 param_noalias_bits: ?[]u32,5187 param_noalias_bits: ?[]u32,
5188 spirv_kernel_options: ?extern struct { x: u32, y: u32, z: u32 },5188 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 },
5190 param_types: []Index,5190 param_types: []Index,
5191 },5191 },
5192 .config = .{5192 .config = .{
...@@ -9104,6 +9104,9 @@ pub fn getFuncType(...@@ -9104,6 +9104,9 @@ pub fn getFuncType(
9104 .spirv_mesh => |mesh| extra.appendSliceAssumeCapacity(.{&.{9104 .spirv_mesh => |mesh| extra.appendSliceAssumeCapacity(.{&.{
9105 mesh.max_primitives,9105 mesh.max_primitives,
9106 mesh.max_vertices,9106 mesh.max_vertices,
9107 mesh.x,
9108 mesh.y,
9109 mesh.z,
9107 }}),9110 }}),
9108 else => {},9111 else => {},
9109 };9112 };
...@@ -12591,10 +12594,10 @@ const PackedCallingConvention = packed struct(u18) {...@@ -12591,10 +12594,10 @@ const PackedCallingConvention = packed struct(u18) {
12591 };12594 };
12592 }12595 }
1259312596
12594 fn extraLen(cc: PackedCallingConvention) u2 {12597 fn extraLen(cc: PackedCallingConvention) u3 {
12595 return switch (cc.tag) {12598 return switch (cc.tag) {
12596 .spirv_kernel, .spirv_task => 3,12599 .spirv_kernel, .spirv_task => 3,
12597 .spirv_mesh => 2,12600 .spirv_mesh => 5,
12598 else => 0,12601 else => 0,
12599 };12602 };
12600 }12603 }
...@@ -12650,6 +12653,9 @@ const PackedCallingConvention = packed struct(u18) {...@@ -12650,6 +12653,9 @@ const PackedCallingConvention = packed struct(u18) {
12650 .stage_output = @fromBackingInt(@intCast(cc.extra)),12653 .stage_output = @fromBackingInt(@intCast(cc.extra)),
12651 .max_primitives = trailing[0],12654 .max_primitives = trailing[0],
12652 .max_vertices = trailing[1],12655 .max_vertices = trailing[1],
12656 .x = trailing[2],
12657 .y = trailing[3],
12658 .z = trailing[4],
12653 },12659 },
12654 else => comptime unreachable,12660 else => comptime unreachable,
12655 },12661 },
src/Sema.zig+3
...@@ -8777,6 +8777,9 @@ fn checkReturnTypeAndCallConv(...@@ -8777,6 +8777,9 @@ fn checkReturnTypeAndCallConv(
8777 if (mesh.max_vertices == 0 or mesh.max_primitives == 0) {8777 if (mesh.max_vertices == 0 or mesh.max_primitives == 0) {
8778 return sema.fail(block, callconv_src, "mesh shader 'max_vertices' and 'max_primitives' must be at least 1", .{});8778 return sema.fail(block, callconv_src, "mesh shader 'max_vertices' and 'max_primitives' must be at least 1", .{});
8779 }8779 }
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 }
8780 if (!target.cpu.has(.spirv, .mesh_shading_ext)) {8783 if (!target.cpu.has(.spirv, .mesh_shading_ext)) {
8781 return sema.fail(block, callconv_src, "calling convention '{t}' requires the 'mesh_shading_ext' feature", .{@"callconv"});8784 return sema.fail(block, callconv_src, "calling convention '{t}' requires the 'mesh_shading_ext' feature", .{@"callconv"});
8782 }8785 }
src/link/SpirV.zig+4
...@@ -757,6 +757,10 @@ fn emitEntryPoints(...@@ -757,6 +757,10 @@ fn emitEntryPoints(
757 .entry_point = final_id,757 .entry_point = final_id,
758 .mode = .{ .output_primitives_ext = .{ .primitive_count = mesh.max_primitives } },758 .mode = .{ .output_primitives_ext = .{ .primitive_count = mesh.max_primitives } },
759 });759 });
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 });
760 try execution_modes_section.emit(gpa, .OpExecutionMode, .{764 try execution_modes_section.emit(gpa, .OpExecutionMode, .{
761 .entry_point = final_id,765 .entry_point = final_id,
762 .mode = switch (mesh.stage_output) {766 .mode = switch (mesh.stage_output) {
test/cases/callconv_spirv.zig+1-1
...@@ -2,7 +2,7 @@ export fn vert() callconv(.spirv_vertex) void {}...@@ -2,7 +2,7 @@ export fn vert() callconv(.spirv_vertex) void {}
2export fn frag() callconv(.{ .spirv_fragment = .{ .depth_assumption = .greater } }) void {}2export fn frag() callconv(.{ .spirv_fragment = .{ .depth_assumption = .greater } }) void {}
3export fn comp() callconv(.{ .spirv_kernel = .{ .x = 8, .y = 8, .z = 1 } }) void {}3export fn comp() callconv(.{ .spirv_kernel = .{ .x = 8, .y = 8, .z = 1 } }) void {}
4export fn task() callconv(.{ .spirv_task = .{ .x = 1, .y = 1, .z = 1 } }) void {}4export 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
7// compile7// compile
8// output_mode=Obj8// output_mode=Obj