Commit Graph

3813 Commits

Author SHA1 Message Date
Niklas Haas 3faf1fb0a4
vo: avoid putting large voctrl_performance_data on stack
This is around 512 kB, which is just way too much. Heap-allocate it
instead. Also cut down the max pass count to 64, since 128 was
unrealistically high even for vo_opengl.
2017-09-11 18:20:18 +02:00
Niklas Haas 71c25df5e6
vo_opengl: refactor timer_pool_measure (again)
Instead of relying on power-of-two buffer sizes and unsigned overflow,
make this code more robust (and also cleaner).

Why can't C get a real modulo operator?
2017-09-11 02:42:50 +02:00
Niklas Haas 8a4f2f0ac0
vo_opengl: fix out-of-bounds access in timer_pool_measure
This was there even before the refactor, but the refactor exposed the
bug. I hate C's useless fucking modulo operator so much. I've gotten hit
by this exact bug way too many times.
2017-09-11 02:07:04 +02:00
Niklas Haas 0fe4a492c4
vo_opengl: fix out-of-bounds read in update_uniform
Since the addition of UBOs, the assumption that the uniform index
corresponds to the pass->params.inputs index is no longer true. Also,
there's no reason it would even need this - since the `input` is also
available directly in sc_uniform.

I have no idea how I've been using this code for as long as I have
without any segfaults until earlier today.
2017-09-11 01:04:08 +02:00
Niklas Haas 1da53248ab
vo_opengl: refactor/fix mp_pass_perf code
This was needlessly complicated and prone to breakage, because even the
references to the ring buffer could end up getting invalidated and
containing garbage data on e.g. shader cache flush. For much the same
reason why we can't keep around the *timer_pool, we're also forced to
hard-copy the entire sample buffer per pass per frame.

Not a huge deal, though. This is, what, a few kB per frame? We have more
pressing CPU performance concerns anyway.

Also simplified/fixed some other code.
2017-09-11 00:35:23 +02:00
Niklas Haas d0c87dd579
vo_opengl: add a gamut warning feature
This clearly highlights all out-of-gamut/clipped pixels. (Either too
bright or too saturated)

