Changeset 294803 in webkit


Ignore:
Timestamp:
May 25, 2022 10:22:59 AM (2 years ago)
Author:
zan@falconsigh.net
Message:

[Linux] GBMBufferSwapchain should only conditionally create linear-formatted buffer objects
https://bugs.webkit.org/show_bug.cgi?id=240637

Reviewed by Adrian Perez de Castro.

Spawning new gbm_bo objects should not default to requesting linear-storage
buffers. Instead, these should only be created when necessary, e.g. when
copying software-decoded video data into these buffers.

By default, no GBM flags are used. When required, the linear-storage requirement
is enscribed in the new flags field of the GBMBufferSwapchain::BufferDescription
object and acted upon in the GBMBufferSwapchain::getBuffer() call, using the
GBM_BO_USE_LINEAR flag in the gbm_bo_create() call.

The DMABuf-specific sink in MediaPlayerPrivateGStreamer is the only place at the
moment where linear-storage buffers are used since software-decoded material
originates here and is stored in linear memory.

  • Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp:

(WebCore::GBMBufferSwapchain::getBuffer):

  • Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.h:
  • Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp:

(WebCore::GraphicsContextGLANGLE::makeContextCurrent):

  • Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::pushDMABufToCompositor):

Canonical link: https://commits.webkit.org/250959@main

Location:
trunk/Source/WebCore/platform/graphics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp

    r294100 r294803  
    4949    // If the description of the requested buffers has changed, update the description to the new one and wreck the existing buffers.
    5050    // This should handle changes in format or dimension of the buffers.
    51     if (description.format.fourcc != m_array.description.format.fourcc || description.width != m_array.description.width || description.height != m_array.description.height) {
     51    if (description.format.fourcc != m_array.description.format.fourcc || description.width != m_array.description.width || description.height != m_array.description.height || description.flags != m_array.description.flags) {
    5252        m_array.description = description;
    5353        m_array.object = { };
     
    9696            }
    9797
     98            uint32_t boFlags = 0;
     99            if (description.flags & BufferDescription::LinearStorage)
     100                boFlags |= GBM_BO_USE_LINEAR;
     101
    98102            // For each plane, we spawn a gbm_bo object of the appropriate size and format.
    99103            // TODO: GBM_BO_USE_LINEAR will be needed when transferring memory into the bo (e.g. copying
     
    101105            for (unsigned i = 0; i < buffer->m_description.format.numPlanes; ++i) {
    102106                auto& plane = buffer->m_planes[i];
    103                 plane.bo = gbm_bo_create(device.device(), plane.width, plane.height, uint32_t(plane.fourcc), GBM_BO_USE_LINEAR);
     107                plane.bo = gbm_bo_create(device.device(), plane.width, plane.height, uint32_t(plane.fourcc), boFlags);
    104108                plane.stride = gbm_bo_get_stride(plane.bo);
    105109            }
  • trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.h

    r291392 r294803  
    6565
    6666    struct BufferDescription {
     67        enum Flags : uint32_t {
     68            NoFlags = 0,
     69            LinearStorage = 1 << 0,
     70        };
     71
    6772        DMABufFormat format { };
    6873        uint32_t width { 0 };
    6974        uint32_t height  { 0 };
     75        uint32_t flags { NoFlags };
    7076    };
    7177
  • trunk/Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp

    r294290 r294803  
    9999                .width = std::clamp<uint32_t>(size.width(), 0, UINT_MAX),
    100100                .height = std::clamp<uint32_t>(size.height(), 0, UINT_MAX),
     101                .flags = GBMBufferSwapchain::BufferDescription::NoFlags,
    101102            });
    102103
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r294468 r294803  
    31413141
    31423142    // If the decoder is exporting raw memory, we have to use the swapchain to allocate appropriate buffers
    3143     // and copy over the data for each plane.
     3143    // and copy over the data for each plane. For that to work, linear-storage buffer is required.
    31443144    GBMBufferSwapchain::BufferDescription bufferDescription {
    3145         DMABufFormat::create(fourccValue(GST_VIDEO_INFO_FORMAT(&videoInfo))),
    3146         static_cast<uint32_t>GST_VIDEO_INFO_WIDTH(&videoInfo), static_cast<uint32_t>GST_VIDEO_INFO_HEIGHT(&videoInfo),
     3145        .format = DMABufFormat::create(fourccValue(GST_VIDEO_INFO_FORMAT(&videoInfo))),
     3146        .width = static_cast<uint32_t>GST_VIDEO_INFO_WIDTH(&videoInfo),
     3147        .height = static_cast<uint32_t>GST_VIDEO_INFO_HEIGHT(&videoInfo),
     3148        .flags = GBMBufferSwapchain::BufferDescription::LinearStorage,
    31473149    };
    31483150    if (bufferDescription.format.fourcc == DMABufFormat::FourCC::Invalid)
Note: See TracChangeset for help on using the changeset viewer.