summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-03-17 12:44:53 +0100
committerwm4 <wm4@nowhere>2016-03-17 12:50:26 +0100
commit45db7d52a982482c168b8fc2ee05ecc58237e7dc (patch)
treecd62af80cb7a358153f23798bf83b6c2354274e8
parente26462599bc272f7e90c2c6e820d5d9ec1c801d6 (diff)
downloadmpv-45db7d52a982482c168b8fc2ee05ecc58237e7dc.tar.bz2
mpv-45db7d52a982482c168b8fc2ee05ecc58237e7dc.tar.xz
vo_opengl: fix operation without GL_ARB_texture_rg
This also gets rid of the kind of hard to read texture swizzle setup and turns it into something dumber. Assumes that we don't create any FBOs with 2 channel formats. (Only the video source textures are handled by this commit.)
-rw-r--r--video/out/opengl/video.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 939f979a86..94e728912d 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -127,6 +127,7 @@ struct img_tex {
int tex_w, tex_h;
int w, h;
struct gl_transform transform;
+ bool texture_la; // it's a GL_LUMINANCE_ALPHA texture (access with .ra not .rg)
};
struct fbosurface {
@@ -826,6 +827,7 @@ static void pass_get_img_tex(struct gl_video *p, struct video_image *vimg,
.h = t->h,
.transform = type == PLANE_CHROMA ? chroma : identity_trans,
.components = p->image_desc.components[n],
+ .texture_la = t->gl_format == GL_LUMINANCE_ALPHA,
};
}
}
@@ -1428,9 +1430,14 @@ static void copy_img_tex(struct gl_video *p, int *offset, struct img_tex img)
assert(*offset + count <= 4);
int id = pass_bind(p, img);
- const char *src = "wzyx" + (4 - count);
- const char *dst = (const char*[4]){"wzyx", "wzy", "wz", "w"}[*offset]
- + (4 - *offset - count);
+ char src[5] = {0};
+ char dst[5] = {0};
+ const char *tex_fmt = img.texture_la ? "ragg" : "rgba";
+ const char *dst_fmt = "rgba";
+ for (int i = 0; i < count; i++) {
+ src[i] = tex_fmt[i];
+ dst[i] = dst_fmt[*offset + i];
+ }
if (img.use_integer) {
uint64_t tex_max = 1ull << p->image_desc.component_full_bits;
@@ -1438,7 +1445,7 @@ static void copy_img_tex(struct gl_video *p, int *offset, struct img_tex img)
}
GLSLF("color.%s = %f * vec4(texture(texture%d, texcoord%d)).%s;\n",
- dst, img.multiplier, id, id, src);
+ dst, img.multiplier, id, id, src);
*offset += count;
}