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.)
This commit is contained in:
wm4 2015-05-21 20:27:22 +02:00
parent af667643a0
commit 292266f268
2 changed files with 35 additions and 5 deletions

View File

@ -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;

View File

@ -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;