summaryrefslogtreecommitdiffstats
path: root/video/out/gl_common.h
Commit message (Collapse)AuthorAgeFilesLines
* vo_opengl: remove some unused functionswm42015-01-281-12/+2
| | | | | | These were intended for some plans that were never realized. Also move some comments around and fix them.
* vo_opengl: move utility functions from loader to a separate filewm42015-01-281-13/+0
| | | | | | | 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.
* vo_opengl: fix display of ARGB ith color management enabledwm42015-01-281-1/+0
| | | | | | | | | | | | | | | | | | | | 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.
* vo_opengl: drop sRGB framebuffer detectionwm42015-01-261-1/+0
| | | | | We've stopped using them some time ago (we're doing things manually instead).
* vo_opengl: clean up ewa_lanczos codeNiklas Haas2015-01-221-2/+3
| | | | | | 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.
* vo_opengl: simplify screenshot codewm42015-01-221-3/+0
| | | | | | | | | | | | | | 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.
* cocoa: remove support for systems without gl3.h headerStefano Pigozzi2015-01-221-4/+2
|
* vo_opengl: cleanups after vo_opengl_old removalwm42015-01-211-43/+1
| | | | | | | | | | | | | 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.
* vo_opengl_old: remove ancient ATI-specific YUV conversionswm42015-01-021-10/+0
| | | | | | | | | | 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.
* vo_opengl: make use of newer OpenGL logging APIwm42014-12-231-0/+8
| | | | | | 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: improve fallback handling with GLESwm42014-12-211-0/+2
| | | | | | | | | 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, x11: add ES context creation via GLXwm42014-12-191-0/+1
| | | | | | | | 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.
* vo_opengl: better probe handlingwm42014-12-191-3/+3
| | | | | | | | | | | | | 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.
* vo_opengl: unborkwm42014-12-191-2/+2
| | | | | | | | Probably. The version handling schema is a bit strange (and led to a tricky and obvious bug), but it's quite similar to what OpenGL does at some places, so I blame the OpenGL standard.
* vo_opengl: mess with PixelStorei state managementwm42014-12-191-0/+1
| | | | | | | | | | | | | | | | 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: do not use 4x3 matrixwm42014-12-181-2/+0
| | | | | | | | | | | 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 some aspects of the GL function loaderwm42014-12-181-10/+9
|
* vo_opengl: GLES 3 supportwm42014-12-171-0/+2
| | | | | | | | | | | | 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 quadbuffer/anaglyph stereo 3D renderingwm42014-12-151-8/+0
| | | | | | | | 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.
* client API: expose OpenGL rendererwm42014-12-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: move hwdec parts into their own fileswm42014-12-031-45/+0
| | | | | | 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.
* vdpau/GLX: don't access VO backendwm42014-12-031-1/+0
| | | | | | | | | Same as with the previous commits. In theory, vdpau/x11 GL interop doesn't assume GLX. It could use EGL as well. But since it's always GLX in practice, so we're fine with this. Remove the gl_hwdec.mpgl field - it's unused now.
* vda: make independent from cocoa backendwm42014-12-031-0/+1
| | | | | | | | | Basically, don't access the vo field. There's also no reason anymore to access MPGLContext. We still need to access loaded GL functions though, so add a field for that to gl_hwdec. Untested.
* gl_common: factor context creationwm42014-11-261-4/+6
| | | | | | | 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.
* vo_opengl: minimal EGL on X11 supportwm42014-11-041-0/+1
| | | | | | Pretty useless and only good for testing. Does not include any form of GLES support.
* 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.
* gl_common: add SGI_video_sync extensionwm42014-08-151-0/+3
|
* Add more constwm42014-06-111-1/+1
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* gl_x11: always require some GLX API functions, avoid dlsym()wm42014-05-311-2/+0
| | | | | | | | | | | | | | The functions glXGetProcAddressARB() and glXQueryExtensionsString() were loaded using dlsym(). This could fail when compiling to libmpv, because then dlopen(NULL, ...) will look in the main program's list of libraries, and the libGL linked to libmpv is never considered. (Don't know if this somehow could be worked around.) The result is that using vo_opengl with libmpv can fail. Avoid this by not using dlsym(). glXGetProcAddressARB() was already used directly in the same file, and that never caused any problems. (Still add it to the configure test.) glXQueryExtensionsString() is documented as added in GLX 1.1 - that's ancient.
* video/out: remove unused config() parameterswm42014-05-071-4/+2
| | | | This was cleaned up yesterday.
* m_option: add mp_log callback to OPT_STRING_VALIDATE optionswm42013-12-211-2/+2
| | | | | And also convert a bunch of other code, especially ao_wasapi and ao_portaudio.
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-171-2/+2
|
* gl_video: change internal API for hwdec mp_image downloadStefano Pigozzi2013-12-021-1/+2
| | | | | | Previous API worked under the assumption that download_image is always called after map_image. In practice this is true, but it's better to have a much generic API that doesn't depend on the order in which the functions are called.
* vo_opengl: support for vda hardware decodingStefano Pigozzi2013-12-021-0/+2
| | | | | | | | | | | The harder work was done in the previous commits. After that this feature comes out almost for free. The only problem is I can't get the textures created with CGLTexImageIOSurface2D to download properly, thus the code performs download using some CoreVideo APIs. If someone knows why download of textures created with CGLTexImageIOSurface2D doesn't work please contact me :)
* gl_video: support packed YUV formats with Apple extensionsStefano Pigozzi2013-12-021-0/+1
| | | | | | | | | | This adds support for packed YUV formats (YUVY and UYVY) using the extension GL_APPLE_rgb_422. While supporting this formats on their own is not that important (considering most video is planar YUV) they are used for interoperability with IOSurfaces. Next commit will use this formats to render VDA hardware decoded frames through IOSurface and OpenGL interoperability.
* vo_opengl: add support for rectangle textureswm42013-12-011-0/+3
| | | | | | | | | This allows vo_opengl to use GL_TEXTURE_RECTANGLE textures, either by enabling it with the 'rectangle-textures' sub-option, or by having a hwdec backend force it. By default it's off. The _only_ reason we're adding this is because VDA can export rectangle textures only.
* gl_hwdec: use a imgfmt field instead of a query_format callbackwm42013-11-291-2/+2
| | | | | Now that vdpau always uses a single image format, this can be simplified.
* gl_common: remove unneeded callbackwm42013-11-141-1/+0
| | | | We got rid of this some time ago, but apparently not completely.
* vo_opengl: fix alpha values written to the framebufferwm42013-11-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | When blending OSD and subtitles onto the video, we write bogus alpha values. This doesn't normally matter, because these values are normally unused and discarded. But at least on Wayland, the alpha values are used by the compositor and leads to transparent windows even with opaque video on places where the OSD happens to use transparency. (Also see github issue #338.) Until now, the alpha basically contained garbage. The source factor GL_SRC_ALPHA meant that alpha was multiplied with itself. Use GL_ONE instead (which is why we have to use glBlendFuncSeparate()). This should give correct results, even with video that has alpha. (Or at least it's something close to correct, I haven't thought too hard how the compositor will blend it, and in fact I couldn't manage to test it.) If glBlendFuncSeparate() is not available, fall back to glBlendFunc(), which does the same as the code did before this commit. Technically, we support GL 1.1, but glBlendFuncSeparate is 1.4, and I guess we should try not to crash if vo_opengl_old runs on a system with GL 1.1 drivers only.
* vo_opengl: support for vdpau hardware decodingwm42013-11-051-0/+10
| | | | | | | | | | | | This uses vdpau OpenGL interop to convert a vdpau surface to a texture. Note that this is a bit weak and primitive. Deinterlacing (or any other form of vdpau postprocessing) is not supported. vo_opengl chroma scaling and chroma sample position are not supported. Internally, the vdpau video surfaces are converted to a RGBA surface first, because using the video surfaces directly is too complicated. (These surfaces are always split into separate fields, and the vo_opengl core expects progressive frames or frames with weaved fields.)
* vo_opengl: redo aspects of initialization, change hwdec APIwm42013-11-051-7/+7
| | | | | | | | | | | Instead of checking for resolution and image format changes, always fully reinit on any parameter change. Let init_video do all required initializations, which simplifies things a little bit. Change the gl_video/hardware decoding interop API slightly, so that hwdec initialization gets the full image parameters. Also make some cosmetic changes.
* vo_opengl: cosmetics/fix typoswm42013-11-041-1/+1
|
* Merge branch 'master' into have_configurewm42013-11-041-0/+39
|\ | | | | | | | | Conflicts: configure
| * vo_opengl: add support for VA-API OpenGL interopwm42013-11-041-0/+1
| | | | | | | | | | | | | | | | VA-API's OpenGL/GLX interop is pretty bad and perhaps slow (renders a X11 pixmap into a FBO, and has to go over X11, probably involves one or more copies), and this code serves more as an example, rather than for serious use. On the other hand, this might be work much better than vo_vaapi, even if slightly slower.
| * vo_opengl: add infrastructure for hardware decoding OpenGL interopwm42013-11-041-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | Most hardware decoding APIs provide some OpenGL interop. This allows using vo_opengl, without having to read the video data back from GPU. This requires adding a backend for each hardware decoding API. (Each backend is an entry in gl_hwdec_vaglx[].) The backends expose video data as a set of OpenGL textures. Add infrastructure to support this. The next commit will add support for VA-API.
* | configure: uniform the defines to #define HAVE_xxx (0|1)Stefano Pigozzi2013-11-031-1/+1
|/ | | | | | | | | | | | | | | | | | | | | The configure followed 5 different convetions of defines because the next guy always wanted to introduce a new better way to uniform it[1]. For an hypothetic feature 'hurr' you could have had: * #define HAVE_HURR 1 / #undef HAVE_DURR * #define HAVE_HURR / #undef HAVE_DURR * #define CONFIG_HURR 1 / #undef CONFIG_DURR * #define HAVE_HURR 1 / #define HAVE_DURR 0 * #define CONFIG_HURR 1 / #define CONFIG_DURR 0 All is now uniform and uses: * #define HAVE_HURR 1 * #define HAVE_DURR 0 We like definining to 0 as opposed to `undef` bcause it can help spot typos and is very helpful when doing big reorganizations in the code. [1]: http://xkcd.com/927/ related
* gl_common: osx: fix compilation with latest XQuartz RCStefano Pigozzi2013-10-301-1/+1
| | | | Looks the gl.h header in XQuartz is incompatible with the one in OS X 10.9.
* gl_common: complete mp_msg conversionwm42013-09-121-2/+2
| | | | Hopefully this works on Wayland and Cocoa, which I didn't test.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-2/+2
| | | | Followup commit. Fixes all the files references.
* video/out: use new mp_msg stuff for vo.c and vo_openglwm42013-07-311-2/+2
| | | | The first step; also serves as example.
* vo_opengl_old: use new option APIwm42013-07-221-0/+5
|
* gl_video: improve ditheringwm42013-05-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Use a different algorithm to generate the dithering matrix. This looks much better than the previous ordered dither matrix with its cross-hatch artifacts. The matrix generation algorithm as well as its implementation was contributed by Wessel Dankers aka Fruit. The code in dither.c is his implementation, reformatted and with static global variables removed by me. The new matrix is uploaded as float texture - before this commit, it was a normal integer fixed point matrix. This means dithering will be disabled on systems without float textures. The size of the dithering matrix can be configured, as the matrix is generated at runtime. The generation of the matrix can take rather long, and is already unacceptable with size 8. The default is at 6, which takes about 100 ms on a Core2 Duo system with dither.c compiled at -O2, which I consider just about acceptable. The old ordered dithering is still available and can be selected by putting the dither=ordered sub-option. The ordered dither matrix generation code was moved to dither.c. This function was originally written by Uoti Urpala.
* video/out: introduce vo_control for gl_common based VOswm42013-05-261-8/+1
| | | | | | | | | | | | | | | | Instead of having separate callbacks for each backend-handled feature (like MPGLContext.fullscreen, MPGLContext.border, etc.), pass the VOCTRL responsible for this directly to the backend. This allows removing a bunch of callbacks, that currently must be set even for optional/lesser features (like VOCTRL_BORDER). This requires changes to all VOs using gl_common, as well as all backends that support gl_common. Also introduce VOCTRL_CHECK_EVENTS. vo.check_events is now optional. VO backends can use VOCTRL_CHECK_EVENTS instead to implementing check_events. This has the advantage that the event handling code in VOs doesn't have to be duplicated if vo_control() is used.
* OSX: run native event loop in a separate threadStefano Pigozzi2013-05-121-0/+7
| | | | | | | | | | | | | | This commit is a followup on the previous one and uses a solution I like more since it totally decouples the Cocoa code from mpv's core and tries to emulate a generic Cocoa application's lifecycle as much as possible without fighting the framework. mpv's main is executed in a pthread while the main thread runs the native cocoa event loop. All of the thread safety is mainly accomplished with additional logic in cocoa_common as to not increase complexity on the crossplatform parts of the code.
* gl_common: add some sort of locking APIwm42013-05-121-0