summaryrefslogtreecommitdiffstats
path: root/video/out/gl_common.c
Commit message (Collapse)AuthorAgeFilesLines
* vo_opengl: minor robustness improvement in function loaderwm42015-02-201-2/+5
| | | | | | 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".
* vo_opengl: remove some unused functionswm42015-01-281-19/+7
| | | | | | 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-201/+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-9/+1
| | | | | | | | | | | | | | | | | | | | 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-8/+1
| | | | | We've stopped using them some time ago (we're doing things manually instead).
* vo_opengl: clean up ewa_lanczos codeNiklas Haas2015-01-221-1/+2
| | | | | | 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-24/+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.
* vo_opengl: cleanups after vo_opengl_old removalwm42015-01-211-171/+59
| | | | | | | | | | | | | 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 this VOwm42015-01-201-2/+0
| | | | | 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.
* vo_opengl_old: remove ancient ATI-specific YUV conversionswm42015-01-021-15/+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: don't use 10 bit video on Intel GPUswm42014-12-241-0/+1
| | | | | | | | | | | | 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: use VAOs even in OpenGL 2.1wm42014-12-231-5/+15
| | | | | | | | 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.
* vo_opengl: make use of newer OpenGL logging APIwm42014-12-231-0/+13
| | | | | | 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-3/+7
| | | | | | | | | 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: skip GLES when autoprobingwm42014-12-191-0/+5
| | | | | | | | 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.
* 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: fail if required functions are missingwm42014-12-191-5/+10
| | | | | | | 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.
* vo_opengl: better probe handlingwm42014-12-191-38/+39
| | | | | | | | | | | | | 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: add GLES 2 supportwm42014-12-191-7/+10
| | | | | | | | 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-31/+40
| | | | | | | | | | | | | | | | 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-1/+4
| | | | There are probably many more which I overlooked.
* vo_opengl: clean up GL ES function loadingwm42014-12-181-86/+114
| | | | | | | | | | | | | | | | | | 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).
* vo_opengl: do not use 4x3 matrixwm42014-12-181-11/+4
| | | | | | | | | | | 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-16/+14
|
* vo_opengl: minor simplification in function loaderwm42014-12-181-11/+5
| | | | Don't force every entries without functions to define a dummy array.
* vo_opengl: don't assume legacy OpenGL is available with GLESwm42014-12-171-1/+1
| | | | | | 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.
* vo_opengl: GLES 3 supportwm42014-12-171-11/+32
| | | | | | | | | | | | 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-86/+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.
* vo_opengl: fix linkage typewm42014-12-091-1/+1
| | | | Can happen on Windows, I suppose.
* vo_opengl: don't crash if framebuffers are not availablewm42014-12-091-0/+9
| | | | | | | | | | | 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.
* client API: expose OpenGL rendererwm42014-12-091-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-17/+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.
* gl_common: factor context creationwm42014-11-261-5/+16
| | | | | | | 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/+3
| | | | | | Pretty useless and only good for testing. Does not include any form of GLES support.
* Add some missing "const"swm42014-10-101-1/+1
| | | | | | | 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).
* vo_opengl: don't pass (char*)NULL as %s printf argumentwm42014-08-281-2/+3
| | | | | | glGetString(GL_SHADING_LANGUAGE_VERSION) can return NULL; I suppose this happens on legacy OpenGL, while all the other fields are guaranteed to exist.
* vo_opengl: don't cut off feature list outputwm42014-08-251-1/+1
|
* gl_common: add SGI_video_sync extensionwm42014-08-151-0/+8
|
* Remove some mp_msg calls with no trailing \nwm42014-07-131-2/+4
| | | | | | | The final goal is all mp_msg calls produce complete lines. We want this because otherwise, race conditions could corrupt the terminal output, and it's inconvenient for the client API too. This commit works towards this goal. There's still code that has this not fixed yet, though.
* Audit and replace all ctype.h useswm42014-07-011-1/+0
| | | | | | | | | | | | | | | | Something like "char *s = ...; isdigit(s[0]);" triggers undefined behavior, because char can be signed, and thus s[0] can be a negative value. The is*() functions require unsigned char _or_ EOF. EOF is a special value outside of unsigned char range, thus the argument to the is*() functions can't be a char. This undefined behavior can actually trigger crashes if the implementation of these functions e.g. uses lookup tables, which are then indexed with out-of-range values. Replace all <ctype.h> uses with our own custom mp_is*() functions added with misc/ctype.h. As a bonus, these functions are locale-independent. (Although currently, we _require_ C locale for other reasons.)
* video: introduce failure path for image allocationswm42014-06-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, failure to allocate image data resulted in a crash (i.e. abort() was called). This was intentional, because it's pretty silly to degrade playback, and in almost all situations, the OOM will probably kill you anyway. (And then there's the standard Linux overcommit behavior, which also will kill you at some point.) But I changed my opinion, so here we go. This change does not affect _all_ memory allocations, just image data. Now in most failure cases, the output will just be skipped. For video filters, this coincidentally means that failure is treated as EOF (because the playback core assumes EOF if nothing comes out of the video filter chain). In other situations, output might be in some way degraded, like skipping frames, not scaling OSD, and such. Functions whose return values changed semantics: mp_image_alloc mp_image_new_copy mp_image_new_ref mp_image_make_writeable mp_image_setrefp mp_image_to_av_frame_and_unref mp_image_from_av_frame mp_image_new_external_ref mp_image_new_custom_ref mp_image_pool_make_writeable mp_image_pool_get mp_image_pool_new_copy mp_vdpau_mixed_frame_create vf_alloc_out_image vf_make_out_image_writeable glGetWindowScreenshot
* Add more constwm42014-06-111-25/+25
| | | | | | | 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_common: remove dlsym() fallbackwm42014-05-311-21/+1
| | | | See previous commits.
* gl_x11: always require some GLX API functions, avoid dlsym()wm42014-05-311-1/+1
| | | | | | | | | | | | | | 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.
* gl_common: minor cosmetic changeswm42014-05-261-10/+9
| | | | Why are you reading this message.
* gl_common: correct a typewm42014-05-261-1/+1
| | | | | | | We pass a pointer to a GLint to sscanf, using the %d format. That format _always_ takes int, and not GLint (whatever the heck that is). If GLint is always int, then it doesn't make a difference, but is still better because it doesn't play russian roulette with pointers.
* vo_opengl: always dynamically load OpenGL symbolswm42014-05-261-64/+59
| | | | | | | | | | | | | | Don't emit "hard" references to OpenGL functions. Always use the platform specific function to lookup OpenGL functions, such as glXGetProcAddress() with GLX (x11). This actually fixes the build if only Wayland is enabled (e.g. using --disable-gl-x11 on Linux). Note that some sources claim that wglGetProcAddress() (win32) does not return function pointers for OpenGL 1.1 functions (even if they are valid and necessary in OpenGL 3.0). But if that happens, the fallback employed in gl_w32.c/w32gpa() should catch this.
* video/out: remove unused config() parameterswm42014-05-071-3/+2
| | | | This was cleaned up yesterday.
* msg: rename mp_msg_log -> mp_msgwm42013-12-211-19/+19
| | | | Same for companion functions.
* msg: convert defines to enumwm42013-12-211-1/+1
| | | | Also get rid of MSGL_HINT and the many MSGL_DBG* levels.
* m_option: add mp_log callback to OPT_STRING_VALIDATE optionswm42013-12-211-5/+5
| | | | | And also convert a bunch of other code, especially ao_wasapi and ao_portaudio.
* Move options/config related files from mpvcore/ to options/wm42013-12-171-2/+2
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* vo_opengl: support for vda hardware decodingStefano Pigozzi2013-12-021-0/+4
| | | | | | | | | | | 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/+11
| | | | | | | | | | 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.
* Rename sub.c/.h to osd.c/.hwm42013-11-241-2/+0
| | | | | This was way too misleading. osd.c merely calls the subtitle renderers, instead of actually dealing with subtitles.
* gl_common: print SW renderer warning only if it was the only reason we ↵wm42013-11-141-1/+1
| | | | rejected it
* vo_opengl: fix alpha values written to the framebufferwm42013-11-101-0/+2
| | | | | | | | |