1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-10 00:49:32 +00:00
mpv/video/out/opengl/ra_gl.h
wm4 c6fafbffac vo_opengl: separate hwdec context and mapping, port it to use ra
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.)
2017-08-10 21:24:31 +02:00

54 lines
1.5 KiB
C

#pragma once
#include "common.h"
#include "ra.h"
#include "gl_utils.h"
// For ra.priv
struct ra_gl {
GL *gl;
bool debug_enable;
bool timer_active; // hack for GL_TIME_ELAPSED limitations
};
// For ra_tex.priv
struct ra_tex_gl {
bool own_objects;
GLenum target;
GLuint texture; // 0 if no texture data associated
GLuint fbo; // 0 if no rendering requested, or it default framebuffer
// These 3 fields can be 0 if unknown.
GLint internal_format;
GLenum format;
GLenum type;
struct gl_pbo_upload pbo;
};
// For ra_buf.priv
struct ra_buf_gl {
GLuint buffer;
GLsync fence;
};
// For ra_renderpass.priv
struct ra_renderpass_gl {
GLuint program;
// 1 entry for each ra_renderpass_params.inputs[] entry
GLint *uniform_loc;
int num_uniform_loc; // == ra_renderpass_params.num_inputs
struct gl_vao vao;
};
struct ra *ra_create_gl(GL *gl, struct mp_log *log);
struct ra_tex *ra_create_wrapped_tex(struct ra *ra,
const struct ra_tex_params *params,
GLuint gl_texture);
struct ra_tex *ra_create_wrapped_fb(struct ra *ra, GLuint gl_fbo, int w, int h);
GL *ra_gl_get(struct ra *ra);
void ra_gl_set_debug(struct ra *ra, bool enable);
void ra_gl_get_format(const struct ra_format *fmt, GLint *out_internal_format,
GLenum *out_format, GLenum *out_type);
void ra_gl_get_raw_tex(struct ra *ra, struct ra_tex *tex,
GLuint *out_texture, GLenum *out_target);
bool ra_is_gl(struct ra *ra);