diff options
| author | Robin Voetter <robin@voetter.nl> | 2024-10-20 16:53:53 +0200 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2024-10-27 15:19:55 +0100 |
| commit | 6de456c179d81b9118ecd26eb9d7c90213bac313 (patch) | |
| tree | 1dda74e9dad818e8d00d03438b3bf636470011c6 /src/codegen/spirv.zig | |
| parent | 9b42bc1ce5a1d688aa2167a068a3b75d69888c12 (diff) | |
| download | zig-6de456c179d81b9118ecd26eb9d7c90213bac313.tar.gz zig-6de456c179d81b9118ecd26eb9d7c90213bac313.zip | |
spirv: fix up calling conventions for vulkan
* Fragment and Vertex CCs are only valid for SPIR-V when
running under Vulkan.
* Emit GLCompute instead of Kernel for SPIR-V kernels.
Diffstat (limited to 'src/codegen/spirv.zig')
| -rw-r--r-- | src/codegen/spirv.zig | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 279b7d5056..da527c9ac8 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -1640,13 +1640,18 @@ const NavGen = struct { comptime assert(zig_call_abi_ver == 3); switch (fn_info.cc) { - .auto, .spirv_kernel, .spirv_fragment, .spirv_vertex => {}, - else => @panic("TODO"), + .auto, + .spirv_kernel, + .spirv_fragment, + .spirv_vertex, + .spirv_device, + => {}, + else => unreachable, } - // TODO: Put this somewhere in Sema.zig - if (fn_info.is_var_args) - return self.fail("VarArgs functions are unsupported for SPIR-V", .{}); + // Guaranteed by callConvSupportsVarArgs, there are nog SPIR-V CCs which support + // varargs. + assert(!fn_info.is_var_args); // Note: Logic is different from functionType(). const param_ty_ids = try self.gpa.alloc(IdRef, fn_info.param_types.len); @@ -2969,11 +2974,10 @@ const NavGen = struct { try self.func.prologue.emit(self.spv.gpa, .OpFunction, .{ .id_result_type = return_ty_id, .id_result = result_id, - .function_control = switch (fn_info.cc) { - .@"inline" => .{ .Inline = true }, - else => .{}, - }, .function_type = prototype_ty_id, + // Note: the backend will never be asked to generate an inline function + // (this is handled in sema), so we don't need to set function_control here. + .function_control = .{}, }); comptime assert(zig_call_abi_ver == 3); |
