Skip to content
Snippets Groups Projects
  1. Apr 01, 2022
  2. Mar 31, 2022
  3. Mar 25, 2022
    • Niklas Haas's avatar
      utils/libav: use new acquire/release API · cd696a88
      Niklas Haas authored
      This holds on to the frame for a shorter duration, allowing it to
      interop more easily with e.g. libavcodec filters. Note that this still
      isn't thread safe (cf. pending upstream FFmpeg changes), but a necessary
      step in that direction one way or the other.
      cd696a88
    • Niklas Haas's avatar
      renderer: allow acquiring/releasing frames on-demand · 432ed86a
      Niklas Haas authored
      This is particularly designed for hardware decoding and such, as well as
      interop with e.g. lavfi vulkan. In either case, we don't want to
      permanently consider frames mapped for the entire duration that they may
      stick around in e.g. pl_queue, but rather dynamically acquire/release
      them immediately surrounding the actual usage site.
      
      This implementation is also designed to guarantee that only one frame
      will ever be acquired at a time, which allows us to support some hwdecs
      without requiring multiple mappers.
      
      Fixes videolan/libplacebo#194
      432ed86a
    • Niklas Haas's avatar
      renderer: allow re-using pass_init without image · ce2191db
      Niklas Haas authored
      A bit ugly logic-wise but better for future extensibility, specifically
      because I plan on using `pass_init` to e.g. acquire potentially-unmapped
      frames.
      ce2191db
    • Niklas Haas's avatar
      renderer: change draw_empty_overlays output stage · 1dfb4df1
      Niklas Haas authored
      This is conceptually not really a frame drawing pass, but a blend pass
      (with 0 frames to be blended).
      1dfb4df1
    • Niklas Haas's avatar
      renderer: reorganize pass init code into common helpers · 9e1ff65f
      Niklas Haas authored
      Makes this logic easier to extend in the future, and crucially also
      provides a common place to do uninit code from.
      9e1ff65f
  4. Mar 20, 2022
  5. Mar 18, 2022
  6. Mar 14, 2022
    • Niklas Haas's avatar
      gpu: move shader logging to the gpu.c wrappers · 18f08b3d
      Niklas Haas authored
      I wanted to change the way this is handled such that shaders also get
      printed when being re-loaded from the cache. Rather than re-adding the
      same code to all three GPU instances, I decided it makes more sense to
      just move it to the common helper code.
      
      This does unfortunately re-order most shader debug messages such that
      the errors get printed _above_ the re-print of the source code (on
      errors), but this was the status quo anyways for vulkan. I can live with
      it.
      
      Closes #192
      18f08b3d
  7. Mar 13, 2022
    • Niklas Haas's avatar
      vulkan: refactor queue family APIs · 157e4905
      Niklas Haas authored
      Looking at this API again, it really makes no sense to leave the
      "non-unique" queues unset. Users can trivially recover a check for this
      condition by just doing an equality test on the queues.
      
      Testing for single family vs multi-family can also be done trivially by
      testing for `pl_vulkan.num_queues`.
      
      And lastly, API users (FFmpeg etc.) actually need all queues to be set.
      So pre-setting them to the correctly defaulted values is actually
      hugely useful.
      
      Since we're setting all queues anyway, might as well also set them
      unconditionally in the internal structs. Rewrite the queue family
      selection code to make it cleaner overall.
      157e4905
    • Niklas Haas's avatar
      vulkan/context: properly set pl_vulkan.queue_transfer · 9bdcba19
      Niklas Haas authored
      This wasn't set at all. Oops. Also move the shared code between
      pl_vulkan_create and pl_vulkan_import into a common helper, where it
      should have been all this time.
      
      I have no idea why it wasn't. Somebody shoot the author of this code.
      9bdcba19
    • Niklas Haas's avatar
      vulkan: work around MSAN runtime failures · d5a857d3
      Niklas Haas authored
      I hate MSAN sometimes. This should at least be a permanent solution to
      the issue.
      d5a857d3
  8. Mar 10, 2022
    • Niklas Haas's avatar
      renderer: correctly initialize neutral chroma · 64aa488b
      Niklas Haas authored
      This should not be exactly 0.5, but a value slightly higher than 0.5
      (depending on the image bit depth).
      
      It's possible that we should go with the mpv approach of just setting
      the chroma channels to 0 altogether for grayscale formats. But that
      would require some sort of API change, which I'm unwilling to do as part
      of this commit.
      
      The 0.5 constant for floating point YCbCr is almost surely not actually
      correct, but that preserves the status quo. cf. #155
      
      Fixes https://github.com/mpv-player/mpv/issues/9969
      64aa488b
  9. Mar 08, 2022
    • Niklas Haas's avatar
      ci: enable debug-abort in CI · 5cfa520c
      Niklas Haas authored
      5cfa520c
    • Niklas Haas's avatar
      meson: add debug-abort option · 448165a7
      Niklas Haas authored
      It's sometimes more convenient to get coredumps instead of plain stack
      traces, especially if you didn't have gdb attached to the process at the
      time.
      
      Note that, asymmetrically, we add pl_debug_abort() to the vulkan debug
      callbacks but not the opengl debug callbacks. This is motivated by
      vulkan debug errors mainly corresponding to API usage violations (should
      never happen!), whereas OpenGL debug errors mainly correspond to runtime
      errors (e.g. invalid GLSL files), which should not trigger an abort().
      
      (Note that you can also `(gdb) break pl_log_stack_trace`)
      448165a7
    • Niklas Haas's avatar
      shaders/h274: fix & operator for older GLSL · 4ab85e0f
      Niklas Haas authored
      Older GLSL can't auto-promote 0xFF to 0xFFu. Sigh.
      4ab85e0f
  10. Mar 05, 2022
    • Niklas Haas's avatar
      shaders/h274: pack comp values more efficiently · e3198b1e
      Niklas Haas authored
      Instead of wasting 3 whole 32-bit integers on this (which probably
      becomes 4 integers), pack them into a single 32-bit integer.
      
      Probably doesn't matter much, but hey, it's better, right?
      e3198b1e
    • Niklas Haas's avatar
      shaders/h274: correctly infer comp model values · 03d5b3b9
      Niklas Haas authored
      The ITU-R H.274 spec specifies what values to infer when the
      num_model_values is lower than the required number of components.
      
      As an aside, we also never correctly adapted the model values for
      chroma planes. We also still don't correctly adapt them for subsampled
      planes, but that is a problem for a future commit.
      
      Lastly, the current behavior technically breaks on negative scale values
      (which underflow to huge unsigned int values). Fix this by switching
      from uvec to ivec.
      
      Fixes #187
      03d5b3b9
  11. Mar 02, 2022
    • Niklas Haas's avatar
      vulkan: drop DRM legacy hacks · b840fbdc
      Niklas Haas authored
      So, these flat out just don't work. Mesa supports DRM modifiers these
      days, so the only driver this is useful for is AMDVLK. And I'd rather
      AMD just update their driver to support DRM modifiers, than having to
      play driver guesswork with trying to figure out the right set of
      parameters to pass it.
      
      I'm pretty sure that the validation layers will give us hell regardless
      of what we do, since using DRM textures without proper modifiers results
      in violating all sorts of offset-related invariants one way or the
      other. And simply disabling it also doesn't work, we get visibly corrupt
      output.
      
      Oh well. Closes #186
      b840fbdc
  12. Feb 27, 2022
    • Niklas Haas's avatar
      renderer: fix dithering calculation · f911efb9
      Niklas Haas authored
      This code had several bugs in one:
      
      1. It was looking at `repr`, when it should have been looking at
         `target->repr` as `repr` got normalized previously.
      2. It was looking at `sample_depth` when it should have been looking at
         `color_depth`.
      3. It was using `depth <= 16` even though the documentation claims that
         we only dither to below-16 bit FBOs.
      f911efb9
  13. Feb 25, 2022
    • Niklas Haas's avatar
      shaders/sampling: fix oversample shader · c71bbe1c
      Niklas Haas authored
      No idea what was wrong with this, but it wasn't producing the expected
      results at all. Rewrote it from the ground up to be correct, before
      simplifying the math to get it as close as possible to the previous
      state again.
      
      Can probably be simplified further, but this doesn't need to be
      super-optimized anyway.
      
      Fixes #185
      c71bbe1c
    • Niklas Haas's avatar
      shaders/custom: add parity with mpv shader ops · 5523a8f8
      Niklas Haas authored
      mpv introduced the = and % operators in 1d0349d3b. I personally disagree
      with the implementation of = as `==`, and decided to instead use a fuzzy
      equality test.
      5523a8f8
  14. Feb 24, 2022
    • Niklas Haas's avatar
      renderer: make rrx calculation more consistent · 7f0af9f8
      Niklas Haas authored
      The convention throughout the rest of the code is to multiply ratios,
      not divide them. Also simplifies the computation.
      7f0af9f8
    • Niklas Haas's avatar
      gpu: check for buffer size overflow · 66555957
      Niklas Haas authored
      This failed to catch a real bug, because the check overflowed back to a
      legal value.
      66555957
    • Niklas Haas's avatar
      renderer: support native plane flipping · b542f23e
      Niklas Haas authored
      This is a much cleaner way of handling flipped rendering on e.g. OpenGL,
      requiring less intervention from the user side.
      
      In addition, this can also be used to support planes with negative
      stride. I may even revisit the type of `pl_plane_data.row_stride` to
      support ptrdiff_t, but for now, I want to avoid breaking the API more.
      (And the buffer path requires special handling from the user anyway)
      
      It's worth pointing out that this implementation has a tiny
      suboptimality: since plane flipping is only done as part of plane
      scaling, this means it can't be merged with the debanding shader. Fixing
      that would require a slight rewrite of the code involved, but I don't
      really care to do it at the moment.
      
      Lastly, also fix the libav/dav1d helpers to respect negative strides.
      
      Closes videolan/libplacebo#183
      b542f23e
  15. Feb 22, 2022
    • Niklas Haas's avatar
      shaders/sampling: expand polar sampling fast path · cdc84b6d
      Niklas Haas authored
      Instead of calculating wbase by hard-coding a dependency on the pos_map
      function, communicate the appropriate `base` from the per-pixel
      calculated values of the correct shader invocation.
      
      Compute the correct shader invocation based whether or not the src rect
      is flipped, thus allowing this shader to work properly with flipped
      rects.
      
      Removes both of the current fast path restrictions, allowing the compute
      shader to work with flipped rects and even the sampler2D interface.
      cdc84b6d
  16. Feb 21, 2022
    • Niklas Haas's avatar
      shaders/colorspace: make gamut mapping defaults more conservative · b5c06aa6
      Niklas Haas authored
      PL_GAMUT_DARKEN had a lot of undesirable side effects. It's not a good
      way of fixing this problem, and definitely not something we should hoist
      on users by default if "HDR is too dark" is already the persistent
      complaint around HDR.
      
      Clipping is probably the most conservative default. It doesn't introduce
      the weird white-ish hue shifts that people complain about with regards
      to DESATURATE. It's also the closest to what users expect from naive
      implementations.
      
      Not bumping the API version for this because it doesn't change the
      API/ABI, even though it affects the public header.
      b5c06aa6
    • Niklas Haas's avatar
      shaders/colorspace: add better tone mapping fallback · 01a04c01
      Niklas Haas authored
      Hard-coded to hable for now. Ideally, users should be using a proper
      state object here. But this is way better than the current status quo of
      basically "breaking" (the NULL gets ignored, so the tone mapping
      function somehow ends up being a simple sqrt() function, which in a
      hilarious twist of fate actually doesn't look _too_ awful)
      
      Ideally it would be nice to have more pure GLSL fallbacks for common
      functions. But it's also worth noting that e.g. the LUT-based hable uses
      BT.1886 BPC (instead of linear stretching), making it technically
      distinct.
      
      Fixes #184
      01a04c01
    • Niklas Haas's avatar
      shaders/custom: deprecated PL_HOOK_PRE_OVERLAY · 6abe0884
      Niklas Haas authored
      This was supposed to be part of the previous commit, but I forgot to
      update the remote branch before merging. My bad.
      6abe0884
  17. Feb 19, 2022
    • Niklas Haas's avatar
      renderer: refactor overlays · a857cce8
      Niklas Haas authored
      Instead of forcing per-image overlays to be rendered at image
      resolution, allow them to be specified with respect to whatever
      reference frame the user wants.
      
      Additionally, stop rendering overlays directly onto image frames (even
      at image resolution), and instead render them onto the final image. This
      solves various bugs caused by overlays being blended directly onto
      images that are being processed by hooks, at the cost of reducing
      overlay scaling to bilinear quality.
      
      Add some common.c boilerplate to support the new logic.
      a857cce8
    • Niklas Haas's avatar
      common: fix outdated comment · f5b333bd
      Niklas Haas authored
      pl_rotation_matrix never made it into any public code.
      f5b333bd
    • Niklas Haas's avatar
      gpu: fix emulated upload path alpha channel · 135ba1ea
      Niklas Haas authored
      Without this change, uploading e.g. an rgb8 image to an rgba8 texture
      causes the alpha channel to end up as 0, which is definitely not the
      intended result (sampling back from this texture should be identical to
      sampling from a true rgb8 texture).
      135ba1ea
  18. Feb 18, 2022
    • Niklas Haas's avatar
      renderer: allow overriding FBO bit depth · 9dd3b48f
      Niklas Haas authored
      This implies moving the fbofmt decision-making from the pl_renderer
      creation time to the pl_render_params, which means it gets re-inferred
      per frame. Moves some decision making logic around slightly.
      
      Closes #182
      9dd3b48f
  19. Feb 12, 2022
  20. Feb 11, 2022
    • Niklas Haas's avatar
      utils/upload: drop unnecessary asserts · d74ea8b3
      Niklas Haas authored
      These used to be relevant in the past, but past refactors have gradually
      loosened up these restrictions to the point where it's no longer
      necessary to check anything at all. Even in the case that it would be
      necessary, the `pl_tex_upload` call itself would be responsible for
      appropriate error checking, so asserting here is always wrong.
      d74ea8b3
  21. Feb 10, 2022
Loading