summaryrefslogtreecommitdiffstats
path: root/video/out
Commit message (Collapse)AuthorAgeFilesLines
* vo_opengl: support compute shadersNiklas Haas2017-07-247-100/+317
| | | | | | | | These can either be invoked as dispatch_compute to do a single computation, or finish_pass_fbo (after setting compute_size_minimum) to render to a new texture using a compute shader. To make this stuff all work transparently, we try really, really hard to make compute shaders as identical to fragment shaders as possible in their behavior.
* vo_opengl: cut down on FBOTEX_FUZZY abuseNiklas Haas2017-07-241-4/+2
| | | | | | | | Don't use FBOTEX_FUZZY where the FBO is sized according to p->texture_w/h, since this changes infrequently (and when it does, we need to reset everything anyway). No real reason to make this change other than that it possibly prevents nasty surprises in the future, so I feel more comfortable about it.
* common, vo_opengl: add/use helper for formatted strings on the stackwm42017-07-242-10/+5
| | | | | | | | | | | Seems like I really like this C99 idiom. No reason not to generalize it do snprintf(). Introduce mp_tprintf(), which basically this idiom to snprintf(). This macro looks like it returns a string that was allocated with alloca() on the caller site, except it's portable C99/C11. (And unlike alloca(), the result is valid only within block scope.) Use it in 2 places in the vo_opengl code. But it has the potential to make a whole bunch of weird looking code look slightly nicer.
* vo_opengl: check format on some printf-like callswm42017-07-242-3/+5
| | | | Fix 1 incorrect use.
* vo_opengl: add direct rendering supportwm42017-07-249-4/+324
| | | | | | | | | | | | | | | | | | | | Can be enabled via --vd-lavc-dr=yes. See manpage additions for what it does. This reminds of the MPlayer -dr flag, but the implementation is completely different. It's the same basic concept: letting the decoder render into a GPU buffer to avoid a copy. Unlike MPlayer, this doesn't try to go through filters (libavfilter doesn't support this anyway). Unless a filter can work in-place, DR will be silently disabled. MPlayer had very complex semantics about buffer types and management (which apparently nobody ever understood) and weird restrictions that mostly limited it to mpeg2 style codecs. The mpv code does not do any of this, and just lets the decoder allocate an arbitrary number of untyped images. (No MPlayer code was used.) Parts of the code based on work by atomnuker (starting point for the generic code) and haasn (some GL definitions, some basic PBO code, and correct fencing).
* vo_opengl: osd: remove stale declarationwm42017-07-231-1/+0
| | | | Was missed in the previous changes.
* vo_opengl: add printf format checking to pass_describe()wm42017-07-221-0/+1
|
* vo_opengl: make VAO helper private, remove old VAO mechanismwm42017-07-222-44/+17
| | | | The struct describing vertex attributes is still public, of course.
* vo_opengl: osd: use new VAO mechanismwm42017-07-223-49/+43
| | | | | | | In addition to using the new VAO mechanism introduced in the previous commit, this tries to keep the OSD code self-contained. This doesn't work all too well (because of the pass and CMS stuff), but it's still better than before.
* vo_opengl: add mechanism to create/cache VAO on the flywm42017-07-223-19/+64
| | | | | | This removes VAO handling from video.c. Instead the shader cache will create the VAO as needed. The consequence is that this creates a VAO per shader, which might be a bit wasteful, but doesn't matter anyway.
* vo_opengl: osd: refactor and simplifywm42017-07-225-43/+34
| | | | | | | | Reduce this to 1 draw call per OSD pass. This removes the need for some annoying special handling regarding 3D video support (we supported duplicating the OSD/subtitles for side-by-side 3D output etc.). Remove the unneeded texture sampler uniform thing.
* vo_opengl: avoid constant divisionsNiklas Haas2017-07-172-40/+42
| | | | | | | These are apparently expensive on some drivers which are not smart enough to turn x/42 into x*1.0/42. So, do it for them. My great test framework says it's okay
* vo_opengl: styleNiklas Haas2017-07-161-1/+1
| | | | Use uintptr_t instead of size_t. Shouldn't matter, but is cleaner.
* vo_opengl: use MP_ALIGN_UP instead of FFALIGNNiklas Haas2017-07-161-1/+1
| | | | Consistency/style
* vo_opengl: use glBufferSubData instead of glMapBufferRangeNiklas Haas2017-07-163-24/+10
| | | | | | | | | | | | | | | | | | | | Performance seems pretty much unchanged but I no longer get nasty spikes on NUMA systems, probably because glBufferSubData runs in the driver or something. As a simplification of the code, we also just size the PBO to always have the full size, even for cropped textures. This seems slower but not by relevant amounts, and only affects e.g. --vf=crop. It also slightly increases VRAM usage for textures with big strides. This new code path is especially nice because it no longer depends on GL_ARB_map_buffer_range, and no longer uses any functions that can possibly fail, thus simplifying control flow and seemingly deprecating the manpage's claim about possible image corruption. In theory we could also reduce NUM_PBO_BUFFERS since it doesn't seem like we're streaming uploads anyway, but leave it in there just in case some drivers disagree...
* vo_opengl: update BufferData usage hintsNiklas Haas2017-07-151-2/+11
| | | | | | | | | | | | | | | STREAM is better than DYNAMIC because we're only using it once per frame. As for COPY vs DRAW, that was pretty much incorrect to begin with - but surprisngly, COPY is actually faster (sometimes significantly so, e.g. on my NUMA system). After testing, the best I can gather is that it has to do with the fact that COPY requires fewer redundant memcpy()s, and also 3x reduce RAM bandwidth (in theory). Anyway, that bit shouldn't introduce any regressions, it's just a documentation update. Maybe I'll change my mind about the comment again the future, it's really hard to tell. Vulkan, please save us!
* vo_opengl: coalesce intra-plane PBOsNiklas Haas2017-07-152-14/+17
| | | | | | | | | | | | | | Instead of allocating three PBOs and cycling through them, we allocate one PBO that's three times as large, and cycle through the subregion offsets. This results in arguably simpler code and faster initialization performance. Especially for 4K textures, initializing PBOs can take quite some time (e.g. 180ms -> 110ms). For 1080p, it's more like 66ms -> 52ms for me. The alignment to 4096 is completely unnecessary by spec, but we do it anyway just for peace of mind.
* vo_opengl: generalize --scale-clamp etc.Niklas Haas2017-07-124-5/+5
| | | | | This can help fight ringing without completely killing it, thus providing a middle-ground between ringing and aliasing.
* vo_opengl: remove redundant gl_video_setup_hooks callNiklas Haas2017-07-121-1/+0
| | | | | | | | This is unnecessary to call from gl_video_resize, because the hooks only (possibly) change when the actual vo_opengl options change. This used to be required back when mpv still had prescaling built in, but since that was all moved to user shaders and the code removed, this is a left-over artifact.
* vo_opengl: fix type of glsl variable frameAman Gupta2017-07-111-1/+1
|
* vo_opengl: don't make assumptions about plane orderwm42017-07-101-9/+30
| | | | | | | | | | | | | | | | | | | The renderer code doesn't list a fixed set of supported formats, but supports anything that is described by AVPixFmtDescriptor and follows a number of constraints. Plane order is not included in those constraints. This means the planes could be in random order, rather than what the vo_opengl renderer happens to assume. For example, it assumes that the 4th plane is alpha, even though alpha could be on any plane. Likewise it assumes that plane 0 was always luma, and planes 2/3 chroma. (In earlier iterations of format support, this was guaranteed by MP_IMGFLAG_YUV_P, but this is not used anymore.) Explicitly set the plane semantics (enum plane_type) by the component descriptors and the used colorspace. The behavior should mostly not change, but it's less likely to break when FFmpeg adds new pixel formats.
* vo_opengl: hwdec_dxva2egl: probe whether ANGLE mapping workswm42017-07-101-0/+12
| | | | | | | With some newer ANGLE builds, mapping can fail with "Failed to create EGL surface" during playback. The reason is unknown, and it might just be an ANGLE bug. Probe whether it works at init time to avoid the problem.
* vo_opengl: fix dumb_mode chroma transformation fixupNiklas Haas2017-07-101-2/+2
| | | | | | | | In commit 6eb0bbe this was changed from xs[n] to use gl_format.chroma_w indiscriminately, which broke chroma rendering when zooming/cropping. The solution is to only use chroma_w for chroma planes. Fixes #4592.
* vo_opengl: describe the remainder passes after user shadersNiklas Haas2017-07-091-0/+1
| | | | | | | | | | | | On optional hook points, we store to a temp FBO and then read from it again to complete any operations that may still be left (e.g. sigmoidization after MAIN/LINEAR). In theory this mechanism should be reworked to avoid the temporary FBO until the next time we actually need one - and also skip redundant passes if we the next thing we need *is* a FBO - but both are those are tricky. Anyway, in the meantime, at least we can label the (semi-)redundant passes that get generated when using user shaders.
* vo_opengl: support tone-mapping-param for `clip`Niklas Haas2017-07-071-1/+1
| | | | | | | This just indicates a fixed linear coefficient to multiply into the signal, similar to the old option --target-brightness (but the inverse thereof). Good for testing purposes, which is why I added it. (This also corresponds somewhat to what zimg does)
* vo_opengl: rework --opengl-dumb-modeNiklas Haas2017-07-071-4/+9
| | | | | | | It's now possible to request non-dumb mode as a user, even when not using any non-dumb features. This change is mostly intended for testing, so I can easily switch between dumb and non-dumb mode on default settings. The default behavior is unaffected.
* vo_opengl: correct off-by-one in scale=oversampleNiklas Haas2017-07-071-1/+1
| | | | This caused a single pixel shift to the top-left, introduced in e3e03d0f3.
* vo_opengl: do not use vaapi-over-GLXwm42017-07-073-5/+4
| | | | | | | | | | | | | | | This backend is selected if vaapi is available, but vaapi-over-EGL is not. This causes various issues around the forced RGB conversion, which is done with fixed, usually incorrect parameters. It seems the existing auto probing check is too weak, and doesn't really prevent it from getting loaded. Fix this by adding a flag to not ever load this during auto probing. I'm still not deleting it, because it's useful for testing on nvidia machines. See #4555.
* vo_opengl: prevent desat from blowing up for negativeNiklas Haas2017-07-071-1/+1
| | | | | | | The current algorithm blew up when the color was negative, such as the case when downscaling with dscale=mitchell or other algorithms that introduce negative ringing. The simplest solution is to just slightly change the calculation to force both parameters to be in-range.
* vo_opengl: also expose NAME_mul for user shadersNiklas Haas2017-07-061-2/+3
| | | | | | | | | This is exposed so that bjin/mpv-prescalers can use textureGatherOffset for performance. Since there are now quite a lot of parameters where it isn't quite clear why they're all defined, add a paragraph to the man page that explains them a bit.
* vo_opengl: prevent division by zero in shaderNiklas Haas2017-07-061-1/+1
| | | | | In theory the max() should clamp it away anyway but I believe division by zero is UB so just avoid it altogether.
* vo_opengl: add --tone-mapping-desaturateNiklas Haas2017-07-064-6/+19
| | | | | | | This helps prevent unnaturally, weirdly colorized blown out highlights for direct images of the sunlit sky and other way-too-bright HDR content. I was debating whether to set the default at 1.0 or 2.0, but went with the more conservative option that preserves more detail/color.
* vo_opengl: get rid of weird double-bind in pass_read_fboNiklas Haas2017-07-051-4/+2
| | | | | | | | This logic doesn't really make sense. copy_img_tex already binds the texture, so why would we bind it a second time? Furthermore, nothing actually uses this return value. Must have been some left-over artifact of a previous iteration of this function. Anyway, it's harmless, just nonsensical. So remove it.
* vo_opengl: remove redundant left-over lineNiklas Haas2017-07-051-1/+0
| | | | The pass_read_fbo immediately below replaces it
* vo_opengl: use textureGatherOffset for polar filtersNiklas Haas2017-07-055-44/+90
| | | | | | | | | | | | | | | | | | This is more efficient on my machine (nvidia), but only when applied to groups of exactly 4 texels. So we switch to the more efficient textureGather for groups of 4. Some notes: - textureGatherOffset seems to be faster than textureGather by a non-negligible amount, but for some reason, textureOffset is still slower than a straight-up texture - textureGather* requires GLSL 400; and at least on nvidia, this requires actually allocating a GL 4.0 context. - the code in opengl/common.c that clamped the GLSL version to 330 is deprecated, because the old user shader style has been removed completely in the meantime - To combat the growing complexity of the polar sampling code, we drop the antiringing functionality from EWA shaders completely, since it never really worked well for EWA to begin with. (Horrific artifacting)
* w32_common: use sent messages to wake up the Win32 threadJames Ross-Gowan2017-07-041-5/+12
| | | | | | | | | | | | | | | | | Instead of PostMessage, use SendNotifyMessage from the SendMessage family of functions to wake up the Win32 thread from the VO thread. When a message is sent rather than posted between threads, it ends up in a different queue which is processed before posted messages and can be processed in more places. This prevents a playback glitch when clicking on the titlebar, but not moving the window. With PostMessage-based wakeups, VOCTRLs could be delayed for up to 500ms after the user clicks on the titlebar, but with SendNotifyMessage, they still complete in under a millisecond. Also, instead of handling WM_USER, process the dispatch queue before every message. This ensures the dispatch queue is processed as soon as possible. WM_NULL is used to wake up the window procedure in case there are no other messages being processed.
* vo_opengl: make the pass info mechanism more robustNiklas Haas2017-07-031-17/+26
| | | | | | | | | | - change asserts to silent exits - check all pointers before use - move the p->pass initialization code to the right place This should hopefully cut down on the amount of crashing by making the code fundamentally more robust, while also fixing a concrete issue where opengl-cb failed to initialize p->pass.
* w32_common: use SWP_NOSENDCHANGING when resizing childJames Ross-Gowan2017-07-031-1/+1
| | | | | | This seems to reduce glitches when resizing a --wid program (or it could be a placebo.) Since we don't need the WM_WINDOWPOSCHANGING handler in --wid mode, it should be fine.
* filter_kernels: add radius cutoff functionalityNiklas Haas2017-07-035-9/+24
| | | | | | | | This allows filter functions to be prematurely cut off once their contributions start becoming insignificant. This effectively prevents wasted GPU time sampling from parts of the function that are essentially reduced to zero by the window function, providing anywhere from a 10% to 20% speedup. (5700μs -> 4700μs for me)
* options: change everything againwm42017-07-022-7/+2
| | | | Fucking bullshit.
* x11: add 128x128 sized icon supportXu Zhao2017-07-021-0/+5
|
* x11: load icon differentlywm42017-07-012-83/+40
| | | | | | | | Now it's sourced from the etc/ PNG files directly, instead of preprocessing them with imagemagick. Add some ad-hoc code to decode PNG files with libavcodec. At least we can drop the zlib code in exchange.
* vo_opengl: describe vdpau reinterleaving passNiklas Haas2017-07-011-0/+1
| | | | This shows up as (unknown pass) otherwise.
* vo_opengl: fix some more pass_info_reset issuesNiklas Haas2017-07-011-1/+10
| | | | | | | | | | | | 2f41c4e8 exposed some other edge cases as well. Globally resetting the pass info was not the right way to go about it, because we don't know in advance what the frame type is going to be - at least not with the current code structure. (In principle, we could separately indicate the frame type and the pass type and then only reset it on the first actual pass_describe call, but that's annoying as well) Also fixes a latent issue where p->pass was never initialized, which broke the MP_DBG debugging code in some cases.
* vo_opengl: call pass_info_reset earlierNiklas Haas2017-07-011-1/+1
| | | | | Omitting this call resulted in a crash when has_frame was false. But we can just call it way earlier, because there's really no reason not to.
* vo_opengl: merge uploading and renderingNiklas Haas2017-07-011-14/+14
| | | | | | Since all existing code does gl_video_upload immediately followed by pass_render_frame, we can just move the upload into pass_render_frame itself, which arguably makes more sense anyway.
* vo_opengl: refactor vo performance subsystemNiklas Haas2017-07-019-100/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces `vo-performance` by `vo-passes`, bringing with it a number of changes and improvements: 1. mpv users can now introspect the vo_opengl passes, which is something that has been requested multiple times. 2. performance data is now measured per-pass, which helps both development and debugging. 3. since adding more passes is cheap, we can now report information for more passes (e.g. the blit pass, and the osd pass). Note: we also switch to nanosecond scale, to be able to measure these passes better. 4. `--user-shaders` authors can now describe their own passes, helping users both identify which user shaders are active at any given time as well as helping shader authors identify performance issues. 5. the timing data per pass is now exported as a full list of samples, so projects like Argon-/mpv-stats can immediately read out all of the samples and render a graph without having to manually poll this option constantly. Due to gl_timer's design being complicated (directly reading performance data would block, so we delay the actual read-back until the next _start command), it's vital not to conflate different passes that might be doing different things from one frame to another. To accomplish this, the actual timers are stored as part of the gl_shader_cache's sc_entry, which makes them unique for that exact shader. Starting and stopping the time measurement is easy to unify with the gl_sc architecture, because the existing API already relies on a "generate, render, reset" flow, so we can just put timer_start and timer_stop in sc_generate and sc_reset, respectively. The ugliest thing about this code is that due to the need to keep pass information relatively stable in between frames, we need to distinguish between "new" and "redrawn" frames, which bloats the code somewhat and also feels hacky and vo_opengl-specific. (But then again, this entire thing is vo_opengl-specific)
* d3d: UWP support for D3D11VAwm42017-06-301-9/+4
| | | | | | | For some braindead reason, Microsoft decided to prevent you from dynamically loading system libraries. This makes portability harder. And we're talking about portability between Microsoft OSes!
* d3d: make DXVA2 support optionalwm42017-06-302-4/+4
| | | | | | | | | | | | This partially reverts the change from a longer time ago to always build DXVA2 and D3D11VA together. To make it simpler, we change the following: - building with ANGLE headers is now required to build D3D hwaccels - if DXVA2 is enabled, D3D11VA is still forcibly built - the CLI vo_opengl ANGLE backend is now under --egl-angle-win32 This is done to reduce the dependency mess slightly.
* vo_direct3d: remove non-working nv12 shader supportwm42017-06-302-134/+0
| | | | | | | | | It never worked. It relied on some obscure texture format to provide the equivalent of GL_RG or GL_LUMINANCE_ALPHA, but no hardware seemed to report support for it ever. No idea what's the correct way to do this. On D3D11 it exists, of course. (Actually I'd like to remove the whole VO.)
* video: get rid of swapped packed YUVwm42017-06-304-10/+2
| | | | | | Another legacy annoyance. The only place where packed YUV is still important is slightly older Apple hardware or drivers, which require it for efficient hardware decoding.
* vo_opengl: remove mp_imgfmt_desc and IMGFLAG_ usagewm42017-06-303-35/+48
| | | | | These were weird due to their past, and often undefined or ill-defined. Time to get rid of them.
* vo_opengl: restructure format setupwm42017-06-307-131/+105
| | | | | | | | | | | | Instead of setting up a weird swizzle (which is linked to how the internal renderer code works, rather than the generic format code), add per-component mapping to gl_imgfmt_desc. The renderer still computes the weird swizzle, but at least it's confined to itself. Also, it appears the hwdec backends don't need this anymore. It's really nice that the messy init_format() goes away too.
* options: change path list options, and document list optionswm42017-06-302-1/+7
| | | | | | | | | | | | | | | | | | | | | | | The changes to path list options is basically getting rid of the need to pass multiple paths to a single option. Instead, you can use the option multiple times. The old behavior can be used by using the -set suffix with the option. Change some options to path lists. For example --script is now append by default, and if you use --script-set, you need to use ":"/";" as separator instead of ",". --sub-paths/--audio-file-paths is a deprecated alias now, and will break if the user tries to pass multiple paths to it. I'm assuming that if these are used, most users will pass only 1 path anyway. --opengl-shaders has more compatibility handling, since it's probably rather common that users pass multiple options to it. Also document all that in the manpage. I'll probably regret this later, as it somewhat increases the complexity of the option parser, rather than increasing it.
* vo_direct3d: fix buildwm42017-06-291-1/+0
| | | | That format is worthless anyway.
* video: drop some unused IMGFMT aliaseswm4