Commit Graph

120 Commits

Author SHA1 Message Date
wm4 58ba2a9087 vo_rpi: use EGL to render subtitles
Slightly faster than using the dispmanx mess (perhaps to a large amount
due to the rather stupid C-only unoptimized ASS->RGBA blending code).

Do this by reusing vo_opengl's subtitle renderer, and vo_opengl's RPI
backend.
2015-08-18 23:01:09 +02:00
wm4 5b14ceb315 vo_opengl: minor simplifications
No functional changes.
2015-08-01 21:11:38 +02:00
wm4 f15e652dd4 vo_opengl: framebuffers work under GLES 2
They are not entirely full-featured in GLES 2, but they appear to
provide all we need. Thus we can enable them.
2015-07-27 23:27:49 +02:00
wm4 bdc60daffa vo_opengl: remove legacy GL detection
This detected whether an OpenGL context still provided legacy OpenGL if
the OpenGL version is modern (>= 3.0). This was actually only needed for
vo_opengl_old, because it relied on legacy functions. Since it's gone,
this code isn't needed either.

(Also, the removed comment about OpenGL 3.0 was wrong: you could just
query GL_CONTEXT_FLAGS and see if the forward compatible bit was set.)
2015-07-24 23:34:43 +02:00
wm4 898855cc0d vo_opengl: reduce verbose output
Outputting the detected OpenGL features was useless and redundant with
the extension loading output.

Also, remove MPGL_CAP_3D_TEX from OpenGL(ES) 3.0. This block didn't
include the glTexImage3D function, so that was pointless and couldn't
have worked. The OpenGL 2.1 block does it correctly.
2015-07-11 20:01:28 +02:00
wm4 561416597e client API, dxva2: add a workaround for OpenGL fullscreen issues
This is basically a hack for drivers which prevent the mpv DXVA2 decoder
glue from working if OpenGL is in fullscreen mode.

Since it doesn't add any "hard" new API to the client API, some of the
code would be required for a true zero-copy hw decoding pipeline, and
sine it isn't too much code after all, this is probably acceptable.
2015-07-03 16:38:12 +02:00
wm4 cc51dafa96 vo_opengl: log some more stuff in verbose mode 2015-07-03 15:12:42 +02:00
wm4 c169292902 vo_opengl: update EGL code
Use the newer internal GL backend API.
2015-07-02 00:25:30 +02:00
wm4 99bc049745 vo_opengl: remove unused GL API functions 2015-07-02 00:08:17 +02:00
wm4 3170473003 vo_opengl: output slightly more debugging info on backend probing 2015-05-30 21:25:28 +02:00
wm4 bad932e8ed vo_opengl: hardcode rquested GL version in backends
The requested version field didn't make much sense anymore, and was even
partially ignored by some backends.
2015-05-14 13:07:00 +02:00
wm4 fa39dadb05 x11: use new OpenGL backend API 2015-05-14 00:05:54 +02:00
wm4 df97c30e0e vo_opengl: create new API for OpenGL VO backends
An attempt to get rid of the weird mix of callbacks that take either
struct vo or MPGLCopntext as parameter. This is not perfect, and the
API will probably change a bit until all other code is ported to it.
the main question is how to separate struct vo completely from the
windowing code, which actually needs vo for very little.

In the end, the legacy callbacks will be dropped.
2015-05-14 00:05:43 +02:00
wm4 10de9b091a vo_opengl: change user options for requesting GLES
Instead of having separate backends, make use of GLES a flag. This
reduces the number of backends and the resulting annoyances.

Also, nobody cares about using GLES, so there's no backward
compatibility either.
2015-05-14 00:05:39 +02:00
wm4 27da344e6f vo_opengl: merge GL backend creation/initialization
The final goal is to remove the nonsense separation between the 3
backend init/vo_init/GL context creation calls.
2015-05-13 22:56:44 +02:00
wm4 5ab05f61ca vo_opengl: remove mpgl_lock calls
Awkward stuff not needed anymore.
2015-05-13 22:03:24 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4 8fff125422 RPI support
This requires FFmpeg git master for accelerated hardware decoding.
Keep in mind that FFmpeg must be compiled with --enable-mmal. Libav
will also work.

Most things work. Screenshots don't work with accelerated/opaque
decoding (except using full window screenshot mode). Subtitles are
very slow - even simple but huge overlays can cause frame drops.

This always uses fullscreen mode. It uses dispmanx and mmal directly,
and there are no window managers or anything on this level.

