Skip to content
  • José María Casanova Crespo's avatar
    v3d: Enables DRM_FORMAT_MOD_BROADCOM_SAND128 support · 95c4f0f9
    José María Casanova Crespo authored
    
    
    It enables SAND modifier with columns 128-bytes-wide support for
    NV12 format.
    
    When a DRM_FORMAT_MOD_BROADCOM_SAND128 is enabled an imported NV12
    texture format has a different layout. Luma and Chroma planes layout
    is interleaved for every 128-bytes-wide columns.
    
    Although TFU was supposed to convert a NV12 with SAND_COL128 modifier
    from YUV to sRGB color space, it expects a particular swizzle that is not
    the one provided by the video decoder available at the Raspberry Pi 4.
    
    This patch follows a similar approach to VC4 YUV blit, using a custom
    blit shader that transforms a NV12 texture with SAND_COL128 modifier
    with the two interleaved planes to two not-interleaved textures with
    UIF format, as it was a regular NV12 format texture.
    
    To reduce the number of texture-fetch operations during the blit, we
    are reading and writing the textures in pixel groups of 32-bits. This
    implies some swizzling of the pixels to meet the particularities
    of the different micro-tile layouts for 8bpp, 16bpp and 32bpp.
    
    With this approach, we are not adding a new format that could be named
    "NV12_SAND128". We are just enabling a format modifier.
    
    v2: Rework checks for supported modifiers (Alejandro Piñeiro)
        Destroy custom shaders on context destroy (Alejandro Piñeiro)
        Add more comments (Alejandro Piñeiro)
        SAND128 in query_dmabuf_modifiers should report external_only true.
    
    Reviewed-by: default avatarAlejandro Piñeiro <apinheiro@igalia.com>
    Part-of: <!10051>
    95c4f0f9