aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickrendertarget.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2024-02-02 15:45:21 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2024-02-05 16:48:30 +0100
commit501fc71df69bf8b58eed9cf8af998edb3212c069 (patch)
tree9853210b2065ccfdf6eaaefef93fe57b14bd5213 /src/quick/items/qquickrendertarget.cpp
parentfff13f885370c02e7b8696ecedbfafa436e48ace (diff)
sg: Allow adopting foreign textures with GL_SRGB8_ALPHA8
Do what the other (Vulkan, D3D) paths do: set the appropriate QRhiTexture flag while mapping to RGBA8. This has no visible effect, but it avoids flooding the debug output with warnings in Quick 3D XR applications on Android (Quest 3) when using OpenGL ES. (because it hits the 'default' case that prints a warning and continues with UnknownFormat; not having the correct enum value in QRhiTexture has no effect in typical Qt Quick / 3D apps, but nonetheless we should not hit that path) The usage of sRGB formats is an interesting case with VR compositors: with Vulkan and D3D12 we explicitly drop the _SRGB format in Quick 3D XR (e.g. we change VK_FORMAT_R8G8B8A8_SRGB to VK_FORMAT_R8G8B8A8_UNORM) before passing the native image object to Qt Quick, but there this is necessary since having a _SRGB format changes the behavior in shader writes (because the image/render target views inherit the QRhiTexture format in the QRhi backends), whereas Qt Quick 3D performs linearization and sRGB conversion at the end of the pipeline, so this would clash (like doing an additional unwanted linear-sRGB conversion on the already sRGB data) OpenGL is different, however, when it comes to the API: there is no implicit behavior unless the appropriate state is enabled (which we do not do), hence the OpenGL (ES) path in Quick 3D XR does not need to perform the format demotion, but then it is ideal if Qt Quick accepts those formats (which was missing until now for some reason unknown). Regardless, the demotion may still be implemented in Quick 3D XR separately later. In practice this should remove the "GL format 35907 is not supported" messages appearing in the Android logs on every frame or so with Quick 3D XR apps. Change-Id: I3e9135f790be0eda51d3b1d68f6d115eb1a21000 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquickrendertarget.cpp')
-rw-r--r--src/quick/items/qquickrendertarget.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/quick/items/qquickrendertarget.cpp b/src/quick/items/qquickrendertarget.cpp
index 9c4f02b5ae..391b525114 100644
--- a/src/quick/items/qquickrendertarget.cpp
+++ b/src/quick/items/qquickrendertarget.cpp
@@ -212,8 +212,9 @@ QQuickRenderTarget QQuickRenderTarget::fromOpenGLTexture(uint textureId, uint fo
d->pixelSize = pixelSize;
d->sampleCount = qMax(1, sampleCount);
- auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromGL(format);
- d->u.nativeTexture = { textureId, 0, uint(rhiFormat), 0 };
+ QRhiTexture::Flags rhiFlags;
+ auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromGL(format, &rhiFlags);
+ d->u.nativeTexture = { textureId, 0, uint(rhiFormat), uint(rhiFlags) };
return rt;
}
@@ -277,8 +278,9 @@ QQuickRenderTarget QQuickRenderTarget::fromOpenGLTextureMultiView(uint textureId
d->pixelSize = pixelSize;
d->sampleCount = qMax(1, sampleCount);
- auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromGL(format);
- d->u.nativeTextureArray = { textureId, 0, arraySize, uint(rhiFormat), 0 };
+ QRhiTexture::Flags rhiFlags;
+ auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromGL(format, &rhiFlags);
+ d->u.nativeTextureArray = { textureId, 0, arraySize, uint(rhiFormat), uint(rhiFlags) };
return rt;
}