summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuqing Zhu <carol.zhu@nxp.com>2016-10-13 09:59:54 +0800
committerOtavio Salvador <otavio@ossystems.com.br>2016-10-27 10:36:28 -0200
commit5fd1a78c41e0c5ebc591d13a220927cbbd9fe5bc (patch)
tree6630420f07bd0e241558566fd8aa4017e66ec6c9
parent86afc6c9e207989eeeccc405cee2f10277ca935e (diff)
downloadmeta-freescale-5fd1a78c41e0c5ebc591d13a220927cbbd9fe5bc.tar.gz
gstreamer1.0-plugins-bad: Fix MRT cannot work in GLES3.0
1. Add #ifdefine Marco to avoid redefinition of GL_COLOR_ATTACHMENT(1,2). 2. Change to use glBlitFramebuffer for textures copy. glCopyTexImage2D cannot work because we cannot get texture internal format. Signed-off-by: Yuqing Zhu <carol.zhu@nxp.com> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
-rwxr-xr-xrecipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0007-glplugin-glcolorconvert-fix-MRT-cannot-work-in-GLES3.patch168
-rw-r--r--recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_%.bbappend1
2 files changed, 169 insertions, 0 deletions
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0007-glplugin-glcolorconvert-fix-MRT-cannot-work-in-GLES3.patch b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0007-glplugin-glcolorconvert-fix-MRT-cannot-work-in-GLES3.patch
new file mode 100755
index 00000000..d4858328
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad/0007-glplugin-glcolorconvert-fix-MRT-cannot-work-in-GLES3.patch
@@ -0,0 +1,168 @@
1From 5b4e2d726602b0c92b789fce0dc85a1f0c860bbc Mon Sep 17 00:00:00 2001
2From: Haihua Hu <jared.hu@nxp.com>
3Date: Wed, 20 Apr 2016 16:38:31 +0800
4Subject: [PATCH 3/6] [glplugin] glcolorconvert: fix MRT cannot work in GLES3.0
5
61. Add #ifdefine Marco to avoid redefinition of GL_COLOR_ATTACHMENT(1,2).
72. Change to use glBlitFramebuffer for textures copy. glCopyTexImage2D
8 cannot work because we cannot get texture internal format.
9
10Upstream-Status: Inappropriate [i.MX specific]
11
12Signed-off-by: Haihua Hu <jared.hu@nxp.com>
13---
14 gst-libs/gst/gl/glprototypes/fbo.h | 6 +--
15 gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h | 7 +--
16 gst-libs/gst/gl/gstglcolorconvert.c | 2 +-
17 gst-libs/gst/gl/gstglmemory.c | 54 +++++++++++++++++++++---
18 4 files changed, 55 insertions(+), 14 deletions(-)
19
20diff --git a/gst-libs/gst/gl/glprototypes/fbo.h b/gst-libs/gst/gl/glprototypes/fbo.h
21index d142483..789f289 100644
22--- a/gst-libs/gst/gl/glprototypes/fbo.h
23+++ b/gst-libs/gst/gl/glprototypes/fbo.h
24@@ -102,9 +102,9 @@ GST_GL_EXT_FUNCTION (GLboolean, IsFramebuffer,
25 GST_GL_EXT_END ()
26
27 GST_GL_EXT_BEGIN (offscreen_blit,
28- GST_GL_API_NONE,
29- 255, 255,
30- 255, 255, /* not in either GLES */
31+ GST_GL_API_OPENGL3 | GST_GL_API_GLES2,
32+ 3, 0,
33+ 3, 0,/* enable to avoid using glCopyTexImage2D for texture copying */
34 "EXT\0ANGLE\0",
35 "framebuffer_blit\0")
36 GST_GL_EXT_FUNCTION (void, BlitFramebuffer,
37diff --git a/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h b/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h
38index d282990..1980476 100644
39--- a/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h
40+++ b/gst-libs/gst/gl/glprototypes/gstgl_gles2compat.h
41@@ -34,9 +34,10 @@ G_BEGIN_DECLS
42 //END FIXME
43
44 /* UNSUPPORTED */
45-
46-#define GL_COLOR_ATTACHMENT1 0
47-#define GL_COLOR_ATTACHMENT2 0
48+#ifndef GL_COLOR_ATTACHMENT1
49+#define GL_COLOR_ATTACHMENT1 0x8CE1
50+#define GL_COLOR_ATTACHMENT2 0x8CE2
51+#endif
52 #ifndef GL_TEXTURE_ENV
53 #define GL_TEXTURE_ENV 0
54 #endif
55diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c
56index 4ed947e..490ec54 100644
57--- a/gst-libs/gst/gl/gstglcolorconvert.c
58+++ b/gst-libs/gst/gl/gstglcolorconvert.c
59@@ -2075,7 +2075,7 @@ _init_convert (GstGLColorConvert * convert)
60 }
61
62 /* Requires reading from a RG/LA framebuffer... */
63- if (USING_GLES2 (convert->context) &&
64+ if (!USING_GLES3 (convert->context) &&
65 (GST_VIDEO_INFO_FORMAT (&convert->out_info) == GST_VIDEO_FORMAT_YUY2 ||
66 GST_VIDEO_INFO_FORMAT (&convert->out_info) ==
67 GST_VIDEO_FORMAT_UYVY)) {
68diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c
69index 402fd4d..f2706ea 100644
70--- a/gst-libs/gst/gl/gstglmemory.c
71+++ b/gst-libs/gst/gl/gstglmemory.c
72@@ -69,6 +69,12 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_GL_MEMORY);
73 #ifndef GL_TEXTURE_EXTERNAL_OES
74 #define GL_TEXTURE_EXTERNAL_OES 0x8D65
75 #endif
76+#ifndef GL_READ_FRAMEBUFFER
77+#define GL_READ_FRAMEBUFFER 0x8CA8
78+#endif
79+#ifndef GL_DRAW_FRAMEBUFFER
80+#define GL_DRAW_FRAMEBUFFER 0x8CA9
81+#endif
82
83 G_DEFINE_TYPE (GstGLMemoryAllocator, gst_gl_memory_allocator,
84 GST_TYPE_GL_BASE_MEMORY_ALLOCATOR);
85@@ -608,7 +614,7 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
86 guint out_gl_format, out_tex_target;
87 GstMapInfo sinfo;
88 guint src_tex_id;
89- guint fbo;
90+ guint fbo[2];
91
92 gl = src->mem.context->gl_vtable;
93 out_tex_target = gst_gl_texture_target_to_gl (out_target);
94@@ -632,31 +638,65 @@ gst_gl_memory_copy_teximage (GstGLMemory * src, guint tex_id,
95
96 /* FIXME: try and avoid creating and destroying fbo's every copy... */
97 /* create a framebuffer object */
98- gl->GenFramebuffers (1, &fbo);
99- gl->BindFramebuffer (GL_FRAMEBUFFER, fbo);
100+ gl->GenFramebuffers (2, &fbo[0]);
101+ gl->BindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
102
103- gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
104+ gl->FramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
105 gst_gl_texture_target_to_gl (src->tex_target), src_tex_id, 0);
106
107-// if (!gst_gl_context_check_framebuffer_status (src->context))
108-// goto fbo_error;
109+ if (!gst_gl_context_check_framebuffer_status (src->mem.context))
110+ goto fbo_error;
111+
112+ gl->BindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
113+
114+ gl->FramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
115+ gst_gl_texture_target_to_gl (src->tex_target), tex_id, 0);
116
117+ if (!gst_gl_context_check_framebuffer_status (src->mem.context))
118+ goto fbo_error;
119+
120+ /*
121 gl->BindTexture (out_tex_target, tex_id);
122 gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (src)->query,
123 GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "CopyTexImage2D took");
124 gl->CopyTexImage2D (out_tex_target, 0, out_gl_format, 0, 0, out_width,
125 out_height, 0);
126 gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (src)->query);
127+ */
128+
129+ /*
130+ * glCopyTexImage2D cannot work without internal_format
131+ * we cannot get the internal_format in this function
132+ * so use glBlitFramebuffer for texture copy
133+ */
134+ GST_CAT_LOG(GST_CAT_GL_MEMORY,"Use BlitFramebuffer copy texture %d into %d",
135+ src_tex_id, tex_id);
136+ gl->ReadBuffer ( GL_COLOR_ATTACHMENT0 );
137+ gl->BlitFramebuffer ( 0, 0, out_width, out_height,
138+ 0, 0, out_width, out_height,
139+ GL_COLOR_BUFFER_BIT, GL_LINEAR );
140
141 gl->BindTexture (out_tex_target, 0);
142 gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
143
144- gl->DeleteFramebuffers (1, &fbo);
145+ gl->DeleteFramebuffers (2, &fbo[0]);
146
147 gst_memory_unmap (GST_MEMORY_CAST (src), &sinfo);
148
149 return TRUE;
150
151+fbo_error:
152+ {
153+ gl->BindTexture (out_tex_target, 0);
154+ gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
155+
156+ gl->DeleteFramebuffers (2, &fbo[0]);
157+
158+ gst_memory_unmap (GST_MEMORY_CAST (src), &sinfo);
159+
160+ return FALSE;
161+ }
162+
163 error:
164 return FALSE;
165 }
166--
1671.9.1
168
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_%.bbappend b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_%.bbappend
index 7fba6e21..adc75b72 100644
--- a/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_%.bbappend
+++ b/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_%.bbappend
@@ -16,6 +16,7 @@ SRC_URI_append = " file://0001-glplugin-Change-wayland-default-res-to-1024x768.p
16 file://0004-Fix-dependence-issue-between-gst-plugin-.patch \ 16 file://0004-Fix-dependence-issue-between-gst-plugin-.patch \
17 file://0005-glcolorconvert-convert-YUV-to-RGB-use-directviv.patch \ 17 file://0005-glcolorconvert-convert-YUV-to-RGB-use-directviv.patch \
18 file://0006-glwindow-work-around-for-no-frame-when-imxplayer-use.patch \ 18 file://0006-glwindow-work-around-for-no-frame-when-imxplayer-use.patch \
19 file://0007-glplugin-glcolorconvert-fix-MRT-cannot-work-in-GLES3.patch \
19" 20"
20 21
21 22