Commit e389f524c9
src/codegen/spirv.zig
@@ -1456,6 +1456,7 @@ pub const DeclGen = struct {
.name = fqn,
});
+ // Temporarily generate a test kernel declaration if this is a test function.
if (self.module.test_functions.contains(self.decl_index)) {
try self.generateTestEntryPoint(fqn, spv_decl_index);
}
src/link/SpirV.zig
@@ -135,10 +135,21 @@ pub fn updateDeclExports(
decl_index: Module.Decl.Index,
exports: []const *Module.Export,
) !void {
- _ = self;
- _ = module;
- _ = decl_index;
- _ = exports;
+ const decl = module.declPtr(decl_index);
+ if (decl.val.tag() == .function and decl.ty.fnCallingConvention() == .Kernel) {
+ // TODO: Unify with resolveDecl in spirv.zig.
+ const entry = try self.decl_link.getOrPut(decl_index);
+ if (!entry.found_existing) {
+ entry.value_ptr.* = try self.spv.allocDecl(.func);
+ }
+ const spv_decl_index = entry.value_ptr.*;
+
+ for (exports) |exp| {
+ try self.spv.declareEntryPoint(spv_decl_index, exp.options.name);
+ }
+ }
+
+ // TODO: Export regular functions, variables, etc using Linkage attributes.
}
pub fn freeDecl(self: *SpirV, decl_index: Module.Decl.Index) void {