Has some (documented) caveats. Also make TONE_MAPPING_CLIP stop actually
clamping the value range (it's unnecessary and breaks this feature).
2017-09-10 18:19:46 +02:00
Niklas Haas 5771f7abf4
vo_opengl: add support for vulkan GLSL dialect
Redefining texture1D / texture3D seems to be illegal, they are already
built-in macros or something. So just use tex1D and tex3D instead.

Additionally, GL_KHR_vulkan_glsl requires using explicit vertex
locations and bindings, so make some changes to facilitate this. (It
also requires explicitly setting location=0 for the color attachment
output)
2017-09-04 13:53:23 +02:00
Niklas Haas 62f0677614 vo_opengl: use rgba16 for 3DLUTs instead of rgb16
Vulkan compat. rgb16 doesn't exist on hardware anyway, might as well
just generate the 3DLUT against rgba16 as well. We've decided this is
the simplest way to do vulkan compatibility: just make sure we never
actually need 3-component textures.
2017-09-04 13:53:14 +02:00
Niklas Haas 8cf5799ab1 vo_opengl: refactor scaler LUT weight packing/loading
This is mostly done so we can support using textures with more
components than the scaler LUTs have entries. But while we're at it,
also change the way the weights are packed so that they're always
sequential with no gaps. This allows us to simplify
pass_sample_separated_get_weights as well.
2017-09-04 13:53:14 +02:00
Niklas Haas f589a3bd78
vo_opengl: scale deband-grain to the signal range
This prevents blowing up for high dynamic range sources, where a noise
level of 48 can suddenly mean 4800.
2017-09-03 21:51:48 +02:00
James Ross-Gowan 9a28088e74 filter_kernels: correct spline64 kernel
This seems to have had some copy/paste errors. It should now match the
implementation in fmtconv:
https://github.com/EleonoreMizo/fmtconv/blob/00453a86dd73/src/fmtcl/ContFirSpline64.cpp#L58-L76
2017-09-03 21:18:06 +02:00
James Ross-Gowan 7897f79217 input: merge mouse wheel and axis keycodes
Mouse wheel bindings have always been a cause of user confusion.
Previously, on Wayland and macOS, precise touchpads would generate AXIS
keycodes and notched mouse wheels would generate mouse button keycodes.
On Windows, both types of device would generate AXIS keycodes and on
X11, both types of device would generate mouse button keycodes. This
made it pretty difficult for users to modify their mouse-wheel bindings,
since it differed between platforms and in some cases, between devices.

To make it more confusing, the keycodes used on Windows were changed in
18a45a42d5 without a deprecation period or adequate communication to
users.

This change aims to make mouse wheel binds less confusing. Both the
mouse button and AXIS keycodes are now deprecated aliases of the new
WHEEL keycodes. This will technically break input configs on Wayland and
macOS that assign different commands to precise and non-precise scroll
events, but this is probably uncommon (if anyone does it at all) and I
think it's a fair tradeoff for finally fixing mouse wheel-related
confusion on other platforms.
2017-09-03 20:31:44 +10:00
James Ross-Gowan 8fe4aa94ee cocoa: fix button numbering for back/forward
It seems like the Cocoa backend used to return the same mpv keycodes for
mouse back/forward as it did for scrolling up and down. Fix this by
explicitly mapping all Cocoa button numbers to the right mpv keycodes.
2017-09-03 20:31:44 +10:00
James Ross-Gowan 957e9a37db input: use mnemonic names for mouse buttons
mpv's mouse button numbering is based on X11 button numbering, which
allows for an arbitrary number of buttons and includes mouse wheel input
as buttons 3-6. This button numbering was used throughout the codebase
and exposed in input.conf, and it was difficult to remember which
physical button each number actually referred to and which referred to
the scroll wheel.

In practice, PC mice only have between two and five buttons and one or
two scroll wheel axes, which are more or less in the same location and
have more or less the same function. This allows us to use names to
refer to the buttons instead of numbers, which makes input.conf syntax a
lot easier to remember. It also makes the syntax robust to changes in
mpv's underlying numbering. The old MOUSE_BTNx names are still
understood as deprecated aliases of the named buttons.

This changes both the input.conf syntax and the MP_MOUSE_BTNx symbols in
the codebase, since I think both would benefit from using names over
numbers, especially since some platforms don't use X11 button numbering
and handle different mouse buttons in different windowing system events.

This also makes the names shorter, since otherwise they would be pretty
long, and it removes the high-numbered MOUSE_BTNx_DBL names, since they
weren't used.

Names are the same as used in Qt:
https://doc.qt.io/qt-5/qt.html#MouseButton-enum
2017-09-03 20:31:44 +10:00
wm4 9f0e358827 vo_opengl: fix overlay mode (again)
Did I mention yet that I regret this overlay mode thing?
2017-08-30 12:19:32 +02:00
wm4 96462040ec vd_lavc: change auto-probe order to prefer cuda over vdpau-copy
This aims at making --opengl-hwdec-interop=cuda --hwdec=yes select the
correct decoding mode: cuda instead of vdpau-copy.
2017-08-30 12:08:40 +02:00
wm4 a9571fcc0f vo_opengl: don't discard buffered video on redundant resize calls
If a VO-area option changes, gl_video_resize() is called
unconditionally. This function does something even if the size does not
change (at least it discards buffered frames for interpolation), which
can lead to stutter when you keep firing option change events during
playback.

Check for an actual resize, and if nothing changes, exit early.
2017-08-29 15:15:34 +02:00
wm4 a46500a2c8 vo_opengl: don't assume imgfmt=0 is valid
Could cause a crash if anything called ra_get_imgfmt_desc(imgfmt=0). Let
it fail correctly. This can happen if a hwdec backend does not set
hw_subfmt correctly.
2017-08-29 15:05:32 +02:00
Niklas Haas cc79d48d22
vo_opengl: fix the renderpass target format at creation time
Required for vulkan.
2017-08-27 14:37:47 +02:00
Niklas Haas 7baa18d5f8 vo_opengl: fix misleading comment in ra.h
tex_upload is not just for buffers
2017-08-27 14:36:28 +02:00
Niklas Haas 1d47473a7b
vo_opengl: use UBOs where supported/required
This also introduces RA_CAP_GLOBAL_UNIFORM. If this is not set, UBOs
*must* be used for non-bindings. Currently the cap is ignored though,
and the shader_cache *always* generates UBO-using code where it can.
Could be made an option in principle.

Only enabled for drivers new enough to support explicit UBO offsets,
just in case...

No change to performance, which is probably what we expect.
2017-08-27 14:36:04 +02:00
Niklas Haas 136cf2b770 vo_opengl: add support for UBOs
Not actually used by anything yet, but straightforward enough to add to
the RA API for starters.
2017-08-27 14:36:00 +02:00
Niklas Haas 8404a354e5 vo_opengl: clarify RA_CAP_DIRECT_UPLOAD
This no longer concerns the API user except in as much as the API user
probably wants to know whether or not PBOs are active, so keep around
the CAP field even though it's mostly useless now.
2017-08-27 14:36:00 +02:00
Niklas Haas 7684fda6ac vo_opengl: refactor shader_cache binding
There's no reason to be needlessly wasteful with our binding points
here. Just add a CAP for it.
2017-08-27 14:36:00 +02:00
Niklas Haas 45bae90f4d vo_opengl: be explicit about IMG_RW
Both vulkan and opengl distinguish between rendering to an image and
using an image as a storage attachment. So make this an explicit
capability instead of lumping it in with render_dst. (That way we could
support, for example, using an image as a storage attachment without
requiring a framebuffer)

The real reason for this change is that you can directly use the output
FBO as a storage attachment on vulkan but you can't on opengl, which
makes this param structly separate from render_dst.
2017-08-27 14:36:00 +02:00
Niklas Haas f40717a664 vo_opengl: use size_t offset for vertex offsets
I don't like the feeling of "reusing" the int binding for this. It
feels... wrong, somehow. I'd prefer to use an explicit "offset" field.
(Plus, I might re-use this for uniform buffers or something)

YMMV
2017-08-27 14:36:00 +02:00
James Ross-Gowan eacd97d536 mp_image: include config.h directly
This is needed for HAVE_SSE4_INTRINSICS. config.h used to be included as
a transitive dependency of vf.h, but the include statement was removed
from vf.h in 8f2ccba71b.

Also silence an unused variable warning that was introduced in the same
commit.
2017-08-26 00:41:04 +10:00
wm4 68dc7d1695 vo_opengl: allow selection of true 32 bit float if float16 unavailable
Shouldn't make a difference for OpenGL (even with the weird duplication
of these functions removed). Might be useful for the WIP vulkan backend.
2017-08-24 22:44:41 +02:00
wm4 ecef999d19 vd_lavc: work around some more idiotic FFmpeg nonsense
Like in commit bd356333c7, but for the other hwaccels as well.

