Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 1 | From be426ad76c3e486f1364dd292cf8e1c633c80e91 Mon Sep 17 00:00:00 2001 |
| 2 | From: Vincent Davis Jr <vince@underview.tech> |
| 3 | Date: Thu, 8 Dec 2022 10:39:47 -0600 |
| 4 | Subject: [PATCH] libavdevice: opengl_enc.c update dynamic function loader |
| 5 | |
| 6 | Upstream-Status: Inappropriate |
| 7 | |
| 8 | RPI-Distro repo clones original ffmpeg and applies patches to enable |
| 9 | raspiberry pi support. |
| 10 | |
| 11 | For meta-raspberrypi ffmpeg builds, when opengl |
| 12 | is enabled do_compile will fail. Reasion is that |
| 13 | glGetProcAddress is undefined in either GLES2/gl2.h |
| 14 | or GLES2/gl2ext.h. |
| 15 | |
| 16 | define SelectedGetProcAddress to SDL_GL_GetProcAddress |
| 17 | if sdl2 is included. If not included, define function |
| 18 | pointers at compile time versus runtime. |
| 19 | |
| 20 | Signed-off-by: Vincent Davis Jr <vince@underview.tech> |
| 21 | --- |
| 22 | libavdevice/opengl_enc.c | 44 ++++++++++++++++++++++++++++++++++++---- |
| 23 | 1 file changed, 40 insertions(+), 4 deletions(-) |
| 24 | |
| 25 | diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c |
| 26 | index 2bdb8da7..eabc1bf8 100644 |
| 27 | --- a/libavdevice/opengl_enc.c |
| 28 | +++ b/libavdevice/opengl_enc.c |
| 29 | @@ -37,12 +37,13 @@ |
| 30 | #include <OpenGL/gl3.h> |
| 31 | #elif HAVE_ES2_GL_H |
| 32 | #include <ES2/gl.h> |
| 33 | -#else |
| 34 | -#include <GL/gl.h> |
| 35 | -#include <GL/glext.h> |
| 36 | #endif |
| 37 | #if HAVE_GLXGETPROCADDRESS |
| 38 | #include <GL/glx.h> |
| 39 | +#else |
| 40 | +#define GL_GLEXT_PROTOTYPES |
| 41 | +#include <GLES2/gl2.h> |
| 42 | +#include <GLES2/gl2ext.h> |
| 43 | #endif |
| 44 | |
| 45 | #if CONFIG_SDL2 |
| 46 | @@ -493,8 +494,14 @@ static int av_cold opengl_load_procedures(OpenGLContext *opengl) |
| 47 | |
| 48 | #if HAVE_GLXGETPROCADDRESS |
| 49 | #define SelectedGetProcAddress glXGetProcAddress |
| 50 | +#define CAN_DYNAMIC_LOAD 1 |
| 51 | #elif HAVE_WGLGETPROCADDRESS |
| 52 | #define SelectedGetProcAddress wglGetProcAddress |
| 53 | +#elif CONFIG_SDL2 |
| 54 | +#define SelectedGetProcAddress SDL_GL_GetProcAddress |
| 55 | +#define CAN_DYNAMIC_LOAD 1 |
| 56 | +#else |
| 57 | +#define CAN_DYNAMIC_LOAD 0 |
| 58 | #endif |
| 59 | |
| 60 | #define LOAD_OPENGL_FUN(name, type) \ |
| 61 | @@ -504,7 +511,8 @@ static int av_cold opengl_load_procedures(OpenGLContext *opengl) |
| 62 | return AVERROR(ENOSYS); \ |
| 63 | } |
| 64 | |
| 65 | -#if CONFIG_SDL2 |
| 66 | +#if CAN_DYNAMIC_LOAD |
| 67 | +#if CONFIG_SDL2 |
| 68 | if (!opengl->no_window) |
| 69 | return opengl_sdl_load_procedures(opengl); |
| 70 | #endif |
| 71 | @@ -534,9 +542,37 @@ static int av_cold opengl_load_procedures(OpenGLContext *opengl) |
| 72 | LOAD_OPENGL_FUN(glGetShaderInfoLog, FF_PFNGLGETSHADERINFOLOGPROC) |
| 73 | LOAD_OPENGL_FUN(glEnableVertexAttribArray, FF_PFNGLENABLEVERTEXATTRIBARRAYPROC) |
| 74 | LOAD_OPENGL_FUN(glVertexAttribPointer, FF_PFNGLVERTEXATTRIBPOINTERPROC) |
| 75 | +#else |
| 76 | + procs->glActiveTexture = glActiveTexture; |
| 77 | + procs->glGenBuffers = glGenBuffers; |
| 78 | + procs->glDeleteBuffers = glDeleteBuffers; |
| 79 | + procs->glBufferData = glBufferData; |
| 80 | + procs->glBindBuffer = glBindBuffer; |
| 81 | + procs->glGetAttribLocation = glGetAttribLocation; |
| 82 | + procs->glGetUniformLocation = glGetUniformLocation; |
| 83 | + procs->glUniform1f = glUniform1f; |
| 84 | + procs->glUniform1i = glUniform1i; |
| 85 | + procs->glUniformMatrix4fv = glUniformMatrix4fv; |
| 86 | + procs->glCreateProgram = glCreateProgram; |
| 87 | + procs->glDeleteProgram = glDeleteProgram; |
| 88 | + procs->glUseProgram = glUseProgram; |
| 89 | + procs->glLinkProgram = glLinkProgram; |
| 90 | + procs->glGetProgramiv = glGetProgramiv; |
| 91 | + procs->glGetProgramInfoLog = glGetProgramInfoLog; |
| 92 | + procs->glAttachShader = glAttachShader; |
| 93 | + procs->glCreateShader = glCreateShader; |
| 94 | + procs->glDeleteShader = glDeleteShader; |
| 95 | + procs->glCompileShader = glCompileShader; |
| 96 | + procs->glShaderSource = glShaderSource; |
| 97 | + procs->glGetShaderiv = glGetShaderiv; |
| 98 | + procs->glGetShaderInfoLog = glGetShaderInfoLog; |
| 99 | + procs->glEnableVertexAttribArray = glEnableVertexAttribArray; |
| 100 | + procs->glVertexAttribPointer = (FF_PFNGLVERTEXATTRIBPOINTERPROC) glVertexAttribPointer; |
| 101 | +#endif |
| 102 | |
| 103 | return 0; |
| 104 | |
| 105 | +#undef CAN_DYNAMIC_LOAD |
| 106 | #undef SelectedGetProcAddress |
| 107 | #undef LOAD_OPENGL_FUN |
| 108 | } |
| 109 | -- |
| 110 | 2.38.1 |
| 111 | |