summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/ra_gl.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-07 19:14:18 +0200
committerwm4 <wm4@nowhere>2017-08-07 19:17:28 +0200
commit47ea771b7a29b04e35276d38733f72970b4dd448 (patch)
tree2a9f9c52acba9f662d62a290f739c502c6ca0ff8 /video/out/opengl/ra_gl.c
parent1adf324d8b1261abfc02d905f98055991b29ac11 (diff)
downloadmpv-47ea771b7a29b04e35276d38733f72970b4dd448.tar.bz2
mpv-47ea771b7a29b04e35276d38733f72970b4dd448.tar.xz
vo_opengl: further GL API use separation
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.
Diffstat (limited to 'video/out/opengl/ra_gl.c')
-rw-r--r--video/out/opengl/ra_gl.c52
1 files changed, 48 insertions, 4 deletions
diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c
index a1373588fc..da6f5e92d1 100644
--- a/video/out/opengl/ra_gl.c
+++ b/video/out/opengl/ra_gl.c
@@ -6,7 +6,7 @@
static struct ra_fns ra_fns_gl;
-int ra_init_gl(struct ra *ra, GL *gl)
+static int ra_init_gl(struct ra *ra, GL *gl)
{
if (gl->version < 210 && gl->es < 200) {
MP_ERR(ra, "At least OpenGL 2.1 or OpenGL ES 2.0 required.\n");
@@ -16,6 +16,8 @@ int ra_init_gl(struct ra *ra, GL *gl)
struct ra_gl *p = ra->priv = talloc_zero(NULL, struct ra_gl);
p->gl = gl;
+ ra_gl_set_debug(ra, true);
+
ra->fns = &ra_fns_gl;
ra->caps = 0;
if (gl->mpgl_caps & MPGL_CAP_1D_TEX)
@@ -100,20 +102,46 @@ int ra_init_gl(struct ra *ra, GL *gl)
MP_TARRAY_APPEND(ra, ra->formats, ra->num_formats, fmt);
}
- GLint max_wh;
- gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_wh);
- ra->max_texture_wh = max_wh;
+ GLint ival;
+ gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &ival);
+ ra->max_texture_wh = ival;
+
+ if (ra->caps & RA_CAP_COMPUTE) {
+ gl->GetIntegerv(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, &ival);
+ ra->max_shmem = ival;
+ }
gl->Disable(GL_DITHER);
return 0;
}
+struct ra *ra_create_gl(GL *gl, struct mp_log *log)
+{
+ struct ra *ra = talloc_zero(NULL, struct ra);
+ ra->log = log;
+ if (ra_init_gl(ra, gl) < 0) {
+ talloc_free(ra);
+ return NULL;
+ }
+ return ra;
+}
+
static void gl_destroy(struct ra *ra)
{
talloc_free(ra->priv);
}
+void ra_gl_set_debug(struct ra *ra, bool enable)
+{
+ struct ra_gl *p = ra->priv;
+ GL *gl = ra_gl_get(ra);
+
+ p->debug_enable = enable;
+ if (gl->debug_context)
+ gl_set_debug_logger(gl, enable ? ra->log : NULL);
+}
+
static void gl_tex_destroy(struct ra *ra, struct ra_tex *tex)
{
GL *gl = ra_gl_get(ra);
@@ -949,6 +977,20 @@ static uint64_t gl_timer_stop(struct ra *ra, ra_timer *ratimer)
return timer->result;
}
+static void gl_flush(struct ra *ra)
+{
+ GL *gl = ra_gl_get(ra);
+ gl->Flush();
+}
+
+static void gl_debug_marker(struct ra *ra, const char *msg)
+{
+ struct ra_gl *p = ra->priv;
+
+ if (p->debug_enable)
+ gl_check_error(p->gl, ra->log, msg);
+}
+
static struct ra_fns ra_fns_gl = {
.destroy = gl_destroy,
.tex_create = gl_tex_create,
@@ -966,4 +1008,6 @@ static struct ra_fns ra_fns_gl = {
.timer_destroy = gl_timer_destroy,
.timer_start = gl_timer_start,
.timer_stop = gl_timer_stop,
+ .flush = gl_flush,
+ .debug_marker = gl_debug_marker,
};