vo_opengl also kind of works, but is pretty useless and slow. It can't
use opaque hardware decoding (copy back can be used by forcing the
option --vd=lavc:h264_mmal). Keep in mind that the dispmanx backend
is preferred over the X11 ones in case you're trying on X11; but X11
is even more useless on RPI.

This doesn't correctly reject extended h264 profiles and thus doesn't
fallback to software decoding. The hw supports only up to the high
profile, and will e.g. return garbage for Hi10P video.

This sets a precedent of enabling hw decoding by default, but only
if RPI support is compiled (which most hopefully it will be disabled
on desktop Linux platforms). While it's more or less required to use
hw decoding on the weak RPI, it causes more problems than it solves
on real platforms (Linux has the Intel GPU problem, OSX still has
some cases with broken decoding.) So I can live with this compromise
of having different defaults depending on the platform.

Raspberry Pi 2 is required. This wasn't tested on the original RPI,
though at least decoding itself seems to work (but full playback was
not tested).
2015-03-29 16:09:56 +02:00
wm4 45ff6cef62 vo_opengl: minor simplification
We don't need alternative function names in the GL loader anymore.
2015-03-25 12:40:45 +01:00
wm4 6d9f15a8ab vo_opengl: check extensions properly
With the previous commit, we have no need anymore to check a part of an
extension string (for ignoring a prefix). So check the extension string
properly, instead of just using the broken old strstr() method, which
could accidentally ignore prefixes or suffixes. Do this by extending
the check to whether the extension name is properly delimited by spaces
or string start/end.
2015-03-25 12:36:36 +01:00
wm4 85c21ae409 vo_opengl: cleanup swap_control extension loading
Instead of somehow looking for the substring "_swap_control" and trying
to several arbitrary function names, do it cleanly. The old approach has
the problem that it's not very exact, and may even load a pointer to a
function which doesn't exist. (Some GL implementations like Mesa return
function pointers even the functions which don't exist, and calling them
crashes.)

I couldn't find any evidence that glXSwapInterval, wglSwapIntervalSGI,
or wglSwapInterval actually exist, so don't include them. They were
carried over from MPlayer times.

To make diagnostics easier, print a warning in verbose mode if the
function could not be loaded.
2015-03-25 12:29:19 +01:00
wm4 cdf9abd872 vo_opengl: drop support for old framebuffer extension
Drop support for GL_EXT_framebuffer_object. It has 2 problems: semantics
might be slightly different from the "proper" GL_ARB_framebuffer_object
extension (but is likely completely untested), and also our extension
loader is too dumb to load the same group of function pointers
represented by different extensions only once.
2015-03-25 12:00:57 +01:00
wm4 aedea2a79f vo_opengl: don't test for arrays
Even the lowest supported GL versions have arrays. This test was for
returning arrays from functions, which didn't work in lower GL versions,
but we don't need it anymore.
2015-03-13 11:55:31 +01:00
wm4 9861abf8ff vo_opengl: minor robustness improvement in function loader
Check the scanf() return value, and don't continue if it doesn't find
both numbers (can happen with GLES 1.0). Also, some implementations can
return NULL from glGetString() if something is "broken".
2015-02-20 18:53:35 +01:00
wm4 616481ad29 vo_opengl: remove some unused functions
These were intended for some plans that were never realized.

Also move some comments around and fix them.
2015-01-28 19:40:52 +01:00
wm4 3583559164 vo_opengl: move utility functions from loader to a separate file
gl_common.c contained the function loader (which is big) and additional
utility functions (not so big, but will grow when moving more out of
gl_video.c). Just split them. There are no changes other than some
modifications to comments.
2015-01-28 19:40:46 +01:00
wm4 f3c84a322d vo_opengl: fix display of ARGB ith color management enabled
PNG uses a different component order from GL_RGBA, so we upload the
surface using the "wrong" order, and then fix it in the shader. This
breaks if a sRGB texture (GL_SRGB) is used: the hardware will not touch
the alpha channel, which means that the B component is not adjusted,
leading to incorrect output.

Just remove the use of sRGB textures completely. It might lead to a
slight slow down when playing RGB with color management enabled, but
with this combination of obscure use case with minor performance impact
it's not a meaningful disadvantage.

Unfortunately this also means that alpha is handled incorrectly with our
own color management, but alpha isn't so important and can be fixed
later. (0.0 and 1.0 are unchanged by the transfer function, so it
"mostly" works.)

