Commit Graph

5355 Commits

Author SHA1 Message Date
Dudemanguy 879824a47f wayland: add wp-fractional-scale-v1 support
This protocol is pretty important since it finally lets us solve the
longstanding issue of fractional scaling in wayland (no more mpv doing
rendering over the target resolution and then being scaled down). This
protocol also can completely replace the buffer_scale usage that we are
currently using for integer scaling so hopefully this can be removed
sometime in the future. Note that vo_dmabuf_wayland is omitted from the
fractional scale handling because we want the compositor to handle all
the scaling for that VO.

Fixes #9443.
2023-01-24 00:04:39 +00:00
Dudemanguy 006ec9ce43 wayland: rewrite geometry and scaling handling
This is in preparation for fractional scaling support. Basically, redo
all the coordinates in wayland so that wl->geometry is equal exactly to
what is being put out to the screen (no extra wl->scaling multiplication
required). The wl->vdparams variable is also eliminated for simplicity.
This changes mpv's behavior on wayland with hidpi scaling but that will
be addressed in more detail with the next commit.
2023-01-24 00:04:39 +00:00
sfan5 9b59d39a3a vo_gpu: implement VO_DR_FLAG_HOST_CACHED
For OpenGL, this is based on simply comparing GL_VENDOR strings against
a list of allowed vendors.

Co-authored-by: Nicolas F. <ovdev@fratti.ch>
Co-authored-by: Niklas Haas <git@haasn.dev>
2023-01-23 14:13:34 +01:00
Niklas Haas 2531a89fcb vo_gpu_next: implement VO_DR_FLAG_HOST_CACHED
For sufficiently new versions of libplacebo.
2023-01-23 14:13:34 +01:00
sfan5 c7ea0cd68f vd_lavc: add "auto" choice for vd-lavc-dr
--vd-lavc-dr defaulted to "yes", which caused issues on certain
hardware. Instead of disabling it, add a new "auto" value and
make it the default.

The "auto" choice will enable DR only when we can request host-cached
buffers (as signalled by the new VO_DR_FLAG_HOST_CACHED).

Co-authored-by: Nicolas F. <ovdev@fratti.ch>
Co-authored-by: Niklas Haas <git@haasn.dev>
2023-01-23 14:13:34 +01:00
Niklas Haas f8c17f55f9 vo: add `int flags` to the get_image signature
This is a huge disgusting mess to thread through everywhere. Maybe I'm
stupid for attempting to solve the problem this way.
2023-01-23 14:13:34 +01:00
Dudemanguy 92a6f2d687 drm: rewrite based around vo_drm_state
A longstanding pain point of the drm VOs is the relative lack of state
sharing. While drm_common does provide some sharing, it's far less than
other platforms like x11 or wayland. What we do here is essentially copy
them by creating a new vo_drm_state struct and using it in vo_drm and
context_drm_egl. Much of the functionality that was essentially
duplicated in both VOs/contexts is now reduced simple functions in
drm_common. The usage of the term 'kms' was also mostly eliminated since
this is libdrm nowadays from a userspace perspective.
2023-01-21 17:08:29 +00:00
Niklas Haas 8c617765fe mp_image: fix XYZ primaries default
This was incorrectly set to BT.2020, when it should be DCI-P3 for pretty
much all real-world XYZ content (which is digital cinema content).
2023-01-21 13:03:33 +01:00
Niklas Haas b091dfda71 hwdec_cuda: drop support for PL_HANDLE_WIN32_KMT
This handle type was only needed for backwards compatibility with
windows 7. Dropping it allows us to simplify the code: there is no
longer a need for runtime checks, as the handle type can now be
statically assigned based on the platform.

The motivating usecase here, apart from code simplification, is a
desired switch to timeline semaphores, which (in the CUDA API) only
supports the non-KMT win32 handles.

It's worth pointing out that we need no runtime check for
IsWindows8OrGreater(), because the `export_caps.sync` check will already
fail on versions of windows not supporting PL_HANDLE_WIN32.
2023-01-17 11:38:46 +01:00
Thomas Weißschuh f52cfdabca wayland: only warn when actually missing idle inhibit support 2023-01-16 19:26:09 +00:00
Thomas Weißschuh 2bbf880d96 vo: make driver list static 2023-01-16 19:25:54 +00:00
Thomas Weißschuh f66c5404f4 vo: remove trailing NULL element from driver array 2023-01-16 19:25:54 +00:00
Dudemanguy 6cdce9e18e wayland: store presentation feedbacks in a pool
Officially, the most cursed part of the wayland code in mpv (third or
fourth try now?) This time, let's allocate a pool during init
(arbitrarily set to the maximum swapchain length mpv allows, 8; don't
even know if this actually works in wayland). Then we add/remove
feedbacks from the pool during the lifecycle of the VO, and clean it up
all at the end. Hopefully, this does the trick for good this time.
2023-01-13 22:24:11 -06:00
Dudemanguy f32c5586d6 Revert "wayland: dispatch and wait for compositor events in uninit"
This ended up being a bad idea. The problem is that it introduces
ordering when destroying events (something we weren't worried about
before) and Lynne pointed out a problem with the callback not also being
destroyed before the surface in IRC. Just undo this and go with a
different approach (next commit). P.S. the wayland_dispatch_events name
change is kept though because I like that better.

This reverts commit aa8ddfcdf3.
2023-01-13 22:23:49 -06:00
sfan5 1201d59f0b various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriate
In debug mode the macro causes an assertion failure.
In release mode it works differently and tells the compiler that it can
assume the codepath will never execute. For this reason I was conversative
in replacing it, e.g. in mpv-internal code that exhausts all valid values
of an enum or when a condition is clear from directly preceding code.
2023-01-12 22:02:07 +01:00
sfan5 7b03cd367d various: replace if + abort() with MP_HANDLE_OOM()
MP_HANDLE_OOM also aborts but calls assert() first, which
will result in an useful message if compiled in debug mode.
2023-01-12 22:02:07 +01:00
sfan5 833bff8738 {video,audio}: adjust unsafe strncpy usages 2023-01-12 22:02:07 +01:00
sfan5 f4280e5238 video/x11: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5 2703a2c8ff video: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5 356096b954 ra_d3d11: fix incorrect type
As it happens, `SIZE_T` and `size_t` are not the same length on 32-bit Windows
2023-01-12 22:02:07 +01:00
Dudemanguy a5b9d529ee vo_dmabuf_wayland: drop support for linux-dmabuf-v2
The only real reason this was ever supported is because it was
dramatically simpler than v4, so it was put in as an initial
implementation. Later, v4 support was added and we left v2 for
compatibility, but let's just drop it. Compositors all use v4 nowadays,
and v2 is significantly limited (no modifier support for example). It's
better to just remove this dead code for simplicity.
2023-01-12 17:42:35 +00:00
Aaron Boxer 865a159244 vo_dmabuf_wayland: support panscan and panning 2023-01-11 18:10:40 +00:00
Dudemanguy 4beb1bcae7 vo_wlshm: properly support video panscan
Turns out it was already doing this under the hood the entire time. The
only catch is that the vo just needed a resize.
2023-01-09 19:30:26 -06:00
Dudemanguy 8439c084e1 wayland: make vo_wayland_reconfig a bool
This was already returning true/false but the type was int. Also
simplify a few places in the wayland contexts where we can just return
the value of this function instead of doing redundant checks.
2023-01-08 20:42:42 +00:00
Dudemanguy d73fc7912a wayland: cleanup on vo_wayland_init error
Instead of just returning true/false, it's better to have this function
cleanup itself. We can eliminate some redundant uninit calls elsewhere
in the code as well.
2023-01-08 20:42:42 +00:00
Dudemanguy e4e0e7dfcf vo: change vo_platform_init to bool
There's several functions that are used for initializing mpv on a
certain platform (x11, wayland, etc.). These currently are all int, but
they actually return 1 and 0 like a boolean. This gets a bit confusing
because actual vo preinit functions return 0 and -1 instead. Just make
these all bool instead and return true/false to make it clearer.
2023-01-08 20:42:42 +00:00
Dudemanguy e43393c4da vo_wlshm: cleanup on failure
If failure occurs during preinit, vo_wlshm should goto an error and
cleaup itself like the other VOs.
2023-01-08 12:39:50 -06:00
Dudemanguy c5af54eb35 vo_dmabuf_wayland: goto err instead of returning
Returning early is clearly wrong. It should use to goto to cleanup after
itself. Also renamed from error_out to err for purely comestic reasons.
2023-01-08 12:19:14 -06:00
Christoph Reiter 96773f39e1 vulkan: fix build error for 32bit builds with clang
vk->surface is a handle and not a pointer, so assign VK_NULL_HANDLE.
This fixes the following build error on 32bit Windows when using clang for example,
which errors out when assigning a 32bit pointer to a 64bit integer:

  ../mpv-0.35.0/video/out/vulkan/utils.c:37:21:
    error: incompatible pointer to integer conversion assigning to 'VkSurfaceKHR' (aka 'unsigned long long') from 'void *' [-Wint-conversion]
          vk->surface = NULL;
                      ^ ~~~~
