Commit Graph

4316 Commits

Author SHA1 Message Date
Philip Langdale 4c133f3b45 vo_gpu: ra_pl: Add getter for pl_gpu
We need access to the underlying pl_gpu to make libplacebo calls
from hwdecs.
2019-04-21 23:55:22 +03:00
Philip Langdale b74b39dfb5 vo_gpu: vulkan: Add back context_win for libplacebo
Feature parity with the original ra_vk obviously requires win32 support,
so let's put it back in.
2019-04-21 23:55:22 +03:00
Niklas Haas 7006d6752d vo_gpu: vulkan: use libplacebo instead
This commit rips out the entire mpv vulkan implementation in favor of
exposing lightweight wrappers on top of libplacebo instead, which
provides much of the same except in a more up-to-date and polished form.

This (finally) unifies the code base between mpv and libplacebo, which
is something I've been hoping to do for a long time.

Note: The ra_pl wrappers are abstract enough from the actual libplacebo
device type that we can in theory re-use them for other devices like
d3d11 or even opengl in the future, so I moved them to a separate
directory for the time being. However, the rest of the code is still
vulkan-specific, so I've kept the "vulkan" naming and file paths, rather
than introducing a new `--gpu-api` type. (Which would have been ended up
with significantly more code duplicaiton)

Plus, the code and functionality is similar enough that for most users
this should just be a straight-up drop-in replacement.

Note: This commit excludes some changes; specifically, the updates to
context_win and hwdec_cuda are deferred to separate commits for
authorship reasons.
2019-04-21 23:55:22 +03:00
Niklas Haas 9f7dcc0726 mp_image: align stride to multiple of texel size
This helps with compatibility and/or performance in particular for
oddly-sized formats like rgb24. We use a loop to avoid having to
calculate the lcm (or waste bytes in the extremely common case of the
byte size and the stride align having shared factors).
2019-04-21 23:55:22 +03:00
Niklas Haas a3c808c6c8 vo_gpu: fix segfault when OSD tex creation fails
If !osd->texture, then mpgl_osd_draw_prepare fails.
2019-04-21 23:55:22 +03:00
Niklas Haas f0b6860d62 vo_gpu: index desc namespaces by ra
No reason to require them be constant. This allows them to depend on
runtime characteristics of the `ra`.
2019-04-21 23:55:22 +03:00
der richter 90e44d3ff2 cocoa-cb: add support for custom colored title bar 2019-04-02 02:09:01 +03:00
der richter 837e5058ff cocoa-cb: refactor title bar styling
half of the materials we used were deprecated with macOS 10.14, broken
and not supported by run time changes of the macOS theme. furthermore
our styling names were completely inconsistent with the actually look
since macOS 10.14, eg ultradark got a lot brighter and couldn't be
considered ultradark anymore.

i decided to drop the old option --macos-title-bar-style and rework
the whole mechanism to allow more freedom. now materials and appearance
can be set separately. even if apple changes the look or semantics in
the future the new options can be easily adapted.
2019-04-02 02:09:01 +03:00
Akemi 23f55569be cocoa-cb: add support for mac 10.14 Dark mode and run time switching
setting the appearance of the window to nil will always use the system
setting and changes on run time switches too. this is only the case for
macOS 10.14.
2019-04-02 02:09:01 +03:00
der richter d5be1e2729 cocoa-cb: move all title bar related functionality in its own file
quite a lot of the title bar functionality and logic was within our
window. since we recently added a custom title bar class to our window
i decided to move all that functionality into that class and in its
own file.

this is also a preparation for the next commits.
2019-04-02 02:09:01 +03:00
Akemi 9d5805fba4 cocoa-cb: remove an unused variable 2019-04-02 02:09:01 +03:00
Akemi 0bea384153 cocoa-cb: simplify CGL pixel format creation
i found the old pixel format creation a bit too messy. pixel format
attribute arrays and look ups were all over the place, the actual logic
what kind of format was created was inscrutable, the software pixel
format was hardcoded and no probing was done.

i split the attributes into mandatory and optional ones, one mandatory
for a hardware and software pixel format each, and moved those to the
top of the class. that way new attributes can be easily added to either
the mandatory or optional attributes and they don't mess up the actual
pixel creation logic any more. furthermore both hardware and software
pixel formats are being probed the same way now. to minimise code
duplications the probing was moved into its own function.
2019-04-02 02:05:11 +03:00
Akemi 716b871928 cocoa-cb: add support for dragging certain strings onto the window
only the dragged types NSFilenamesPboardType and NSURLPboardType were
supported to be dropped on the window, which was inconsistent with the
dragged types the dock icon supports. the dock icon additional supports
strings that represents an URL or a path. the system takes care of
validating the strings properly in the case of the dock icon, but in the
case of dropping on the window it needs to be done manually.

