• Show log

    Commit

  • Hash : 0f75fc3d
    Author : Shahbaz Youssefi
    Date : 2025-01-20T14:10:41

    Vulkan: Transition foreign images to the FOREIGN queue on submit
    
    Vulkan's interaction with AHB and dmabuf images is through the FOREIGN
    queue family.  When ANGLE uses these images, it must take ownership of
    the images by doing a queue family ownership transfer (QFOT) away from
    the FOREIGN queue family and into the graphics queue family used by the
    Vulkan backend.
    
    Prior to this change, ANGLE would do the QFOT away from FOREIGN once
    such a foreign image is imported into an EGL image.  Afterwards, usage
    in ANGLE works correctly.  What ANGLE did not handle is when a foreign
    entity wants to use these images _after_ ANGLE has used them.
    
    For the above to work correctly, ANGLE must do a QFOT back into FOREIGN
    before the image can be used by the foreign entity.  Unfortunately,
    EGL does not provide a clear point for this hand-off to happen.  ANGLE
    has no choice then to proactively transition the images back into
    FOREIGN at some point "just in case".
    
    For some native drivers, this hand-off to FOREIGN can be quite frequent.
    For example, on Android for most vendors there is no actual layout
    transition between graphics and FOREIGN queue families (the actual data
    layout is the same), so a cache flush/invalidate at strategic points
    (such as the end of the command buffer) is sufficient as equivalent to
    transition to FOREIGN (and another at the beginning of the command
    buffer as equivalent to transition from FOREIGN).
    
    As a layer over Vulkan's formalism, ANGLE is less lucky; it has to
    enumerate exactly which image is being transitioned to and away from
    FOREIGN.  Transitions away from FOREIGN are in principle easy.  As long
    as the image is marked as being in the FOREIGN queue family, it will
    automatically transition to the graphics queue family on first use.
    
    In this change, when a foreign image is transitioned out of the FOREIGN
    queue, it's added to a list of images to be transitioned back to FOREIGN
    at submit time.  Once submission is done, the image may or may not
    actually be used by a foreign entity, but ANGLE cannot know that.  The
    next time the image is used in ANGLE, it is transitioned out of FOREIGN.
    
    Verifying correctness with multi-threading is tricky, and relies on GL's
    requirement that access in one context is followed by a synchronization
    and rebind in another context before it can be used there.  This means
    that the image's transition to FOREIGN (at the end of one submission)
    naturally happens before the transition back from FOREIGN (at the
    beginning of the next submission).  Because the set of images to
    transition is tracked in the context, submissions in other contexts
    don't interfere with the above logic.
    
    The situation can be more complicated with one-off submissions, but
    fortunately, no such usage of foreign images is present.
    
    Another wrinkle is simultaneous usage of the image as read-only in two
    contexts.  According to GL, this is not a hazard and requires no
    synchronization.  However this is broken in ANGLE even for non-foreign
    images (see http://anglebug.com/42266349), because as what _seems_ like
    read-only usage of the image from GL's point of view (like sampling from
    the image), there are associated write operations from Vulkan's point of
    view (image layout transitions and QFOT).  This change does not attempt
    to address this corner case.
    
    Bug: angleproject:42263241
    Bug: angleproject:42262454
    Bug: angleproject:390443243
    Bug: chromium:382527242
    Change-Id: Idd4ef1fecfa3fccf1a4063f1bddb08d28b85386b
    Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6184604
    Reviewed-by: Charlie Lao <cclao@google.com>
    Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
    

  • Properties

  • Git HTTP https://git.kmx.io/kc3-lang/angle.git
    Git SSH git@git.kmx.io:kc3-lang/angle.git
    Public access ? public
    Description

    A conformant OpenGL ES implementation for Windows, Mac, Linux, iOS and Android.

    Homepage

    Github

    Users
    thodg_m kc3_lang_org thodg_w www_kmx_io thodg thodg_l
    Tags