summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-21 20:27:22 +0200
committerwm4 <wm4@nowhere>2015-05-21 20:27:22 +0200
commit292266f26892080d905e374e03c6a8d57942ca0e (patch)
tree04248dfbfe8f57f31ebe6aa35d6fabfb0e19159e
parentaf667643a0a7939c2cdb0d5e1451f45e376a0449 (diff)
downloadmpv-292266f26892080d905e374e03c6a8d57942ca0e.tar.bz2
mpv-292266f26892080d905e374e03c6a8d57942ca0e.tar.xz
vo_opengl: vda: make it work anywhere
A rather dumb hack to copy the problematic rectangle textures (mandated by VDA) into 2D ones. (This isn't done yet for OpenGL 3.0+. We need to make sure the performance isn't reduced too much by it.)
-rw-r--r--video/out/gl_hwdec_vda.c5
-rw-r--r--video/out/gl_video.c35
2 files changed, 35 insertions, 5 deletions
diff --git a/video/out/gl_hwdec_vda.c b/video/out/gl_hwdec_vda.c
index 079b7029b3..0b7cda2c3e 100644
--- a/video/out/gl_hwdec_vda.c
+++ b/video/out/gl_hwdec_vda.c
@@ -121,11 +121,6 @@ static bool check_hwdec(struct gl_hwdec *hw)
return false;
}
- if (hw->gl->version < 300) {
- MP_ERR(hw, "need >= OpenGL 3.0 for core rectangle texture support\n");
- return false;
- }
-
if (!CGLGetCurrentContext()) {
MP_ERR(hw, "need cocoa opengl backend to be active");
return false;
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index ff2921c0f4..3c747ccd12 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -203,6 +203,7 @@ struct gl_video {
bool use_indirect;
bool use_linear;
float user_gamma;
+ struct fbotex copy_fbos[4];
int frames_rendered;
@@ -557,6 +558,9 @@ static void uninit_rendering(struct gl_video *p)
for (int n = 0; n < FBOSURFACES_MAX; n++)
fbotex_uninit(&p->surfaces[n].fbotex);
+ for (int n = 0; n < 4; n++)
+ fbotex_uninit(&p->copy_fbos[n]);
+
gl_video_reset_surfaces(p);
}
@@ -1306,12 +1310,43 @@ static void pass_sample(struct gl_video *p, int src_tex, struct scaler *scaler,
GLSL(color.a = 1.0;)
}
+static void pass_copy_from_rect(struct gl_video *p)
+{
+ struct src_tex new_pass_tex[TEXUNIT_VIDEO_NUM];
+ assert(sizeof(new_pass_tex) == sizeof(p->pass_tex));
+ memcpy(&new_pass_tex, &p->pass_tex, sizeof(p->pass_tex));
+ memset(&p->pass_tex, 0, sizeof(p->pass_tex));
+
+ for (int n = 0; n < TEXUNIT_VIDEO_NUM; n++) {
+ struct src_tex *src = &new_pass_tex[n];
+ if (src->gl_tex && src->gl_target == GL_TEXTURE_RECTANGLE) {
+ p->pass_tex[0] = (struct src_tex){
+ .gl_tex = src->gl_tex,
+ .gl_target = GL_TEXTURE_RECTANGLE,
+ .tex_w = src->tex_w,
+ .tex_h = src->tex_h,
+ .src = {0, 0, src->tex_w, src->tex_h},
+ };
+ const char *get = p->gl->version < 300 ? "texture2DRect" : "texture";
+ GLSLF("vec4 color = %s(texture0, texcoord0);\n", get);
+ finish_pass_fbo(p, &p->copy_fbos[n], src->tex_w, src->tex_h, 0, 0);
+ src->gl_tex = p->copy_fbos[n].texture;
+ src->gl_target = GL_TEXTURE_2D;
+ }
+ }
+
+ memcpy(&p->pass_tex, &new_pass_tex, sizeof(p->pass_tex));
+}
+
// sample from video textures, set "color" variable to yuv value
static void pass_read_video(struct gl_video *p)
{
struct gl_transform chromafix;
pass_set_image_textures(p, &p->image, &chromafix);
+ if (p->gl->version < 300 && p->pass_tex[0].gl_target == GL_TEXTURE_RECTANGLE)
+ pass_copy_from_rect(p);
+
if (p->plane_count == 1) {
GLSL(vec4 color = texture(texture0, texcoord0);)
return;