1. 29 Sep, 2018 1 commit
    • Niklas Haas's avatar
      common: switch to explicit includes · b6104e12
      Niklas Haas authored
      Since we no longer need the GCC pragma for symbol visibility, there's
      also no more reason to have common.h import everything under the sun -
      so only have modules import what they actually use.
      
      This speeds up compilation a tiny bit.
      b6104e12
  2. 27 Sep, 2018 1 commit
    • Niklas Haas's avatar
      dispatch: rework the shader identification mechanism · 5cbcbcec
      Niklas Haas authored
      Rather than having the uint8_t be public, which makes little sense with
      no public way to merge shaders (sh_subpass is private), just add an
      internal _ex function for the (relatively few) cases where we actually
      need this merging stuff.
      
      For the most cases, we can just always use identifier 0, this also gives
      us better caching for stuff like OSD passes etc.
      5cbcbcec
  3. 28 May, 2018 1 commit
    • Niklas Haas's avatar
      shaders: add support for ICC profiles and 3DLUTs · eb14d3bd
      Niklas Haas authored
      Code taken from mpv, with some modifications. The shader stuff is from
      scratch, but lcms.c draws heavily from code I already wrote.
      
      This again uses LittleCMS 2, with which I've been very satisfied.
      Partially addresses #23.
      eb14d3bd
  4. 13 Feb, 2018 1 commit
  5. 02 Feb, 2018 1 commit
    • Niklas Haas's avatar
      ra: rename ra to pl_gpu, change ra_ to pl_ · 3e881060
      Niklas Haas authored
      This is a very major rewrite operation, but all of the actual logic is
      unaffected. The change is completely cosmetic.
      
      The idea behind this is to avoid clashing the mpv ra_ namespace when
      libplacebo eventually makes its way back into mpv, allowing it to
      coexist with vo_gpu peacefully (at least for the transition period).
      
      It's also sort of weirdly inconsistent with the rest of libplacebo
      anyway.
      3e881060
  6. 22 Jan, 2018 2 commits
  7. 25 Dec, 2017 2 commits
    • Niklas Haas's avatar
      shaders: add high quality dithering · aa04f95b
      Niklas Haas authored
      The algorithm is ported from mpv; with some minor modifications (AVLFG
      -> rand()). Blue noise is internally preferred wherever possiblle, with
      ordered LUT being an alternative - and falling back to fixed function
      ordered and finally white noise when LUTs are not available.
      
      Also contains some minor other modifications (maximum shader literal LUT
      size, maximum dither depth)
      aa04f95b
    • Niklas Haas's avatar
      shaders: rework sh_lut mechanism · e2dabec9
      Niklas Haas authored
      1. Drop the use of UBOs and SSBOs; since not only are there unaddressed
         packing concerns, but they also don't really provide an advantage.
         Instead, use regular uniform floats (i.e. input variables with
         dim_v), but only do this by default if we have global inputs.
      
      2. Implement the missing case (SH_LITERAL)
      
      3. Improve the signature for the `fill` function.
      
      On my nvidia hardware, both SH_LITERAL and SH_UNIFORM sadly explode for
      large inputs - SH_UNIFORM exhausts the UBO size limits when using
      vulkan, mainly due to the vec4/float packing inefficiency. SH_LITERAL on
      the other hand just makes the nvidia shader compiler explode. Further
      investigation is required, but for small LUTs it should work
      nonetheless.
      e2dabec9
  8. 22 Dec, 2017 1 commit
    • Niklas Haas's avatar
      shaders: refactor pl_shader_obj and add sh_lut · 456aa914
      Niklas Haas authored
      This refactors the way we store data like scaler LUTs, with the intent
      of generalizing it for other types of LUTs (e.g. dither matrix) in an
      easy-to-use but flexible way.
      
      Instead of trying to come up with sane semantics for who gets to use
      what fields inside a pl_shader_obj, we just abstract it away and let the
      caller deal with the *priv representation (as usual). Unfortunately,
      this requires "nesting" pl_shader_objs for cases like the sampler LUTs
      where we need to store information about the scaling kernel *and* the
      underlying LUT. But that's not too bad, I think.
      
      I had to rewrite the code that uses pl_shader_objs. Hopefully for the
      better.
      456aa914
  9. 10 Nov, 2017 1 commit
    • Niklas Haas's avatar
      shaders: place shader inputs dynamically · 301bf233
      Niklas Haas authored
      Instead of hard-coding the bindings and position in pl_shader_res, place
      them dynamically once we have a better idea of the overall inputs. This
      is needed to enable shader merging without conflicting bindings /
      offsets. The logic is moved to pl_dispatch instead.
      301bf233
  10. 09 Nov, 2017 1 commit
    • Niklas Haas's avatar
      shaders: add sh_subpass / shader merging · 7465c43b
      Niklas Haas authored
      This adds the secondary shader as a subpass of the first shader;
      exposing it as a function (much like pl_shader_finalize). There is
      currently still no public shader merging API, but it could easily be
      built on top of this.
      
      This switches from void *tmp to ta_ref *tmp in order to avoid breaking
      memory allocated by the attached objects.
      7465c43b
  11. 06 Nov, 2017 3 commits
    • Niklas Haas's avatar
      shaders: seed sh_prng with gl_FragCoord · df91c5d3
      Niklas Haas authored
      No need to waste a VA on this (or force the user to pass one in)
      df91c5d3
    • Niklas Haas's avatar
      shaders: generalize the PRNG · c99cd6bf
      Niklas Haas authored
      I've also found some independent resources describing this exact
      algorithm. In particular, one of them also offers a performance tip: we
      can use fract() instead of x - floor() since we don't need the exact
      modulus semantics.
      c99cd6bf
    • Niklas Haas's avatar
      shaders: refactor randomness seeding · 8f0890de
      Niklas Haas authored
      Instead of having the user pass in seed values, instead pass in a global
      `index` on pl_shader generation, and use this to internally seed the
      PRNG / perturb the dither matrix / etc.
      
      This removes the highly state-dependent garbage from the *_params
      structs, which is the right thing to do for the upcoming pl_renderer
      options.
      8f0890de
  12. 05 Nov, 2017 2 commits
    • Niklas Haas's avatar
      shaders: seed sh_prng with gl_FragCoord · efd0d9a5
      Niklas Haas authored
      No need to waste a VA on this (or force the user to pass one in)
      efd0d9a5
    • Niklas Haas's avatar
      shaders: generalize the PRNG · a6ea1100
      Niklas Haas authored
      I've also found some independent resources describing this exact
      algorithm. In particular, one of them also offers a performance tip: we
      can use fract() instead of x - floor() since we don't need the exact
      modulus semantics.
      a6ea1100
  13. 31 Oct, 2017 1 commit
    • Niklas Haas's avatar
      shaders: major refactor of tone mapping and color spaces · 7aa14ac3
      Niklas Haas authored
      This accomplishes several things:
      
      1. vec4 colors are now explicitly always normalized such that 1.0 is the
         reference white, and out-out-range values are used to communicate
         high dynamic range images. This makes a lot of processing steps
         saner, and doesn't matter much in the end. It also makes better use
         of the dynamic range of a float FBO, which is better for
         representational efficiency than linear FBOs either way.
      
      2. HDR metadata now includes the frame average light level, not just the
         signal peak. This is important because it allows us to linearly
         darken over-bright scenes, which are sadly common due to shit
         mastering.
      
      3. The tone mapping code takes into account the desired target peak and
         frame average light level. Not strictly necessary, but could be
         useful to play around with; especially for PQ output.
      
      4. The peak detection SSBO code is fundamentally fixed. This had a large
         number of issues, too many to even bother listing. Now it should
         actually work properly.
      7aa14ac3
  14. 22 Oct, 2017 1 commit
  15. 21 Oct, 2017 1 commit
  16. 20 Oct, 2017 3 commits
    • Niklas Haas's avatar
      shaders: remove the dynamic variable renaming crap · d8f63a6e
      Niklas Haas authored
      This was brittle and ugly and slow and annoying anyway. Instead, turn
      this into a user problem. Most users probably know what requirements
      they have, no need to have this annoying code in their hot paths.
      
      For the pl_dispatch system, we can just get this for free as long as you
      `reset_frame` before starting over. This should be fine for the purposes
      of pl_dispatch, which was never meant to be as flexible as pl_shader
      anyway.
      d8f63a6e
    • Niklas Haas's avatar
      shaders: cache the position of all bound textures · 8850611f
      Niklas Haas authored
      This avoids all potential headaches due to multiple evaluation of the
      compute shader position macro
      8850611f
    • Niklas Haas's avatar
      dispatch: refactor compute shader generation · 436d9865
      Niklas Haas authored
      This required making some (semi-significant) changes to shaders/ra as
      well. This provides the infrastructure to properly simulate vertices.
      
      Also clarified the lifetime/usage rules of ident_t.
      436d9865
  17. 17 Oct, 2017 4 commits
    • Niklas Haas's avatar
      shaders: implement HDR peak detection · 6c8c357c
      Niklas Haas authored
      Taken from mpv, with some modifications to fit the new system.
      
      Not entirely sure I'm happy with the buffer building code. It might be a
      good idea to add some sort of mid-level wrapper that makes this easier
      for pl_shaders, but since the peak detection SSBO is the only current
      user of this interface, doing it the ugly way is probably fine.
      6c8c357c
    • Niklas Haas's avatar
      shaders: add shader object tracking mechanism · 04bc66cb
      Niklas Haas authored
      For shaders which require access to "configured" objects, this tracks
      the object's lifetime and allows the shader to re-use the same
      configured object across frames, with the caller being responsible for
      cleanup.
      
      Not entirely sure if I want to just chuck everything in there or do
      subtyping via void *priv, but I think for now the chuck-everything
      approach is fine.
      04bc66cb
    • Niklas Haas's avatar
      shaders: slightly refactor the compute shader interface · f2a3064e
      Niklas Haas authored
      This is more convenient code-wise. Also adds some much-needed helpers.
      f2a3064e
    • Niklas Haas's avatar
      shaders: track output size metadata · 849a88be
      Niklas Haas authored
      This is important both for stuff like debanding (which doesn't want the
      output size to change) as well as stuff like upscaling (which *does*
      want the output size to change).
      849a88be
  18. 16 Oct, 2017 1 commit
    • Niklas Haas's avatar
      shaders: minor fixes · 25e7bf7e
      Niklas Haas authored
      Variable consistency, better order for attributes, properly scaled
      texture coordinates, and better identifier tracking
      25e7bf7e
  19. 15 Oct, 2017 1 commit
    • Niklas Haas's avatar
      shaders: split up into components · ca6dbb55
      Niklas Haas authored
      Move shaders helpers to an internal shaders.h, and split up the public
      shaders API based on the type of rendering that's being done. The
      overall idea here is to limit public/shaders.h to the "low-level" shader
      access stuff, which is normally taken care of by pl_dispatch.
      ca6dbb55