Commit Graph

17 Commits

Author SHA1 Message Date
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
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 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 c82ffb6670 vo_gpu: libplacebo: simplify tex transfers for libplacebo 168+
Upstream libplacebo got refactored to use byte-sized strides rather than
texel-sized strides. This commit makes mpv's ra_pl wrapper take
advantage of that, rather than forcing a stride-fixing memcpy.

Note that, technically, we would still need a stride fixing memcpy in
cases when the true stride is not a multiple of the format's texel
*alignment*, however this is a much rarer case and extremely unlikely to
occur in practice, since all relevant formats use power-of-two texel
alignments.
2021-10-31 19:39:58 +01:00
Niklas Haas 564f3dba56 vo_gpu: libplacebo: add missing include
This was removed from common.h upstream since it was a cyclic
dependency. We need to re-import it into utils.h manually.
2021-10-04 12:09:58 +02:00
Niklas Haas 275c00974e vo_gpu: libplacebo: drop conditional code paths for old versions
No longer needed with the bump to v3.104.
2021-10-04 12:09:58 +02:00
Niklas Haas 48e8cb6a89 vo_gpu: libplacebo: drop code deprecated in libplacebo v3
This is only needed for back-compat with libplacebo v2, and will break
due to upstream removal starting with libplacebo v4.
2021-10-04 12:09:58 +02:00
Niklas Haas 6265724f33 vo_gpu: placebo: keep track of texture sample mode
This fixes an issue where dithering was effectively broken on libplacebo
versions >= 103 because the dither texture was being sampled with
edge-clamped rather than repeating semantics.
2021-03-21 17:18:20 +01:00
Niklas Haas 09d7c75bfe vo_gpu: libplacebo: require v2.72.0
It's about a year old, and packaged pretty much everywhere that bothers
to package libplacebo at all. Older versions are only a thing on LTS,
which will probably also use older mpv so it works out.

Starting with v2.72.0, libplacebo validates all of its parameters
internally and turns them into function failures. Doing it twice is
awfully redundant, so we can drop the parameter validation.

Also allows us to drop some preprocessor macros.
2021-02-23 12:44:04 +02:00
Niklas Haas 7c4465cefb vo_gpu: placebo: update for upstream API changes
The concept of sample/address modes was moved from `pl_tex` to
`pl_desc_binding`.

The `pl_tex_blit()` function also underwent an API change.
2020-12-04 23:49:31 +01:00
Niklas Haas b16d8865b7 vo_gpu: placebo: add fallback code for stride mismatch
For cases in which the requirements of the GPU API prevent directly
uploading a texture with a given stride, we need to fix the stride
manually in host memory. This incurs an extra memcpy, but there's not
much we can do about it. (Even in `ra_gl` land, the driver will just
hide this memcpy from the user)

Note: This code could be done better. It could only copy as many texels
as needed, and it could pick a stride that's a multiple of
`gpu->limits.align_tex_xfer_stride` for better performance. Patches
welcome (tm)

Fixes #7759
2020-06-16 02:54:59 +02:00
Niklas Haas 09b68648f1 vo_gpu: ra_pl: add timers support
Added in libplacebo v60, unfortunately with some changes in design that
make it a bit of an awkward fit for the way timers are used in mpv.

Timer queries in libplacebo don't support "start" and "stop"-style
operations, and instead are attached directly to operations. The only
sane way of implementing this in the ra API is to have a single 'active
timer' that gets attached to every pass, taking care to sort distinct
operations into distinct pl_timer queries within that ra_timer.

This design unfortunately doesn't let us have multiple 'active timers'
concurrently, similar to the current such limitation in ra_gl. But it's
also not a big deal.
2020-05-16 06:18:44 +02:00
Niklas Haas 349eb0b7fc vo_gpu: suppress PL_FATAL logs during probing
These were still mapped to MP errors during probing, but they also get
triggered when instance creation fails due to lack of support for e.g.
wayland. Since waylandvk is probed above x11vk, we should probably
suppress these by default.

Closes #7626
2020-05-03 16:27:37 +02:00
Philip Langdale e2976e662d video/out/gpu: Add a `storable` flag to ra_format
While `ra` supports the concept of a texture as a storage
destination, it does not support the concept of a texture format
being usable for a storage texture. This can lead to us attempting
to create a texture from an incompatible format, with undefined
results.

So, let's introduce an explicit format flag for storage and use
it. In `ra_pl` we can simply reflect the `storable` flag. For
GL and D3D, we'll need to write some new code to do the compatibility
checks. I'm not going to do it here because it's not a regression;
we were already implicitly assuming all formats were storable.

Fixes #6657
2019-07-08 00:59:28 +02:00
Philip Langdale ffb8ffdd55 vo/gpu: ra_pl: Add helper to get pl_fmt from ra_format
When interacting directly with libplacebo, we may need to pass a
pl_fmt based on an ra_format. Although the mapping is currently
trivial, it's worth wrapping to make it easy to adapt if this
changes in the future.
2019-04-21 23:55:22 +03:00
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
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