--- video/out/opengl/utils.c.orig +++ video/out/opengl/utils.c @@ -466,7 +466,9 @@ struct sc_entry { int num_uniforms; bstr frag; bstr vert; +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 struct gl_timer *timer; +#endif }; struct gl_shader_cache { @@ -521,7 +523,9 @@ void gl_sc_reset(struct gl_shader_cache GL *gl = sc->gl; if (sc->needs_reset) { +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_stop(gl); +#endif gl->UseProgram(0); for (int n = 0; n < sc->num_uniforms; n++) { @@ -554,7 +558,9 @@ static void sc_flush_cache(struct gl_sha talloc_free(e->vert.start); talloc_free(e->frag.start); talloc_free(e->uniforms); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_free(e->timer); +#endif } sc->num_entries = 0; } @@ -1143,7 +1149,9 @@ struct mp_pass_perf gl_sc_generate(struc *entry = (struct sc_entry){ .vert = bstrdup(NULL, *vert), .frag = bstrdup(NULL, *frag), +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 .timer = gl_timer_create(gl), +#endif }; } // build vertex shader from vao and cache the locations of the uniform variables @@ -1168,10 +1176,17 @@ struct mp_pass_perf gl_sc_generate(struc gl->ActiveTexture(GL_TEXTURE0); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_start(entry->timer); +#endif sc->needs_reset = true; +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 return gl_timer_measure(entry->timer); +#else + struct mp_pass_perf dummy = {0}; + return dummy; +#endif } // Maximum number of simultaneous query objects to keep around. Reducing this @@ -1179,6 +1194,7 @@ struct mp_pass_perf gl_sc_generate(struc // available #define QUERY_OBJECT_NUM 8 +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 struct gl_timer { GL *gl; GLuint query[QUERY_OBJECT_NUM]; @@ -1292,6 +1308,7 @@ void gl_timer_stop(GL *gl) if (gl->EndQuery) gl->EndQuery(GL_TIME_ELAPSED); } +#endif // Upload a texture, going through a PBO. PBO supposedly can facilitate // asynchronous copy from CPU to GPU, so this is an optimization. Note that --- video/out/opengl/utils.h.orig +++ video/out/opengl/utils.h @@ -19,6 +19,10 @@ #ifndef MP_GL_UTILS_ #define MP_GL_UTILS_ +#ifdef __APPLE__ +#include +#endif + #include "common.h" #include "math.h" @@ -175,6 +179,7 @@ struct mpv_global; void gl_sc_set_cache_dir(struct gl_shader_cache *sc, struct mpv_global *global, const char *dir); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 struct gl_timer; struct gl_timer *gl_timer_create(GL *gl); @@ -182,6 +187,7 @@ void gl_timer_free(struct gl_timer *time void gl_timer_start(struct gl_timer *timer); void gl_timer_stop(GL *gl); struct mp_pass_perf gl_timer_measure(struct gl_timer *timer); +#endif #define NUM_PBO_BUFFERS 3 --- video/out/opengl/video.c.orig +++ video/out/opengl/video.c @@ -256,8 +256,10 @@ struct gl_video { struct pass_info pass_redraw[PASS_INFO_MAX]; struct pass_info *pass; int pass_idx; +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 struct gl_timer *upload_timer; struct gl_timer *blit_timer; +#endif // hooks and saved textures struct saved_tex saved_tex[SHADER_MAX_SAVED]; @@ -2903,14 +2905,20 @@ void gl_video_render_frame(struct gl_vid rc.y1 = -p->vp_h - p->dst_rect.y0; rc.y0 = -p->vp_h - p->dst_rect.y1; } +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_start(p->blit_timer); +#endif gl->BlitFramebuffer(rc.x0, rc.y0, rc.x1, rc.y1, rc.x0, rc.y0, rc.x1, rc.y1, GL_COLOR_BUFFER_BIT, GL_NEAREST); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_stop(gl); +#endif gl->BindFramebuffer(GL_READ_FRAMEBUFFER, 0); gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 pass_record(p, gl_timer_measure(p->blit_timer)); +#endif } } } @@ -2990,12 +2998,14 @@ static void frame_perf_data(struct pass_ } } +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 void gl_video_perfdata(struct gl_video *p, struct voctrl_performance_data *out) { *out = (struct voctrl_performance_data){0}; frame_perf_data(p->pass_fresh, &out->fresh); frame_perf_data(p->pass_redraw, &out->redraw); } +#endif // This assumes nv12, with textures set to GL_NEAREST filtering. static void reinterleave_vdpau(struct gl_video *p, struct gl_hwdec_frame *frame) @@ -3066,10 +3076,14 @@ static bool pass_upload_image(struct gl_ struct gl_hwdec_frame gl_frame = {{{0}}}; pass_describe(p, "map frame (hwdec)"); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_start(p->upload_timer); +#endif bool ok = p->hwdec->driver->map_frame(p->hwdec, vimg->mpi, &gl_frame) >= 0; +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_stop(gl); pass_record(p, gl_timer_measure(p->upload_timer)); +#endif vimg->hwdec_mapped = true; if (ok) { @@ -3100,7 +3114,9 @@ static bool pass_upload_image(struct gl_ assert(mpi->num_planes == p->plane_count); pass_describe(p, "upload frame (swdec)"); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_start(p->upload_timer); +#endif for (int n = 0; n < p->plane_count; n++) { struct texplane *plane = &vimg->planes[n]; @@ -3113,8 +3129,10 @@ static bool pass_upload_image(struct gl_ 0, 0, plane->w, plane->h); gl->BindTexture(plane->gl_target, 0); } +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_stop(gl); pass_record(p, gl_timer_measure(p->upload_timer)); +#endif return true; @@ -3310,8 +3328,10 @@ static void init_gl(struct gl_video *p) if (p->texture_16bit_depth > 0) MP_VERBOSE(p, "16 bit texture depth: %d.\n", p->texture_16bit_depth); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 p->upload_timer = gl_timer_create(gl); p->blit_timer = gl_timer_create(gl); +#endif debug_check_gl(p, "after init_gl"); } @@ -3331,8 +3351,10 @@ void gl_video_uninit(struct gl_video *p) gl->DeleteTextures(1, &p->lut_3d_texture); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_timer_free(p->upload_timer); gl_timer_free(p->blit_timer); +#endif for (int i = 0; i < PASS_INFO_MAX; i++) { talloc_free(p->pass_fresh[i].desc.start); talloc_free(p->pass_redraw[i].desc.start); --- video/out/opengl/video.h.orig +++ video/out/opengl/video.h @@ -20,6 +20,10 @@ #include +#ifdef __APPLE__ +#include +#endif + #include "options/m_option.h" #include "sub/osd.h" #include "common.h" @@ -156,7 +160,9 @@ void gl_video_render_frame(struct gl_vid void gl_video_resize(struct gl_video *p, int vp_w, int vp_h, struct mp_rect *src, struct mp_rect *dst, struct mp_osd_res *osd); +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 void gl_video_perfdata(struct gl_video *p, struct voctrl_performance_data *out); +#endif struct mp_csp_equalizer; struct mp_csp_equalizer *gl_video_eq_ptr(struct gl_video *p); void gl_video_eq_update(struct gl_video *p); --- video/out/vo_opengl.c.orig +++ video/out/vo_opengl.c @@ -311,7 +311,9 @@ static int control(struct vo *vo, uint32 vo->want_redraw = true; return true; case VOCTRL_PERFORMANCE_DATA: +#if !defined(__APPLE__) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 gl_video_perfdata(p->renderer, (struct voctrl_performance_data *)data); +#endif return true; }