1. 07 Feb, 2020 40 commits
    • Romain Vimont's avatar
      opengl: merge fragment_shaders.c into sampler.c · 4a332189
      Romain Vimont authored
      The code in fragment_shaders.c is part of the implementation of the
      sampler: it generates the fragment shader to expose a GLSL function
      "vlc_texture(vec2 coords)".
    • Romain Vimont's avatar
      opengl: merge DrawWithShaders() into _Draw() · ee4e981d
      Romain Vimont authored
      The function vlc_gl_renderer_Draw() (almost) just called
      DrawWithShaders(). There is no need for a separate function.
    • Romain Vimont's avatar
      opengl: do not pass the picture_t to the renderer · b58e0f95
      Romain Vimont authored
      The renderer is expected to be independant of the input picture format.
      Instead, update the sampler directly.
    • Romain Vimont's avatar
      opengl: remove all interop usages from renderer · 5ce72fad
      Romain Vimont authored
      Remove the remaining usage of interop from renderer.
      Now, the renderer only need to use the sampler.
    • Romain Vimont's avatar
      opengl: move sampler ownership to vgl · c8dfc1e4
      Romain Vimont authored
      The sampler were owned by the renderer.
      Move it to vgl, so that the renderer never have to handle an interop
      instance directly.
    • Romain Vimont's avatar
      opengl: expose video format in sampler · 25952f33
      Romain Vimont authored
      For convenience, expose the video format directly in sampler.
    • Romain Vimont's avatar
      opengl: update pictures from sampler · cb46633f
      Romain Vimont authored
      The renderer should not know the interop, so it may not be responsible
      to upload the textures.
      Move the pictures update to sampler.
    • Romain Vimont's avatar
      opengl: move orientation matrix init to sampler · 36c45cd8
      Romain Vimont authored
      The orentation matrix is managed by the sampler. Move its initialization
      to opengl_fragment_shader_init() (called by the sampler).
    • Romain Vimont's avatar
      opengl: move sampler initialization to constructor · 2e4b12f9
      Romain Vimont authored
      Move opengl_fragment_shader_init() call from renderer to sampler.
    • Romain Vimont's avatar
      opengl: generate the extensions from the sampler · c1b9054c
      Romain Vimont authored
      The sampler handles the input pictures, so it is also responsible for
      generating the necessary GLSL extensions code (if any).
    • Romain Vimont's avatar
      opengl: store fragment shader in sampler · 2aabaa1c
      Romain Vimont authored
      The function opengl_fragment_shader_init() both initializes the
      and creates the fragment shader.
      To be able to move its initialization outside the renderer, store it in
      the sampler instead of returning it. This will also allow to provide the
      "extensions" part of the fragment shader as a separate string.
    • Romain Vimont's avatar
      opengl: only use sampler from fragment_shaders.c · d97f2b92
      Romain Vimont authored
      The renderer instance is not needed anymore.
    • Romain Vimont's avatar
      opengl: remove interop reference from renderer · 12cf3873
      Romain Vimont authored
      Remove the (weak) reference to the interop from the renderer structure.
      The interop is still accessed explicitly from the renderer via the
      sampler structure for now.
    • Romain Vimont's avatar
      opengl: expose functions to call sampler callbacks · 735ec23b
      Romain Vimont authored
      The fact that the sampler use internal function pointers (instead of
      if-blocks for example) is an internal detail.
    • Romain Vimont's avatar
      opengl: simplify pf_prepare_shader() · 30207710
      Romain Vimont authored
      Remove tex_width and tex_height parameters, as they are either unused or
      accessible from the sampler itself.
    • Romain Vimont's avatar
      opengl: remove alpha parameter from prepare_shader · b0fff4f0
      Romain Vimont authored
      The alpha value was used to render subpictures, which are now drawn by
      the subpictures renderer using its own fragment shader.
    • Romain Vimont's avatar
      opengl: load uniforms from sampler · 64d71b43
      Romain Vimont authored
      Load uniforms related to sampler from sampler->pf_prepare_shader.
    • Romain Vimont's avatar
      opengl: fetch locations from sampler · 9c10beb4
      Romain Vimont authored
      Fetch locations related to sampler from sampler->pf_fetch_locations.
    • Romain Vimont's avatar
      opengl: move callbacks to sampler · 44bffa33
      Romain Vimont authored
      The sampler is responsible to fetch its location and initialize its
      textures and uniforms.
    • Romain Vimont's avatar
      opengl: define identity matrices in gl_util.h · 7a24bee4
      Romain Vimont authored
      This will allow to use them from several files.
    • Romain Vimont's avatar
      opengl: reference common objects from sampler · 79fe0356
      Romain Vimont authored
      For convenience, expose the vlc_gl_t and the OpenGL virtual table in
    • Romain Vimont's avatar
      opengl: extract sampler creation and destruction · 1806de15
      Romain Vimont authored
      Extract sampler creation and destruction to separate functions.
    • Romain Vimont's avatar
      opengl: reference interop from sampler · 1e3833ae
      Romain Vimont authored
      This allows to use an interop instance without a renderer.
    • Romain Vimont's avatar
      opengl: use the interop format in renderer · 81ccbfbb
      Romain Vimont authored
      The interop initializes its own video_format_t from the input format.
      In the renderer initialization, always use this updated format. This
      avoids an additional format parameter, which may be confusing.
    • Romain Vimont's avatar
      opengl: move interop ownership to vgl · f9812e0e
      Romain Vimont authored
      The interop instances were owned by the renderers.
      To prepare for making the renderers independant of the input picture
      (in particular, independant of the interop), make the vgl own the
      interop instances.
    • Romain Vimont's avatar
      opengl: extract renderer fields to sampler · f9a952ea
      Romain Vimont authored
      Move the fields necessary to retrieve a picture pixel from its
    • Romain Vimont's avatar
      opengl: move fragment shader creation to renderer · dfc2d11a
      Romain Vimont authored
      Make the renderer create the vertex shader, using the vlc_texture()
      function generated by fragment_shader.c.
    • Romain Vimont's avatar
      opengl: extract vlc_texture() · 7836e06c
      Romain Vimont authored
      Extract a fragment shader function to provide the pixel color of a
      picture from pictures coordinates.
      Concretely, it replaces:
          void main(void) {
           vec3 pic_hcoords = vec3(PicCoords, 1.0);
           gl_FragColor = result * FillColor;
          vec4 vlc_texture(vec2 pic_coords) {
           vec3 pic_hcoords = vec3(pic_coords, 1.0);
           return result * FillColor;
          void main() {
           gl_FragColor = vlc_texture(PicCoords);
    • Romain Vimont's avatar
      opengl: remove unused source format parameter · 7cf9b68d
      Romain Vimont authored
      The video_format_t parameter of vout_display_opengl_Display() is not
      used anymore. Remove it.
    • Romain Vimont's avatar
      opengl: move paddings computation to _Prepare() · df210b20
      Romain Vimont authored
      Texture paddings were computed in _Display(), while the picture format
      is known in _Prepare().
      This will allow to remove the video_format_t parameter of _Display().
    • Romain Vimont's avatar
      opengl: move down vlc_gl_renderer_Prepare() · 9209511e
      Romain Vimont authored
      It will be modified to depend on static functions. Move it below them.
      This will make the diff more readable.
    • Romain Vimont's avatar
      opengl: merge successive loops · a040e072
      Romain Vimont authored
      After the previous changes, two successive loops iterating tex_count
      times can now be merged into one.
    • Romain Vimont's avatar
      opengl: apply stereo transform using a matrix · 15b9a0d3
      Romain Vimont authored
      The multiview mode (stereo) was applied by changing the texture
      paddings to crop only the left eye.
      The problem is that these texture paddings are specific to the input
      picture, while the stereo mode is specific to the renderer, which should
      be independent of the input picture.
      To separate these concerns, apply the stereo mode using a matrix to
      transform the texture coordinates from the renderer.
    • Romain Vimont's avatar
      opengl: apply orientation in fragment shader · 5ef030bf
      Romain Vimont authored
      Apply all texture coordinates transformation in the fragment shader.
      This is necessary to be able to implement a renderer independent of the
      input picture (i.e. without even knowing the details) by using a single
      GLSL function "vlc_texture(vec2 pic_coords)".
    • Romain Vimont's avatar
      opengl: setup coords once for all · 5de65d25
      Romain Vimont authored
      Now that the coordinates are independant of paddings (which are
      transmitted via a separate transform matrix), there is no need to
      recompute them when the paddings change.
    • Romain Vimont's avatar
      opengl: convert texture coords in fragment shader · d5f97ca5
      Romain Vimont authored
      A picture is stored in OpenGL textures (one per plane), possibly with
      padding (the texture may be larger than the actual picture).
      The conversion from pictures coordinates to texture coordinates (which
      takes the padding into account) was applied on the input coordinates,
      before the vertex shader. As a consequence, the vertex shader received
      one vector of input texture coordinates per plane (the padding is not
      necessarily the same for all the planes):
          (before this commit)
         picture   texture
         coords    coords        (attributes)      (varyings)
                (1 per plane)
                   (x0, y0) --> MultiTexCoord0     TexCoord0     fragment
         (x,y) --> (x1, y1) --> MultiTexCoord1 --> TexCoord1 --> shader
                   (x2, y2) --> MultiTexCoord2     TexCoord2
      This poses a problem to separate chroma conversion from rendering: the
      renderer should be able to retrieve a pixel color in picture
      coordinates, regarless of the input format or padding.
      To solve this issue, pass the picture coordinates instead of the texture
      coordinates as attribute, and initialize uniform matrices to convert
      from picture to texture coordinates for each plane directly in the
      fragment shader:
          (after this commit)
         coords    (attribute)     (varying)
         (x,y) --> PicCoordsIn --> PicCoords --> fragment shader
                                   TexCoordsMap0 --'||
                      (uniforms)   TexCoordsMap1 ---'|
                                   TexCoordsMap2 ----'
      Note that this also changes the multiplication order of
      (non-commutative) matrices, from (semantically):
          TexCoords = Orientation * TexCoordsMap * PicCoords
          TexCoords = TexCoordsMap * Orientation * PicCoords
      The latter is the correct one: the orientation defines how the input
      picture is rotated, so it must apply to picture coordinates, regardless
      of the actual coordinates in the texture.
      As a side effect, BuildRectangle, BuildSphere and BuildCube are now
      independant of both the number of planes and any texture padding.
      For now, TexCoordsMap is computed from the renderer, but the goal is to
      move it to a separate component (a "sampler").
    • Romain Vimont's avatar
      opengl: expose npot support in gl_api · 74b906dd
      Romain Vimont authored
      Expose in vlc_gl_api whether it supports non-power of 2 textures.
    • Romain Vimont's avatar
      opengl: move fields from interop to gl_api · 0c3420e5
      Romain Vimont authored
      The fields is_gles and glexts (extensions) are not specific to interop,
      and may be useful without an interop instance.
    • Romain Vimont's avatar
      opengl: pass vlc_gl_api instead of virtual table · 3ff525c6
      Romain Vimont authored
      Pass the whole structure (which will have new fields soon) to interop
      and renderers, instead of the virtual table only.
    • Romain Vimont's avatar
      opengl: move vtable to vlc_gl_api · 6c540fc0
      Romain Vimont authored
      Use a separate component for storing OpenGL API-specific utils (for now,
      only the vtable).