Skip to content

Commit ed0aa42

Browse files
[GBM] Allow ForceLinear buffers even when DRM_FORMAT_MOD_LINEAR is not in the modifier list
https://bugs.webkit.org/show_bug.cgi?id=309351 Reviewed by Carlos Garcia Campos. When ForceLinear is requested but DRM_FORMAT_MOD_LINEAR is not among the supported modifiers, clear the modifier list instead of skipping the format entirely. This allows GBM to allocate a linear buffer via the implicit modifier path. Also simplify the error check to crash on any negotiation failure rather than only on the ForceLinear case. Covered by existing tests - when using certain GPU drivers. * Source/WebCore/platform/graphics/gbm/MemoryMappedGPUBuffer.cpp: (WebCore::MemoryMappedGPUBuffer::create): Canonical link: https://commits.webkit.org/308883@main
1 parent 2b9471c commit ed0aa42

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Source/WebCore/platform/graphics/gbm/MemoryMappedGPUBuffer.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ std::unique_ptr<MemoryMappedGPUBuffer> MemoryMappedGPUBuffer::create(const IntSi
8282
continue;
8383

8484
if (flags.contains(BufferFlag::ForceLinear)) {
85-
if (format.modifiers.contains(DRM_FORMAT_MOD_LINEAR)) {
86-
// If a linear buffer is requested - only allow a single modifier.
87-
auto useFormat = format;
85+
// If a linear buffer is requested - only allow a single modifier.
86+
auto useFormat = format;
87+
if (format.modifiers.contains(DRM_FORMAT_MOD_LINEAR))
8888
useFormat.modifiers = { DRM_FORMAT_MOD_LINEAR };
89-
return useFormat;
90-
}
89+
else
90+
useFormat.modifiers = { };
91+
return useFormat;
9192
} else if (flags.contains(BufferFlag::ForceVivanteSuperTiled)) {
9293
if (format.modifiers.contains(DRM_FORMAT_MOD_VIVANTE_SUPER_TILED)) {
9394
// If a Vivante super-tiled buffer is requested - only allow a single modifier.
@@ -104,8 +105,8 @@ std::unique_ptr<MemoryMappedGPUBuffer> MemoryMappedGPUBuffer::create(const IntSi
104105

105106
auto bufferFormat = negotiateBufferFormat();
106107

107-
if (flags.contains(BufferFlag::ForceLinear) && (!bufferFormat.has_value() || !bufferFormat->modifiers.contains(DRM_FORMAT_MOD_LINEAR))) {
108-
WTFLogAlways("ERROR: ForceLinear flag set but DRM_FORMAT_MOD_LINEAR not supported by the negotiated buffer format. Aborting ..."); // NOLINT
108+
if (!bufferFormat.has_value()) {
109+
WTFLogAlways("ERROR: Could not negotiate a suitable buffer format. Aborting ..."); // NOLINT
109110
CRASH();
110111
}
111112

0 commit comments

Comments
 (0)