support for strings is added by also allowing the NSPasteboardTypeString
type and manually validating the strings. strings are split by new lines
and trimmed, to also support a list of URLs and paths. every new element
is checked if being an URL or path and only then being added to the
playlist.
2019-04-02 02:04:31 +03:00
Akemi 3f6be83350 cocoa-cb: synchronise the flush with the render
this could lead to a crash on deinit when flush
was called while the opengl state was cleaned up.

Fixes #6323
2019-04-02 02:02:02 +03:00
Akemi b207c1d4a1 cocoa-cb: fix a Cocoa window position on init bug
on init an NSWindow can't be placed on a none Main screen NSScreen
outside the Main screen's frame bounds.

To fix this we just check if the target screen is different from the
main screen and if that is the case we check the actual position with
the expect one. if they are different we try to reposition the window
to the wanted position.

Fixes #6453
2019-04-02 02:01:02 +03:00
Akemi 9aa0905c10 cocoa-cb: fix Space switching when quitting fs
when quitting mpv in fullscreen the System always switchs to Space 1
regardless of which Space mpv was on previous to switching to fs. to fix
this we close the window before quitting fs. that way the System
switches back the the Space mpv was previous on before fs.
2019-04-02 01:59:52 +03:00
Akemi 0caaa1a37c cocoa-cb: notify vo when window is minimised 2019-04-02 01:51:42 +03:00
Akemi 731804a27e cocoa-cb: fix crash when querying window state
Fixes #6489
2019-04-02 01:51:42 +03:00
Akemi 48a463d641 cocoa-cb: wakeup vo when new events are available
new events were added but not fetched by the vo, because we didn't
signal the vo that new events were available.

actually wakeup the vo when new events are available.
2019-04-02 01:46:52 +03:00
Philip Sequeira 98eea65605 x11: fix cursor hiding initial state
Regression from 8e3308d687.

Broken cases were:
* --no-cursor-autohide acted like --cursor-autohide=always.
* --cursor-autohide-fs-only always hid the cursor if starting
  non-fullscreen; entering fullscreen at least once fixed it.
2019-03-16 21:17:32 +01:00
Bin Jin dd83b66652 vo_gpu: increase user shader size limit
The old size limit was chosen before LUT texture was supported in user
shader. At that time, the whole user shader will be compiled and run
on GPU, which makes large user shader impractical to be used.

With the introduction of LUT texture, the old size limit doesn't make
any sense. For example, a 1024x1024 rgba16f LUT will cost 32MB shader
size.

Fix this by increasing the size limit to a value that's unlikely be
reached.
2019-03-13 21:47:24 +02:00
wnoun 94203436c4 vo_libmpv: fix null pointer dereference
Closes: #6507
2019-03-11 01:55:59 +02:00
Jan Ekström 199aabddcc Merge branch 'master' into pr6360
Manual changes done:
  * Merged the interface-changes under the already master'd changes.
  * Moved the hwdec-related option changes to video/decode/vd_lavc.c.
2019-03-11 01:00:27 +02:00
Bin Jin 1d0349d3b5 vo_gpu: add two useful operators to user shader
modulo operator could be used to check if size is multiple of a
certain number.

equal operator could be used to verify if size of different textures
aligns.
2019-03-09 12:56:11 +01:00
Bin Jin b3cbd46509 vo_gpu: make texture offset available to CHROMA hooks
Before this commit, texture offset is set after all source textures
are finalized. Which means CHROMA hooks won't be able to align with
luma planes. This could be problematic for chroma prescalers utilizing
information from luma plane.

Fix this by find the reference texture early, and set global texture
offset early.
2019-03-09 12:56:11 +01:00
zc62 e37c253b92 lcms: allow infinite contrast
Fixes #5980
2019-03-09 12:55:44 +01:00
Anton Kindestam 537006965e context_drm_egl: implement n-buffering
This allows context_drm_egl to use as many buffers as libgbm or the
swapchain_depth setting allows (whichever is smaller).

On pause and on still images (cover art etc.) to make sure that output does not
lag behind user input, the swapchain is drained and reverts to working in a dual
buffered (equivalent to swapchain-depth=1) manner.

When possible (swapchain-depth>=2), the wait on the page flip event is now not
done immediately after queueing, but is deferred to the next invocation of
swap_buffers. Which should give us more CPU time between invocations.