Fixes #4794.
2017-08-24 11:35:17 +02:00
wm4 60ba7eebd7 vd_lavc: fix mid-stream hwdec fallback
Not resetting hwdec_request_reinit caused it to flush on every packet,
which not only caused it to fail triggering the actual fallback, and let
it never decode a new frame, but also to get stuck on EOF.
2017-08-23 14:02:44 +02:00
wm4 8f2ccba71b video: change --deinterlace behavior
This removes all GPL only code from it, and that's the whole purpose.
Also happens to be much simpler.

The "deinterlace" option still sort of exists, but only as runtime
changeable option. The main change in behavior is that the property will
not report back the actual deint state. Or in other words, if inserting
or initializing the filter fails, the deinterlace property will still
return "yes". This is in line with most recent behavior changes to
properties and options.
2017-08-22 19:08:07 +02:00
wm4 1b2185657f vo_direct3d: fix build
Broken by previous commit. Fix completely untested.
2017-08-22 17:32:05 +02:00
wm4 03cf150ff3 video: redo video equalizer option handling
I really wouldn't care much about this, but some parts of the core code
are under HAVE_GPL, so there's some need to get rid of it. Simply turn
the video equalizer from its current fine-grained handling with vf/vo
fallbacks into global options. This makes updating them much simpler.

This removes any possibility of applying video equalizers in filters,
which affects vf_scale, and the previously removed vf_eq. Not a big
loss, since the preferred VOs have this builtin.

Remove video equalizer handling from vo_direct3d, vo_sdl, vo_vaapi, and
vo_xv. I'm not going to waste my time on these legacy VOs.

vo.eq_opts_cache exists _only_ to send a VOCTRL_SET_EQUALIZER, which
exists _only_ to trigger a redraw. This seems silly, but for now I feel
like this is less of a pain. The rest of the equalizer using code is
self-updating.

See commit 96b906a51d for how some video equalizer code was GPL only.
Some command line option names and ranges can probably be traced back to
a GPL only committer, but we don't consider these copyrightable.
2017-08-22 17:01:35 +02:00
wm4 d67aa6da6b vf_eq: remove this filter
Both the video equalizer command/option glue, which drives this filter,
as well as the filter itself are slightly GPL contaminated. So it goes.

After this commit, "--vf=eq" will actually use libavfilter's vf_eq (if
FFmpeg was compiled in GPL mode), but it has different options and will
not listen to the equalizer VOCTRLs.
2017-08-22 15:58:49 +02:00
wm4 d2bdb72b69 options: add a thread-safe way to notify option updates
So far, we had a thread-safe way to read options, but no option update
notification mechanism. Everything was funneled though the main thread's
central mp_option_change_callback() function. For example, if the
panscan options were changed, the function called vo_control() with
VOCTRL_SET_PANSCAN to manually notify the VO thread of updates. This
worked, but's pretty inconvenient. Most of these problems come from the
fact that MPlayer was written as a single-threaded program.

