summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/ra_gl.c
Commit message (Collapse)AuthorAgeFilesLines
* vo_opengl: separate hwdec context and mapping, port it to use rawm42017-08-101-76/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This does two separate rather intrusive things: 1. Make the hwdec context (which does initialization, provides the device to the decoder, and other basic state) and frame mapping (getting textures from a mp_image) separate. This is more flexible, and you could map multiple images at once. It will help removing some hwdec special-casing from video.c. 2. Switch all hwdec API use to ra. Of course all code is still GL specific, but in theory it would be possible to support other backends. The most important change is that the hwdec interop returns ra objects, instead of anything GL specific. This removes the last dependency on GL-specific header files from video.c. I'm mixing these separate changes because both requires essentially rewriting all the glue code, so better do them at once. For the same reason, this change isn't done incrementally. hwdec_ios.m is untested, since I can't test it. Apart from superficial mistakes, this also requires dealing with Apple's texture format fuckups: they force you to use GL_LUMINANCE[_ALPHA] instead of GL_RED and GL_RG. We also need to report the correct format via ra_tex to the renderer, which is done by find_la_variant(). It's unknown whether this works correctly. hwdec_rpi.c as well as vo_rpi.c are still broken. (I need to pull my RPI out of a dusty pile of devices and cables, so, later.)
* vo_opengl: go back to using GL_TIME_ELAPSEDNiklas Haas2017-08-081-16/+25
| | | | | | | | Less flexible than GL_TIMESTAMP but supported by more platforms. This will mean that nested queries have to be detected and silently omitted, but oh well. Not much use for them anyway. Fixes #4721.
* vo_opengl: don't call glGetProgramBinary if GL_PROGRAM_BINARY_LENGTH==0wm42017-08-081-2/+4
| | | | Noticed in #4717, although the issue might be about something else.
* client API: more opengl_cb clarificationswm42017-08-071-1/+1
| | | | Also fix a typo in ra_gl.c. Too greedy for a separate commit.
* vo_opengl: add another ra_format field to exclude insane formatswm42017-08-071-0/+1
| | | | | | Generic description of pixel formats is hard. In this case, the Apple special format for packed YUV could have been interpreted as a RGB format with funny packing.
* vo_opengl: further GL API use separationwm42017-08-071-4/+48
| | | | | | | | | | | | | | | Move multiple GL-specific things from the renderer to other places like vo_opengl.c, vo_opengl_cb.c, and ra_gl.c. The vp_w/vp_h parameters to gl_video_resize() make no sense anymore, and are implicitly part of struct fbodst. Checking the main framebuffer depth is moved to vo_opengl.c. For vo_opengl_cb.c it always assumes 8. The API user now has to override this manually. The previous heuristic didn't make much sense anyway. The only remaining dependency on GL is the hwdec stuff, which is harder to change.
* vo_opengl: fix minor memory leakwm42017-08-071-1/+4
| | | | Don't leak the buffer if glGetProgramBinary() fails.
* vo_opengl: nuke ra_gl->first_runNiklas Haas2017-08-071-6/+12
| | | | | | Completely unnecessary, we can just update the uniforms immediately after creating the program. In theory, for GLSL 4.20+, we could even skip this, but oh well.
* vo_opengl: simplify mirroring and fix it if glBlitFramebuffer is usedwm42017-08-071-5/+2
| | | | | | | | | | | | | | | | | | The vp_w/vp_h variables and parameters were not really used anymore (they were redundant with ra_tex w/h) - but vp_h was still used to identify whether rendering should be done mirrored. Simplify this by adding a fbodst struct (some bad naming), which contains the render target texture, and some parameters how it should be rendered to (for now only flipping). It would not be appropriate to make this a member of ra_tex, so it's a separate struct. Introduces a weird regression for the first frame rendered after interpolation is toggled at runtime, but seems to work otherwise. This is possibly due to the change that blit() now mirrors, instead of just copying. (This is also why ra_fns.blit is changed.) Fixes #4719.
* vo_opengl: generalize ra_buf to support other buffer objectsNiklas Haas2017-08-071-37/+70
| | | | | This allows us to integrate PBOs and SSBOs into the same abstraction, with the potential to easily add UBOs if the need arises.
* vo_opengl: drop ra_gl.h from shader_cache.cNiklas Haas2017-08-061-0/+1
| | | | | | Since the GL *gl is no longer needed for the timers, we can get rid of the sc->gl dependency. This requires moving a utility function (which is not GL-specific anyway) out of gl_utils.h and into utils.h
* vo_opengl: move timers to struct raNiklas Haas2017-08-061-0/+73
| | | | | | | In order to prevent code duplication and keep the ra abstraction as small as possible, `ra` only implements the actual timer queries, it does not do pooling/averaging of the results. This is instead moved to a ra-neutral struct timer_pool in utils.c.
* vo_opengl: ra_gl: make getting GL ptr slightly less tediouswm42017-08-051-35/+20
|
* vo_opengl: move shader handling to rawm42017-08-051-1/+381
| | | | | | | | | | | | | Now all GL-specifics of shader compilation are abstracted through ra. Of course we still have everything hardcoded to GLSL - that isn't going to change. Some things will probably change later - in particular, the way we pass uniforms and textures to the shader. Currently, there is a confusing mismatch between "primitive" uniforms like floats, and others like textures. Also, SSBOs are not abstracted yet.
* vo_opengl: organize ra PBO flag slightly differentlywm42017-08-051-1/+1
| | | | | | | | Instead of having a mutable ra_tex field (and the only one), move the flag to struct ra, since we have only 2 tex_upload user calls anyway, and both want the same PBO behavior. (At first I considered making it a RA_TEX_UPLOAD_ flag, but why bother. PBOs are a terribly GL-specific thing, so we can't expect a reasonable abstraction of it anyway.)
* vo_opengl: make OSD code use ra for textureswm42017-08-051-3/+13
| | | | | | | | | | | | This requires a silly extension to ra_fns.tex_upload: since the OSD texture can be much larger than the actual OSD image data to upload, a mechanism for uploading only to a small part of the texture is needed. Otherwise, we'd have to realloc/copy the data, just to pad it, and then pay for uploading the padding too. The RA_TEX_UPLOAD_DISCARD flag is not interpreted by GL (not sure how you'd tell GL about this), but it clarifies the API and might be helpful if we support other backend APIs in the future.
* vo_opengl: restore OSX "old" hwdecwm42017-08-051-1/+1
| | | | Probably. Untested.
* vo_opengl: pass ra objects during rendering instead of GL objectswm42017-08-051-3/+154
| | | | | | | | | Another "small" step towards removing GL dependencies from the renderer. This commit generally passes ra_tex objects instead of GL FBO integer IDs to various rendering functions. video.c still manually binds the FBOs when calling shaders. This also happens to fix a memory leak with output_fbo.
* vo_opengl: make fbotex helper use rawm42017-08-051-2/+35
| | | | | | | | Further work removing GL dependencies from the actual video renderer, and moving them into ra backends. Use of glInvalidateFramebuffer() falls away. I'd like to keep this, but it's better to readd it once shader runs are in ra.
* vo_opengl: use GL_CLIENT_STORAGE_BIT for DRNiklas Haas2017-08-031-1/+1
| | | | | | | | | mesa won't pick client storage unless this bit is set, and we *absolutely* want to be using client storage for our DR PBOs. Performance is shit on AMD otherwise. (Nvidia always uses client storage for persistent coherent buffers whether you tell it it or not, probably because it's way faster and nvidia doesn't trust users to figure that out on their own)
* vo_opengl: remove unused ra_mapped_buffer.preferred_align fieldwm42017-08-031-1/+0
| | | | | | | | | | | It makes no sense to have this on an already created buffer. If anything, the ra backend would have to export this as a global value (e.g. struct ra field), so that whatever allocates the buffer can account for the required alignment. Since this code is in vo_opengl.c in the first place, and since GL doesn't dictate any special alignment here, it doesn't make sense in the first place to export this. (Maybe something like this will be required later.)
* vo_opengl: manage dither texture via rawm42017-07-291-3/+8
| | | | | | | | | Also add some more helpers. Fix the broken math.h include statement. utils.c uses ra_gl.h internals, which it shouldn't, and which will be removed again as soon as this code gets converted to ra fully.
* vo_opengl: use ra_* for format negotiation toowm42017-07-291-0/+3
| | | | | | | | | | | | | Format handling via ra_* was added earlier, but the format negotiation part was forgotten. Actually move some aspects of it to ra_get_imgfmt_desc(). Also make sure the unorm and float formats selected by the common format lookup functions are linear filterable. (For OpenGL, this is implicitly guaranteed, so it wasn't done before.) Whether these assumptions should be checked/enforced in the ra code at all is a bit fuzzy, but with ra being helper code only for the actual video renderer, it's probably justified.
* vo_opengl: start work on rendering API abstractionwm42017-07-261-0/+290
This starts work on moving OpenGL-specific code out of the general renderer code, so that we can support other other GPU APIs. This is in a very early stage and it's only a proof of concept. It's unknown whether this will succeed or result in other backends. For now, the GL rendering API ("ra") and its only provider (ra_gl) does texture creation/upload/destruction only. And it's used for the main video texture only. All other code is still hardcoded to GL. There is some duplication with ra_format and gl_format handling. In the end, only the ra variants will be needed (plus the gl_format table of course). For now, this is simpler, because for some reason lots of hwdec code still requires the GL variants, and would have to be updated to use the ra ones. Currently, the video.c code accesses private ra_gl fields. In the end, it should not do that of course, and it would not include ra_gl.h. Probably adds bugs, but you can keep them.