summaryrefslogtreecommitdiffstats
path: root/video/out/gl_video.c
Commit message (Collapse)AuthorAgeFilesLines
* vo_opengl: don't use 10 bit video on Intel GPUswm42014-12-241-0/+30
| | | | | | | | | | | | 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.
* vo_opengl_cb: always setup/break vertex array bindingswm42014-12-231-3/+13
| | | | | | | | | | | Originally, this code was written to have full control over the OpenGL state, rather than having to cooperate with unknown components by being embeded like vo_opengl_cb is meant to be. As a consequence, it was thought to be ok to setup a global binding (if the context is below OpenGL 3.0, which guarantees VAOs). This could break badly. Fix it by setting up and breaking the bindings on entry/exit.
* vo_opengl: don't allow setting 3D LUT if unsupportedwm42014-12-231-1/+5
| | | | | The code was always uploading the 3D LUT (even of unused), as long as vo_opengl was setting a icc-profile. This could crash with GLES 2.
* vo_opengl: make use of newer OpenGL logging APIwm42014-12-231-1/+35
| | | | | | 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.
* vo_opengl, vo_opengl_cb: check GL version in rendererwm42014-12-221-0/+5
| | | | | | vo_opengl actually checks this in the context creation code already, but it still increases robustness in case the requirements are changed later.
* vo_opengl: fix feature detectionwm42014-12-221-1/+1
| | | | Fixes #1373.
* vo_opengl: improve fallback handling with GLESwm42014-12-211-7/+21
| | | | | | | | | 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.
* vo_opengl: silence an INVALID_ENUM error with GLES2James Ross-Gowan2014-12-211-1/+2
| | | | Signed-off-by: wm4 <wm4@nowhere>
* vo_opengl: GLES does not support GL_BGRAwm42014-12-201-1/+1
| | | | | | | | | | | | | Apparently GLES 2 and 3 do not support this. (The implementations I tested with were derived from desktop OpenGL and were not overly strict with this.) This is no problem; just use GL_RGBA and mangle the channels in the shader. Also disable direct support for image formats like IMGFMT_RGB555 with GLES; at least some of them are not supported in this form, and the formats aren't important anyway.
* vo_opengl_old: fix OSD regressionwm42014-12-201-1/+1
| | | | | | | | | | | | | | | | | Commit 0e8fbdbd removed the rg_texture requirement from vo_opengl; commit 541f6731 changed to a more convenient method. Both commits broke vo_opengl_old in some ways. vo_opengl_old always requires GL_ALPHA for single-channel texture, because it draws the OSD without shaders and by using certain blend modes. So we need to explicitly distinguish between vo_opengl and vo_opengl_old in the OSD renderer, and force fixed texture formats for vo_opengl_old. The other logic is specific to the internals of vo_opengl. (Although it might be possible to get the same result by playing with the old GL fixed-function functions in vo_opengl_old. But seems like a waste of time.) Fixes #1370.
* vo_opengl: minor simplificationwm42014-12-191-5/+5
| | | | The parameter to default_tex_params() is always the same.
* vo_opengl: add GLES 2 supportwm42014-12-191-3/+17
| | | | | | | | 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.
* vo_opengl: mess with PixelStorei state managementwm42014-12-191-13/+8
| | | | | | | | | | | | | | | | 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.
* vo_opengl: disable some unavailable features under ESwm42014-12-191-2/+5
| | | | There are probably many more which I overlooked.
* vo_opengl: do not use 4x3 matrixwm42014-12-181-1/+8
| | | | | | | | | | | 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.
* vo_opengl: simplify the case without texture_rgwm42014-12-181-17/+9
| | | | | | | | | | | | If GL_RED was not available, we used GL_ALPHA. But this is an unnecessary complication, and it's easier to use GL_LUMINANCE instead. With the latter, a texture will return the .r component set, and as long as the shader doesn't look at the other components, the shader doesn't need any changes. Some of the changes added in 0e8fbdbd are now unneeeded. Also, realign the entire gl_byte_formats_legacy table.
* vo_opengl: GLES 3 supportwm42014-12-171-4/+35
| | | | | | | | | | | | 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.
* vo_opengl: remove useless FBO testwm42014-12-171-34/+2
| | | | | | | | | Remove the readback stuff; it was a useless mess. Don't test GL_R16 as FBO. The intention was to measure the effective bitdepth of the texture, except that it was never actually done. (There's also a OpenGL function which is supposed to retrieve the bitdepth, but we don't use that either.)
* vo_opengl: cleanup dither texture creationwm42014-12-171-4/+9
| | | | Might be slightly more compatible too, and will make it work on GLES.
* vo_opengl: switch default FBO format to rgba, use GL_RGBAwm42014-12-171-3/+6
| | | | | | | | | | I'm hoping this is generally more compatible, and it works with GLES. This probably has not much of an effect on desktop GL. It also switches only the default format for --vo=opengl, not --vo=opengl-hq. "-hq" already uses GL_RGBA16, though since it's a sized format, the story is a bit different, and it won't work on GLES either.
* vo_opengl: remove requirement for RG textureswm42014-12-161-27/+66
| | | | | Features not supported are disabled (although with a misleading error message).
* vo_opengl: remove inactive codewm42014-12-161-1/+0
|
* vo_opengl: fix broken rejection of extended scalingwm42014-12-161-3/+2
| | | | | Possibly explains why some users got mysterious FBO errors on crappy hardware.
* vo_opengl: remove quadbuffer/anaglyph stereo 3D renderingwm42014-12-151-37/+5
| | | | | | | | 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.
* vo_opengl: make shader text output slightly nicerwm42014-12-091-2/+2
| | | | It was missing an indentation in some cases.
* vo_opengl_cb: simplify reconfigure, render transparent if unconfiguredwm42014-12-091-1/+2
| | | | | | | I think that's expected; mpv shouldn't draw anything while no video is active. This doesn't blend transparently, though. Also document the vo_opengl_cb thing.
* vo_opengl: make background color configurablewm42014-12-091-3/+8
| | | | | This mainly affects the black bars that are drawn if the window and video aspect ratios mismatch.
* client API: expose OpenGL rendererwm42014-12-091-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* vo_opengl: enable fancy-downscaling for opengl-hq againwm42014-12-081-1/+1
| | | | | | I guess most problems with it have been fixed. It's still slower than necessary, though.
* vo_opengl: use all filter sizes possible with the shaderswm42014-12-081-28/+21
| | | | | | | | | | | | | | Not all filter sizes the shaders could handle were in the filter_sizes list. The shader can handle any multiple of 4 (the sizes 2 and 6 are special-cased to keep it simple). Add all possible filter sizes, up to 64. 64 is ridiculously high anyway. Most of the larger filter sizes are completely useless for upscaling, but help with the fancy-downscaling option. (Although it would still be more efficient to use cascaded scalers to handle downscaling better.) I considered doing something less stupid than the hardcoded array, but it seems this is still the simplest solution.
* vo_opengl: refactor: instantiate scaler functions at runtimewm42014-12-081-10/+26
| | | | | | | | | | | | | | | | | Before this commit, the convolution scaler shader functions were pre- instantiated in the shader file. For every filter size, a corresponding function (with the filter size as suffix) had to be present. Change this, and make the C code emit the necessary bits. This means the shader code is much reduced. (Although hopefully it doesn't make shader compilation faster - it would require a really dumb compiler if it spends its time on dead code.) It also makes it more flexible, which is the main goal. The DEF_SCALER0 stuff is needed because the C code writes the header of the shader, at a point where scaler macros are not defined yet.
* vo_opengl: never use 1D textures for lookup textureswm42014-12-081-19/+8
| | | | | | | | | This was a microoptimization for small filters which need 4 or less weights per sample point. When I originally wrote this code, using a 1D texture seemed to give a slight speed gain, but now I couldn't measure any difference. Remove this to simplify the code.
* vo_opengl: extend filter size to 64wm42014-12-061-3/+4
| | | | | | For better downscaling. Maybe the list of filter sizes shouldn't be static...
* vo_opengl: disable fancy-downscaling for opengl-hq againwm42014-12-061-1/+1
| | | | | Seems it's actually buggy, beyond the problem that large filter sizes are required.
* vo_opengl: extend filter size to 32wm42014-12-061-3/+4
| | | | | | Also replace the weights calculations for 8/12/16 with the generic weight function definition macro. (The weights 2/4/6 follow slightly different rules.)
* vo_opengl: make uninit idempotentwm42014-12-031-0/+3
|
* vo_opengl: move hwdec parts into their own fileswm42014-12-031-0/+1
| | | | | | 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.
* vo_opengl: minor changeswm42014-12-021-7/+9
| | | | | | | | | | | | | | Always set the viewport on entry. The way the viewport is tracked is a bit complicated in my opinion, and in fact it doesn't even reduce the number of GL calls. Setting it on entry is actually redundant if video covers the screen fully, because the handle_pass() unconditionally sets it anyway, but avoiding it would complicate the cases gl->Clear() is actually needed. Add a fbo argument to gl_video_render_frame(). This allows you to render into a FBO rather than the default framebuffer. It will be useful for providing an API to render on an external GL context. (If that will actually be added.)
* vo_opengl: print error number if framebuffer creation failswm42014-12-021-2/+4
| | | | | | | | Seems like a waste not to print this. Anyone with enough technical knowledge to have use for the exact error can map the number back to the GL symbol, so don't bother to convert it to a symbol.
* vo_opengl: remove redundant GL state initializationwm42014-12-011-4/+0
| | | | | | | All of these are already the defaults. One exception is glDepthMask(), which is enabled by default. But if the framebuffer has no depth buffer anyway, it shouldn't make a difference.
* vo_opengl: enable fancy-downscaling by default for opengl-hqwm42014-11-291-0/+1
|
* vo_opengl: disable fancy-downscaling for anamorphic videowm42014-11-291-20/+33
| | | | Includes some arbitrary minor refactoring.
* gl_video: minor simplificationwm42014-11-271-4/+0
| | | | Not needed anymore.
* vo_opengl: Linearize non-RGB sRGB files correctly (eg. JPEG)Niklas Haas2014-11-261-7/+25
| | | | Signed-off-by: wm4 <wm4@nowhere>
* vo_opengl: make operator precedence explicitwm42014-11-261-1/+2
| | | | More readable.
* vo_opengl: fix srgb with certain inputswm42014-11-261-1/+1
| | | | | | | | | Sampling from the source texture and scaling must always be done separately in this mode. Fix suggested by haasn. Still looks a bit wrong, though.
* vo_opengl: somethingwm42014-11-261-1/+1
| | | | | | Insert explanation here. Fixes #1023.
* vo_opengl: allow setting different filters for downscalingwm42014-11-141-2/+5
|
* vo_opengl: don't reset user-set gamma when using vo_cmdlinewm42014-11-111-0/+3
|
* vo_opengl: initialize renderer after setting sizewm42014-11-071-0/+2
| | | | | | | | | | | This silences the warning: video/out/gl_video.c:1091:51: runtime error: division by zero when running with clang -fsanitize=undefined. Division by zero is legal according to IEEE, but I guess clang doesn't care about standard. While triggering this warning isn't actually avoided in all cases, it's avoided in the common case and also makes people shut up about it.
* vo_opengl: draw OSD twice in 3D mode casewm42014-10-291-6/+50
| | | | | | | | | | | | | Apparently this is needed for correct 3D mode subtitles. In general, it seems you need to duplicate the whole "GUI", so it's done for all OSD elements. This doesn't handle the "duplication" of the mouse pointer. Instead, the mouse can be used for the top/left field only. Also, it's possible that we should "compress" the OSD in the direction it's duplicated, but I don't know about that. Fixes #1124, at least partially.
* cocoa: reintroduce async resizeStefano Pigozzi2014-10-181-0/+12
| | | | | | | After removing synchronous libdispatch calls, this looks like it doesn't deadlock anymore. I also experimented with pthread_mutex_trylock liek wm4 suggested, but it leads to some annoying black flickering. I will fallback to that only if some new deadlocks are discovered.
* vo_opengl: fix wrong commentswm42014-10-161-2/+2
| | | | | | The previous commit was actually incorrect, and the change had absolutely no effect. The two formats are (fortunately) the same. I'm probably too tired.
* vo_opengl: fix theoretical format mismatch issuewm42014-10-161-4/+4
| | | | | | | | | This would have been wrong for hw decoders which pass us NV12 or NV21. The format the GL shader filter chain gets is stored in p->image_desc, while p->image_format still contains the "real" input format (which in case of hw decoding is an opsque hw accel format). Since no hw decoder did this, this is really just a theoretical fix and doesn't fix any actual bugs.
* cocoa: move to a simpler threading modelStefano Pigozzi2014-10-041-12/+0
| | | | | | | | | | | | | | Unfortunately using dispatch_sync for synchronization turned out to be really bad for us. It caused a wide array of race conditions, deadlocks, etc. Moving to a very simple mutex. It's not clear to me how to do liveresizing with this, for now it just flickers with is unacceptable (maybe I'll draw black instead). This should fix all the threading cocoa bugs. Reopen if it's not the case! Fixes #751 Fixes #1129
* sanitizer: avoid divide-by-zero instancesBen Boeckel2014-09-141-1/+1
| | | | | | | | Merges pull request #1094, with some minor changes. mpv expects IEEE, and IEEE allows divisions by 0 for floats, so these shouldn't actually be a problem, but do it anyway for the sake of clang. Signed-off-by: wm4 <wm4@nowhere>
* vo_opengl: remove macro operator from shaderBin Jin2014-08-291-5/+5
| | | | Removes '##' operator from OpenGL shader code.
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+1
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* vo_opengl: add radius options for filtersBin Jin2014-08-261-0/+10
| | | | | | | Add two new options, make it possible for user to set the radius for some of the filters with no fixed radius. Also add three new filters with the new radius parameter supported.
* vo_opengl: add cparam1 and cparam2 optionsBin Jin2014-08-261-13/+19
| | | | | | Although cscale is rarely used, it's possible that params of cscale are accidentally set to lparam1 and lparam2, which might cause unexpected results.
* video: move display and timing to a separate threadwm42014-08-121-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The VO is run inside its own thread. It also does most of video timing. The playloop hands the image data and a realtime timestamp to the VO, and the VO does the rest. In particular, this allows the playloop to do other things, instead of blocking for video redraw. But if anything accesses the VO during video timing, it will block. This also fixes vo_sdl.c event handling; but that is only