Fixes #1530.
2015-01-28 13:36:07 +01:00
wm4 4a06a66501 vo_opengl: drop sRGB framebuffer detection
We've stopped using them some time ago (we're doing things manually
instead).
2015-01-26 06:12:35 +01:00
Niklas Haas f5e48f0235 vo_opengl: clean up ewa_lanczos code
This fixes compatibility with GLES 2.0 and makes the code a bit neater
in general. It also properly forces indirect scaling for subsampled
video regardless of the lscale setting.
2015-01-22 19:29:23 +01:00
wm4 5bb24980ae vo_opengl: simplify screenshot code
Instead of reading back the image from textures, keep a reference to the
original image, and return that.

The main reason this was done this way was that originally, images
weren't refcounted, and would be deallocated or overwritten as soon as
the VO's draw call returned. But now there isn't really a good reason
for this anymore. One possibly _could_ argue that it was better because
other code could reuse the image sooner (e.g. for the cache), but on the
other hand, the VO runs already on a different thread, and filtering and
decoding each run on other threads too, so this argument probably
wouldn't hold up.
2015-01-22 18:31:10 +01:00
wm4 e34957940b vo_opengl: cleanups after vo_opengl_old removal
Don't load all the legacy functions (including ancient extensions).
Slightly simplify function loader and context creation, now that legacy
GL doesn't need to be handled. Remove the code for drawing OSD in legacy
mode.

Remove all the header hacks, which were meant for ancient OpenGL headers
which didn't even support things like OpenGL 1.3. Instead, adjust the
GLX check to make sure we get both OpenGL 3x and 2.1 symbols. For win32
and OSX, we assume that the user has the latest headers anyway. For
wayland, we hope that things somehow go right.
2015-01-21 20:32:42 +01:00
wm4 724f722d7f vo_opengl_old: remove this VO
At this point, there is probably no hardware left that doesn't do
OpenGL 2.1, and at the same time is fast enough to handle video.
2015-01-20 21:15:04 +01:00
wm4 7873301be8 vo_opengl_old: remove ancient ATI-specific YUV conversions
While there's no actual need to get rid of these, I want to make sure
nobody actually needs this stuff, and removing it is the best way to
get to know this. We still can revert this commit if it turns out there
is a significant need for this stuff.

The final goal is removing vo_opengl_old entirely. Add a warning, which
basically announces this intention.
2015-01-02 00:59:27 +01:00
wm4 5a3070304f vo_opengl: don't use 10 bit video on Intel GPUs
vo_opengl was originally written against OpenGL 3 core, and it seems
GPUs/drivers supporting this are mostly sane. Later, it was made to work
with OpenGL 2.1 too. Lately we removed the requirement for RG textures,
and look, someone reported a problem with "lesser" Intel GPUs.

This commit does the same in vo_opengl what was added to vo_opengl_old a
long time ago.

Fixes #1383.
2014-12-24 16:54:47 +01:00
wm4 2ad1906be6 vo_opengl_cb: use VAOs even in OpenGL 2.1
Using them reduces state change, since now at least vo_opengl_cb has to
setup/break the vertex array bindings on every frame if no VAOs are
available.

This reverts the VAO related change in commit f64665e7.
2014-12-23 14:32:24 +01:00
wm4 a8ffa0d0eb vo_opengl: make use of newer OpenGL logging API
GL_ARB_debug_output provides a logging callback, which can be used to
diagnose problems etc. in case the driver supports it. It's enabled only
if the vo_opengl "debug" suboption is set.
2014-12-23 02:46:44 +01:00
wm4 d5a7ad630f vo_opengl: improve fallback handling with GLES
Whether we have texture_rg doesn't matter much anymore; the scaler
should be fine with this. But on ES 2.0, 1st class arrays are missing,
so even if filterable float textures should be available, it won't work.

Dithering (at least the "fruit" variant) will not work either, because
it uses floats.
2014-12-21 23:46:54 +01:00
wm4 e749d26ac3 vo_opengl: skip GLES when autoprobing
There are probably bugs with GLES support; also, if you somehow get GLES
instead of desktop GL on a desktop computer, something else is probably
wrong. So I see no point in using this automatically. We first need to
find out whether the GLES support works on real hardware, and whether
it is useful at all.
2014-12-19 20:34:11 +01:00
wm4 d31e584292 vo_opengl, x11: add ES context creation via GLX
Apparently GLX can do this, so using EGL is not strictly required.

