98 lines
4.5 KiB
Diff
98 lines
4.5 KiB
Diff
From b829ca7c36d3d525b3f794d8c3ebf3417bdcb43a Mon Sep 17 00:00:00 2001
|
|
From: Peter Varga <pvarga@inf.u-szeged.hu>
|
|
Date: Tue, 25 Mar 2025 14:53:38 +0100
|
|
Subject: [PATCH] NativeSkiaOutputDeviceVulkan: Use minimal set of usage flags
|
|
for VkImage
|
|
|
|
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT usage flag is not necessary because
|
|
the native VkImage imported into QSG seems to be only accessed via
|
|
sampling. VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT also seems to conflict
|
|
with the VK_IMAGE_LAYOUT_UNDEFINED initial layout with Nvidia driver.
|
|
VK_IMAGE_LAYOUT_UNDEFINED is a requirement for importing external
|
|
texture from Chromium.
|
|
|
|
Keep VK_IMAGE_USAGE_SAMPLE_BIT usage flag because it is a requirement
|
|
for sampling.
|
|
|
|
Remove the corressponding VK_IMAGE_LAYOUT_PRINITIALIZED initial layout
|
|
workaround for Nvidia. It is not necessary without the
|
|
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT flag and fixes validation layer
|
|
warning.
|
|
|
|
Also remove VK_IMAGE_USAGE_TRANSFER_DST_BIT and
|
|
VK_IMAGE_TRANSFER_SRC_BIT usage flags because those are not used and
|
|
seem to be leftover from an earlier implementation.
|
|
|
|
Pick-to: 6.8
|
|
Task-number: QTBUG-123607
|
|
Change-Id: If9dba4b6ff9d584e3d103ec8d05b7fe0cdaec339
|
|
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
|
|
(cherry picked from commit f88fa0c83c7f0c063475539b327065f8615fe9d7)
|
|
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
|
|
---
|
|
.../native_skia_output_device_vulkan.cpp | 24 +++++--------------
|
|
1 file changed, 6 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/src/core/compositor/native_skia_output_device_vulkan.cpp b/src/core/compositor/native_skia_output_device_vulkan.cpp
|
|
index c40530644..924cc951b 100644
|
|
--- a/src/core/compositor/native_skia_output_device_vulkan.cpp
|
|
+++ b/src/core/compositor/native_skia_output_device_vulkan.cpp
|
|
@@ -112,16 +112,6 @@ QSGTexture *NativeSkiaOutputDeviceVulkan::texture(QQuickWindow *win, uint32_t te
|
|
QVulkanFunctions *f = win->vulkanInstance()->functions();
|
|
QVulkanDeviceFunctions *df = win->vulkanInstance()->deviceFunctions(qtVulkanDevice);
|
|
|
|
- VkImageLayout imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
- VkPhysicalDeviceProperties deviceProperties;
|
|
- f->vkGetPhysicalDeviceProperties(qtPhysicalDevice, &deviceProperties);
|
|
- if (deviceProperties.vendorID == 0x10DE) {
|
|
- // FIXME: This is a workaround for Nvidia driver.
|
|
- // The imported image is empty if the initialLayout is not
|
|
- // VK_IMAGE_LAYOUT_PREINITIALIZED.
|
|
- imageLayout = VK_IMAGE_LAYOUT_PREINITIALIZED;
|
|
- }
|
|
-
|
|
VkExternalMemoryImageCreateInfoKHR externalMemoryImageCreateInfo = {
|
|
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR,
|
|
.pNext = nullptr,
|
|
@@ -210,10 +200,6 @@ QSGTexture *NativeSkiaOutputDeviceVulkan::texture(QQuickWindow *win, uint32_t te
|
|
Q_ASSERT(sharedHandle != INVALID_HANDLE_VALUE);
|
|
#endif
|
|
|
|
- constexpr VkImageUsageFlags kUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
|
- | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT
|
|
- | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
|
-
|
|
VkImageCreateInfo importedImageCreateInfo = {
|
|
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
|
.pNext = &externalMemoryImageCreateInfo,
|
|
@@ -229,11 +215,13 @@ QSGTexture *NativeSkiaOutputDeviceVulkan::texture(QQuickWindow *win, uint32_t te
|
|
.arrayLayers = 1,
|
|
.samples = VK_SAMPLE_COUNT_1_BIT,
|
|
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
|
- .usage = kUsage,
|
|
+ // The image is fed into a combined image sampler
|
|
+ .usage = VK_IMAGE_USAGE_SAMPLED_BIT,
|
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
|
.queueFamilyIndexCount = 0,
|
|
.pQueueFamilyIndices = nullptr,
|
|
- .initialLayout = imageLayout,
|
|
+ // VkExternalMemoryImageCreateInfo only allows UNDEFINED
|
|
+ .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
|
};
|
|
|
|
#if BUILDFLAG(IS_OZONE)
|
|
@@ -314,8 +302,8 @@ QSGTexture *NativeSkiaOutputDeviceVulkan::texture(QQuickWindow *win, uint32_t te
|
|
df->vkBindImageMemory(qtVulkanDevice, importedImage, importedImageMemory, 0);
|
|
|
|
QQuickWindow::CreateTextureOptions texOpts(textureOptions);
|
|
- QSGTexture *texture = QNativeInterface::QSGVulkanTexture::fromNative(importedImage, imageLayout,
|
|
- win, size(), texOpts);
|
|
+ QSGTexture *texture = QNativeInterface::QSGVulkanTexture::fromNative(
|
|
+ importedImage, importedImageCreateInfo.initialLayout, win, size(), texOpts);
|
|
|
|
m_frontBuffer->textureCleanupCallback = [=]() {
|
|
df->vkDestroyImage(qtVulkanDevice, importedImage, nullptr);
|
|
--
|
|
2.49.0
|
|
|