[vlc-commits] opengl: converter: change pf_allocate_texture

Thomas Guillem git at videolan.org
Fri Feb 3 09:58:10 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Feb  3 09:56:41 2017 +0100| [559a682df30b6c445dd5f3823c4a4ca3fc570d20] | committer: Thomas Guillem

opengl: converter: change pf_allocate_texture

This callback is now used to allocate all textures. This will allow more
control on the converter side (some API allocate textures by batch).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=559a682df30b6c445dd5f3823c4a4ca3fc570d20
---

 modules/video_output/opengl/converters.c  | 19 ++++++++++---------
 modules/video_output/opengl/internal.h    | 16 +++++++---------
 modules/video_output/opengl/vout_helper.c | 21 +++++++++------------
 3 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/modules/video_output/opengl/converters.c b/modules/video_output/opengl/converters.c
index d8112a5..cb4a3e4 100644
--- a/modules/video_output/opengl/converters.c
+++ b/modules/video_output/opengl/converters.c
@@ -699,15 +699,16 @@ error:
 #endif /* VLCGL_HAS_PBO */
 
 static int
-tc_common_allocate_texture(const opengl_tex_converter_t *tc, GLuint texture,
-                           unsigned tex_idx, const GLsizei tex_width,
-                           const GLsizei tex_height)
+tc_common_allocate_textures(const opengl_tex_converter_t *tc, GLuint *textures,
+                            const GLsizei *tex_width, const GLsizei *tex_height)
 {
-    (void) texture;
-
-    glTexImage2D(tc->tex_target, 0, tc->texs[tex_idx].internal,
-                 tex_width, tex_height, 0, tc->texs[tex_idx].format,
-                 tc->texs[tex_idx].type, NULL);
+    for (unsigned i = 0; i < tc->tex_count; i++)
+    {
+        glBindTexture(tc->tex_target, textures[i]);
+        glTexImage2D(tc->tex_target, 0, tc->texs[i].internal,
+                     tex_width[i], tex_height[i], 0, tc->texs[i].format,
+                     tc->texs[i].type, NULL);
+    }
     return VLC_SUCCESS;
 }
 
@@ -820,7 +821,7 @@ common_init(opengl_tex_converter_t *tc)
 
     tc->pf_update       = tc_common_update;
     tc->pf_release      = tc_common_release;
-    tc->pf_allocate_texture = tc_common_allocate_texture;
+    tc->pf_allocate_textures = tc_common_allocate_textures;
 
 #ifdef VLCGL_HAS_PBO
     const bool supports_pbo = tc->api->BufferStorage
diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index 2658833..fc1ee22 100644
--- a/modules/video_output/opengl/internal.h
+++ b/modules/video_output/opengl/internal.h
@@ -212,22 +212,20 @@ struct opengl_tex_converter_t
     void *priv;
 
     /*
-     * Callback to allocate data for a bound texture
+     * Callback to allocate data for bound textures
      *
      * This function pointer can be NULL. Software converters should call
-     * glTexImage2D() to allocate texture data (it will be deallocated by the
+     * glTexImage2D() to allocate textures data (it will be deallocated by the
      * caller when calling glDeleteTextures()).
      *
      * \param fc OpenGL tex converter
-     * \param texture bound texture
-     * \param tex_idx texture index
-     * \param tex_width texture width
-     * \param tex_height texture height
+     * \param textures array of textures to bind (one per plane)
+     * \param tex_width array of tex width (one per plane)
+     * \param tex_height array of tex height (one per plane)
      * \return VLC_SUCCESS or a VLC error
      */
-    int (*pf_allocate_texture)(const opengl_tex_converter_t *fc, GLuint texture,
-                               unsigned tex_idx, const GLsizei tex_width,
-                               const GLsizei tex_height);
+    int (*pf_allocate_textures)(const opengl_tex_converter_t *tc, GLuint *textures,
+                                const GLsizei *tex_width, const GLsizei *tex_height);
 
     /*
      * Callback to allocate a picture pool
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index d573750..0ae232e 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -407,19 +407,16 @@ GenTextures(const opengl_tex_converter_t *tc,
         glTexParameteri(tc->tex_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
         glTexParameteri(tc->tex_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
         glTexParameteri(tc->tex_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-        if (tc->pf_allocate_texture != NULL)
+    }
+
+    if (tc->pf_allocate_textures != NULL)
+    {
+        int ret = tc->pf_allocate_textures(tc, textures, tex_width, tex_height);
+        if (ret != VLC_SUCCESS)
         {
-            int ret = tc->pf_allocate_texture(tc, textures[i], i, tex_width[i],
-                                              tex_height[i]);
-            if (ret != VLC_SUCCESS)
-            {
-                if (i > 0)
-                {
-                    glDeleteTextures(i, textures);
-                    memset(textures, 0, tc->tex_count * sizeof(GLuint));
-                }
-                return ret;
-            }
+            glDeleteTextures(tc->tex_count, textures);
+            memset(textures, 0, tc->tex_count * sizeof(GLuint));
+            return ret;
         }
     }
     return VLC_SUCCESS;



More information about the vlc-commits mailing list