mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-06-04 02:44:50 +00:00
renderer/metal: load shaders from precompiled lib
This commit is contained in:
@@ -156,27 +156,29 @@ pub const PostUniforms = extern struct {
|
||||
|
||||
/// Initialize the MTLLibrary. A MTLLibrary is a collection of shaders.
|
||||
fn initLibrary(device: objc.Object) !objc.Object {
|
||||
// Hardcoded since this file isn't meant to be reusable.
|
||||
const data = @embedFile("../shaders/cell.metal");
|
||||
const source = try macos.foundation.String.createWithBytes(
|
||||
data,
|
||||
.utf8,
|
||||
false,
|
||||
const start = try std.time.Instant.now();
|
||||
|
||||
const data = try macos.dispatch.Data.create(
|
||||
@embedFile("../shaders/Ghostty.metallib"),
|
||||
macos.dispatch.queue.getMain(),
|
||||
macos.dispatch.Data.DESTRUCTOR_DEFAULT,
|
||||
);
|
||||
defer source.release();
|
||||
defer data.release();
|
||||
|
||||
var err: ?*anyopaque = null;
|
||||
const library = device.msgSend(
|
||||
objc.Object,
|
||||
objc.sel("newLibraryWithSource:options:error:"),
|
||||
objc.sel("newLibraryWithData:error:"),
|
||||
.{
|
||||
source,
|
||||
@as(?*anyopaque, null),
|
||||
data,
|
||||
&err,
|
||||
},
|
||||
);
|
||||
try checkError(err);
|
||||
|
||||
const end = try std.time.Instant.now();
|
||||
log.debug("shader library loaded time={}us", .{end.since(start) / std.time.ns_per_us});
|
||||
|
||||
return library;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user