This commit works towards a more flexible mechanism. It adds an update
callback to m_config_cache (the thing that is already used for
thread-safe access of global options).

This alone would still be rather inconvenient, at least in context of
VOs. Add another mechanism on top of it that uses mp_dispatch_queue, and
takes care of some annoying synchronization issues. We extend
mp_dispatch_queue itself to make this easier and slightly more
efficient.

As a first application, use this to reimplement certain VO scaling and
renderer options. The update_opts() function translates these to the
"old" VOCTRLs, though.

An annoyingly subtle issue is that m_config_cache's destructor now
releases pending notifications, and must be released before the
associated dispatch queue. Otherwise, it could happen that option
updates during e.g. VO destruction queue or run stale entries, which is
not expected.

Rather untested. The singly-linked list code in dispatch.c is probably
buggy, and I bet some aspects about synchronization are not entirely
sane.
2017-08-22 15:50:33 +02:00
Niklas Haas 09c501a40e
vo_opengl: refactor tex_upload to ra_buf_pool
Also refactors the usage of tex_upload to make ra_tex_upload_pbo a
RA-internal thing again.

ra_buf_pool has the main advantage of being dynamically sized depending
on buf_poll, so for OpenGL we'll end up only using one buffer (when not
persistently mapping) - while for vulkan we'll use as many as necessary,
which depends on the swapchain depth anyway.
2017-08-22 09:55:49 +02:00
wm4 437469c103 x11: fix that window could be resized when using embedding
Somewhat lazy fix. The code isn't particularly robust or correct wrt.
window embedding.

Fixes #4784.
2017-08-21 15:15:55 +02:00
wm4 028faacff5 video: add metadata handling for spherical video
This adds handling of spherical video metadata: retrieving it from
demux_lavf and demux_mkv, passing it through filters, and adjusting it
with vf_format. This does not include support for rendering this type of
video.

We don't expect we need/want to support the other projection types like
cube maps, so we don't include that for now. They can be added later as
needed.

Also raise the maximum sizes of stringified image params, since they
can get really long.
2017-08-21 14:56:07 +02:00
Martin Herkt 82d9419f62
Revert "x11: drop xscrnsaver use"
This broke screensaver/powersave inhibition with at least KDE and
LXDE. This is a release blocker.

Since fdo, KDE and GNOME idiots seem to be unable to reach
a consensus on a simple protocol, this seems unlikely to get
fixed upstream this year, so revert this change.

Fixes #4752.
Breaks #4706 but I don’t give a damn.

This reverts commit 3f75b3c343.
2017-08-20 09:18:39 +02:00
Martin Herkt a82007dd1e
Revert "x11: use xdg-screensaver suspend/resume"
This reverts commit 6694048272.
2017-08-20 09:11:07 +02:00
James Ross-Gowan 2d78705b73 context_angle: remove unused variable
Unused since 16e0a39482.
2017-08-20 16:46:02 +10:00
James Ross-Gowan 08ec444ba5 context_angle: replace hard-coded array size 2017-08-19 22:05:29 +10:00
Akemi 344b75f52d osx: code cleanups and cosmetic fixes
silence build warnings, clean up code style and remove unused code.
2017-08-18 19:47:47 +02:00
Niklas Haas 01058b16f9 vo_opengl: allow texture uploads to fail
Surprisingly makes the code shorter, not longer
2017-08-18 02:33:29 +02:00
Niklas Haas abb7e88e3c
vo_opengl: clarify the ra_fns.debug_marker 2017-08-18 01:10:37 +02:00
Niklas Haas 46d86da630 vo_opengl: refactor RA texture and buffer updates
- tex_uploads args are moved to a struct
- the ability to directly upload texture data without going through a
  buffer is made explicit
- the concept of buffer updates and buffer polling is made more explicit
  and generalized to buf_update as well (not just mapped buffers)
- the ability to call tex_upload/buf_update on a tex/buf is made
  explicit during tex/buf creation
- uploading from buffers now uses an explicit offset instead of
  implicitly comparing *src against buf->data, because not all buffers
  may actually be persistently mapped
- the initial_data = immutable requirement is dropped. (May be re-added
  later for D3D11 if that ever becomes a thing)

This change helps the vulkan abstraction immensely and also helps move
common code (like the PBO pooling) out of ra_gl and into the
opengl/utils.c

