mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Merge pull request #2101 from qwerasd205/shader-fix
Fix crash on launch with custom shaders in Metal renderer
This commit is contained in:
@ -496,7 +496,7 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
|||||||
errdefer gpu_state.deinit();
|
errdefer gpu_state.deinit();
|
||||||
|
|
||||||
// Get our CAMetalLayer
|
// Get our CAMetalLayer
|
||||||
const layer = switch (builtin.os.tag) {
|
const layer: objc.Object = switch (builtin.os.tag) {
|
||||||
.macos => layer: {
|
.macos => layer: {
|
||||||
const CAMetalLayer = objc.getClass("CAMetalLayer").?;
|
const CAMetalLayer = objc.getClass("CAMetalLayer").?;
|
||||||
break :layer CAMetalLayer.msgSend(objc.Object, objc.sel("layer"), .{});
|
break :layer CAMetalLayer.msgSend(objc.Object, objc.sel("layer"), .{});
|
||||||
@ -556,7 +556,8 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
|||||||
|
|
||||||
break :state .{
|
break :state .{
|
||||||
// Resolution and screen textures will be fixed up by first
|
// Resolution and screen textures will be fixed up by first
|
||||||
// call to setScreenSize. This happens before any draw call.
|
// call to setScreenSize. Draw calls will bail out early if
|
||||||
|
// the screen size hasn't been set yet, so it won't error.
|
||||||
.front_texture = undefined,
|
.front_texture = undefined,
|
||||||
.back_texture = undefined,
|
.back_texture = undefined,
|
||||||
.sampler = sampler,
|
.sampler = sampler,
|
||||||
@ -869,6 +870,9 @@ pub fn updateFrame(
|
|||||||
) !void {
|
) !void {
|
||||||
_ = surface;
|
_ = surface;
|
||||||
|
|
||||||
|
// If we don't have a screen size yet then we can't render anything.
|
||||||
|
if (self.screen_size == null) return;
|
||||||
|
|
||||||
// Data we extract out of the critical area.
|
// Data we extract out of the critical area.
|
||||||
const Critical = struct {
|
const Critical = struct {
|
||||||
bg: terminal.color.RGB,
|
bg: terminal.color.RGB,
|
||||||
@ -1071,6 +1075,9 @@ pub fn updateFrame(
|
|||||||
pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void {
|
pub fn drawFrame(self: *Metal, surface: *apprt.Surface) !void {
|
||||||
_ = surface;
|
_ = surface;
|
||||||
|
|
||||||
|
// If we don't have a screen size yet then we can't render anything.
|
||||||
|
if (self.screen_size == null) return;
|
||||||
|
|
||||||
// If we have no cells rebuilt we can usually skip drawing since there
|
// If we have no cells rebuilt we can usually skip drawing since there
|
||||||
// is no changed data. However, if we have active animations we still
|
// is no changed data. However, if we have active animations we still
|
||||||
// need to draw so that we can update the time uniform and render the
|
// need to draw so that we can update the time uniform and render the
|
||||||
|
Reference in New Issue
Block a user