Although, since gbm_surface_has_free_buffers() can only tell us a boolean value
and not how many buffers we have left, we are forced to do this contortionist
dance where we first overshoot until gbm_surface_has_free_buffers() reports 0,
followed by immediately waiting so we can free a buffer, to be able to get the
deferred wait on page flip rolling.

With this commit we do not rely on the default vsync fences/latency emulation of
video/out/opengl/context.c, but supply our own, since the places we create and
wait for the fences needs to be somewhat different for best performance.

Minor fixes:

 * According to GBM documentation all BO:s gotten with
   gbm_surface_lock_front_buffer must be released before gbm_surface_destroy is
   called on the surface.
 * We let the page flip handler function handle the waiting_for_flip flag.
2019-02-25 01:25:25 +01:00
Anton Kindestam ae115bd8d8 opengl: Support GL_ARB_sync style fences on OpenGL ES 3.0
OpenGL ES 3.0 and up has suppport for for GL_ARB_sync style fences.
Make sure that mpv can use them.
2019-02-25 01:25:25 +01:00
Niklas Haas 8b563a0346 vo_gpu: fix initial seeding of the peak detect ssbo
This solves some edge cases when using files with very weird metadata
(e.g. MaxCLL 10k and so forth). Instead of just blindly seeding it with
the tagged metadata, forcibly set the initial state from the detected
values.
2019-02-18 01:54:06 +02:00
Niklas Haas 3f1bc25d4d vo_gpu: use dB units for scene change detection
Rather than the linear cd/m^2 units, these (relative) logarithmic units
lend themselves much better to actually detecting scene changes,
especially since the scene averaging was changed to also work
logarithmically.
2019-02-18 01:54:06 +02:00
Niklas Haas b4b719e337 vo_gpu: clamp sigmoid function
Can explode on some clips otherwise
2019-02-18 01:54:06 +02:00
Niklas Haas 258ed5d471 vo_gpu: tone map before gamut mapping
Gamut mapping can take very bright out-of-gamut colors into the
negatives, which completely destroys the color balance (which tone
mapping tries its best to preserve).
2019-02-18 01:54:06 +02:00
Niklas Haas 677ae4f8fe vo_gpu: make --gamut-warning warn on negative colors
As is the case for actually out-of-gamut colors (rather than just too
bright colors).
2019-02-18 01:54:06 +02:00
Niklas Haas 11b58415d5 vo_gpu: improve numerical accuracy of PQ OETF constant
Not a huge deal, but we can do the division in C, which makes the float
constant larger.
2019-02-18 01:54:06 +02:00
Niklas Haas 4e8022da26 vo_gpu: allow color management in dumb mode
There's no point to disallow target-trc/prim in dumb mode, since they
still work fine.
2019-02-18 01:54:06 +02:00
Niklas Haas fdd671188d vo_gpu: improve accuracy of HDR brightness estimation
This change switches to a logarithmic mean to estimate the average
signal brightness. This handles dark scenes with isolated highlights
much more faithfully than the linear mean did, since the log of the
signal roughly corresponds to the perceptual brightness.
2019-02-18 01:54:06 +02:00
Niklas Haas 12e58ff8a6 vo_gpu: allow boosting dark scenes when tone mapping
In theory our "eye adaptation" algorithm works in both ways, both
darkening bright scenes and brightening dark scenes. But I've always
just prevented the latter with a hard clamp, since I wanted to avoid
blowing up dark scenes into looking funny (and full of noise).

But allowing a tiny bit of over-exposure might be a good thing. I won't
change the default just yet (better let users test), but a moderate
value of 1.2 might be better than the current 1.0 limit. Needs testing
especially on dark scenes.
2019-02-18 01:54:06 +02:00
Niklas Haas 6179dcbb79 vo_gpu: redesign peak detection algorithm
The previous approach of using an FIR with tunable hard threshold for
scene changes had several problems:

- the FIR involved annoying hard-coded buffer sizes, high VRAM usage,
  and the FIR sum was prone to numerical overflow which limited the
  number of frames we could average over. We also totally redesign the
  scene change detection.

- the hard scene change detection was prone to both false positives and
  false negatives, each with their own (annoying) issues.

Scrap this entirely and switch to a dual approach of using a simple
single-pole IIR low pass filter to smooth out noise, while using a
softer scene change curve (with tunable low and high thresholds), based
on `smoothstep`. The IIR filter is extremely simple in its
implementation and has an arbitrarily user-tunable cutoff frequency,
while the smoothstep-based scene change curve provides a good, tunable
tradeoff between adaptation speed and stability - without exhibiting
either of the traditional issues associated with the hard cutoff.