This also technically has the side-benefit / side-constraint of using
PBOs for OSD texture uploads as well, which actually seems to help
performance on machines where --opengl-pbo is faster than the naive code
path. Because of this, I decided to hook up the OSD code to the
opengl-pbo option as well.

One drawback of this refactor is that the GL_STREAM_COPY hack for
texture uploads "got lost", but I think I'm happy with that going away
anyway since DR almost fully deprecates it, and it's not the "right
thing" anyway - but instead an nvidia-only hack to make this stuff work
somewhat better on NUMA systems with discrete GPUs.

Another change is that due to the way fencing works with ra_buf (we get
one fence per ra_buf per upload) we have to use multiple ra_bufs instead
of offsets into a shared buffer. But for OpenGL this is probably better
anyway. It's possible that in future, we could support having
independent “buffer slices” (each with their own fence/sync object), but
this would be an optimization more than anything. I also think that we
could address the underlying problem (memory closeness) differently by
making the ra_vk memory allocator smart enough to chunk together
allocations under the hood.
2017-08-18 00:34:34 +02:00
Niklas Haas 9ca5a2a5d8 vo_opengl: make blitting an explicit capability
Instead of merging it into render_dst. This is better for vulkan,
because blitting in vulkan both does not require a FBO *and* requires a
different image layout.

Also less "hacky" for OpenGL, since now the weird blit=FBO requirement
is an implementation detail of ra_gl
2017-08-18 00:19:14 +02:00
Niklas Haas 8209376468 vo_opengl: make ra_fns.timer_create optional 2017-08-18 00:19:14 +02:00
Niklas Haas b74067bc74
vo_opengl: remove redundant #defines in unsharp_hook
These are no longer valid anyway, and the code doesn't use them.
2017-08-17 09:12:28 +02:00
James Ross-Gowan 16e0a39482 vo_opengl: extract non-ANGLE specific D3D11 code
This extracts non-ANGLE specific code to d3d11_helpers.c, which is
modeled after egl_helpers.c. Currently the only consumer is
context_angle.c, but in future this may allow the D3D11 device and
swapchain creation logic to be reused in other backends.

Also includes small improvements to D3D11 device creation. It is now
possible to create feature level 11_1 devices (though ANGLE does not
support these,) and BGRA swapchains, which might be slightly more
efficient than ARGB, since its the same format used by the compositor.
2017-08-17 00:28:38 +10:00
wm4 f24612db44 img_format: #if -> #ifdef
Oops.
2017-08-16 11:15:52 +02:00
wm4 6694048272 x11: use xdg-screensaver suspend/resume
If it doesn't work this time, I'll remove all X11 screensaver code.

Fixes #4763.
2017-08-15 20:32:44 +02:00
wm4 34ab0386cb vo_rpi: fix operation
Commit 697c4389a9 worked "almost". I couldn't test it at the time.
2017-08-15 19:41:23 +02:00
wm4 935df644af vo_opengl: fix incorrect glBindFramebuffer() call
Used the wrong binding.
2017-08-15 19:08:54 +02:00
wm4 b44e81d9c3 vo_opengl: fix dangling pointers when VAOs are not available
This is for legacy GL: if VAOs are not available, the helper has to
specify vertex attributes again on every rendering. gl_vao_init() keeps
the vertex array for this purpose. Unfortunately, a temporary argument
was passed to the function, instead of the permanent copy.

Also, it didn't use num_entries (instead expected the array being
terminated by a {0} entry). Fix that source code indentation too.
2017-08-15 18:59:59 +02:00
wm4 16d22ea02a img_format: better exclusion of bayer formats
These are useless and shouldn't be confused with normal RGB formats.
Replace the earlier hack checking the format name with a proper check.
(Not sure when this flag was added. Libav won't have it anyway, but also
no bayer formats.)
2017-08-15 17:03:35 +02:00
wm4 63b1031ca2 vo_opengl: support float pixel formats
Like AV_PIX_FMT_GBRPF32LE.
2017-08-15 17:00:35 +02:00
wm4 df8cc84f47 vo_opengl: remove DR image layouting code to renderer
No reason to have it in a higher level.
2017-08-14 19:57:44 +02:00
wm4 cacc6db2a3 vo_opengl: hwdec_vdpau: use correct source texture size
In commit c6fafbffac we accidentally set the logical texture size to
the cropped video size, which is not correct. This caused rendering
artifacts in some cases.

Use the video surfaces size instead. Since the current mp_image_params
contains the cropped size only, wrapper texture creation has to be moved
to the _map function. Move the same code for the mixer case (strictly
speaking this is not needed, but seems more symmetric).

(Also there is no need to clear gl_textures on uninit - leftover from
the old hwdec mapper API. So we just drop that part.)

