aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-07-08 13:40:39 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-08-03 17:43:09 +0000
commit81f258717e21c6f47eb98419b2fb0271b5c26240 (patch)
treea2a537d5a4f3a3bf15f0d5b878aed6a15ae31c5e
parent4d826160ddc21a89b62a027bcb0853e7ff49187b (diff)
sg: Prevent not supported format warnings when wrapping external textures
Amends 1df2cf6bad7207f16ddca17344cc1324e50f287e Clearly the intention is to continue using RGBA8 as the default when nothing is specified, but then the unknown/invalid value is not handled correctly in the conversion functions. As a result, when running f.ex. tst_qquickrendercontrol one gets warnings such as "VkFormat 0 is not supported". This is now avoided. Change-Id: I0dd2cda3fefe24a1bdac075892df5a6eb8796181 Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit c0bb8a0afb32d234918e9f460fa921658c2eef9f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/items/qquickrendertarget.cpp4
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp3
-rw-r--r--src/quick/scenegraph/qsgrhisupport_mac.mm1
3 files changed, 6 insertions, 2 deletions
diff --git a/src/quick/items/qquickrendertarget.cpp b/src/quick/items/qquickrendertarget.cpp
index 18bd297b50..e29e8839ba 100644
--- a/src/quick/items/qquickrendertarget.cpp
+++ b/src/quick/items/qquickrendertarget.cpp
@@ -383,7 +383,7 @@ QQuickRenderTarget QQuickRenderTarget::fromD3D11Texture(void *texture, uint form
*/
QQuickRenderTarget QQuickRenderTarget::fromD3D11Texture(void *texture, const QSize &pixelSize, int sampleCount)
{
- return fromD3D11Texture(texture, 0, pixelSize, sampleCount);
+ return fromD3D11Texture(texture, 0 /* DXGI_FORMAT_UNKNOWN */, pixelSize, sampleCount);
}
#endif
@@ -469,7 +469,7 @@ QQuickRenderTarget QQuickRenderTarget::fromMetalTexture(MTLTexture *texture, uin
*/
QQuickRenderTarget QQuickRenderTarget::fromMetalTexture(MTLTexture *texture, const QSize &pixelSize, int sampleCount)
{
- return fromMetalTexture(texture, 0, pixelSize, sampleCount);
+ return fromMetalTexture(texture, 0 /* MTLPixelFormatInvalid */, pixelSize, sampleCount);
}
#endif
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp
index 3199023417..ede98e865a 100644
--- a/src/quick/scenegraph/qsgrhisupport.cpp
+++ b/src/quick/scenegraph/qsgrhisupport.cpp
@@ -257,6 +257,7 @@ QRhiTexture::Format QSGRhiSupport::toRhiTextureFormatFromGL(uint format)
case GL_RGBA:
Q_FALLTHROUGH();
case GL_RGBA8:
+ case 0:
rhiFormat = QRhiTexture::RGBA8;
break;
case GL_BGRA:
@@ -330,6 +331,7 @@ QRhiTexture::Format QSGRhiSupport::toRhiTextureFormatFromVulkan(uint format, QRh
sRGB = true;
Q_FALLTHROUGH();
case VK_FORMAT_R8G8B8A8_UNORM:
+ case VK_FORMAT_UNDEFINED:
rhiFormat = QRhiTexture::RGBA8;
break;
case VK_FORMAT_B8G8R8A8_SRGB:
@@ -540,6 +542,7 @@ QRhiTexture::Format QSGRhiSupport::toRhiTextureFormatFromD3D11(uint format, QRhi
sRGB = true;
Q_FALLTHROUGH();
case DXGI_FORMAT_R8G8B8A8_UNORM:
+ case DXGI_FORMAT_UNKNOWN:
rhiFormat = QRhiTexture::RGBA8;
break;
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
diff --git a/src/quick/scenegraph/qsgrhisupport_mac.mm b/src/quick/scenegraph/qsgrhisupport_mac.mm
index 302b8dae80..1d882ab3e5 100644
--- a/src/quick/scenegraph/qsgrhisupport_mac.mm
+++ b/src/quick/scenegraph/qsgrhisupport_mac.mm
@@ -18,6 +18,7 @@ QRhiTexture::Format toRhiTextureFormatFromMetal(uint format, QRhiTexture::Flags
sRGB = true;
Q_FALLTHROUGH();
case MTLPixelFormatRGBA8Unorm:
+ case MTLPixelFormatInvalid:
rhiFormat = QRhiTexture::RGBA8;
break;
case MTLPixelFormatBGRA8Unorm_sRGB: