hardware/intel/libva
修订版 | fac3fb471759c436e0e7dab0d083929586292074 (tree) |
---|---|
时间 | 2016-03-03 12:56:42 |
作者 | Cyril Drouet <cyril.drouet@imme...> |
Commiter | Xiang, Haihao |
glx: check OpenGL 3.1 extensions
I successfully implemented hardware decoding with VAAPI via FFmpeg
by copying the data back to the CPU's memory; however, when I tried
to use the data directly from the GPU (instead of copying them back)
by using VA/GLX to convert the decoded VASurfaces to OpenGL textures,
I ran into some issues.
With the latest version of libva, vaCreateSurfaceGLX fails all the time
when I set OpenGL to 3.1 or above. If I set it to 3.0, then it doesn't
fail, and everything works correctly. I downloaded the sources of libva
and it fails when checking for GL extensions because of the use of
glGetString(GL_EXTENSIONS) which is deprecated. I have implemented a fix
on my end (which I've attached for convenience) which works well for me
but I haven't done a lot of testing, and I would rather use the official
version of libva.
Signed-off-by: Cyril Drouet <cyril.drouet@immerex.com>
Signed-off-by: Víctor Jáquez <vjaquez@igalia.com>
@@ -191,18 +191,40 @@ static int check_extension(const char *name, const char *ext) | ||
191 | 191 | return 0; |
192 | 192 | } |
193 | 193 | |
194 | +static int check_extension3(const char *name) | |
195 | +{ | |
196 | + int nbExtensions, i; | |
197 | + PFNGLGETSTRINGIPROC glGetStringi = 0; | |
198 | + | |
199 | + glGetStringi = (PFNGLGETSTRINGIPROC) get_proc_address("glGetStringi"); | |
200 | + if(!glGetStringi) | |
201 | + return 0; | |
202 | + | |
203 | + | |
204 | + glGetIntegerv(GL_NUM_EXTENSIONS, &nbExtensions); | |
205 | + for(i = 0; i < nbExtensions; i++) | |
206 | + { | |
207 | + const GLubyte *strExtension = glGetStringi(GL_EXTENSIONS, i); | |
208 | + if(strcmp(strExtension, (const GLubyte *)name) == 0) | |
209 | + return 1; | |
210 | + } | |
211 | + | |
212 | + return 0; | |
213 | +} | |
214 | + | |
194 | 215 | static int check_tfp_extensions(VADriverContextP ctx) |
195 | 216 | { |
196 | 217 | const char *gl_extensions; |
197 | 218 | const char *glx_extensions; |
198 | 219 | |
199 | 220 | gl_extensions = (const char *)glGetString(GL_EXTENSIONS); |
200 | - if (!check_extension("GL_ARB_texture_non_power_of_two", gl_extensions)) | |
221 | + if (!check_extension("GL_ARB_texture_non_power_of_two", gl_extensions) && !check_extension3("GL_ARB_texture_non_power_of_two")) | |
201 | 222 | return 0; |
202 | 223 | |
203 | 224 | glx_extensions = glXQueryExtensionsString(ctx->native_dpy, ctx->x11_screen); |
204 | 225 | if (!check_extension("GLX_EXT_texture_from_pixmap", glx_extensions)) |
205 | 226 | return 0; |
227 | + | |
206 | 228 | return 1; |
207 | 229 | } |
208 | 230 |
@@ -211,10 +233,11 @@ static int check_fbo_extensions(VADriverContextP ctx) | ||
211 | 233 | const char *gl_extensions; |
212 | 234 | |
213 | 235 | gl_extensions = (const char *)glGetString(GL_EXTENSIONS); |
214 | - if (check_extension("GL_ARB_framebuffer_object", gl_extensions)) | |
236 | + if (check_extension("GL_ARB_framebuffer_object", gl_extensions) || check_extension3("GL_ARB_framebuffer_object")) | |
215 | 237 | return 1; |
216 | - if (check_extension("GL_EXT_framebuffer_object", gl_extensions)) | |
238 | + if (check_extension("GL_EXT_framebuffer_object", gl_extensions) || check_extension3("GL_EXT_framebuffer_object")) | |
217 | 239 | return 1; |
240 | + | |
218 | 241 | return 0; |
219 | 242 | } |
220 | 243 |