Title: [294803] trunk/Source/WebCore/platform/graphics
- Revision
- 294803
- Author
- z...@falconsigh.net
- Date
- 2022-05-25 10:22:59 -0700 (Wed, 25 May 2022)
Log 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
Modified Paths
Diff
Modified: trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp (294802 => 294803)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp 2022-05-25 16:53:05 UTC (rev 294802)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.cpp 2022-05-25 17:22:59 UTC (rev 294803)
@@ -48,7 +48,7 @@
// If the description of the requested buffers has changed, update the description to the new one and wreck the existing buffers.
// This should handle changes in format or dimension of the buffers.
- if (description.format.fourcc != m_array.description.format.fourcc || description.width != m_array.description.width || description.height != m_array.description.height) {
+ 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) {
m_array.description = description;
m_array.object = { };
}
@@ -95,12 +95,16 @@
return nullptr;
}
+ uint32_t boFlags = 0;
+ if (description.flags & BufferDescription::LinearStorage)
+ boFlags |= GBM_BO_USE_LINEAR;
+
// For each plane, we spawn a gbm_bo object of the appropriate size and format.
// TODO: GBM_BO_USE_LINEAR will be needed when transferring memory into the bo (e.g. copying
// over the software-decoded video data), but might not be required for backing e.g. ANGLE rendering.
for (unsigned i = 0; i < buffer->m_description.format.numPlanes; ++i) {
auto& plane = buffer->m_planes[i];
- plane.bo = gbm_bo_create(device.device(), plane.width, plane.height, uint32_t(plane.fourcc), GBM_BO_USE_LINEAR);
+ plane.bo = gbm_bo_create(device.device(), plane.width, plane.height, uint32_t(plane.fourcc), boFlags);
plane.stride = gbm_bo_get_stride(plane.bo);
}
Modified: trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.h (294802 => 294803)
--- trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.h 2022-05-25 16:53:05 UTC (rev 294802)
+++ trunk/Source/WebCore/platform/graphics/gbm/GBMBufferSwapchain.h 2022-05-25 17:22:59 UTC (rev 294803)
@@ -64,9 +64,15 @@
~GBMBufferSwapchain();
struct BufferDescription {
+ enum Flags : uint32_t {
+ NoFlags = 0,
+ LinearStorage = 1 << 0,
+ };
+
DMABufFormat format { };
uint32_t width { 0 };
uint32_t height { 0 };
+ uint32_t flags { NoFlags };
};
class Buffer : public ThreadSafeRefCounted<Buffer> {
Modified: trunk/Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp (294802 => 294803)
--- trunk/Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp 2022-05-25 16:53:05 UTC (rev 294802)
+++ trunk/Source/WebCore/platform/graphics/gbm/GraphicsContextGLGBM.cpp 2022-05-25 17:22:59 UTC (rev 294803)
@@ -98,6 +98,7 @@
.format = DMABufFormat::create(uint32_t(contextAttributes().alpha ? DMABufFormat::FourCC::ARGB8888 : DMABufFormat::FourCC::XRGB8888)),
.width = std::clamp<uint32_t>(size.width(), 0, UINT_MAX),
.height = std::clamp<uint32_t>(size.height(), 0, UINT_MAX),
+ .flags = GBMBufferSwapchain::BufferDescription::NoFlags,
});
GLenum textureTarget = drawingBufferTextureTarget();
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (294802 => 294803)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-05-25 16:53:05 UTC (rev 294802)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2022-05-25 17:22:59 UTC (rev 294803)
@@ -3140,10 +3140,12 @@
}
// If the decoder is exporting raw memory, we have to use the swapchain to allocate appropriate buffers
- // and copy over the data for each plane.
+ // and copy over the data for each plane. For that to work, linear-storage buffer is required.
GBMBufferSwapchain::BufferDescription bufferDescription {
- DMABufFormat::create(fourccValue(GST_VIDEO_INFO_FORMAT(&videoInfo))),
- static_cast<uint32_t>GST_VIDEO_INFO_WIDTH(&videoInfo), static_cast<uint32_t>GST_VIDEO_INFO_HEIGHT(&videoInfo),
+ .format = DMABufFormat::create(fourccValue(GST_VIDEO_INFO_FORMAT(&videoInfo))),
+ .width = static_cast<uint32_t>GST_VIDEO_INFO_WIDTH(&videoInfo),
+ .height = static_cast<uint32_t>GST_VIDEO_INFO_HEIGHT(&videoInfo),
+ .flags = GBMBufferSwapchain::BufferDescription::LinearStorage,
};
if (bufferDescription.format.fourcc == DMABufFormat::FourCC::Invalid)
return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes