Skip to content
Snippets Groups Projects
  1. Jul 02, 2021
    • James Ross-Gowan's avatar
      d3d11: add initial implementation · be32ca68
      James Ross-Gowan authored
      Add a pl_gpu implementation that uses Direct3D 11. This uses SPIRV-Cross
      to translate shaders from GLSL to HLSL. In its current state, plplay
      works and the test suite passes with feature level 10_0 and up. (9_x is
      unlikely to ever pass due to runtime-enforced shader complexity limits.)
      
      Missing features include emulated texture formats, cached_program,
      `pl_gpu_limits.thread_safe`, and HDR/high bit depth support in
      pl_swapchain, though these shouldn't be too hard to implement.
      
      This also updates the GLFW demos to be able to use Direct3D 11 through
      GLFW_NO_API.
      
      Closes #18
      be32ca68
    • Niklas Haas's avatar
      glsl: refactor spirv compilation · 480dc28f
      Niklas Haas authored
      Rather than fixing/determining the pl_glsl_version at compiler creation
      time, this is now taken dynamically as a compilation parameter. In
      addition to this, the exact API / target version to compile against will
      be inferred from the GLSL description, rather than set explicitly. This
      allows us to take into account some of these limits during shader
      compilation.
      
      Move stuff into the common glsl/ subdir, mostly to allow the creation of
      glsl/utils.h which contains shared helpers between C and C++ that can't
      be placed into spirv.h directly due to C99/C++ incompatibility.
      
      Finally, rename some usage sites for consistency, enabling `stage` to
      always refer to the shader stage, `shader` to refer to the shader
      itself, and `glsl` to refer to the pl_glsl_version struct.
      
      Requires bumping the shaderc dependency. Fortunately, none of the usual
      candidates (debian stable etc.) even *package* ubuntu, so we're fine.
      480dc28f
  2. Jun 27, 2021
    • James Ross-Gowan's avatar
      gpu: only invalidate pl_pass_run_params.target in a raster pass · 7acd201d
      James Ross-Gowan authored and Niklas Haas's avatar Niklas Haas committed
      `pl_pass_run_params.target` should only be used for PL_PASS_RASTER and
      ignored for PL_PASS_COMPUTE, however pl_pass_run was invalidating the
      texture for both types of passes.
      
      This was found because `pl_dispatch_finish` unconditionally sets
      `target` for both types of passes. That should be harmless, but since
      `load_target` only gets set for raster passes, it resulted in
      `pl_dispatch_params.target` always being invalidated for compute passes.
      7acd201d
    • Niklas Haas's avatar
      tests/libav: explicitly test only LE variants · 58de4668
      Niklas Haas authored
      Since our libav helpers rejects BE formats, using the NE-dependent
      aliases here is wrong. This makes the test framework pass on BE
      platforms. Though I'm not very convinced that the code actually works
      correctly, it's probably impossible to test in the absence of BE GPUs to
      test against.
      
      Closes videolan/libplacebo#160
      58de4668
  3. Jun 15, 2021
  4. Jun 14, 2021
    • Niklas Haas's avatar
      demos/plplay: add pass stats · e341dad3
      Niklas Haas authored
      Not entirely happy with the presentation, but I also can't particularly
      be bothered to prettify it. It serves its purpose of illustrating this
      functionality.
      e341dad3
    • Niklas Haas's avatar
      renderer: add info callback mechanism · b3a910f0
      Niklas Haas authored
      Forwards the information from the dispatch to the renderer API user, in
      the most transparent way, while also adding metadata about what "kind"
      of operation we're performing (frame rendering or blending).
      
      Closes videolan/libplacebo#156
      b3a910f0
  5. Jun 13, 2021
  6. Jun 10, 2021
  7. Jun 05, 2021
  8. Jun 03, 2021
    • Niklas Haas's avatar
      vulkan: add checks for per-stage descriptor count limits · 7553c7a1
      Niklas Haas authored
      This prevents undefined behavior in the hypothetical case of these
      limits being very low.
      
      Technically this omits some limits such as checking against
      maxPerStageDescriptorSamplers for PL_DESC_SAMPLED_TEX, but I'm going out
      on a limb here and assuming that maxPerStageDescriptorSampledImages will
      never be lower than maxPerStageDescriptorSamplers.
      7553c7a1
    • Niklas Haas's avatar
      vulkan: suppress MSAN warning · 1777dc18
      Niklas Haas authored
      CI doesn't catch this patch because CI doesn't have DRM modifiers.
      1777dc18
    • Niklas Haas's avatar
      opengl: split up gpu.c into sub-components · 1eabeaaa
      Niklas Haas authored
      Same justification as for vulkan. I decided not to create `gpu_buf.c`
      because the OpenGL buffer code is comparatively tiny.
      1eabeaaa
    • Niklas Haas's avatar
      vulkan: split up gpu.c into sub-components · 43baa23d
      Niklas Haas authored
      This was a pretty monolithic file that was getting hard to work with or
      view changes in. Split it up as best I can.
      
      Refactored some things along the way, such as reducing the use of
      mostly-obsolete helpers, and fixing a thread safety bug for the lazy
      destructors.
      43baa23d
    • Niklas Haas's avatar
      gpu: add extra capability for read-write storage · c5c67506
      Niklas Haas authored
      D3D11 only supports readonly or writeonly access for a lot of otherwise
      storable formats, because readwrite access is its own special thing in
      D3D11. To support this, restrict the ability to use READWRITE access
      behind a new capability, since its usage is relatively rare (only really
      mattering for the compute shader blend emulation code, in which case
      this cap merely exists to prevent us from accidentally auto-upgrading
      shaders for non-readwritable storage images).
      c5c67506
    • Niklas Haas's avatar
      gpu: add `pl_gpu_limits.buf_transfer` · 67857f60
      Niklas Haas authored
      Turns out D3D11 is actually a special enough snowflake to not support
      buffer<->texture copies, instead they introduce "shadow textures" to
      serve as quasi-buffers that can only be used for buffer transfers.
      
      They don't really fit into our architecture, and nothing *really*
      depends on it anyway (except mapped buffers, for which a check is easily
      introduced in the few places that use them).
      67857f60
    • Niklas Haas's avatar
      gpu: entirely refactor pl_gpu_caps · 2d0786d1
      Niklas Haas authored
      I wasn't happy with this bit field. It was clumsy, interfered with
      rebases, limited to 64 entries, awkward to work with, and didn't really
      serve any practical purpose.
      
      Additionally, a lot of these fields make far more sense in
      `pl_glsl_desc` rather than `pl_gpu_limits`, especially the ones that
      only affect shader generation, as these are also useful for `pl_shader`.
      
      Rename it to `pl_glsl_version` while we're breaking everything, to
      prevent confusion with descriptors  which are also confusingly called
      `*_desc` everywhere.
      
      The various `blacklist_caps` fields were deleted without a deprecation
      because I don't think they had any users other than our own CI.
      2d0786d1
    • Niklas Haas's avatar
      gpu: correctly implement `max_vbo_size` · b64d5c02
      Niklas Haas authored
      This was missing a check, print-out and `dummy` entry.
      b64d5c02
  9. Jun 02, 2021
  10. May 31, 2021
    • James Ross-Gowan's avatar
      dispatch: write the correct number of passes in pl_dispatch_save · 369e2da2
      James Ross-Gowan authored and Niklas Haas's avatar Niklas Haas committed
      It's valid for pl_pass_create not to write a cached program. In this
      case, pl_dispatch_save should only write the number of passes that have
      a program to save, in order to prevent a buffer overread in
      pl_dispatch_load.
      
      This also updates pl_shader_tests to handle passes that don't write
      a cached program.
      369e2da2
    • Niklas Haas's avatar
      shaders/colorspace: make default desaturation significantly stronger · 07e27776
      Niklas Haas authored
      I think it's becoming increasingly clear that users expect the look and
      feel of the desaturated tone mapping, probably due to the fact that it's
      also the easiest to implement and therefore the most common. But more
      importantly, it avoids very weird results for strongly saturated
      highlights.
      07e27776
    • Niklas Haas's avatar
      colorspace: infer BT.1886 by default · 543a1f33
      Niklas Haas authored
      This mainly affects the users of `pl_color_space_infer`, i.e.
      pl_renderer and pl_shader_color_map.
      
      Now that we handle black points correctly (and infer a 1000:1 contrast
      as well), I think this results in marginally better results than the
      naive gamma 2.2 fallback.
      
      As a slight exception, still infer gamma 2.2 for linear light content,
      to avoid unnecessary black point adaptation. This is very unlikely to
      affect most users.
      543a1f33
    • Niklas Haas's avatar
      renderer: mix in the rendered frame's native color space · ae9048aa
      Niklas Haas authored
      This is far better than ping-ponging between this and `image.color`,
      especially because it avoids e.g. unnecessarily adapting the black point
      back and forth between it and linear light. In the ideal case, this
      makes it a no-op.
      
      It also means we now effectively perform frame blending in linear light,
      which I think is a net gain anyways, especially because it also avoids
      needing to unlinearize every single frame in the mixing shader (though
      one could in theory also easily fix that problem by moving it to the
      previous step).
      
      Also fixes an issue where this adaptation resulted in incorrect results,
      although truthfully I'm not entirely sure why.
      ae9048aa
    • Niklas Haas's avatar
      demos/plplay: allow -v to increase verbosity · fbf67710
      Niklas Haas authored
      Too lazy to write a proper getopt() loop atm, I just need this for some
      quick debugging.
      fbf67710
    • Niklas Haas's avatar
      demos/plplay: add output colorspace options · 22929055
      Niklas Haas authored
      Useful for debugging tone mapping and stuff, especially by explicitly
      setting the output color space to PQ.
      
      One annoying thing is that switching from an SDR curve to PQ doesn't
      inherit an SDR contrast, unless you switch to BT.1886 first. Could
      probably be handled smarter in some ways, but I suppose this is good
      enough.
      
      Another annoying thing is the lack of precision for nuklear's float
      properties, but oh well.
      22929055
    • Niklas Haas's avatar
      utils/libav: implement `sig_floor` parsing · b262bbdb
      Niklas Haas authored
      b262bbdb
    • Niklas Haas's avatar
      utils/dav1d: implement `sig_floor` parsing · f52f6c86
      Niklas Haas authored
      f52f6c86
    • Niklas Haas's avatar
      shaders/colorspace: implement full black point adaptation · fe524192
      Niklas Haas authored
      This is a massive change, and a big departure from the current way of
      handling colorspaces / black points (which was passing it off to the ICC
      backend or else just defaulting to gamma 2.2).
      
      We now fully track black points, giving rise to effective contrast
      information, in particular for absolute luminance EOTFs (PQ, HLG,
      BT.1886). The tone mapping shaders have been adapted to adjust the black
      point as required.
      
      This also means that we now effectively correctly handle BT.1886
      emulation even on displays without ICC profiles. This *would* ordinarily
      severely alter the default presentation, so we also change the default
      transfer of pl_color_space_monitor from gamma 2.2 to UNKNOWN, which
      allows the color mapping to avoid adapting typical SDR signals for
      unknown displays. (Something that should have been done a while ago, to
      be honest)
      
      Requires an unfortunate API break for `pl_shader_(de)linearize`, but as
      far as I can tell, these APIs are very un-used, so I'm not too worried.
      
      Also remove an undocumented and useless parameter from
      PL_TONE_MAPPING_CLIP, which now does exactly what it says.
      
      Closes #151
      fe524192
    • Niklas Haas's avatar
      shaders/colorspace: fix `gamut_clipping` for HDR outputs · 9690a815
      Niklas Haas authored
      This incorrectly always clipped to the interval [0.0, 1.0] even for HDR
      outputs where such clipping is completely wrong. Fix it by clipping to
      the correct volume.
      9690a815
    • Niklas Haas's avatar
      shaders/colorspace: use constants for sh_luma_coeffs · 6d85372b
      Niklas Haas authored
      These are unlikely to change to the extent that would make this
      usage of specialization constants problematic.
      6d85372b
    • Niklas Haas's avatar
      colorspace: add more pure power gamma functions · a94d4bf5
      Niklas Haas authored
      Truthfully the only motivation for this commit is that I want to have
      PL_COLOR_TRC_GAMMA24 exist for backwards compatibility with the legacy
      handling of (non-black-scaled) BT.1886.
      
      In theory we could also probably do something smarter like encoding the gamma
      value into the enum value itself, but that can also be done later and I
      don't want this commit to become that invasive. (And it sets a precedent
      I don't like with regards to how to handle unknown enum members in
      switch statements)
      a94d4bf5
    • Niklas Haas's avatar
      renderer: another compatibility bug with older GLSL · c9fe2acd
      Niklas Haas authored
      Missed by 3c705836
      c9fe2acd
  11. May 24, 2021
Loading