Commit Graph

2477 Commits

Author SHA1 Message Date
wm4 92d06f43fa vo_opengl: fix some more GLES shader issues
Just like commit f9a2fc59. There are probably some more such cases.
The vec2 constructor calls are probably fine, but don't bother with
confusing inconsistencies.
2015-11-19 21:19:04 +01:00
wm4 23f3b99003 vo_opengl: create FBOs in a more GLES conformant way
While desktop GL's glTexImage2D() essentially accepts anything, GLES is
much stricter. The combination of allowed formats/types/internal formats
is exactly specified. The GLES 3.0.4 specification lists them in
table 3.2. (The ANGLE API validation code references this table.)

The table could probably be extended into a general declarative table
about GL formats covering other uses, but this would be a big
non-trivial project, so don't bother and accept a minor degree
of duplication with other tables.

Note that the format and type do (or should) not matter here, because
no image data is transferred to the GPU.
2015-11-19 21:17:57 +01:00
wm4 b86a59aa4f vo_opengl: better check for float texture support
We don't only need float textures for advanced scaling - we also need
them to be filterable with GL_LINEAR. On GLES, this is not supported
until GLES 3.1, but some implementation expose them with extensions.
2015-11-19 21:17:45 +01:00
Kevin Mitchell 368431f57c vo_opengl: check shader string before sscanfing it 2015-11-19 08:14:06 -08:00
Kevin Mitchell 94147762fc vo_opengl: add missing log newline 2015-11-19 08:11:35 -08:00
wm4 a6fb80baa4 vo_opengl: add RGBA8 framebuffer format, enable non-dumb mode for ES 3.0
This makes advanced scaling sort-of work for GLES 3.0 (on ANGLE). It's
still not very advisable, as 8 bits might not be enough to avoid
debanding. (Ironically, the debanding filter can be enabled, and does
not raise any GL errors - but probably doesn't do anything useful.)
2015-11-19 14:45:06 +01:00
wm4 f9a2fc592f vo_opengl: don't mix floats and integers in dither shader
Some GLSL dialects (GLSL ES 3.00) do not have such implicit conversions.
They have to be made floats for the sake of the shader compiler.
2015-11-19 14:41:49 +01:00
James Ross-Gowan 76e4374d06 vo_opengl: fix ANGLE GLES3 mode
Turns out glGetTexLevelParameter, which is missing in ANGLE, is a
GLES3.1 function. Removing it from the list of core GLES3 functions
makes ANGLE work in GLES3 mode.
2015-11-19 20:37:30 +11:00
wm4 516e7d19da x11: request bypassing compositor
Maybe this is a good idea. Also add an option to disable it again, for
the sake of testing.

Fixes #2502.
2015-11-18 21:48:29 +01:00
James Ross-Gowan e76ec2c963 vo_opengl: add initial ANGLE support
ANGLE is a GLES2 implementation for Windows that uses Direct3D 11 for
rendering, enabling vo_opengl to work on systems with poor OpenGL
drivers and bypassing some of the problems with native GL, such as VSync
in fullscreen mode.

Unfortunately, using GLES2 means that most of vo_opengl's advanced
features will not work, however ANGLE is under rapid development and
GLES3 support is supposed to be coming soon.
2015-11-18 23:07:33 +11:00
wm4 0ec35fa111 videotoolbox: make decoder format customizable
Because apparently there's no ideal universally working format.

The weird OpenGL texture format for kCVPixelFormatType_32BGRA is from:

http://stackoverflow.com/questions/22077544/draw-an-iosurface-to-an-opengl-context

(Which apparently got it from the linked Apple example code.)
2015-11-17 21:21:19 +01:00
wm4 25fe9e89e7 vo_opengl: osx: error out if there is no IOSurface 2015-11-17 15:22:47 +01:00
wm4 e24e0ccd68 vo_opengl: force dumb mode if RG textures are not available
Something goes wrong somewhere. Don't bother, it's only needed for
compatibility with our absolute baseline (GL 2.1/GLES 2).

On the other hand, we can process nv12 formats just fine.
2015-11-16 20:09:15 +01:00
wm4 6b22b21651 vo_opengl: attempt to improve GLX vs. EGL backend detection
For the sake of vaapi interop, we want to use EGL, but on the other
hand, but because driver developers are full of shit, vdpau interop will
not work on EGL (even if the driver supports EGL). The latter happens
with both nvidia and AMD Mesa drivers.

Additionally, EGL vaapi interop support can apparently only detected at
runtime by actually using it. While hwdec_vaegl.c already does this, it
would require initializing libva on _every_ system, which will cause
libav to print an unpreventable bullshit message to the terminal.

Try to counter these huge loads of bullshit by adding more fucking
bullshit.
2015-11-16 16:22:23 +01:00
wm4 07c546b2b4 vo_opengl: fix backend autoprobing
We want the following behavior:
- VO probed, backend probed: only accept non-sw, fail completely
otherwise
- VO forced, backend probed: use the first non-sw, or if none is found,
fall back to the first working sw backend
- VO probed, backend forced: (I don't care about this case)
- VO forced, backend forced: just use that backend

Also, on backend probe failure the vo->probed field was left in its old
state.
2015-11-16 16:15:07 +01:00
Martin Herkt bf0b178e71
win32: support taskbar button progress indicator
This adds support for the progress indicator taskbar extension
that was introduced with Windows 7 and Windows Server 2008 R2.

I don’t like this solution because it keeps its own state and
introduces another VOCTRL, but I couldn’t come up with anything
less messy.

closes #2399
2015-11-15 23:18:24 +01:00
wm4 883d311413 vo_opengl: use glBlitFramebuffer to draw repeated frames
In the display-sync, non-interpolation case, and if the display refresh
rate is higher than the video framerate, we duplicate display frames by
rendering exactly the same screen again. The redrawing is cached with a
FBO to speed up the repeat.

Use glBlitFramebuffer() instead of another shader pass. It should be
faster.

For some reason, post-process was run again on each display refresh.
Stop doing this, which should also be slightly faster. The only
disadvantage is that temporal dithering will be run only once per video
frame, but I can live with this.

One aspect is messy: clearing the background is done at the start on the
target framebuffer, so to avoid clearing twice and duplicating the code,
only copy the part of the framebuffer that contains the rendered video.
(Which also gets slightly messy - needs to compensate for coordinate
system flipping.)
2015-11-15 18:30:54 +01:00
wm4 c7d82dd25c vo: fix unpausing with display-sync
Currently, vo.c will always continue to render the currently queued
frame, which sets last_flip, which in turn confuses vo_get_delay(),
which in turn will show a bogus A/V desync message on unpause. So just
reset it again on unpause.
2015-11-15 13:17:54 +01:00
wm4 cf3b34f17a vo: fix dropping frames with display-sync
I guess the removed code is an old leftover, and makes no sense anymore.
Should fix weird A/V diff dropouts when frames are being dropped with
display-sync.
2015-11-14 21:49:48 +01:00
wm4 a790009a63 player: account for minor VO underruns
If the player sends a frame with duration==0 to the VO, it can trivially
underrun. Don't panic, but keep the correct time.

Also, returning the absolute time from vo_get_next_frame_start_time()
just to turn it into a float with relative time was silly. Rename it and
make it return what the caller needs.
2015-11-14 21:49:48 +01:00
wm4 f0feea5591 command: rename vo-missed-frame-count property
"Missed" implies the frame was dropped, but what really happens is that
the following frame will be shown later than intended (due to the
current frame skipping a vsync).

(As of this commit, this property is still inactive and always
returns 0. See git blame for details.)
2015-11-13 22:41:41 +01:00
Martin Herkt def87f1e5f
win32: avoid detection as exclusive fullscreen window
Apparently Windows treats windows that use OpenGL, cover an entire
screen and have the WS_POPUP style set or are topmost windows as
exclusive fullscreen windows that bypass DWM and cannot be covered
by other windows.
This means we can’t use dwmflush in fullscreen mode, and it also
means that no other window can cover mpv, and it makes the screen
flicker when switching to fullscreen mode.

This can be avoided by not setting the WS_POPUP flag.
Users can still access the old behavior by enabling stay-on-top
(which IMO at least makes sense—now we just need to get dwmflush
autodetection right to avoid nasty surprises).

fixes #2177
2015-11-13 12:41:59 +01:00
wm4 b726fefe5d vo_opengl_cb: do not block on flipping when redrawing
Gives slightly better behavior when used with Qt. (Which tends not to
flip buffers when the window is not visible.)
2015-11-12 22:44:05 +01:00
rr- b7398cbdd8 drm: fix setting up connectors
Fixes regression from 67caea357c.
2015-11-11 19:40:13 +01:00
wm4 9a6ec9de2f vd_lavc: be more careful with flushing the decoder
Until now, we've relied on the following things:

- you can send flush packets to the decoder even if it's fully flushed,
- you can send new packets to a flushed decoder,
- you can send new packers to a partially flushed decoder.

("flushing" refers to sending flush packets to the decoder until the
decoder does not return new pictures, not avcodec_flush_buffers().)

All of these are questionable. The libavcodec API probably doesn't
guarantee that these work well or at all, even though most decoders have
no issue with these. But especially with hardware decoding wrappers
(like MMAL), real problems can be expected. Isolate us from these corner
cases by handling them explicitly.
2015-11-10 16:06:42 +01:00
wm4 4682b0147e vo_opengl: move the glFlush() call to the renderer 2015-11-10 14:36:23 +01:00
wm4 479eb93d9e vo_opengl_cb: better underflow reporting
This applies to unexpected freezes or deadlocks, not e.g. normal
framedrops. The verbose messages also might remind an API user if the
API usage is incorrect, such as not calling mpv_opengl_cb_draw() when a
redraw request was issued.
2015-11-10 14:35:13 +01:00
wm4 9d9f863f55 vo_opengl: limit GLSL to version 3.3
Fixes custom shaders, which define their entrypoint as sample()
function.
2015-11-10 11:51:11 +01:00
Bin Jin 03bbaad686 vo_opengl: fix 10-bit video prescaling
The nnedi3 prescaler requires a normalized range to work properly,
but the original implementation did the range normalization after
the first step of the first pass. This could lead to severe quality
degradation when debanding is not enabled for NNEDI3.

Fix this issue by passing `tex_mul` into the shader code.

Fixes #2464
2015-11-09 22:48:40 +01:00
wm4 3dc0f2ecf0 vo_opengl_cb: make operation more similar to normal VOs
vo_opengl_cb is a special case, because we somehow have to render video
asynchronously, all while "trusting" the API user to do it correctly.
This didn't quite work, and a while ago a compromise using a timeout to
prevent theoretically possible deadlocks was added.

Make it even more synchronous. Basically, go all the way, and
synchronize rendering between VO and user renderer thread to the
full extent possible.

This means the silly frame queue is dropped, and we event attempt to
synchronize the GL SwapBuffer call (via mpv_opengl_cb_report_flip()).

The changes introduced with commit dc33eb56 are effectively dropped. I
don't even remember if they mattered.

In the future, we might make all VOs fetch asynchronously from a frame
queue, which would mostly remove the differences between vo_opengl and
vo_opengl_cb, but this will take a while (if it will even be done).
2015-11-09 20:51:57 +01:00
wm4 eeb5f98758 vo_opengl: handle GL_ARB_uniform_buffer_object with low GLSL versions
Why is this stupid crap being so much a pain for no reason.
2015-11-09 16:24:01 +01:00
wm4 caa497ee8a vo_opengl: fix extension name 2015-11-09 14:29:58 +01:00
wm4 930f841589 vo_opengl: simplify GLSL version detection
Pick the correct GLSL version from the GL_SHADING_LANGUAGE_VERSION
string. Might be somewhat questionable, as we expect the minor version
number not to have leading 0s.

Should help with cases when the reported GLSL version is much higher
than the equivalent of the reported GL version. This problem was
observed in combination with GL_ARB_uniform_buffer_object, which
can't be used if the declared GLSL version is too low.
2015-11-09 14:29:09 +01:00
wm4 11888a9270 vo_opengl: never load vaapi GLX interop by default
Causes more harm than it helps. Will eventually be removed.

Also rename the "reject_emulated" field to "probing" - this is more
appropriate now.
2015-11-09 11:58:38 +01:00
wm4 76e50f6a3d vo_opengl: always preload hwdec interop
Simplifies some auto detection matters.

I _still_ don't want to remove the lazy loading mechanism, because it's
still slightly useful for filters using the hwdec APIs. My main
motivation for not always preloading them is actually that libva prints
random useless crap to the terminal with no way to prevent this.
2015-11-09 11:57:11 +01:00
wm4 7d5282ea5d vo_opengl: rename "drm_egl" to "drm-egl" 2015-11-09 11:21:28 +01:00
rr- f757163058 vo_opengl: disable drm_egl autopickup 2015-11-09 11:19:56 +01:00
wm4 16cd20c46f win32: request MMCSS "Playback" profile 2015-11-08 19:33:38 +01:00
rr- 03013e0fd7 vo_drm: relicense to LGPL
Also removed authorship information (as per convention seen in other
files)
2015-11-08 15:00:15 +01:00
rr- 62f261a7b8 vo_drm: use bool rather than integer return values
Since the errors weren't used for anything other than simple
success/fail checks, I simplified things a bit.
2015-11-08 15:00:15 +01:00
rr- c3f2ef5491 vo_opengl: add DRM EGL backend
Notes:

- Unfortunately the only way to talk to EGL from within DRM I could find
  involves linking with GBM (generic buffer management for Mesa.)
  Because of this, I'm pretty sure it won't work with proprietary NVidia
  drivers, but then again, last time I checked NVidia didn't offer
  proper screen resolution for VT.

- VT switching doesn't seem to work at all. It's worth mentioning that
  using vo_drm before introduction of VT switcher had an anomaly where
  user could switch to another VT and input text to it, while video
  played on top of that VT. However, that isn't the case with drm_egl:
  I can't switch to other VT during playback like this. This makes me
  think that it's either a limitation coming from my firmware or from
  EGL/KMS itself rather than a bug with my code. Nonetheless, I still
  left (untestable) VT switching code in place, in case it's useful to
  someone else.

- The mode_id, connector_id and device_path should be configurable for
  power users and people who wish to watch videos on nonprimary screen.
  Unfortunately I didn't see anything that would allow OpenGL backends
  to register their own set of options. At the same time, adding them to
  global namespace is pointless.

- A few dozens of lines could be shared with vo_drm (setting up VT
  switching, most of code behind page flipping). I don't have any strong
  opinion on this.

- Sometimes I get minor visual glitches. I'm not sure if there's a race
  condition of some sort, unitialized variable (doubtful), or if it's
  buggy driver. (I'm using integrated Intel HD Graphics 4400 with Mesa)

- .config and .control are very minimal.

Signed-off-by: wm4 <wm4@nowhere>
2015-11-08 15:00:15 +01:00
rr- 67caea357c vo_drm: move initialization to drm_common
Makes KMS initialization procedures reusable so that they can be used by
the upcoming DRM EGL adapter.
2015-11-08 14:58:34 +01:00
rr- b1893d2084 vo_opengl: fix typo 2015-11-07 19:46:51 +01:00
wm4 46cee66563 vo_opengl: rename fancy-downscaling to correct-downscaling
The old name was stupid. Very stupid.
2015-11-07 17:49:14 +01:00
Avi Halachmi (:avih) 0062c98dff vo_opengl: fancy-downscaling: enable also for anamorphic clips 2015-11-07 17:44:50 +01:00
wm4 6bbb1e4cf9 x11: print Xlib errors in verbose mode if Xlib messages are silenced
Follow up to commit b984ec52.
2015-11-07 17:43:10 +01:00
wm4 b984ec52aa vo_opengl: x11: silence error messages when using legacy GL context
glXCreateContextAttribsARB() by design can throw some X11 errors. We
ignore these, but we generally still print error messages to the
terminal. This was confusing/annoying users, so silence it. The stupid
part is that the Xlib error handler is global, so we have to be slightly
careful here.
2015-11-06 21:20:23 +01:00
wm4 9693e0f57a Remove some VLAs
They are evil and should be eradicated. Some of these were pretty dumb
anyway.

There are probably some more around in platform specific code or other
code not enabled by default on Linux.
2015-11-06 21:12:20 +01:00
James Ross-Gowan 647b360a0a w32: use DisplayConfig API to retrieve correct monitor refresh rate
This is based on an older patch by James Ross-Gowan. It was rebased and
cleaned up. Also, the DWM API usage present in the older patch was
removed, because DWM reports nonsense rates at least on Windows 8.1
(they are rounded to integers, just like with the old GDI API - except
the GDI API had a good excuse, as it could report only integers).

Signed-off-by: wm4 <wm4@nowhere>
2015-11-06 19:53:18 +01:00
James Ross-Gowan 68ac45e487 w32: always get screenrc from an HMONITOR
This simplifies update_screen_rect a bit. Unless --fs-screen=all is
used, it will always get an HMONITOR and call GetMonitorInfo to
determine its dimensions. This will make it easier for the next few
commits to determine the colour profile and the refresh rate from the
HMONITOR.

There is a slight change in behaviour. When selecting a screen that is
out of range, such as --screen=9 on a machine with only two monitors,
the old code would silently select the last existing monitor. The new
code prints an error message and falls back to the default screen (same
as the Cocoa code.)

Signed-off-by: wm4 <wm4@nowhere>
2015-11-06 19:53:18 +01:00