Skip to content
Snippets Groups Projects
  1. Jan 07, 2021
  2. Jan 06, 2021
    • Niklas Haas's avatar
      vo_gpu: implement frame mixing · 49747db5
      Niklas Haas authored
      This is extremely long overdue for how much of a trivial process it
      turned out to be to actually implement/test it. I'm embarrassed it took
      us this long to get this feature, which was for several years the only
      major roadblock to libplacebo replacing vo_gpu in mpv.
      
      Note that I haven't really tested it on real data, just eyeballed the
      weights to make sure it seems to be doing the right thing.
      
      In the process of testing, I finally sobered about how all of my
      idealized assumptions about the nature of temporal resampling and signal
      theory were quite unpragmatic in practice. I went back to the assumption
      of a ZOH world, in which frames aren't samples "centered" on themselves,
      but effectively, go with the principle of least surprise by behaving the
      way they would on a real LCD: start at timestamp, last until replaced.
      
      In particular, for the convolution-based frame mixers, we assume we're
      actually sampling the start of the frame, not the center of the frame.
      This is, again, to avoid surprising users about their frames being
      unexpectedly blurry in cases where their code is calibrated around a ZOH
      world.
      
      I originally had anticipated to have to write "helper" functions to make
      calculating the correct timestamps etc. easier for the user, but I think
      the current API design is so easy that such a helper function is
      unnecessary.
      
      Note that I also added a new pl_filter_mitchell_clamp to go along with
      it, since clamped mitchell is what mpv's tscale also defaults to.
      (Although I still think NULL is the better default)
      
      Closes #13
      49747db5
  3. Dec 28, 2020
    • Niklas Haas's avatar
      opengl: fix warning on talloc_free · eb012d4b
      Niklas Haas authored
      Whatever.
      eb012d4b
    • Niklas Haas's avatar
      opengl: improve error checking on gl_pass_create · c9affe73
      Niklas Haas authored
      This function could do with an extra gl_check_err, especially on the
      glGetProgramBinary path, since I've observed sporadic failures of that
      in the past.
      c9affe73
    • Niklas Haas's avatar
      bstr: dramatically increase float precision · 9aa63a46
      Niklas Haas authored
      It occurred to me that it really makes no sense to limit the precision
      here, and it *has* bitten us in a number of ways, and also caused
      general headaches in the form of needing to pass some floats as 1.0/%f
      to escape the precision loss.
      
      I seem to have completely forgotten that we actually control the float
      printing code and can set the preciison to whatever we want. So just set
      it as high as reasonable, because this is intended for machine consumption
      anyway.
      
      20 digits gives us enough to cover the ~16 digits of the IEEE mantissa
      alongside some extra for the order of magnitude (~11 bits). This really
      ought to be enough for everyone.
      9aa63a46
    • Niklas Haas's avatar
      opengl: enable PL_FMT_CAP_BLENDABLE for opengl FBOs · 2b321cbf
      Niklas Haas authored
      I can't find any wording anywhere that would imply these are somehow
      *not* blendable, so I assume they just always are.
      
      Fixes https://github.com/haasn/libplacebo/issues/89
      2b321cbf
  4. Dec 26, 2020
    • Niklas Haas's avatar
      gpu: add pl_shared_mem.stride_w/h · ab915ccf
      Niklas Haas authored
      This can differ from the image dimensions for DMA-buffers, in particular
      with modifier support (i.e. for non-linear images). This is
      straightforward to implement for OpenGL (although OpenGL doesn't support
      3D imports), but Vulkan is still missing any sort of DMA modifier
      support, so we just warn if it mismatches.
      
      Fixes https://github.com/haasn/libplacebo/issues/88
      ab915ccf
  5. Dec 16, 2020
    • Niklas Haas's avatar
      utils/libav: use asynchronous uploads if possible · 9586dc23
      Niklas Haas authored
      This can speed up pl_upload_avframe() significantly, approaching zero
      overhead (direct rendering) under favorable circumstances.
      9586dc23
    • Niklas Haas's avatar
      gpu: make pl_tex_upload/download asynchronous where possible · d59a0bad
      Niklas Haas authored
      For pl_tex_upload, this allows us to use host pointer imports, due to
      the relaxed need to ensure `ptr` can be freed after `pl_tex_upload`
      returns.
      
      For pl_tex_download, this allows us to skip the very nasty blocking
      poll, as long as the user has provided some sort of callback.
      
      Also add a test case demonstrating a nice speedup on my system (~40 fps
      -> ~200 fps upload, ~160 fps -> ~200 fps download).
      
      Closes videolan/libplacebo#123
      d59a0bad
    • Niklas Haas's avatar
      gpu: add asynchronous texture transfers · bac6e4d9
      Niklas Haas authored
      This allows us to not only fix some of the shortcomings of pointer-based
      transfers, but also make the API easier for users that need to e.g.
      deref external images once an operation completes. Due to OpenGL
      restrictions, this is dependent on a new GPU capability flag.
      
      Partially implements #123
      bac6e4d9
    • Niklas Haas's avatar
      gpu: nuke pl_buf_pool · 0bab5830
      Niklas Haas authored
      I think the status quo is that creating and destroying pl_buf should be
      as cheap as possible, so there's really no point in having a separate
      abstraction for somehow pooling buffers together. This is a left-over
      from when `pl_buf_destroy` on an in-use buffer was undefined behaviour,
      which hasn't been the case for some time now.
      
      Removed not only because they're unnecessary, but also because the
      unnecessary boilerplate is getting in the way of a planned refactor.
      0bab5830
  6. Dec 11, 2020
  7. Dec 07, 2020
  8. Dec 05, 2020
  9. Dec 04, 2020
    • Niklas Haas's avatar
      renderer: allow blending final output · 5e809d89
      Niklas Haas authored
      This is pretty trivial to support, and moves things further in
      consideration of #118.
      5e809d89
    • Niklas Haas's avatar
      gpu: disentangle texture filters from pl_tex · 0d6b3709
      Niklas Haas authored
      Merging the texture filter with the pl_tex object itself is a left-over
      from the mpv RA days. While it involves a different set of tradeoffs, I
      think it's far better overall to have this concept separate from the
      texture, simply because it allows the shaders to pick their preferred
      sample mode dynamically (improving performance in many cases), and in
      general reduces the burden on the provider of the textures (i.e. the
      user) to set this up.
      
      In addition to splitting this from the pl_tex, we move it to
      pl_desc_binding, where it can be changed at runtime. To cut down on
      redundancy, we re-use pl_desc_binding for pl_shader_desc as well. Note
      that `access` could also live inside pl_desc_binding in principle, but
      there's no practical reason to need this because changing the access
      mode requires a shader recompilation anyway.
      
      Deprecate all the old fields rather than removing them outright, to
      hopefully cut down on the amount of frustration this change will cause.
      The `pl_tex_blit` function got params-ified en passant, though, which is
      probably the most breaking change amidst this sea of breaking changes.
      0d6b3709
  10. Dec 03, 2020
    • Niklas Haas's avatar
      renderer: fix aliasing in corner case · 48877b0d
      Niklas Haas authored
      This logic was old and wrong, because params->upscaler and
      params->downscaler might point to the same thing, in which case this can
      end up being `true` even when downscaling.
      
      Essentially, this would trigger if both upscaler and downscaler are set
      to something like bicubic, in which case downscaling would alias.
      48877b0d
    • Niklas Haas's avatar
      renderer: fix wrong assertion · c0e1ee8f
      Niklas Haas authored
      This should be <= 4, not < 4.
      c0e1ee8f
    • Niklas Haas's avatar
      vulkan: decouple samplers from pl_tex_vk · 3bc5d883
      Niklas Haas authored
      VkSamplers aren't actually tied to any specific image or imageview, so
      we can statically create them on pl_gpu creation and just assign the
      correct sampler when updating the descriptor.
      
      This reduces the amount of unnecessary objects per texture
      creation/destruction by a grand total of one (1).
      
      Sort of pointless at the moment, but the idea moving forwards is to also
      decouple the idea of samplers from the `pl_tex` abstraction entirely.
      3bc5d883
    • Niklas Haas's avatar
      gpu: add pl_tex_poll · 4033158a
      Niklas Haas authored
      After holding out against this function for the longest time ever, I
      finally stumbled upon a justified use case for its existence:
      synchronizing resource destruction of imported textures with external
      libraries.
      
      I hope I made it sufficiently clear that this function's existence does
      not imply you can skip out on using pl_sync / semaphores.
      4033158a
    • Niklas Haas's avatar
      vulkan: log errors related to handle type probing · a1728417
      Niklas Haas authored
      Should hopefully make issues like #117 easier to debug.
      a1728417
  11. Dec 02, 2020
    • Niklas Haas's avatar
      utils/libav: sanitize some illegal metadata combinations · 30efeff0
      Niklas Haas authored
      As clarified by @cyanreg, FFmpeg filters are supposed to ignore
      obviously "wrong" combinations, in particular RGB + limited range. We
      also make an effort to clean up broken sig_peak tagging, since this
      exists in practice.
      
      I decided not to sanitize the other paramaters until I encounter a
      broken file that demand it, because it's hard to draw the line
      otherwise, although we could certainly come up with a few more ideas for
      things that are potential candidates. (ICtCp with non-HDR curve? XYZ?)
      
      Also clean up some whitespace because I can't be bothered making a
      separate commit for it.
      30efeff0
    • Niklas Haas's avatar
      include: mark deprecated things as deprecated · bd72b233
      Niklas Haas authored
      We over-ride this when compiling our own code, though, to avoid
      triggering deprecation warnings in our own fallback paths.
      
      As a side-note, also fix the `include` test to include the correct
      config.h location.
      bd72b233
    • Niklas Haas's avatar
      renderer: merge pl_image and pl_render_target into pl_frame · 5b508c5b
      Niklas Haas authored
      This is motivated by these two structs, essentially, having
      conglomerated into unity. Drop the deprecated fields from each and just
      go ahead with the big search & replace.
      
      This also allows us to unify a couple of helper functions, quite
      pleasingly. The only really annoying thing is that `target.av1_grain`
      makes zero sense, but whatever.
      
      We also provide a new helper function to bridge the "functionality gap"
      in the `pl_render_target_partial` / `pl_tex_clear` checks.
      
      An attempt was made to preserve backwards compatibility, for what it's
      worth.
      5b508c5b
    • Niklas Haas's avatar
      renderer: fix possible compute to non-storable fbo · 8037ba53
      Niklas Haas authored
      The scaler code only checks whether or not the FBOFMT is storable,
      but in the case of e.g. draw_overlays, we have to check the actual FBO
      (provided by the user) instead.
      
      Solve this by just checking both. (Note: In theory, if the FBO is
      storable but FBOFMT is not, this would be a false negative. But
      whatever.)
      8037ba53
    • Niklas Haas's avatar
      renderer: allow rendering to planar targets · 831404dd
      Niklas Haas authored
      This is a major overhaul of the target rendering code, and the renderer
      code in general (to keep things organized and understandable).
      
      The motivation comes from vf_libplacebo, which wants to let users render
      out subsampled YCbCr content directly. Unfortunately, we're still pretty
      much forced to upconvert to RGB internally, if only for the sake of
      things like tone mapping, linear scaling, and so forth. Plus, the entire
      pl_renderer architecture is very much designed around the idea that
      there's only one plane currently being rendered. While it's not entirely
      impossible to change this, it'd be _way_ outside the scope of this
      already massive change.
      
      Due to the major change of a core API, I decided to make the old `pl_tex
      *fbo` interface merely deprecated, rather than removing it entirely. Due
      to the increasing unification between `pl_image` and `pl_render_target`,
      I may choose to merge these into a single `pl_frame` at some point in
      the future, but that would also imply dropping this bit of backwards
      compatibility, so I'll postpone that refactor until after the next major
      release.
      
      Pick up a few bugs related to the dithering/compute indirection code
      while we're at it.
      
      Added a new test case to make sure it round trips, even for oddly-sized
      planes.
      831404dd
    • Niklas Haas's avatar
      shaders/colorspace: fix yet another bt.2390 overflow · 1b80bc4c
      Niklas Haas authored
      Turns out we also need to clamp negative values, specifically for the PQ
      function. I'm not sure if both clamps are strictly needed, but I guess
      it's better to be safe than sorry.
      1b80bc4c
    • Niklas Haas's avatar
      libav: backwards compatibility with older versions · 5ad31fe5
      Niklas Haas authored
      We can go all the way back to 55.74 by dropping our reliance on
      AVCOL_PRI_EBU3213. Fortunately, this is not needed, because the
      backwards compatible name AVCOL_PRI_JEDEC_P22 is identical to it.
      5ad31fe5
    • Niklas Haas's avatar
      ci: update to new image · 84df9e4d
      Niklas Haas authored
      This includes libavutil-dev, so we can run the libav test.
      84df9e4d
  12. Dec 01, 2020
  13. Nov 30, 2020
    • Niklas Haas's avatar
      shaders/sampling: allow sampling arbitrary components · 89b0cefb
      Niklas Haas authored
      This replaces `int components` by a new `uint8_t component_mask`, which
      is more flexible. I decided not to deprecate the original field, because
      it doesn't really cause any harm to continue supporting, and in most
      cases you don't need the flexibility provided by a mask, so it's just a
      hassle.
      
      Made for the sake of allowing us to more efficiently render sub-sampled
      planes without needing to waste GPU time scaling unnecessary components
      like luma.
      89b0cefb
    • Niklas Haas's avatar
      shaders/colorspace: fix dithering to high depth · 50fa6bc1
      Niklas Haas authored
      The old code tried printf'ing a small float using %f, which resulted in
      a rounded literal that was quite far from 1/scale. This led to the image
      getting brighter than it should be, globally. The effect was very
      significant for higher bit depths.
      
      Fixed this, and improved the precision, by printing exact integer
      literals, which get turned into exact float literals by the shader
      compiler.
      50fa6bc1
    • Niklas Haas's avatar
      renderer: fix subsampled plane alignment (again) · 18310a67
      Niklas Haas authored
      I never seem to get a break with this logic. Anyway, what happened
      *this* time was that I noticed `rx`, `ry` were being incorrectly
      calculated (they're supposed to be floats, but I was dividing two ints).
      
      I also realized while working through a paper example that using `rx`
      for the plane shifts was incorrect to begin with. Fortunately, for most
      real-world content, `rx` and `rrx` are identical. For cases where they
      aren't, the earlier answer ended up effectively cancelling out this
      error, at the cost of an off-by-one (resulting in tiny, probably
      unnoticed chroma misalignment).
      
      The correct logic is to use rrx/rry for both. Fixed, and tested. (In
      particular, by making sure a YCbCr image survives being converted to
      RGB and back to YCbCr by the renderer)
      18310a67
  14. Nov 27, 2020
  15. Nov 26, 2020
    • Niklas Haas's avatar
      vulkan: allow disabling page-rounding imported pointers · 9db5f97d
      Niklas Haas authored
      This is technically a hack, or at the very least, some sort of
      ID/UD-type behaviour. It works in practice (for good reasons), but
      juuust in case, it would really be a smart idea to allow disabling it.
      
      Also swap the order of the error messages to make sure checks happen in
      a more sensible order.
      9db5f97d
  16. Nov 25, 2020
    • Niklas Haas's avatar
      shaders/av1: relax luma==0 restriction · 7b5cd58c
      Niklas Haas authored
      After having managed to contrive in my head a scenario in which the luma
      plane somehow ends up with luma in an index other than 0 (uploading UYVY
      to an rgba8 texture and aliasing it as rg8, the luma information is now
      in the G channel), I realized it's a good idea to support this.
      
      It's not really a horrendeous break of API, because the backwards
      compatible behaviour is, handily, what you get if you just ignore this
      new field's existence.
      7b5cd58c
Loading