Skip to content

Commit 0af1b2b

Browse files
committed
NativeSkiaOutputDeviceVulkan: Fix Vulkan rendering with AMD GPU on Linux
gbm_bo_get_modifier() may return invalid DRM format modifier for AMD driver. In this case, create VkImage without DRM format modifier and fallback tiling to VK_IMAGE_TILING_OPTIMAL instead of VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT. Pick-to: 6.8 6.9 Fixes: QTBUG-123607 Change-Id: Iacf4fc514ab42fa9ab712f5d9fde2d20000f599d Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent 9ef6a18 commit 0af1b2b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/core/compositor/native_skia_output_device_vulkan.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,23 @@ QSGTexture *NativeSkiaOutputDeviceVulkan::texture(QQuickWindow *win, uint32_t te
136136
.pPlaneLayouts = &planeLayout,
137137
};
138138

139+
bool usingDrmModifier = false;
139140
if (nativePixmap) {
140141
qCDebug(lcWebEngineCompositor, "VULKAN: Importing NativePixmap into VkImage.");
141142
gfx::NativePixmapHandle nativePixmapHandle = nativePixmap->ExportHandle();
142-
if (nativePixmapHandle.planes.size() != 1)
143-
qFatal("VULKAN: Multiple planes are not supported.");
143+
qCDebug(lcWebEngineCompositor, " DRM Format Modifier: 0x%lx", nativePixmapHandle.modifier);
144144

145-
planeLayout.offset = nativePixmapHandle.planes[0].offset;
146-
planeLayout.rowPitch = nativePixmapHandle.planes[0].stride;
147-
modifierInfo.drmFormatModifier = nativePixmapHandle.modifier;
145+
if (nativePixmapHandle.modifier != gfx::NativePixmapHandle::kNoModifier) {
146+
usingDrmModifier = true;
147+
if (nativePixmapHandle.planes.size() != 1)
148+
qFatal("VULKAN: Multiple planes are not supported.");
148149

149-
externalMemoryImageCreateInfo.pNext = &modifierInfo;
150+
planeLayout.offset = nativePixmapHandle.planes[0].offset;
151+
planeLayout.rowPitch = nativePixmapHandle.planes[0].stride;
152+
modifierInfo.drmFormatModifier = nativePixmapHandle.modifier;
153+
154+
externalMemoryImageCreateInfo.pNext = &modifierInfo;
155+
}
150156
externalMemoryImageCreateInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
151157

152158
scopedFd = std::move(nativePixmapHandle.planes[0].fd);
@@ -225,9 +231,9 @@ QSGTexture *NativeSkiaOutputDeviceVulkan::texture(QQuickWindow *win, uint32_t te
225231
};
226232

227233
#if BUILDFLAG(IS_OZONE)
228-
if (nativePixmap)
234+
if (usingDrmModifier)
229235
importedImageCreateInfo.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
230-
else
236+
else if (vkImageInfo.fAlloc.fMemory != VK_NULL_HANDLE)
231237
importedImageCreateInfo.tiling = vkImageInfo.fImageTiling;
232238
#endif
233239

0 commit comments

Comments
 (0)