spirv: deny OpEntryPoint in asm

Kernels should be exported by marking the kernel using callconv(.Kernel) and
exporting it as a regular function.
This commit is contained in:
Robin Voetter
2023-04-08 15:03:05 +02:00
parent e389f524c9
commit 1de2d2ee1c

View File

@@ -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,