Commit Graph

3838 Commits

Author SHA1 Message Date
Jan Ekström c72b897e9c vo_gpu_next/context: get graphics API-specific contexts from pl_gpu
By receiving the graphics API-specific contexts from the generic
pl_gpu instance, it is not necessary to store them separately.
As the current priv struct stores nothing else, this allows its
removal. This removal cleans up related compiler warnings regarding
unused variables in case of opengl and d3d11 being disabled in
mpv/libplacebo.

Functions to receive the underlying vulkan,gl,d3d11 structure were
added in libplacebo version 4.182. Our current requirement for
gpu-next is 4.190, and thus we can freely utilize these helper
functions.
2022-02-06 22:59:14 +02:00
Philip Langdale 240340d60a vo_gpu: hwdec_vaapi: Don't probe formats for irrelevant endpoints
While testing support for the exotic formats used by Intel vaapi for
4:2:2 and 4:4:4 surfaces, I realised that we were enumerating all
endpoints and checking formats for them. The problem with this is
that decoding (VLD) endpoints are only a subset of what vaapi exposes.

All the encoding endpoints are there too, and there is also the
None profile that we don't care about, but which generates ffmpeg
warnings if you try and examine it.

So, let's only look at VLD endpoints. This will speed things up a
little bit and make the logging less noisy.
2022-02-06 14:40:18 +02:00
Niklas Haas 5d31c7310c libplacebo: switch to new target format API
`target_dummy` got deprecated in version v4.169. We unfortunately have
to hide this behind an #if for the time being.
2022-02-03 18:22:14 +01:00
Niklas Haas d59eb58007 libplacebo: switch to new GPU limits APIs
`caps` is deprecated, and replaced by individual fields in
`pl_glsl_version` / `pl_gpu_limits`.
2022-02-03 18:22:14 +01:00
Niklas Haas b2958670a3 libplacebo: switch to v4 naming convention
All of these const struct pointers got typedefs, clean up the code
accordingly.
2022-02-03 18:22:14 +01:00
Niklas Haas 88c6c84b64 libplacebo: update log helpers
Use the pl_log APIs introduced in libplacebo v4, replacing the
deprecated pl_context concept.
2022-02-03 18:22:14 +01:00
Niklas Haas e8e89fae38 libplacebo: bump minimum dependency to 4.157
This has been the latest stable release for about half a year now. This
version in particular lets us get rid of all the deprecation warnings in
the older code. (See the following commits)
2022-02-03 18:22:14 +01:00
Niklas Haas 9d1f48bda2 vo_gpu_next: create shader cache dir if missing
Failing to do this results in the shader cache not actually ever being
written, ergo no shader caching being done. Oops.
2022-02-03 18:22:14 +01:00
Niklas Haas a2b147abc6 build: rename libplacebo version check
Rename from "libplacebo-v4" to "libplacebo-next" to more closely capture
the intent, since this will become libplacebo v5 eventually (tm).
2022-02-03 18:22:14 +01:00
Julian Orth c25129339d wayland: always start rendering after a resize
The wayland backend contains logic to detect if the window is hidden. If
so, we skip rendering as an optimization. However, if we receive
multiple resize events in rapid succession, we will send the compositor
new buffers faster than the refresh rate of the monitor.  Therefore the
compositor will not send us frame events which we incorrectly interpret
as the window being hidden.

Once the last buffer has actually been rendered, the compositor sends us
a frame event. However, if at that point playback is paused, there is no
logic to restart rendering of frames that we skipped due to the above
optimization.  Therefore we never send the compositor new buffers
corresponding to the new size of the window and the surface will either
be too small or too large.

The simplest solution is to always render a few frames after we receive
a resize event.
2022-02-03 16:15:59 +00:00
garamond13 67a2b2852c filter kernels: add cosine window
filter kernels: add cosine window
2022-02-03 01:25:50 +01:00
Jan Ekström 053f10003c vo_gpu_next: initial attempt at adding d3d11 support 2022-02-02 22:53:32 +02:00
Jan Ekström 723a2ba762 vo_gpu_next/context: common'ize things that would be common for non-vulkan
This prepares us to not duplicate all of this code for d3d11.
2022-02-02 21:48:01 +02:00
Jan Ekström 13d0df7c21 vo_gpu/d3d11: enable access to the underlying ra_ctx swap chain
This enables us to utilize it from gpu-next.
2022-02-02 21:48:01 +02:00
James Ross-Gowan 3c4b8433dc vo_gpu/d3d11: add more usage flags to the swapchain images
vo_gpu_next and libplacebo expect swapchain images to be able to be
blitted to, which for libplacebo on FL11_0 and up means they have to
have DXGI_USAGE_UNORDERED_ACCESS, since libplacebo uses a compute shader
to emulate certain kinds of blits. For libplacebo's benefit, set all
applicable usage flags on swapchain images.
2022-02-02 21:48:01 +02:00
Jan Ekström 65f9a688a4 vo_gpu/d3d11: early exit in start_frame if output fbo is nullptr 2022-02-02 21:48:01 +02:00
Avi Halachmi (:avih) 555c15efba win32: apply geometry position to content instead of window
The docs specify that the +-X+-Y geometry values position the content.
This used to work correctly but got broken at 8fb4fd9a .
Geometry size is unaffected - this only concerns position.

Commit 8fb4fd9a made it center the window rather than the content by
taking the borders into account during positioning, but forgot to make
an exception when a position is specified explicitly.

This commit adds this exception, and now if a specific position is
requested then the borders are ignored, and the content is positioned
correctly.
2022-02-02 13:05:55 +02:00
Dudemanguy 19dd61fa19 wayland: always resize when scale changes on surface enter
a02901cae7 changed how mpv was handling
wl_surface_set_buffer_scale. It's correct in that constantly setting the
surface scale on every resize (which mpv was previously doing) is
unneccessary and not right. However, it introduced a slight regression
if someone moved a surface to a new monitor with the same resolution but
a different scale. It did not trigger a resize and thus the video would
have incorrect dimensions. A later refactor changed how things looked
inside here, but this regression wasn't fixed. A resize should always be
triggered if the scale changes in this surface event. Fixes #9426.
2022-01-27 18:34:17 -06:00
Ryan Hendrickson 9098ae5a16 wayland: support extra mouse buttons
Mouse button event codes above `BTN_EXTRA` (the ones currently defined
in `input-event-codes.h` are `BTN_FORWARD`, `BTN_BACK`, and `BTN_TASK`)
are mapped to `MP_MBTN9` and up. (Reminder that due to historical
reasons, the names `BTN_FORWARD` and `BTN_BACK` are completely
misleading; the real forward and back buttons are `BTN_SIDE` and
`BTN_EXTRA` and are already mapped correctly by mpv.)

This functionality is analogous to what the X11 backend supports in
`video/out/x11_common.c` and what the Cocoa backend supports in
`video/out/cocoa/events_view.m`.
2022-01-28 00:14:56 +00:00
Dudemanguy 073fbd98ee wayland: actually handle 0x0 resizes correctly
According to the xdg-shell protocol spec, a 0x0 size from the compositor
means that "the client should decide its own window dimension". We were
not doing this correctly. What should happen is that mpv should simply
reuse the old window size if it is not maximized or fullscreened. This
should work on all (reasonably recent) versions of mutter and an
compositor that follows the spec.

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/stable/xdg-shell/xdg-shell.xml#L1050
2022-01-27 15:15:43 +00:00
Dudemanguy 5bcf061744 Revert "wayland: ignore 0x0 resizes"
So actually according to the xdg-shell spec, a 0x0 resize is meant to
indicate that "the client should decide its own window dimension".
Previously, this just accidentally worked. In mutter 41.3, they changed
how 0x0 resizes were sent and what actually happened was that mpv tried
to resize itself to 0x0. This was obviously broken, so the reverted
commit naively just ignored 0x0. It actually seemed to work, but it
ended up breaking older versions of mutter. It's also not exactly the
correct fix so it deserves a revert.

This reverts commit d16defac27.

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/stable/xdg-shell/xdg-shell.xml#L1050
2022-01-27 15:15:43 +00:00
Dudemanguy e809ef0441 x11: sanitize window title to UTF-8 for EWMH
Both _NET_WM_NAME and _NET_WM_ICON_NAME (part of Extended Window Manager
Hints) require that the string is UTF-8*. mpv was not doing this and
thus violating the spec. Just sanitize the title for these two atoms.
Note that XA_WM_NAME and XA_WM_ICON_NAME have no such requirement so
those atoms are left the same. Fixes #8812.

*: https://specifications.freedesktop.org/wm-spec/1.3/ar01s05.html
2022-01-24 15:07:00 +00:00
Dudemanguy 5b16fe4134 wayland: sanitize toplevel title to UTF-8
The xdg-shell protocol requires that the toplevel title is UTF-8*. Go
ahead and leverage existing mpv tools to sanitize the title. Fixes #9694

*: 0aaf12157e/stable/xdg-shell/xdg-shell.xml (L638)
2022-01-24 15:07:00 +00:00
Dudemanguy d16defac27 wayland: ignore 0x0 resizes
Apparently mutter can send us 0x0 resizes* for whatever reason. Probably
there's some interal reason why this occurs, but for us trying to resize
to 0x0 is obviously terrible and results in all kinds of brokenness.
Just ignore any 0 values. Fixes #9748.