Fixes #4760.
2017-08-14 12:17:39 +02:00
wm4 c20df5b3e1 vo_opengl: hwdec_ios: fix build 2017-08-11 22:00:44 +02:00
wm4 8b1d4b978d vo_opengl: remove some dead code
These were replaced by ra equivalents, and with the recent changes, all
of them became fully unused.
2017-08-11 21:29:35 +02:00
wm4 1d0bf4073b vo_opengl: handle probing GL texture formats better
Retrieve the depth for each component and internal texture format
separately. Only for 8 bit per component textures we assume that all
bits are used (or else we would in my opinion create too many probe
textures).

Assuming 8 bit components are always correct also fixes operation in
GLES3, where we assumed that each component had -1 bits depth, and this
all UNORM formats were considered unusable. On GLES, the function to
check the real bit depth is not available. Since GLES has no 16 bit
UNORM textures at all, except with the MPGL_CAP_EXT16 extension, just
drop the special condition for it. (Of course GLES still manages to
introduce a funny special case by allowing GL_LUMINANCE , but not
defining GL_TEXTURE_LUMINANCE_SIZE.)

Should fix #4749.
2017-08-11 21:29:35 +02:00
wm4 e7a9bd6937 vo_opengl: remove another unneeded GL include
Getting mp_pass_perf seriously requires including vo.h???
2017-08-11 21:29:35 +02:00
wm4 697c4389a9 rpi: fix build
Runtime untested, because I get this:

  [vo/rpi] Could not get DISPMANX objects.

This happened even when building older git versions, and on a RPI image
that hasn't changed in the recent years. I don't know how to make this
POS work again, so I guess if there's a bug in the new code, it will
remain broken.
2017-08-11 21:29:35 +02:00
wm4 de3eecce7f vo_opengl: move strictly private ra_gl structs to .c file
So that nothing accidentally accesses these.
2017-08-11 21:29:35 +02:00
wm4 fba4e8aa40 vo_opengl: remove some indirect GL header inclusions from core renderer 2017-08-10 21:36:57 +02:00
wm4 c6fafbffac vo_opengl: separate hwdec context and mapping, port it to use ra
This does two separate rather intrusive things:

 1. Make the hwdec context (which does initialization, provides the
    device to the decoder, and other basic state) and frame mapping
    (getting textures from a mp_image) separate. This is more
    flexible, and you could map multiple images at once. It will
    help removing some hwdec special-casing from video.c.
 2. Switch all hwdec API use to ra. Of course all code is still
    GL specific, but in theory it would be possible to support other
    backends. The most important change is that the hwdec interop
    returns ra objects, instead of anything GL specific. This removes
    the last dependency on GL-specific header files from video.c.

I'm mixing these separate changes because both requires essentially
rewriting all the glue code, so better do them at once. For the same
reason, this change isn't done incrementally.

hwdec_ios.m is untested, since I can't test it. Apart from superficial
mistakes, this also requires dealing with Apple's texture format
fuckups: they force you to use GL_LUMINANCE[_ALPHA] instead of GL_RED
and GL_RG. We also need to report the correct format via ra_tex to
the renderer, which is done by find_la_variant(). It's unknown whether
this works correctly.

hwdec_rpi.c as well as vo_rpi.c are still broken. (I need to pull my
RPI out of a dusty pile of devices and cables, so, later.)
2017-08-10 21:24:31 +02:00
wm4 b2fb3f1340 vo_opengl: hwdec_cuda: fix filtering mode
Probably explains quality issues in some cases.
2017-08-09 21:02:23 +02:00
wm4 9c5dcf9398 vo_opengl: shrink the hwdec overlay API
Just remove one callback, and fold the functionality into the other one.
RPI will still not compile, so the hwdec_rpi.c changes are untested.
2017-08-09 20:57:37 +02:00
wm4 de6d3f8ca1 vd_lavc: fix device leak with copy-mode hwaccels
Apparently this was broken by the "ctx->hwdec" check in the if condition
guarding the destroy call, and "ctx->hwdec = NULL;" was moved up
earlier, making this always dead code.

This should probably be refcounted or so, although that could make it
worse as well. For now, add a flag whether the device should be
destroyed.

Fixes #4735.
2017-08-09 12:00:56 +02:00
wm4 7397e8ab42 vo_opengl: add a hack for Apple's broken iOS hwdec stuff
As seen in hwdec_ios.m, it insists on using the legacy luminance alpha
formats for mapped textures.
2017-08-08 17:53:19 +02:00
Niklas Haas 6087f63003
vo_opengl: go back to using GL_TIME_ELAPSED
Less flexible than GL_TIMESTAMP but supported by more platforms. This
will mean that nested queries have to be detected and silently omitted,
but oh well. Not much use for them anyway.

