mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-10-25 13:31:41 +00:00
Fix blocking during rendering rather than in waitToRender() on MoltenVK
MoltenVK does a lazy fetch of the drawable only when it's being modified, so waitToRender() is completely ineffective as is. Rendering a small empty overlay in waitToRender() forces the next drawable wait to happen in waitToRender(), before we pick the current frame to render. This removes one display refresh period of latency when using V-sync.
This commit is contained in:
1 parent
d997a0d0c8
commit
6e231778a2
2 files changed
+147
-64
No files matched your search
@@ -28,6 +28,11 @@ private:
|
||||
// from getting a new drawable while the current one is getting scanned out.
|
||||
#define PLVK_USE_DYNAMIC_SWAPCHAIN_DEPTH 1
|
||||
|
||||
// MoltenVK will block for the next drawable when we render the next frame
|
||||
// rather than inside pl_swapchain_start_frame(), so we will force it to wait
|
||||
// by rendering some no-op work right after we get the new swapchain frame.
|
||||
#define PLVK_USE_EARLY_RENDER_TO_WAIT 1
|
||||
|
||||
#endif
|
||||
|
||||
class PlVkRenderer : public IFFmpegRenderer {
|
||||
@@ -54,7 +59,11 @@ private:
|
||||
static void unlockQueue(AVHWDeviceContext *dev_ctx, uint32_t queue_family, uint32_t index);
|
||||
static void overlayUploadComplete(void* opaque);
|
||||
|
||||
void beginRenderTiming();
|
||||
void endRenderTiming();
|
||||
|
||||
bool createSwapchain(int depth);
|
||||
bool createOverlay(pl_overlay* overlay, SDL_Surface* surface);
|
||||
bool mapAvFrameToPlacebo(const AVFrame *frame, pl_frame* mappedFrame);
|
||||
void unmapAvFrameFromPlacebo(const AVFrame *frame, pl_frame* mappedFrame);
|
||||
bool populateQueues(int videoFormat);
|
||||
@@ -76,6 +85,7 @@ private:
|
||||
|
||||
#ifdef PLVK_USE_DYNAMIC_SWAPCHAIN_DEPTH
|
||||
int m_DelayedPresents = 0;
|
||||
Uint32 m_RenderStartTime = 0;
|
||||
#endif
|
||||
|
||||
// SDL state
|
||||
@@ -96,6 +106,11 @@ private:
|
||||
pl_tex m_Textures[PL_MAX_PLANES] = {};
|
||||
pl_color_space m_LastColorspace = {};
|
||||
|
||||
#ifdef PLVK_USE_EARLY_RENDER_TO_WAIT
|
||||
pl_overlay m_EmptyOverlay = {};
|
||||
pl_overlay_part m_EmptyOverlayPart = {};
|
||||
#endif
|
||||
|
||||
// Pending swapchain state shared between waitToRender(), renderFrame(), and cleanupRenderContext()
|
||||
pl_swapchain_frame m_SwapchainFrame = {};
|
||||
bool m_HasPendingSwapchainFrame = false;
|
||||
|
||||
Reference in new issue
Block a user