2023-01-08 16:09:01 +01:00
Dudemanguy aa8ddfcdf3 wayland: dispatch and wait for compositor events in uninit
Similar to some other issues we've had with unprocessed compositor
events. When quitting mpv, there's two things we should be doing:
dispatching any last minute wayland events and then waiting for a
compositor reply. Luckily, there's already an internal helper for this
(renamed to wayland_dispatch_events for consistency) that we can use.
All of the special casing of wl->feedback becomes unneccesary and we can
remove this from vo_wayland_state with this method. Fixes #110022.
2023-01-03 20:45:39 +00:00
Dudemanguy 4bbb1ccfd7 wayland: initalize display_fd as -1
In the event of a failed wayland initalization, the display_fd is
actually 0 instead of -1 which would correctly indicate it doesn't
exist. Also move the fd check inside vo_wayland_dispatch_events since
that function shouldn't ever do anything if we don't actually have a
display fd.
2023-01-03 20:45:39 +00:00
Dudemanguy 24e2251b73 wayland: consistently employ use_present
We have a use_present bool that keeps track of whether or not to use
presentation time. However, the creation of the feedback listener
actually wasn't checking this and was instead checking for the existence
of wl->presentation. There's no point in always creating the
listener and feedback if mpv isn't actually going to use it. Just change
it to use_present instead.
2023-01-03 20:45:39 +00:00
repojohnray fee6847aa7 vo: hwdec: fix drmGetDeviceNameFromFd2() related memory leak
This commit fixes a minor memory leak related to drmGetDeviceNameFromFd2().
This function returns a string allocated with strdup().
2023-01-02 16:48:24 -08:00
repojohnray 2e9c43f931 hwdec_drmprime: fix memory leak 2023-01-02 19:46:07 +01:00
Kacper Michajłow ad65c8855b vo_opengl: do not blindly reject all Microsoft's OpenGL implementations
This change enables mpv to work in the WSL2 (WSLg) environment where
OpenGL is implemented on top of D3D12.

This reverts commit 149d98d244.

Mentioned OpenGL implementation (GDI Generic) in the original change
will be rejected by version check, so there is no need to handle it
manually.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2022-12-30 11:02:52 -05:00
Sultan Alsawaf 4a2aa36674 x11: add modesetting to the xpresent whitelist
Since the modesetting driver now has TearFree support with integration into
xpresent, it's important that xpresent is used with the modesetting driver
to get the correct vsync timing when a frame is delayed by one vblank
interval due to a pending page-flip enqueued by a different entity. The
modesetting driver ensures that the xpresent extension reports the correct
presentation timing when TearFree is used; mpv just needs to listen to it.

Add the modesetting driver to the xpresent whitelist so mpv can get the
correct presentation completion timing when modesetting TearFree is used.

This is also helpful for when xpresent performs page flips directly in the
modesetting driver and a natural delay in the display pipeline causes a
page flip to be delayed by one vblank interval or more.
2022-12-27 13:07:33 +01:00
sfan5 d8ae14653a build: add configure test for POSIX shm for the sake of vo_kitty
Android's POSIX coverage is pretty sketchy but not like we have a choice.
2022-12-26 15:08:07 +01:00
Mia Herkt 874e28f4a4
vo_kitty: Introduce modern sixel alternative
See https://sw.kovidgoyal.net/kitty/graphics-protocol/

This makes no attempt at querying terminal features or handling
terminal errors, as it would require mpv to pass the response codes
from the terminal to the vo instead of interpreting them as
keystrokes made by the user and acting very unpredictably.

Tested with kitty and konsole.

Fixes #9605
2022-12-21 19:39:30 +01:00
chen70 3447463008 hwdec/d3d11va: fix a possible memory leak 2022-12-21 19:03:38 +01:00
garamond13 27dab30209 filter_kernels: fix kaiser
Seems to me that params[1] is set to NAN and here should be the same value as in params[0].
2022-12-20 13:53:25 +01:00
Mia Herkt 56f0ba22f1
vo_sixel: Implement write() loop
Not all systems are Linux. Also update the comment to better reflect
POSIX documentation.
2022-12-20 10:45:36 +01:00
Mia Herkt 125fd4c2f9
vo_sixel: Rename draw-clear -> config-clear 2022-12-20 10:29:49 +01:00
Mia Herkt 08747c4965
osdep/terminal.h: Rename screen buffer controls
SAVE/RESTORE were a bit misleading.
2022-12-20 10:26:53 +01:00
Mia Herkt a4cac2ddc6
vo_sixel: Alias/deprecate exit-clear -> alt-screen
Also update documentation to reflect actual behavior.
2022-12-20 10:22:51 +01:00
Mia Herkt 12c3203e98
vo_sixel: Make buffering optional
It can be slower than unbuffered.
2022-12-20 10:06:49 +01:00
Mia Herkt fe21553637 vo_sixel: Buffer full output sequence
This allows the VO to write its output without interference from other
processes or threads.
2022-12-19 13:48:49 +01:00
Mia Herkt 3ca31b6cf4 vo_sixel: Use write(2) on POSIX platforms 2022-12-19 13:48:49 +01:00
Mia Herkt 0f721ab51c vo_tct: Use newer options API 2022-12-19 13:48:49 +01:00
Mia Herkt 85f1fa0715 vo_sixel: Move user options to struct 2022-12-19 13:48:49 +01:00
Mia Herkt 68ae603e75 vo_sixel: Add option to skip clear while drawing 2022-12-19 13:48:49 +01:00