Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac/vulkan: add support for visibility check for rendering #15917

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions video/out/mac_common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,18 @@ class MacCommon: Common {
}
}

@objc func fillVsync(info: UnsafeMutablePointer<vo_vsync_info>) {
@objc func fillVsync(info: UnsafeMutablePointer<vo_vsync_info>) {
if option.mac.macos_render_timer != RENDER_TIMER_PRESENTATION_FEEDBACK { return }

let next = presentation?.next()
info.pointee.vsync_duration = next?.duration ?? -1
info.pointee.skipped_vsyncs = next?.skipped ?? -1
info.pointee.last_queue_display_time = next?.time ?? -1
}
}

@objc func isVisible() -> Bool {
return window?.occlusionState.contains(.visible) ?? false
}

override func displayLinkCallback(_ displayLink: CVDisplayLink,
_ inNow: UnsafePointer<CVTimeStamp>,
Expand Down
7 changes: 7 additions & 0 deletions video/out/vulkan/context_mac.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ static int mac_vk_color_depth(struct ra_ctx *ctx)
return 0;
}

static bool mac_vk_check_visible(struct ra_ctx *ctx)
{
struct priv *p = ctx->priv;
return [p->vo_mac isVisible];
}

static bool mac_vk_init(struct ra_ctx *ctx)
{
struct priv *p = ctx->priv = talloc_zero(ctx, struct priv);
Expand Down Expand Up @@ -84,6 +90,7 @@ static bool mac_vk_init(struct ra_ctx *ctx)
.swap_buffers = mac_vk_swap_buffers,
.get_vsync = mac_vk_get_vsync,
.color_depth = mac_vk_color_depth,
.check_visible = mac_vk_check_visible,
};

VkInstance inst = vk->vkinst->instance;
Expand Down
Loading