Fixes #4721.
2017-08-08 17:08:25 +02:00
wm4 7f9193b353 Revert "mp_image_pool: disallow adding read only frames"
This reverts commit 0ce3dce03a.

We actually explicitly add read-only frames in some of the hwaccel code
via mp_image_new_custom_ref(), which sets AV_BUFFER_FLAG_READONLY. It's
probably better to keep it this way.

Fixes #4652 (and some related issues with D3D).
2017-08-08 16:16:55 +02:00
wm4 0b10a07b63 vo_opengl: don't call glGetProgramBinary if GL_PROGRAM_BINARY_LENGTH==0
Noticed in #4717, although the issue might be about something else.
2017-08-08 13:16:37 +02:00
wm4 3f75b3c343 x11: drop xscrnsaver use
It's an ancient X11 protocol extension that apparently nobody uses
anymore (desktop environments in particular have replaced it with
equally bad protocols that require tons of dependencies). Users keep
complaining about it being a required dependency.

The impact is likely minimal to none.

Fixes #4706 and other annoying people.
2017-08-08 12:55:41 +02:00
wm4 c1bcd30b09 vo_opengl: cosmetics to comments 2017-08-08 11:38:29 +02:00
wm4 61c8a147b5 vo_opengl: call ra_free() in the correct context
This also fixes a double free in vo_opengl_cb.c.
2017-08-07 19:57:15 +02:00
wm4 bbb57694b0 vf_vapoursynth: fix inverted sign and restore 10 bit support
Fixes #4720, I think.
2017-08-07 19:31:15 +02:00
wm4 168ffbaf23 client API: more opengl_cb clarifications
Also fix a typo in ra_gl.c. Too greedy for a separate commit.
2017-08-07 19:24:25 +02:00
wm4 d45fbecbb5 vo_opengl: add another ra_format field to exclude insane formats
Generic description of pixel formats is hard. In this case, the Apple
special format for packed YUV could have been interpreted as a RGB
format with funny packing.
2017-08-07 19:18:58 +02:00
wm4 47ea771b7a vo_opengl: further GL API use separation
Move multiple GL-specific things from the renderer to other places like
vo_opengl.c, vo_opengl_cb.c, and ra_gl.c.

The vp_w/vp_h parameters to gl_video_resize() make no sense anymore, and
are implicitly part of struct fbodst.

Checking the main framebuffer depth is moved to vo_opengl.c. For
vo_opengl_cb.c it always assumes 8. The API user now has to override
this manually. The previous heuristic didn't make much sense anyway.

The only remaining dependency on GL is the hwdec stuff, which is harder
to change.
2017-08-07 19:17:28 +02:00
wm4 1adf324d8b vo_opengl: fix minor memory leak
Don't leak the buffer if glGetProgramBinary() fails.
2017-08-07 18:46:40 +02:00
Niklas Haas bed421d483
vo_opengl: nuke ra_gl->first_run
Completely unnecessary, we can just update the uniforms immediately
after creating the program. In theory, for GLSL 4.20+, we could even
skip this, but oh well.
2017-08-07 17:47:04 +02:00
Niklas Haas ecbb02148b vo_opengl: better formatting for enum RA_CAP
Also fixes an issue where 1 << 5 was used twice, probably because of the
terrible formatting obscuring this bug
2017-08-07 17:46:04 +02:00
Niklas Haas 01a40bb1ee vo_opengl: also support RA_VARTYPE_INT vertex attribs
No reason not to.
2017-08-07 17:46:04 +02:00
wm4 346ac1e09f vo_opengl: simplify mirroring and fix it if glBlitFramebuffer is used
The vp_w/vp_h variables and parameters were not really used anymore
(they were redundant with ra_tex w/h) - but vp_h was still used to
identify whether rendering should be done mirrored.

Simplify this by adding a fbodst struct (some bad naming), which
contains the render target texture, and some parameters how it should be
rendered to (for now only flipping). It would not be appropriate to make
this a member of ra_tex, so it's a separate struct.

Introduces a weird regression for the first frame rendered after
interpolation is toggled at runtime, but seems to work otherwise. This
is possibly due to the change that blit() now mirrors, instead of just
copying. (This is also why ra_fns.blit is changed.)

