[vlc-devel] [PATCH 12/13] vout/opengl: add a new API to configure fragment shaders

Thomas Guillem thomas at gllm.fr
Mon Dec 12 17:03:53 CET 2016


Add a new struct: opengl_fmt_cfg_t. This struct can be used to configure a
fragment shader in function of a video_format_t. The main objective is to allow
developers to add support for HW specific chromas in separate files.
---
 modules/video_output/opengl/internal.h | 64 ++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index 25f5a55..42a7e96 100644
--- a/modules/video_output/opengl/internal.h
+++ b/modules/video_output/opengl/internal.h
@@ -113,4 +113,68 @@ typedef struct {
 
 } vout_display_opengl_api_t;
 
+typedef struct opengl_fmt_cfg_t opengl_fmt_cfg_t;
+
+/*
+ * Callback to initialize a opengl_fmt_cfg_t struct
+ *
+ * The function implementing this callback should initialize a fragment_shader
+ * in function of the video format.
+ *
+ * \param api function pointer to the GL API
+ * \param fmt video format
+ * \param fc opengl format configuration that need to be filled on success
+ * \return VLC_SUCCESS or a VLC error
+ */
+typedef int (*opengl_fmt_cfg_init_cb)(const vout_display_opengl_api_t *api,
+                                      const video_format_t *fmt,
+                                      opengl_fmt_cfg_t *fc);
+
+/*
+ * Structure that is filled by a opengl_fmt_cfg_init_cb function
+ */
+struct opengl_fmt_cfg_t
+{
+    /* Video chroma used by this configuration, cannot be 0 */
+    vlc_fourcc_t chroma;
+    /* Texture mapping (usually: GL_TEXTURE_2D), cannot be 0 */
+    GLenum tex_target;
+
+    /* glTex*Image2D internalFormat param (if tex_target is a 2D texture) */
+    GLint  tex_internal;
+    /* glTex*Image2D format param (if tex_target is a 2D texture) */
+    GLenum tex_format;
+    /* glTex*Image2D type param (if tex_target is a 2D texture) */
+    GLenum tex_type;
+
+    /* The compiled fragment shader, cannot be 0 */
+    GLuint fragment_shader;
+
+    /* Private context */
+    void *priv;
+
+    /*
+     * Callback to prepare the fragment shader
+     *
+     * This function pointer cannot be NULL. This callback can be used to
+     * specify values of uniform variables for the program object that is
+     * attached to the configured shared.
+     *
+     * \param api function pointer to the GL API
+     * \param fc opengl format configuration
+     * \param program current program object
+     */
+    void (*pf_prepare_shader)(const vout_display_opengl_api_t *api,
+                              const opengl_fmt_cfg_t *fc, GLuint program);
+
+    /*
+     * Callback to release the shader and the private context
+     *
+     * This function pointer cannot be NULL.
+     * \param api function pointer to the GL API
+     * \param fc opengl format configuration
+     */
+    void (*pf_release)(const vout_display_opengl_api_t *api,
+                       const opengl_fmt_cfg_t *fc);
+};
 #endif /* include-guard */
-- 
2.10.2



More information about the vlc-devel mailing list