This code tries to create an ES context if creating a desktop GL context
fails. Also, a "x11es" backend for forcing ES (instead of desktop GL) is
added, mostly for testing and debugging.
2014-12-19 20:29:31 +01:00
wm4 b7277d25e5 vo_opengl: fail if required functions are missing
Before this, missing additional but required functions were ignored.
("Main" functions still made it error out.) But we pretty much expect
that these are present on a given version level, and only an extremely
buggy OpenGL implementation would not do this.
2014-12-19 18:54:39 +01:00
wm4 88982f2855 vo_opengl: better probe handling
Involve detection of software renderers in the probing properly. Other
VOs could handle probing also more gracefully, and e.g. produce less
noise if an API is unavailable. (Although other than the OpenGL VOs,
only vo_wayland will.)

Now the "sw" suboption for vo_opengl[_old] is strictly speaking not
needed anymore. Doing "--vo=opengl" disables the probing logic, and will
always force it, if possible.

Includes some simplifications as well.
2014-12-19 18:54:39 +01:00
wm4 a0051b9da2 vo_opengl: add GLES 2 support
Rather basic support. Almost nothing works, and even if it does, it's
bound to be inefficient (due to texture upload). This was tested with
the nVidia desktop binary drivers, which provide GLES 2 support only.
However, nVidia is not known to be very strict about OpenGL, and the
driver is very new too, so the vo_opengl code will have bugs too.
2014-12-19 01:21:19 +01:00
wm4 fe35130ba9 vo_opengl: mess with PixelStorei state management
This is needed for GLES 2 support. GLES 2 doesn't support
GL_UNPACK_ROW_LENGTH, and we shouldn't even use this constant, since a
GLES implementation could raise an error.

So set it only if neccessary, and leave it in the default state
otherwise. This also smuggles in a ES 2 fallback for glUploadTex(),
and querying an extension relevant for ES 2. For the alignment state
(GL_[UN]PACK_ALIGNMENT) do the same for symmetry. All 4 states
(alignment/rows x pack/unpack) are now assumed to be in their initial
states by default.

Also redo the PixelStorei handling in the function table. I could rebase
this, but look at the commit time.
2014-12-19 01:21:18 +01:00
wm4 de3e26bc84 vo_opengl: disable some unavailable features under ES
There are probably many more which I overlooked.
2014-12-19 00:15:38 +01:00
wm4 f64665e7e9 vo_opengl: clean up GL ES function loading
Previously, this was sort of messed together with desktop OpenGL
loading. Add explicit support for ES, and clean up the mess. Also sort
the function arrays alphabetically (at least most of them).

In some cases, add functions to multiple sections. This keeps the number
of sections down.

Don't check for GL_ARB_vertex_array_object. This feature must be used in
OpenGL 3 core, while it may be not available at all in earlier versions,
and not using it if it's available as extension only has no advantages.

This commit also considers GLES 2, because actual support for it will be
added with a later commit.

Also get rid of some MPGL_VER() uses (see some commits ago).
2014-12-18 23:51:21 +01:00
wm4 1b766ab208 vo_opengl: do not use 4x3 matrix
This was a nice trick to get the mpv colormatrix directly into OpenGL,
because the memory representation happened to match.

Unfortunately, OpenGL ES 2 doesn't have glUniformMatrix4x3fv().

Even more unfortunately, the memory representation is now incompatible.
It would be nice to change it, but that would mean getting into a big
mess.
2014-12-18 22:24:45 +01:00
wm4 32fb3dae87 vo_opengl: simplify some aspects of the GL function loader 2014-12-18 21:06:17 +01:00
wm4 6f0da71c6b vo_opengl: minor simplification in function loader
Don't force every entries without functions to define a dummy array.
2014-12-18 15:29:47 +01:00
wm4 649e337f4d vo_opengl: don't assume legacy OpenGL is available with GLES
OpenGL 3.0 has the weird situation that it's "hard" to detect whether
legacy GL is really present. Since we pretend that we have OpenGL 3.0 if
we use GLES, it was assuming legacy GL is available.
2014-12-17 22:39:04 +01:00
wm4 10befa26d9 vo_opengl: GLES 3 support
Tested with MESA on software emulation. Seems to work well, although the
default FBO format in opengl-hq disables most interesting features. I
have no idea how well it will work on real hardware (or if it does at
all).

Unfortunately, some features, including playback of 10 bit video, are
not supported. Not sure what to do about this.

GLES 2 or 1 do not work.
2014-12-17 21:48:23 +01:00