*: https://gitlab.gnome.org/GNOME/mutter/-/issues/2091
2022-01-23 13:58:15 -06:00
Niklas Haas 1ba0547bfb vo_gpu: add HOOKED_gather
Can be used conditionally (via #ifdef HOOKED_gather) to use
textureGather in custom shaders.
2022-01-15 10:27:21 +01:00
Niklas Haas eca78ee925 vo_gpu_next: fix SUBBITMAP_BGRA
The only way to fix the channel order here is to create the texture with
bgra format. Incidentally, there used to be a way to set the component
map for overlays directly, but no more. Shouldn't matter since
everything supports bgra8 anyways, though.

Fixes #9699
2022-01-11 23:45:08 +02:00
Niklas Haas 9e2c0b8baa sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA
This was a misnomer, the actual channel order is IMGFMT_BGRA (as the
comment explicitly point out). Rename the enum for consistency.
2022-01-11 23:45:08 +02:00
Niklas Haas 79783f4ac5 vo_gpu: placebo: add missing gamma functions
These got added upstream a while ago. Need to be added to the mapping
helpers.

It might be time to think about bumping the minimum dependency here.

Reported-by: Uoti Urpala <uau@glyph.nonexistent.invalid>
2022-01-10 15:43:57 +01:00
Niklas Haas e3b835de7c vo_gpu_next: forward dovi metadata to libplacebo 2022-01-09 13:06:27 +01:00
Julian Orth 777628e761 wayland: use `xkb_keymap_new_from_buffer`
Instead of `xkb_keymap_new_from_string`. The protocol does not require
the keymap to be null terminated and if the size of the keymap is a
multiple of the page size, using `_from_string` could lead to problems.

Some compositors include a null byte and even include the null byte in
`size`. Therefore we have to use `strnlen` to find the real length of
the string. Note that `_from_string` internally uses `strlen` and then
calls `_from_buffer`.
2022-01-08 15:20:02 +00:00
Julian Orth 3978669ece wayland: map keymaps with `MAP_PRIVATE`
While mpv uses version 1 of the `wl_seat` protocol and `MAP_PRIVATE` is
only required from version 7 on, using `MAP_PRIVATE` allows us to be
compatible with compositors that have only been tested with newer
applications.

Since the keymap is not modified after `mmap`, using `MAP_SHARED` has no
advantage over `MAP_PRIVATE`.
2022-01-08 15:20:02 +00:00
Niklas Haas d09c73c7b2 vo_gpu: add --tone-mapping-mode
This merges the old desaturation control options into a single
enumeration, with the goal of both simplifying how these options work
and also making this list more extensible (including, notably, new
options only supported by vo_gpu_next).

For the hybrid option, I decided to port the (slightly tweaked) values
from libplacebo's pre-refactor defaults, rather than the old values we
had in mpv, to more visually match the look of the vo_gpu_next hybrid.
2022-01-07 06:28:14 +01:00
Niklas Haas f3fccfc395 vo_gpu: add --gamut-mapping-mode
Merge --gamut-clipping and --gamut-warning into a single option,
--gamut-mapping-mode, better corresponding to the new vo_gpu_next APIs
and allowing us to easily extend this option as new modes are added in
the future.
2022-01-07 06:28:14 +01:00
Niklas Haas 2332445d8d vo_gpu_next: use new HDR metadata options
Properly forward the HDR metadata from the mpi to the equivalent (new)
fields in pl_color_space. Used by the new tone mapping code.
2022-01-07 06:28:14 +01:00
Niklas Haas a9cb2e2821 vo_gpu_next: update for new tone mapping options
This was significantly refactored upstream. Switch to new APIs and add
new tone mapping curves and options.

cf. https://code.videolan.org/videolan/libplacebo/-/merge_requests/212
2022-01-07 06:28:14 +01:00
sfan5 57bc5ba6d6 vo_gpu: move image2D precision qualifier to point of use
image2D is only defined from GLSL ES 3.1 onwards, so those statements
broke GLES 2.0. Move the qualifier to a place that is only reached with
the right version requirements.
fixes commit 584ab29c88
2022-01-02 14:01:33 +01:00
Niklas Haas 4b43800079 vo_gpu_next: fix --target-peak scaling
This is in nits, so it needs to be converted.
2021-12-29 00:02:54 +01:00
Dudemanguy 87286fe820 wayland: avoid doing unneccesary window resizes
Commits 04018c3061
cd7a7a1de8 introduced behavior that
updated window geometry during wayland events (specifically surface and
output). This is good but they also are too aggressive with
automatically resizing. For example, if a window is manually resized by
the user and then dragged to a different monitor with different geometry
than the initial monitor, mpv will automatically resize itself to the
window's resolution. The initial thought behind this logic was for
autofit to automatically readjust itself on a new monitor, but doing
that breaks other common use cases. An attempt could be made to
distinguish between autofit and a manual resize but that introduces a
lot of complexity for an edge case. It's better to simply not change the
window geometry here. Internal values are recalculated and scaled of
course, but wl->window_size and wl->geometry should not change.
2021-12-20 22:51:03 +00:00
Philip Langdale fd63bf398a vo_gpu: stop hard-coding max compute group threads
We've been assuming that maximum number of compute group threads is
never less than the 1024 defined by the desktop GL spec. Given that we
haven't had working compute shaders for GLES and I guess the Vulkan
spec defines at least as high a value, we've gotten away with it so
far.

But we should really look the value up and respect it.
2021-12-19 01:51:54 +01:00
sfan5 c8b6dc489b vo_gpu_next: implement VOCTRL_EXTERNAL_RESIZE
This is only needed on Android and supposed to handle a context
resize without reconfiguring the image parameters. reconfig()
already does exactly this so plug it in there.
2021-12-19 01:44:52 +01:00
sfan5 72915e8b76 {player,video}: remove references to obsolete opengl-cb API 2021-12-15 12:29:10 +01:00
Philip Langdale 584ab29c88 vo_gpu: opengl: some fixes to make compute shaders work with GLES
It's supposed to work with GLES >= 3.1 but we had all sorts of bad
assumptions in our version handling, and then our compute shaders
turn out not to be GLSL-ES compliant.

This change contains some necessary, but insufficient, tweaks to the
shaders. Perhaps we'll make it actually work some day.
2021-12-12 20:23:31 -08:00
Philip Langdale 2fc327f2fd vo_gpu: opengl: fix OpenGL ES version and extension handling
Some of the extension declarations did not include the ES version where
they became core functionality, and in some of these cases, there was
never actually an ES extension - it first appeared in core. We also had
a number of buggy version checks where ES versions were compared
against required desktop GL versions.
2021-12-12 20:23:31 -08:00
Philip Langdale 0e76372e86 vo_gpu: opengl: try and create context at version 440 again
nvidia follow the OpenGL spec very strictly, with two particular
consequences:

* They will give you the exact context version that you ask for,
  rather than the highest possible version that meets your request.
* They will hide extensions that the specs say require a higher
  version than you request, even if it's technically possible to
  provide the extension at lower versions.

In our case, we really want a variety of extensions, particularly
compute shaders that are only available in 4.2 or higher. That means
that we must explicitly include a high enough version in our list of
versions to check for us to be able to get a 'good' enough context.

As for which version? We restore the 4.4 version that we had in the
old version selection logic. This is the highest version we ever asked
for, and we have separate logic that clamps the GLSL version to 4.4,
so anything newer wouldn't make a difference.
2021-12-07 15:37:29 -08:00
Niklas Haas 9b06a71a5d vo_gpu: opengl: fix wrong glMemoryBarrier
This call was completely wrong.
2021-12-06 23:59:14 +01:00
Niklas Haas 036bda9166 vo_gpu_next: fix UB in query_format()
`plane_data_from_imgfmt` doesn't zero-initialize the struct, so this
contained invalid values for e.g. `row_stride`, causing formats to
*randomly* fail. (Especially any formats with specific alignment
requirements)

Might fix #9424 and #9425.
2021-12-05 21:24:57 +01:00
Kurt Kartaltepe fc94c8c365 wayland: ensure read and draw buffers are assigned
This is a workaround for nvidia proprietary drivers. The authors of
those drivers interpret the spec such that eglMakeCurrent will not
reconfigure the read and draw buffers. Thus windows wont display
anything drawn by opengl. nvidia authors refer to
https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_no_config_context.txt
specifically Issues 2/3 which reference eglMakeCurrent.

On mesa this is a non-issue and the read/draw targets are assigned with
eglMakeCurrent.

The context must be made current in order to query OpenGL strings. An
earlier proposal to create the wayland window surface similarly to X11
during init was deemed inappropriate so instead we manually set the
targets once we have created a window surface.
2021-12-04 03:04:17 +00:00
Kurt Kartaltepe d86bfebe6d opengl: support DebugMessageCallback on ES
This function is provided by a different extension on OpenGL ES so we
add a separate gl_functions.
2021-12-02 12:20:16 +01:00
Niklas Haas 4991ffa859 vo_gpu_next: implement VOCTRL_SCREENSHOT
Somewhat annoying but still relatively straightforward. There are
several ways to approach this, but I settled on reusing the pl_queue as
a cheap way to get access to the currently mapped frame. This saves us
from having to process `vo_frame` at all, and also avoids any overhead
from re-uploading the same frame twice.

(However maybe there's some circumstance in which `vo_frame` needs to be
queried/updated first, to get a screenshot of the correct frame? I'm not
sure.)

I also had the option of going with either pl_render_image() on the
extract pl_frame, or just calling pl_render_image_mix directly on it. I
went for the latter, because in the optimal case, this allows the
rendered frame to be directly retrieved from the cache, actually
entirely avoiding any sort of recompute overhead. This makes e.g. ctrl+s
during playback essentially free. (Except for the download cost,
obviously)

It would be even neater if we could make this VOCTRL asynchronous and
thereby leverage libplacebo's asynchronous download capabilities. But oh
well. That will have to wait for a sufficiently rainy day.

Closes #9388
2021-11-28 11:58:53 +01:00
Niklas Haas c66f3b0123 vo_gpu_next: factor out some common helpers
In preparation of VOCTRL_SCREENSHOT support
2021-11-28 11:58:53 +01:00
Niklas Haas cc4ac14d51 vo_gpu_next: guard sentinel in free_dr_buf
As noticed in #9526, apparently there's some case in which DR buffers
get corrupted. Add an explicit sentinel check to try and figure out
which cases these are.
2021-11-26 19:59:26 +01:00
Dave Airlie 8ed1368501 vo_gpu: hwdec_vaapi: avoid drm_fourcc.h dependency
Suggested by haasn
2021-11-25 23:11:37 +01:00
Dudemanguy 1ab9119817 wayland: increase the vblank waiting time
This commit sucks bad, but everything else is worse is other ways.
Basically, the current vblank waiting time in the vo_wayland_wait_frame
function (calculated very carefully using presentation statistics) is
randomly too short. Some compositors are quite variable when they
actually return callback so our timeout expires too quickly and throws
everything off. The fix? Add an arbitrary 5% to the vblank value and
pray that nothing gets off that much. Why did they have to make
swapinterval 1/fifo mode indefinitely block? Fixes #9504.
2021-11-25 17:20:26 +00:00
Dudemanguy 55b085707a wayland: initialize presentation time values as 0
Better to avoid any wonky calculations on startup with garbage values.
The others end up being derived from last_ust/last_msc. refresh_interval
is referenced exactly once and could, in theory, result in some terribly
erroneous vblank time.
2021-11-24 23:28:53 -06:00
Kurt Kartaltepe 79bfcc6723 wayland: cancel prepared reads when no events
A read can be prepared on the wayland display FD that is never actually
read. This occurs when events are triggered on other FDs in the fd set.
This change cancels a prepared read if poll reported no events for it.

This fixes some hangs due to how nvidia's EGL implementation polls on
the wayland fd unlike mesa implementations. It is based on nvidia's
proposed fix for qt's similar message pump in
https://codereview.qt-project.org/c/qt/qtwayland/+/373473

Signed-off-by: Kurt Kartaltepe <kkartaltepe@gmail.com>
2021-11-25 04:09:31 +00:00
Dave Airlie a6e5eba6ab vo_gpu: hwdec_vaapi: add dma-buf modifiers support.
If the EGL extension is present, pass the modifiers for each plane
to the EGL driver.
2021-11-23 23:18:54 +01:00
sfan5 dc73f1ad4b vo_gpu_next: implement OpenGL context support
Wrapping the context is pretty straightforward. This is only complicated
by needing to account for the upside-down framebuffer in a few places.
2021-11-22 18:08:56 +01:00
sfan5 d5d62c6a64 vo_gpu_next: factor out context-specific code to gpu_next/context.c
This is done to avoid cluttering vo_gpu_next.c with more ifdeffery and context-specific code
when additional backends are added in the near future.
Eventually gpu_ctx is intended to take the place of ra_ctx to further separate gpu and gpu_next.
2021-11-22 18:08:56 +01:00
sfan5 f32ea013dd video: opengl: teach start_frame() about out_fbo == NULL
This case was added in 662c793a55
for use in vo_gpu_next as a visibility test before rendering a frame.
The OpenGL context doesn't have this so it just returns true.
2021-11-22 18:08:56 +01:00
Niklas Haas 4ca6c2ff34 vo_gpu_next: respect tagged YUV colorspace
Fixes 2b2442ee67
2021-11-22 14:40:11 +01:00
Niklas Haas 2b2442ee67 vo_gpu_next: apply csp overrides for RGB/XYZ/YUV formats
This is needed when the color system is not explicitly tagged, but
instead needs to be inferred by the VO.

Note that there exists the function mp_image_params_guess_csp for this
sort of stuff, but it contains a lot of baggage that I don't want to
replicate, in order to move as much of this logic into pl_renderer as
possible, and therefore also give it the best chance of knowing what
shortcuts it can and can't take.

Fixes the other half of https://github.com/mpv-player/mpv/issues/9499
2021-11-22 12:38:43 +01:00
Dudemanguy 67c1ff8dad vo_gpu_next: fix timings without interpolation
Adding vsync_offset to the pts in pl_queue_update actually messes up
frame timings if one isn't using interpolation. The easiest way to see
this is to have the monitor's refresh rate at an integer multiple of a
video during a panning shot (classic case). There will be very visible
judder/stutter in this case that does not happen in vo_gpu. The cause of
this is the addition of the extra vsync_offset. Just match the semantics
of vo_gpu where this is only used when interpolating.
2021-11-21 22:56:30 +01:00
Niklas Haas 970061efdc vo_gpu_next: fix OOM on wayland
Similar to ff0864d5f0

Fixes #9484
2021-11-20 19:21:50 +01:00
Dudemanguy d2c2bf5a13 wayland: fix a potential segfault on surface enter
This possibility actually existed for years. The wayland protocol is
asynchronous and there's no restriction on when a compositor can send a
surface enter event. In mpv's case, the surface enter event is used to
set some vital things regarded geometry/scaling etc. However, this
implictly assumes that wl->current_output is actually initialized. The
vast majority of the time, vo_wayland_reconfig will happen first which
is where wl->current_output is, and should, be created. There's no
rule/law that the ordering of events will always occur in this order.
Plasma with certain auto-profile conditions can send the surface enter
event before mpv does its initial reconfig. That segfaults of course.
Just add a check to make sure we have wl->current_output here and return
if we don't. This assumes that the compositor will send us another
surface enterance event when mpv actually does the initial surface
commit and roundtrip request later. Wayland logs indicate this does
happen. Fixes #9492.
2021-11-20 10:48:09 -06:00
Dudemanguy 21cdc713bc wayland: support modifiers during axis events
It was never implemented before but it's trivial. As an aside, touch
events currently don't support modifiers either (is this a thing?). Well
if someone complains that can be done later. Fixes #9490.
2021-11-20 09:17:41 -06:00
Niklas Haas 170259c7c3 vo_gpu_next: always cache still frames
Even when not display synced. Prevents redraw overhead for refreshes
while paused.

Also make the logic slightly clearer to follow (since it's inverted).
2021-11-19 22:42:21 +01:00
Leo Izen 763e0d259f vo_gpu_next: fix lancozs typo to lanczos
Fix typo in the warning to avoid ewa_lanczossharp because
it might be removed in the future.
2021-11-19 23:35:27 +02:00
Niklas Haas 7acbecf7b8 vo_gpu: libplacebo: make version logging slightly clearer
Matches what `pl_log_create` does as well.
2021-11-19 21:50:59 +01:00
Niklas Haas 75ee35cec9 vo_gpu_next: simplify and improve frame redrawing logic
This almost perfectly recreates the semantics of --vo=gpu, i.e.:

- still frames are never interpolated
- non-repeated frames bypass single frame cache

The only difference is that libplacebo doesn't do a cache/blit on the
full output image, but rather it re-runs the last rendering step. This
has some advantages and some drawbacks. The most notable advantage is
that it also allows re-using the image contents when the only thing that
changes is the OSD (whereas `--vo=gpu` would force a full re-render for
that). The most notable drawback is that it also implies going through
the dithering and output LUT logic on redraws. All in all, I think this
is a pretty good trade-off in favor of `--vo=gpu-next`.

Fully fixes the last remaining performance difference in #9430.
2021-11-19 14:51:48 +01:00
Niklas Haas 17df53519f vo_gpu_next: fix panning on rotated videos
Closes #9454
2021-11-19 12:10:25 +01:00
sfan5 69f21d5e74 context_glx: fix check for wrong GLX extension
GLX_CONTEXT_PROFILE_MASK_ARB and related constants are provided by
GLX_ARB_create_context_profile but the check was for _create_context.
The former implies the latter (which we also need) so just replace
the checked extension.
2021-11-17 22:38:34 +01:00
sfan5 9afa41945f context_{wayland,x11egl}: use mpegl_create_window_surface() too
Again no functional difference, just uses better APIs when they're available.
2021-11-17 22:38:34 +01:00
sfan5 da3b85b613 context_drm_egl: make use of mpegl_create_window_surface()
This does what 3a10210c56 was supposed to, but better.
2021-11-17 22:38:34 +01:00
sfan5 b69af0abef egl_helpers: introduce wrapper around eglCreatePlatformWindowSurface
It abstracts EGL 1.5, extension checks and other inconsistencies away.
This can be used in context code as the (preferred) alternative to
eglCreateWindowSurface().
2021-11-17 22:38:34 +01:00
sfan5 c3d78b0017 video: opengl: use gl_check_extension() instead of strstr()
Using a simple substring match for extension checks is considered bad practice
because it's incorrect when one extension is a prefix of another's name.
This will almost surely not make a difference in practice but do it for correctness anyway.
2021-11-17 22:38:34 +01:00
sfan5 f5cc28a627 context_drm_egl: use mpegl_get_display() helper over own code
Although there are no known problems with this, using the helper should
be more portable. It will also prefer EGL 1.5's eglGetPlatformDisplay
over eglGetPlatformDisplayEXT if available.
2021-11-17 22:38:34 +01:00
Philip Langdale b030cfe05f vo_gpu: vulkan: open DRM render fd when using VK_KHR_display
While the basic Vulkan Display context can theoretically drive the
display without the involvement of any non-Vulkan code, that prevents
us from using VAAPI acceleration. When initialising VAAPI without a
window system, we need to provide it with an opened DRM render fd
corresponding to the device to use.

In the context of using VK_KHR_display, that means we need to identify
which DRM device matches the selected Vulkan device, and then open its
render fd and set the necessary state that VAAPI expects to find.

With that done, the normal VAAPI<->Vulkan interop can kick in and we
get working acceleration
2021-11-15 21:07:21 -08:00
Emil Velikov 37619c4cf5 options: remove always true m_obj_list::allow_unknown_entries
Ever instance of m_obj_list is a constant and for all of them, the field
is true. Just remove the field all together.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2021-11-15 14:02:08 +00:00
Dudemanguy c478a1efba egl_helpers: remove EGL_OPENGL_ES3_BIT
d2e8bc4499 was the the commit that
originally introduced the usage of this bit. As the message states, the
purpose was to force creating GLES 3 contexts on drivers that do not
return a higher version context than what was requested. With the recent
opengl refactors, mpv's gl selection has already moved away from such
complicated queries. Perhaps when that commit was added things were
different, but nowadays it seems like Mesa simply returns the highest
driver version available that is compatibile with the request (i.e.
requesting GLES 2 returns a GLES 3 context on my machine). In that case,
let's just simply drop EGL_OPENGL_ES3_BIT altogether as it does break
GLES 2 only machines. Fixes #9431.
2021-11-11 16:51:51 +00:00
sfan5 3a10210c56 context_drm_egl: use eglCreatePlatformWindowSurfaceEXT if available
This is identical to eglCreateWindowSurface but should be
preferred as part of EGL's platform extension.
2021-11-11 17:41:42 +01:00
Philip Langdale 2b9d8ae8b1 context_drm_egl: add support for BGR surface formats
The new GBM supporting nvidia drivers declare support for 10bit
surfaces using BGR ordering, rather than RGB, so add support for them.

We've also seen examples of hardware supporting BGR8888 but not
RGB8888 so let's support those too.

Of course, the nvidia EGL driver doesn't publish support for any 10bit
formats so you can't actually do 10bit display. Perhaps they'll
eventually fix that.
2021-11-10 09:57:58 -08:00
Philip Langdale 10d677575a context_drm_egl: use gbm_surface_create_with_modifiers
The GBM supporting nvidia driver doesn't support creating surfaces
without modifiers and using modifiers is more and more recommended as
the right way to do this.

Enumerating modifiers is painfully verbose, but necessary if we are to
allow the driver to pick the best possible one.
2021-11-10 09:57:58 -08:00
Niklas Haas c413720801 vo_gpu_next: fix slight performance regression
This logic, which was working around a libplacebo bug, ended up always
alpha blending - even for sources without an alpha channel. This caused
a minor slowdown to be constantly enabled.

Due to the recent bump to libplacebo v170, this is no longer needed.
2021-11-10 10:38:58 +01:00
Starsam80 69527077c1 vo_gpu_next: Initialize `pl_frame_mix`
Without initializing, the random data causes the `pl_render_image_mix`
function to abort with a SIGSEGV.
2021-11-09 02:14:30 +01:00
Niklas Haas 4470eaf5e5 vo_gpu_next: implement HDR passthrough
Completely untested, since Linux still can't into HDR in 2021. Somebody
please make sure it works.

Technically covers #8219, since gpu-context=drm can be combined with
vo=gpu-next.
2021-11-08 20:57:54 +01:00
Niklas Haas 3cf6147368 vo_gpu_next: drop PL_API_VER checks
These are no longer needed with the minimum version bump.
2021-11-08 18:24:11 +01:00
Niklas Haas ff0864d5f0 vo_gpu_next: fix resource exhaustion on minimized windows
This required an upstream API change to implement in a way that doesn't
unnecessarily re-push or upload frames that won't be used. I consider
this a big enough bug to justify bumping the minimum version for it.

Closes #9401
2021-11-08 18:24:11 +01:00
Dudemanguy f5d545c917 wayland: remove bogus scale_change variable
This was originally added in f2afae55e9
for unclear reasons (way to go me). This concept is clearly incorrect.
It doesn't matter what state the window is in. As soon as mpv detects a
scale change, it needs to reset the buffer scale of the window. Just
remove all this junk and put wl_surface_set_buffer_scale in
set_surface_scaling like it should be. Related issue: #9426.
2021-11-08 09:49:49 -06:00
Niklas Haas 73563cebf9 vo_gpu_next: add automatic translation for ewa_lanczossharp
This one hits a lot of people. Probably because the man page explicitly
recommends it.

Fixes #9408
2021-11-07 22:32:00 +01:00
Niklas Haas eca1b8dc29 vo_gpu_next: implement --dither-depth
I somehow completely forgot about this option existing.

Closes #9416
2021-11-07 18:12:42 +01:00
Niklas Haas 459f7d4a8d vo_gpu_next: remove --builtin-scalers option
Looking at this again I'm not sure it does anything useful at all. The
man page entry is also wrong: `bicubic` is not affected, only
`bicubic_fast`, and those filters are not configurable anyways.

So this would only ever be a debugging option, and I don't see a
pressing need for it.

No interface-change.rst update because it only just got added anyways.
2021-11-07 11:32:57 +01:00
Dudemanguy 662c793a55 vo_gpu_next: call start_frame in vulkan/context.c
In practice, this is for wayland. vo_gpu_next doesn't check the
check_visible parameter since it didn't descend into the
vulkan/context.c file when starting a frame. To make this happen, just
call the start_frame function pointer but pass NULL as the ra_fbo. In
there, we can do the visibility checks and after that bail out of the
start_frame function if ra_fbo is NULL.
2021-11-04 15:59:56 +00:00
Dudemanguy acde63f05a wayland_vk: rename start_frame to check_visible
This vulkan-specific parameter was poorly named and probably causes
confusion. Just rename it to check_visible instead to make clear what is
going on here. Only wayland uses it for now but in theory anyone else
can. As an aside, wayland egl accomplishes this by using an external
swapchain instead (an opengl-only concept in the mpv code). This may or
may not need to be changed in the future when gpu-next gets opengl
support.
2021-11-04 15:59:56 +00:00
Niklas Haas 8bd0dee531 osdep: rename MP_UNREACHABLE
It was pointed out on IRC that the name is misleading, since the actual
semantics of the macro is to assert first.
2021-11-03 15:15:20 +01:00
Niklas Haas 701bd783ca vo_gpu_next: fix --tone-mapping-param mapping
vo_gpu defaults this to NAN, libplacebo uses 0.0 as the default.

Fixes https://github.com/mpv-player/mpv/issues/9386
2021-11-03 14:43:17 +01:00
Niklas Haas 9d5d9b2424 vo_gpu_next: add new libplacebo-based renderer
As discussed in #8799, this will eventually replace vo_gpu. However, it
is not yet complete. Currently missing:

- OpenGL contexts
- hardware decoding
- blend-subtitles=video
- VOCTRL_SCREENSHOT

However, it's usable enough to cover most use cases, and as such is
enough to start getting in some crucial testing.
2021-11-03 14:09:27 +01:00
Niklas Haas c704824b45 osdep: add MP_UNREACHABLE
This seems to work on gcc, clang and mingw as-is, but I made it
conditional on __GNUC__ just in case, even though I can't figure out
which compilers we care about that don't export this define.

Also replace all instances of assert(0) in the code by MP_UNREACHABLE(),
which is a strict improvement.
2021-11-03 14:09:27 +01:00
Niklas Haas edb0caa441 vo_gpu: allow using bare windows as --(t)scale
A lot of people seem to do something like --tscale=box
--tscale-window=<function>. Just let them use --tscale=<function>
directly, by also accepting raw windows.

Kinda hacky but needed for feature parity with vo_gpu_next, which no
longer has `--tscale=box`. Note that because the option struct is still
shared, vo_gpu_next inherits the same option handling code, so we have
to export this feature for vo_gpu as well.
2021-11-03 14:09:27 +01:00
Niklas Haas 242cd76ee7 vo_gpu: vulkan: expose swapchain to mpvk_ctx
So I can reuse it in vo_gpu_next.
2021-11-03 14:09:27 +01:00
Niklas Haas 432581b604 vo_gpu: lift ra_ctx_* opts to a global struct
So I can re-use them for vo_gpu_next.
2021-11-03 14:09:27 +01:00