Commit Graph

110 Commits

Author SHA1 Message Date
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
wm4 1c2cbeabc2 vo_opengl: remove quadbuffer/anaglyph stereo 3D rendering
Obscure feature, and I've never heard of anyone using it.

The anaglyph effects can be reproduced with vf_stereo3d. The only thing
that can't be reproduced with it is "quadbuffer", which requires special
and expensive hardware.
2014-12-15 04:40:26 +01:00
wm4 5beac919d0 vo_opengl: fix linkage type
Can happen on Windows, I suppose.
2014-12-09 22:37:32 +01:00
wm4 56882eaee4 vo_opengl: don't crash if framebuffers are not available
In theory, vo_opengl supports operation without framebuffers. But this
has been broken for a while now (commit cc00b3ff is a contender). It
crashed because it unconditionally called gl->BindFramebuffer() (which
is NULL if framebuffers are missing).

Since this function is actually only called to set the default
framebuffer, the simplest way to deal with this is to provide a dummy
function, insteas of uglifying the code with additional if branches.
2014-12-09 22:28:16 +01:00
wm4 fb855b8659 client API: expose OpenGL renderer
This adds API to libmpv that lets host applications use the mpv opengl
renderer. This is a more flexible (and possibly more portable) option to
foreign window embedding (via --wid).

This assumes that methods like context sharing and multithreaded OpenGL
rendering are infeasible, and that a way is needed to integrate it with
an application that uses a single thread to render everything.

Add an example that does this with QtQuick/qml. The example is
relatively lazy, but still shows how relatively simple the integration
is. The FBO indirection could probably be avoided, but would require
more work (and would probably lead to worse QtQuick integration, because
it would have to ignore transformations like rotation).

Because this makes mpv directly use the host application's OpenGL
context, there is no platform specific code involved in mpv, except
for hw decoding interop.

main.qml is derived from some Qt example.

The following things are still missing:
- a way to do better video timing
- expose GL renderer options, allow changing them at runtime
- support for color equalizer controls
- support for screenshots
2014-12-09 17:59:04 +01:00
wm4 920512d358 vo_opengl: move hwdec parts into their own files
This wasn't done before because there was no advantage in "abstracting"
it. This changed, and putting this into its own files is better than
messing it into gl_common.c/h.
2014-12-03 23:01:19 +01:00
wm4 3fe57e3cb6 gl_common: factor context creation
Always create the context in mpgl_init(), instead of doing it when
mpgl_config_window() is called the first time. This is a small step
towards cleaning up the GL backend interface, and adding other things
like perhaps GLES support, or a callback-driven backend for libmpv.
2014-11-26 20:48:18 +01:00
wm4 bebfaae666 vo_opengl: minimal EGL on X11 support
Pretty useless and only good for testing.

Does not include any form of GLES support.
2014-11-04 01:41:37 +01:00
wm4 26bc6b4831 Add some missing "const"s
The one in msg.c was mistakenly removed with commit e99a37f6.

I didn't actually test the change in ao_sndio.c (but obviously "ap"
shouldn't be static).
2014-10-10 13:44:08 +02:00
wm4 a95cfac078 vo_opengl: don't pass (char*)NULL as %s printf argument
glGetString(GL_SHADING_LANGUAGE_VERSION) can return NULL; I suppose this
happens on legacy OpenGL, while all the other fields are guaranteed to
exist.
2014-08-28 01:52:15 +02:00
wm4 f7eea070f0 vo_opengl: don't cut off feature list output 2014-08-25 00:48:55 +02:00