Fixes #4719.
2017-08-07 16:44:15 +02:00
wm4 41ee66d566 vo_opengl: drop pointless fbotex_init() function 2017-08-07 14:34:18 +02:00
Niklas Haas 9581fbe569 vo_opengl: generalize ra_buf to support other buffer objects
This allows us to integrate PBOs and SSBOs into the same abstraction,
with the potential to easily add UBOs if the need arises.
2017-08-07 12:46:30 +02:00
Akemi f550fdaa91 cocoa: add an option to disable the native macOS fullscreen
Fixes #4014
2017-08-06 22:48:26 +02:00
Niklas Haas 494aa0f651
vo_opengl: only mark frames as fresh if they contain a new image
When using dumb mode, we can actually redraw a frame without uploading
it. Marking this as fresh as well results in unpredictable pass
behavior, which is confusing and makes debugging harder. So mark it as a
redraw instead, in that case.
2017-08-06 02:51:11 +02:00
Niklas Haas 988d188d96
vo_opengl: drop ra_gl.h from shader_cache.c
Since the GL *gl is no longer needed for the timers, we can get rid of
the sc->gl dependency. This requires moving a utility function (which is
not GL-specific anyway) out of gl_utils.h and into utils.h
2017-08-06 00:10:22 +02:00
Niklas Haas e5748e891f vo_opengl: measure pass_draw_osd as a whole
In the past, this always measured the per-shader execution times of the
individual OSD parts, which was thrown off because the shader was reused
anyway. (And apparently recording the OSD shader execution times was
removed completely, probably because of them being so unrealiably
anyway)

Since ra_timer no longer has the restriction of not allowing timers to
run concurrently, we can just wrap the entire OSD block inside a single
osd_timer now, and record that. (Technically, this can still be off when
using --blend-subtitles=video/yes and showing a full-screen OSD at the
same time. Maybe this can be done better?)
2017-08-06 00:10:20 +02:00
Niklas Haas f2298f394e vo_opengl: move timers to struct ra
In order to prevent code duplication and keep the ra abstraction as
small as possible, `ra` only implements the actual timer queries,
it does not do pooling/averaging of the results. This is instead moved
to a ra-neutral struct timer_pool in utils.c.
2017-08-06 00:10:20 +02:00
wm4 56742ecdc9 vo_opengl: ra_gl: make getting GL ptr slightly less tedious 2017-08-05 17:09:25 +02:00
wm4 dddda6e4a5 vo_opengl: move GL state resetting to vo_opengl_cb
This code is pretty much for the sake of vo_opengl_cb API users. It
resets certain state that either the user or our code doesn't reset
correctly. This is somewhat outdated. With GL implicit state being
so awfully large, it seems more reasonable require that any code
restores the default state when returning to the caller. Some
exceptions are defined in opengl_cb.h.
2017-08-05 16:27:09 +02:00
wm4 333cae74ef vo_opengl: move shader handling to ra
Now all GL-specifics of shader compilation are abstracted through ra.
Of course we still have everything hardcoded to GLSL - that isn't going
to change.

Some things will probably change later - in particular, the way we pass
uniforms and textures to the shader. Currently, there is a confusing
mismatch between "primitive" uniforms like floats, and others like
textures.

Also, SSBOs are not abstracted yet.
2017-08-05 16:27:09 +02:00
wm4 f72a33d2cb vo_opengl: organize ra PBO flag slightly differently
Instead of having a mutable ra_tex field (and the only one), move the
flag to struct ra, since we have only 2 tex_upload user calls anyway,
and both want the same PBO behavior. (At first I considered making it
a RA_TEX_UPLOAD_ flag, but why bother. PBOs are a terribly GL-specific
thing, so we can't expect a reasonable abstraction of it anyway.)
2017-08-05 13:48:46 +02:00
wm4 dd096863fa vo_opengl: make OSD code use ra for textures
This requires a silly extension to ra_fns.tex_upload: since the OSD
texture can be much larger than the actual OSD image data to upload, a
mechanism for uploading only to a small part of the texture is needed.
Otherwise, we'd have to realloc/copy the data, just to pad it, and then
pay for uploading the padding too.

The RA_TEX_UPLOAD_DISCARD flag is not interpreted by GL (not sure how
you'd tell GL about this), but it clarifies the API and might be
helpful if we support other backend APIs in the future.
2017-08-05 13:44:30 +02:00
wm4 8dd4ae13ff vo_opengl: restore OSX "old" hwdec
Probably. Untested.
2017-08-05 13:09:05 +02:00
wm4 aac04c0d64 vo_opengl: split utils.c/h
Actually GL-specific parts go into gl_utils.c/h, the shader cache
(gl_sc*) into shader_cache.c/h.

No semantic changes of any kind, except that the VAO helper is made
public again as part of gl_utils.c (all while the goal for gl_utils.c
itself is to be included by GL-specific code).
2017-08-05 13:09:05 +02:00