Skip to content
Snippets Groups Projects
  1. Dec 31, 2018
  2. Dec 22, 2018
    • Niklas Haas's avatar
      tests: rename vulkan_tests · 6110ec30
      Niklas Haas authored
      To emphasize that it's only testing interop, and also point out that we
      should keep these separate.
      6110ec30
    • Philip Langdale's avatar
      meson: bump version · 3cf69d90
      Philip Langdale authored and Niklas Haas's avatar Niklas Haas committed
      3cf69d90
    • Philip Langdale's avatar
      vulkan: add basic import test · cc236bf2
      Philip Langdale authored and Niklas Haas's avatar Niklas Haas committed
      This change adds a test that exports a texture and then imports it
      back in again. This round-tripping is explicitly supported by the
      Vulkan spec.
      
      The test only runs for dma_buf handles because that's the only one
      we have an import implementation for.
      
      I also fixed the existing test which didn't properly check the
      fd value of the buffer.
      cc236bf2
    • Philip Langdale's avatar
      gpu: add support for creating textures bound to imported memory · b38e65cc
      Philip Langdale authored and Niklas Haas's avatar Niklas Haas committed
      This change introduces new capabilities to allow for external memory
      to imported and bound to textures.
      
      The specific use-case is supporting interop with vaapi hardware
      decoding, where dma_buf is used to export decoded video surfaces.
      
      The API basically involves passing a `pl_shared_mem` when creating
      a texture, to describe the external memory to be used. When this
      is done, the external memory is imported and used instead of making
      a normal memory allocation.
      
      Past that point, the texture behaves like a normal one, and destroying
      the texture will free the imported allocation. Note that we will
      repeatedly import a single allocation if it is passed for separate
      textures. This happens in the vaapi case because each surface is
      a single allocation but each plane must be imported as a separate
      texture. The Vulkan spec explicitly required multiple-import to
      work, so this is safe.
      
      I have a corresponding mpv change that demonstrates this all works.
      
      Note that this implementation is more fragile than you'd want because
      we can't use `VK_EXT_image_drm_format_modifier`. This extension has
      yet to be enabled in the Mesa vulkan drivers, and until it is enabled,
      we cannot communicate detailed format information from vaapi to
      Vulkan. Examples of this include the pitch, tiling configuration and
      exact image format. For the common cases we deal with in vaapi, this
      is not fatal - it happens to be the case that pitch and tiling work
      out, and mpv is able to pick a compatible format based on its
      existing format mapping code.
      
      Note that this code may not pass validation, as a result. In my
      mpv tests, I see validation failures when mpv is doing format
      probing, reflecting that some of the more exotic formats cannot
      be matched up without `VK_EXT_image_drm_format_modifier`. However,
      once probing is complete, they decode and display run without
      validation errors.
      b38e65cc
    • Philip Langdale's avatar
      vulkan: add support for external memory with dma_buf fds · 39f4809d
      Philip Langdale authored and Niklas Haas's avatar Niklas Haas committed
      dma_buf fds are treated as a distinct type (vs OPAQUE_FD) in
      Vulkan, and so we need to treat them separately too. While the
      basic interactions are the same as for OPAQUE_FD, there is one
      distinct difference, which is that dma_buf fds cannot be used
      for external semaphores, so we have to separate the handle type
      lists when probing for support.
      
      Note that vkGetMemoryFdPropertiesKHR function import is currently
      unused, but is necessary for importing dma_buf fds down the line.
      While the method is part of the generic external_fd extension, the
      spec says it cannot be used for OPAQUE_FD (seriously?) and so it's
      really only relevant for dma_buf fds.
      39f4809d
    • Niklas Haas's avatar
      gpu: split up import/export caps between tex and buf · 4c6d10d3
      Niklas Haas authored
      In practice, these can be different enough (e.g. dmabufs, which are only
      supported for buffers on RADV, but not images). So split them up in
      preparation for future commits.
      4c6d10d3
  3. Dec 21, 2018
    • Philip Langdale's avatar
      gpu: add import handle_caps · 5ef7b583
      Philip Langdale authored and Niklas Haas's avatar Niklas Haas committed
      In prepartion for supporting importing external memory, we need to
      define separate caps for import handle types. In theory, a Vulkan
      implementation is free to only support a handle type for one
      direction and not the other.
      
      This also means we have a field for import caps for `pl_sync`. This is
      always set to 0 for now as we don't have a use-case for importing
      semaphores.
      5ef7b583
    • Niklas Haas's avatar
      colorspace: add a sig_scale field to pl_color_space · 08566a4c
      Niklas Haas authored
      This can be used to reinterpret what the brightness range of values
      mean. A typical use case is for linear-light content which is
      technically encoded as 0.0 - 1.0, but practically supposed to extend to
      HDR values far beyond the typical SDR brightness. OpenEXR files in
      integer mode are encoded like this, for example.
      
      This also unifies/replaces the hacky old "hdr emulation" mode with the
      new concept, it being simply applied to the target csp in this mode of
      operation.
      08566a4c
  4. Dec 16, 2018
  5. Dec 15, 2018
  6. Dec 10, 2018
  7. Dec 07, 2018
  8. Dec 06, 2018
    • Niklas Haas's avatar
      vulkan: explicitly query supported semaphore handle types · a3e1c43d
      Niklas Haas authored
      Mercifully much easier than buffers/images
      a3e1c43d
    • Niklas Haas's avatar
      malloc: determine the set of supported handles by trial · ec190ee7
      Niklas Haas authored
      Just try asking the driver if it would be okay with a TRANSFER_DST
      buffer for this handle type. If tha fails, so should certainly
      everything else.
      
      Unfortunately, we have no good way of testing which handle types are
      supported for images. We could also use trials here, but we don't really
      distinguish between images and buffers at all in the pl_gpu.handle_caps.
      
      Hopefully this should normally either be supported for both buffers and
      images, or for neither. It's probably best the user just relies on
      `pl_tex_create` failing in environments where buffers are supported but
      images are not.
      ec190ee7
    • Niklas Haas's avatar
      vulkan: enforce image format compatibility with handle type · 6c29d3e1
      Niklas Haas authored
      Similar to the previous commit, we need to ensure compatibility with the
      handle type we are interested in to avoid UB.
      
      Also rewrite the image format compatibility check logic in general to
      make it more future-proof. Also fixes a few memleaks on error (due to
      `return NULL` when it should have done `goto error`).
      6c29d3e1
    • Niklas Haas's avatar
      vulkan: ensure compatibility of buffer handle types · 61b7ec94
      Niklas Haas authored
      Spec says we need to test for compatibility with vkGet*BufferProps
      before creating the VkBuffer, else it's undefined behavior - the driver
      won't signal incompatible handle types by buffer creation failure.
      61b7ec94
    • Niklas Haas's avatar
      vulkan: add support for loading instance-level functions · bc7fce86
      Niklas Haas authored
      After postponing this issue previously because we had no permanent
      context associated with user-provided instances, and no way of
      retroactively knowing what instance-level extensions were provided, the
      solution hit me on the head:
      
      We can just load them as part of the device-level extensions that depend
      on them. Duplicates in this list don't matter, since loading the same
      pointer twice is idempotent.
      bc7fce86
    • Niklas Haas's avatar
      vulkan: reduce handle_type boilerplate · aff6b549
      Niklas Haas authored
      There were a bunch of disjointed switch statements all over the place.
      Reduce these in favor of one helper function, since we'll end up needing
      this more as we go on.
      aff6b549
    • Philip Langdale's avatar
      tests: add coverage for win32 handle types · 3a70f258
      Philip Langdale authored and Niklas Haas's avatar Niklas Haas committed
      No idea if this actually works, but perhaps we'll find out.
      
      If you wanted the test to run and pass on windows 7, you'd
      presumably not want the NT Handle test to run.
      3a70f258
    • Philip Langdale's avatar
      vulkan: add support for win32 handle types · 8dea6887
      Philip Langdale authored and Niklas Haas's avatar Niklas Haas committed
      There are two win32 specific handle types, which we believe to be
      the ones that would be primarily used by a win32 client.
      
      There is the 'NT Handle', which is available on Windows 8 or newer,
      and the 'Global share Handle' (abbreviated as KMT in the Vulkan spec),
      which is available on Windows 7 and newer, but which apparently
      shouldn't be used when the 'NT Handle' type is available. We do not
      attempt to judge usage, and it is up to the client to decide which
      of the two types it wants to use.
      
      Note that the existing logic for identifying the handle_caps is not
      actually sufficient. We need to call specific functions to identify
      what is possible for buffers, images, and semaphores.
      
      * vkGetPhysicalDeviceImageFormatProperties2KHR
      * vkGetPhysicalDeviceExternalBufferPropertiesKHR
      * vkGetPhysicalDeviceExternalSemaphorePropertiesKHR
      
      and these need to be called with the specific flags and parameters,
      so I think it basically ends up being that you can't tell if your
      image/buffer/semaphore is exportable until you create it. Anyway.
      
      I am not in a position to test any of these changes. Someone who
      can build on win32 must do that.
      8dea6887
    • Niklas Haas's avatar
      bstr: rename subproject lib · 08b45ede
      Niklas Haas authored
      This was still called 'lib3rdparty' from a previous iteration of the
      meson subprojects refactor.
      08b45ede
  9. Dec 05, 2018
  10. Dec 04, 2018
    • Niklas Haas's avatar
      3rdparty: use meson subprojects instead · 195f28ea
      Niklas Haas authored
      Major refactor of the source code structure. Now uses meson subprojects
      for "third party" dependencies (including bstr and talloc), and moves a
      lot of the meson boilerplate from src/meson.build to the top-level
      meson.build.
      
      We choose the name 'xtalloc' to make sure we don't collide with samba
      libtalloc, and to reflect the fact that our wrappers abort on OOM.
      195f28ea
Loading