mirror of
https://github.com/mpv-player/mpv
synced 2025-01-10 00:49:32 +00:00
83884fdf03
Use the extension to compute the (hopefully correct) video delay and vsync phase. This is very fuzzy, because the latency will suddenly be applied after some frames have already been shown. This means there _will_ be "jumps" in the time accounting, which can lead to strange effects at start of playback (such as making initial "dropped" etc. frames worse). The only reasonable way to fix this would be running a few dummy frame swaps at start of playback until the latency is known. The same happens when unpausing. This only affects display-sync mode. Correct function was not confirmed. It only "looks right". I don't have the equipment to make scientifically correct measurements. A potentially bad thing is that we trust the timestamps we're receiving. Out of bounds timestamps could wreak havoc. On the other hand, this will probably cause the higher level code to panic and just disable DS. As a further caveat, this makes a bunch of assumptions about UST timestamps. If there are delayed frames (i.e. we skipped one or more vsyncs), the latency logic is mostly reset. There is no attempt to make the vo.c skipped vsync logic to use this. Also, the latency computation determines a vsync duration, and there's no effort to reconcile or share the vo.c logic for determining vsync duration.
56 lines
2.5 KiB
C
56 lines
2.5 KiB
C
#pragma once
|
|
|
|
#include "common/global.h"
|
|
#include "video/out/gpu/context.h"
|
|
#include "common.h"
|
|
|
|
extern const int mpgl_preferred_gl_versions[];
|
|
|
|
// Returns whether or not a candidate GL version should be accepted or not
|
|
// (based on the --opengl opts). Implementations may call this before
|
|
// ra_gl_ctx_init if they wish to probe for multiple possible GL versions.
|
|
bool ra_gl_ctx_test_version(struct ra_ctx *ctx, int version, bool es);
|
|
|
|
// These are a set of helpers for ra_ctx providers based on ra_gl.
|
|
// The init function also initializes ctx->ra and ctx->swapchain, so the user
|
|
// doesn't have to do this manually. (Similarly, the uninit function will
|
|
// clean them up)
|
|
|
|
struct ra_gl_ctx_params {
|
|
// Set to the platform-specific function to swap buffers, like
|
|
// glXSwapBuffers, eglSwapBuffers etc. This will be called by
|
|
// ra_gl_ctx_swap_buffers. Required unless you either never call that
|
|
// function or if you override it yourself.
|
|
void (*swap_buffers)(struct ra_ctx *ctx);
|
|
|
|
// See ra_swapchain_fns.get_latency.
|
|
double (*get_latency)(struct ra_ctx *ctx);
|
|
|
|
// Set to false if the implementation follows normal GL semantics, which is
|
|
// upside down. Set to true if it does *not*, i.e. if rendering is right
|
|
// side up
|
|
bool flipped;
|
|
|
|
// If this is set to non-NULL, then the ra_gl_ctx will consider the GL
|
|
// implementation to be using an external swapchain, which disables the
|
|
// software simulation of --swapchain-depth. Any functions defined by this
|
|
// ra_swapchain_fns structs will entirely replace the equivalent ra_gl_ctx
|
|
// functions in the resulting ra_swapchain.
|
|
const struct ra_swapchain_fns *external_swapchain;
|
|
};
|
|
|
|
void ra_gl_ctx_uninit(struct ra_ctx *ctx);
|
|
bool ra_gl_ctx_init(struct ra_ctx *ctx, GL *gl, struct ra_gl_ctx_params params);
|
|
|
|
// Call this any time the window size or main framebuffer changes
|
|
void ra_gl_ctx_resize(struct ra_swapchain *sw, int w, int h, int fbo);
|
|
|
|
// These functions are normally set in the ra_swapchain->fns, but if an
|
|
// implementation has a need to override this fns struct with custom functions
|
|
// for whatever reason, these can be used to inherit the original behavior.
|
|
int ra_gl_ctx_color_depth(struct ra_swapchain *sw);
|
|
struct mp_image *ra_gl_ctx_screenshot(struct ra_swapchain *sw);
|
|
bool ra_gl_ctx_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo);
|
|
bool ra_gl_ctx_submit_frame(struct ra_swapchain *sw, const struct vo_frame *frame);
|
|
void ra_gl_ctx_swap_buffers(struct ra_swapchain *sw);
|