Another way to think about the new options is that the "low threshold"
provides a margin of error within which we don't care about small
fluctuations in the scene (which will therefore be smoothed out by the
IIR filter).
2019-02-18 01:54:06 +02:00
Niklas Haas 3fe882d4ae vo_gpu: improve tone mapping desaturation
Instead of desaturating towards luma, we desaturate towards the
per-channel tone mapped version. This essentially proves a smooth
roll-off towards the "hollywood"-style (non-chromatic) tone mapping
algorithm, which works better for bright content, while continuing to
use the "linear" style (chromatic) tone mapping algorithm for primarily
in-gamut content.

We also split up the desaturation algorithm into strength and exponent,
which allows users to use less aggressive desaturation settings without
affecting the overall curve.
2019-02-18 01:54:06 +02:00
Emmanuel Gil Peyrot 36600ff163 wayland_common: rename “shell” into “wm_base”
This is the naming xdg-shell stable adopted, it doesn’t make much sense
to keep using “shell” everywhere with all functions calling it
“wm_base”.

Finishes what 76211609e3 started.
2019-02-17 23:44:34 +02:00
Akemi 777a863bb6 cocoa-cb: remove empty elements from dropped URLs
Fixes #6241
2019-02-10 23:47:34 +02:00
Akemi 6ce570359a cocoa-cb: add support for VOCTRL_GET_DISPLAY_NAMES 2019-02-10 22:39:25 +02:00
Akemi ace61c120f cocoa-cb: use Swift Extensions for convenience
preparations for the following commit.
2019-02-10 22:39:25 +02:00
Akemi a4298b1a69 cocoa-cb: fix side by side Split View again
some safety mechanism for the async fs animation aren't needed anymore,
due to possible improved logic and slightly different behaviour on new
macOS versions. that safety fallback prevented the Split View because
it always returned a rectangle of the whole screen, instead of just
part/half of it.

Fixes #6443
2019-01-23 09:32:02 +01:00
Kotori Itsuka 05f0980b96 vo_gpu: allow resetting target-peak to the trc default
Add "auto" the possible values of target-peak.  The default value
for target_peak is to calculate the target using mp_trc_nom_peak.
Unfortunately, this default was outside the acceptable range of
10-10000 nits, which prevented its later reassignment.  So add an
"auto" choice to target-peak which lets clients and scripts go back
to using the trc default after assigning a value.
2019-01-23 09:31:35 +01:00
Akemi 08679f756c vd_lavc: increase the possible length of the hwdec name
this lead to an unexpected videotoolbox-copy hwdec name due to the last
two chars being cut off. since selection is also done by that name one
had to use "videotoolbox-co" to explicitly use the copy mode of
videotoolbox.
2019-01-23 09:30:58 +01:00
wm4 8e3308d687 x11: don't hide cursor if window isn't focused
I found this sort of annoying.

You could argue that the "frontend" should maybe contain this logic, but
who cares.
2018-12-06 10:33:42 +01:00
wm4 f4ce3b8bb9 vo, vo_gpu, glx: correct GLX_OML_sync_control usage
I misunderstood how this extension works. If I understand it correctly
now, it's worse than I thought. They key thing is that the (ust, msc,
sbc) tripple is not for a single swap event. Instead, (ust, msc) run
independently from sbc. Assuming a CFR display/compositor, this means
you can at best know the vsync phase and frequency, but not the exact
time a sbc changed value.

There is GLX_INTEL_swap_event, which might work as expected, but it has
no EGL equivalent (while GLX_OML_sync_control does, in theory).

Redo the context_glx sync code. Now it's either more correct or less
correct. I wanted to add proper skip detection (if a vsync gets skipped
due to rendering taking too long and other problems), but it turned out
to be too complex, so only some unused fields in vo.h are left of it.
The "generic" skip detection has to do.

The vsync_duration field is also unused by vo.c.

Actually this seems to be an improvement. In cases where the flip call
timing is off, but the real driver-level timing apparently still works,
this will not report vsync skips or higher vsync jitter anymore. I could
observe this with screenshots and fullscreen switching. On the other
hand, maybe it just introduces an A/V offset or so.

Why the fuck can't there be a proper API for retrieving these
statistics? I'm not even asking for much.
2018-12-06 10:32:27 +01:00
wm4 b1ba7de34d vo: use a struct for vsync feedback stuff
So new useless stuff can be easily added.
2018-12-06 10:30:25 +01:00
wm4 83884fdf03 vo_gpu: glx: use GLX_OML_sync_control for better vsync reporting
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.
2018-12-06 10:30:14 +01:00