From 1de2d2ee1c70dfd01dc8b161af53ce188e84b1d0 Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Sat, 8 Apr 2023 15:03:05 +0200 Subject: [PATCH] spirv: deny OpEntryPoint in asm Kernels should be exported by marking the kernel using callconv(.Kernel) and exporting it as a regular function. --- src/codegen/spirv/Assembler.zig | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/codegen/spirv/Assembler.zig b/src/codegen/spirv/Assembler.zig index a8ff5175d8..ffb5503afc 100644 --- a/src/codegen/spirv/Assembler.zig +++ b/src/codegen/spirv/Assembler.zig @@ -239,12 +239,17 @@ fn todo(self: *Assembler, comptime fmt: []const u8, args: anytype) Error { /// If this function returns `error.AssembleFail`, an explanatory /// error message has already been emitted into `self.errors`. fn processInstruction(self: *Assembler) !void { - const result = switch (self.inst.opcode.class()) { - .TypeDeclaration => try self.processTypeInstruction(), - else => if (try self.processGenericInstruction()) |result| - result - else - return, + const result = switch (self.inst.opcode) { + .OpEntryPoint => { + return self.fail(0, "cannot export entry points via OpEntryPoint, export the kernel using callconv(.Kernel)", .{}); + }, + else => switch (self.inst.opcode.class()) { + .TypeDeclaration => try self.processTypeInstruction(), + else => if (try self.processGenericInstruction()) |result| + result + else + return, + }, }; const result_ref = self.inst.result().?; @@ -435,8 +440,7 @@ fn processGenericInstruction(self: *Assembler) !?AsmValue { .Annotation => &self.spv.sections.annotations, .TypeDeclaration => unreachable, // Handled elsewhere. else => switch (self.inst.opcode) { - // TODO: This should emit a proper entry point. - .OpEntryPoint => unreachable, // &self.spv.sections.entry_points, + .OpEntryPoint => unreachable, .OpExecutionMode, .OpExecutionModeId => &self.spv.sections.execution_modes, .OpVariable => switch (@intToEnum(spec.StorageClass, operands[2].value)) { .Function => &self.func.prologue,