Skip to content
Snippets Groups Projects
  1. May 28, 2020
    • Niklas Haas's avatar
      shaders/colorspace: implement ITU-R BT.2390 · f793fc04
      Niklas Haas authored
      We make this the default tone mapping function because it's the de-facto
      standard in the industry. Unfortunately, it's quite a bit heavier than
      the other algorithms due to the extra PQ round trip needed during tone
      mapping.
      
      It's entirely possible that we could make the choice of whether to do
      things in PQ space or in linear light a choice completely independent of
      the tone mapping function itself, since arguably PQ's "perceptual
      uniformity" quality makes it a suitable space to do tone mapping in
      regardless of what function we use.
      
      That being said, I don't currently want to consider the headache of
      testing this all, so let's just implement it for BT.2390 and call it a
      day.
      f793fc04
  2. May 27, 2020
  3. May 26, 2020
    • Niklas Haas's avatar
      colorspace: fix default chroma location · 0c19ed29
      Niklas Haas authored
      Simple oversight. This should be PL_CHROMA_LEFT, not PL_CHROMA_TOP_LEFT.
      Our own documentation gets it right, I just had the wrong name in my
      head when writing the code.
      0c19ed29
    • Niklas Haas's avatar
      shaders/custom: implement OFFSET ALIGN · 430aa2f2
      Niklas Haas authored
      Tested on KrigBilateral. Hopefully not too terribly broken.
      
      Fixes #88
      430aa2f2
    • Niklas Haas's avatar
      shaders/custom: fix rects for cropped inputs · aa73a1a3
      Niklas Haas authored
      Rather than using the `params->rect`, we should generally be ignoring it
      in favor of the raw texture dimensions, and only update the rect
      accordingly.
      aa73a1a3
    • Niklas Haas's avatar
      colorspace: treat PL_CHROMA_UNKNOWN as _TOP_LEFT · 04d258da
      Niklas Haas authored
      A lot of subsampled content out there is untagged, but should be treated
      as _TOP_LEFT content (the de-facto standard chroma subsampling mode).
      However, we effectively treat _UNKNOWN as PL_CHROMA_CENTER. To fix this,
      make pl_chroma_location_offset explicitly default the chroma location.
      
      Since a lot of users currently just call that function on the chroma
      planes always (regardless of subsampling), introduce a new helper
      function `pl_image_set_chroma_location` to only set the plane shift for
      actually subsampled planes.
      
      Annoying API break, but it is what it is.
      04d258da
  4. May 25, 2020
  5. May 24, 2020
    • Niklas Haas's avatar
      renderer: refactor pl_render_target.dst_rect · 65e5e17e
      Niklas Haas authored
      This is now pl_rect2df instead of pl_rect2d, to make it easier to use
      the pl_rect2df_aspect* series of functions, especially without requiring
      the hacky rounding integer versions of them. Delete those and add some
      needed helper functions as well.
      
      Rewrite the fix_rects code to crop `src_rect` for any fractional
      offset in the `dst_rect`, and also for regions of the `dst_rect` that
      lie outside the target fbo.
      
      Also fix a bug in the img->w/h calculation for cropped planes.
      65e5e17e
    • Niklas Haas's avatar
      shaders/sampling: allow taking the sampler2D as an argument · 87ccba7d
      Niklas Haas authored
      Requested by VLC, which wants to abstract the texture binding and
      coordinates (vertex attribute) away from the actual shader doing the
      scaling.
      
      This requires adding a new type of shader signature,
      PL_SHADER_SIG_SAMPLER2D, and also extending pl_sample_src to allow
      specifying samplers in this way.
      
      The main glaring note here is that I realized the compute shader does
      some hacks w.r.t the texture coordinate which does not actually work
      in a general sense, since it relies on the mapping logic being performed
      by the pl_dispatch. That being said, it's not entirely clear how vertex
      attributes should work at all for compute shaders like this.
      
      It's entirely possible we may need to work around this either by having
      the thread 0 in the work group broadcast its position to the rest of
      the work group (instead of abusing tex_map), or alternatively, we could
      maybe move some of the pl_dispatch simulation code from the dispatch
      mechanism to the actual shader binding mechanism, so that generated
      compute shaders won't have vertex attributes to begin with.
      87ccba7d
    • Niklas Haas's avatar
      common: add aspect ratio helper code · a41981fa
      Niklas Haas authored
      This is sufficiently nontrivial and often-needed enough that providing
      helpers makes a lot of sense. Add some extra helpers that come up when
      rendering to sub-rects of targets.
      
      The only annoying thing here is the mismatch between pl_rect2df and
      pl_rect2d. Maybe I can come up with a better API here?
      
      Also update the sdl2 demo to actually preserve the aspect ratio, as well
      as add some test cases to the new helper functions.
      a41981fa
    • Niklas Haas's avatar
      shader/sampling: use larger group size for polar sampling · f74ad3c8
      Niklas Haas authored
      I re-benchmarked this and determined that larger group sizes are
      actually faster these days, so just use however many as possible.
      
      The horizontal width of 32 still seems to be pretty decent.
      f74ad3c8
    • Niklas Haas's avatar
      tests/bench: delete some less interesting benchmarks · 2f5b2f56
      Niklas Haas authored
      These consume time without really telling us anything useful.
      2f5b2f56
  6. May 22, 2020
    • Niklas Haas's avatar
      renderer: aggressively re-use FBOs · 39df2eb6
      Niklas Haas authored
      As an addendum to f3a07a, this quenches all concerns by making sure we
      re-use same-sized FBOs wherever possible. The new code should be
      strictly better than even the old code, in terms of minimizing FBO
      resizes.
      
      It is not yet, however, optimal in the sense of minimizing FBO residency
      for FBOs that could be aliased. Doing that would require refcounting
      FBOs or something. (Which I guess isn't too difficult to accomplish, so
      maybe I should give it a try?)
      
      That being said, aliasing FBOs might break cross-frame optimizations,
      which would only end up necessitating us introducing other tricks like
      rotating between different pl_renderer instances, thus defeating the
      gains. Would have to be tested anyway to see if aliasing FBOs actually
      gains more performance than it loses. (And the main benefit would be
      gaining VRAM, anyway)
      
      Reduces some code ugliness as a side benefit.
      39df2eb6
    • Niklas Haas's avatar
      shaders: make sh_subpass slightly stricter · 00127130
      Niklas Haas authored
      The current logic allows resizeable parents to become non-resizeable,
      which is a big no-no since resizeable parents are almost definitely
      intended for a framebuffer size that has nothing at all to do with the
      subpass.
      
      To fix this, only allow merging resizeable shaders with subpasses that
      are also resizeable.
      00127130
    • Niklas Haas's avatar
      renderer: don't hard-error when sh_subpass fails · 38b875d9
      Niklas Haas authored
      As an aside, we also make sh_subpass not explicitly spam/fail the parent
      shader in this case.
      38b875d9
    • Niklas Haas's avatar
      renderer: completely refactor struct img · 525279eb
      Niklas Haas authored
      Rather than this merely representing an "in-flight" image, with the
      img->sh only living for as long as this exists between different pass
      types, `img` is now conceptually persistent and either in one of two
      modes: `sh`, or `tex`. This allows us to, in principle, avoid doing
      redundant FBO roundtrips for cases where the previous pass thinks the
      next pass needs a tex but the next pass actually needs a sh, such as is
      currently the case for the AV1 grain shader.
      
      Since `pass_hook` in particular can randomly mutate `img` to either of
      the two forms, callers must now be somewhat vigilant to make sure they
      always use `img_tex()` and `img_sh()` to access the "current"
      shader/texture, rather than relying on local variables staying
      persistent.
      
      The use of locally initialized pl_shader is now exclusive to passes that
      keep their own pl_dispatch_begin calls (for various reasons).
      525279eb
    • Niklas Haas's avatar
      renderer: use a dynamic list of FBOs instead of hard-coding them · fae66ede
      Niklas Haas authored
      The current approach was to pair each FBO with its use, "semantically".
      The intent was to minimize the number of "reallocations" that would be
      required if the number of passes changed dynamically (e.g. as the
      renderer options changed). However, this is not only an unrealistic
      design goal to optimize for (users can use separate pl_renderers for
      wildly different purposes, and for a single conceptual video stream it
      doesn't really matter), but also, it gets in the way of a planned
      refactor I have concerning `struct img`.
      
      Change this to make all FBOs dynamically allocated. The current
      implementation simply uses a counter, but a more advanced implementation
      could use a pool of textures and find ones that have matching sizes
      before recreating ones that don't. The API shouldn't change as a result
      of this.
      fae66ede
  7. May 21, 2020
    • Niklas Haas's avatar
      ci: update container version · 0386edd3
      Niklas Haas authored
      In doing so I finally hit the time bomb caused by assuming blacklisting
      compute is only needed on that specific driver version. Turns out, the
      same issue is present even on newer driver versions. Since I have no
      idea how else to work around and/or debug it, just permanently disable
      compute on the CI.
      
      Unfortunately, for some reason, the `shaderc` version in this version of
      the CI image hits random internal exceptions when trying to compile
      pretty much anything. But using glslang directly works. Except for msan,
      because we don't have msan-instrumented libc++.
      
      Some other changes needed for whatever reason.
      0386edd3
    • Niklas Haas's avatar
      spirv: handle shaderc internal errors properly · 3b1dd90b
      Niklas Haas authored
      These don't generate any errors, but the compilation status still isn't
      "success". Treat these as errors as well, in terms of logging.
      3b1dd90b
    • Niklas Haas's avatar
      vulkan: always load VK_KHR_surface · e630b7ae
      Niklas Haas authored
      There's really no reason not to. Also clarify that these functions are
      not, in fact, "mandatory" instance-level function pointers.
      e630b7ae
Loading