summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Skip Vulkan on Android in QRhi autotest"Assam Boudjelthia2024-04-051-2/+1
| | | | | | | | | | | | This reverts commit 0d413506a1b019efecff41318a9134d79f2abcd1. Reason for revert: Latest emulator fixed the issue. Task-number: QTBUG-118220 Task-number: QTQAINFRA-5971 Pick-to: 6.7 Change-Id: I0d4792ef68a3ad840c8c353f55cb96d0be7cd66e Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* rhi: Add support for resolving depth-stencilLaszlo Agocs2024-04-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add setDepthResolveTexture(). Should work similarly to the color attachments' resolveTexture, but for depth or depth-stencil. However, this is another fragmented feature. - D3D11/12: Not supported. AFAICS multisample resolve (ResolveSubresource) is just not supported for depth or depth-stencil formats. - Vulkan: Not supported with Vulkan 1.0. Supported with Vulkan 1.1 and the two extensions. (VK_KHR_depth_stencil_resolve which in turn requires VK_KHR_create_renderpass2 since the 1.0 structs are not extensible, so now need to use VkRenderPassCreateInfo2 and all the '2' structs) In Vulkan 1.2 the above are in core, without the KHR suffix, but we cannot just use that because our main target, the Quest 3 (Android) is Vulkan 1.1. So 1.2 and up is ignored for now and we always look for the 1.1 KHR extensions. The depth resolve filter is forced for SAMPLE_0. AVG seems to be supported on desktop (NVIDIA) at least, but that's not guaranteed, so would need physical device support checks. On the Quest 3 it does not seem to be supported. And in any case, other APIs such as Metal do not have an AVG filter mode at all, so just use SAMPLE_0 always. - OpenGL (not ES): Should work, both when the multisample data is a renderbuffer and a texture. Relies on glBlitFramebuffer with filter NEAREST. What it does internally, with regards to the depth/stencil resolve mode, is not under our control. - OpenGL ES: Should work when the multisample buffer is a texture. But it will not work when a multisample renderbuffer (setDepthStencilBuffer, not setDepthTexture) is used because the GLES-only multisample extensions (GL_EXT_multisampled_render_to_texture, GL_OVR_multiview_multisampled_render_to_texture, which we prefer over the explicit resolve-based approach) work with textures only. - Metal: Should work. Task-number: QTBUG-122292 Change-Id: Ifa7ca5e1be78227bd6bd7546dde3a62f7fdbc95e Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add configure feature for MetalTor Arne Vestbø2024-03-191-1/+1
| | | | | | | Simplifies maintenance of code paths that rely on Metal. Change-Id: I1d1f705fffc14dbafde346eeb555b43be6d5be54 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* rhi: Add basic support for specifying a view format for a textureLaszlo Agocs2024-03-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have to be able to strip the _SRGB nonsense from the render target view formats when rendering into textures that are provided from an external engine (e.g. OpenXR) and are forced onto us with formats such as VK_FORMAT_R8G8B8A8_SRGB. This highlights some limitation of the current system, which has very limited handling of sRGB stuff since proper renderers such as Qt Quick 3D have first class support for linearization and converting to sRGB at the end of their shading pipeline, so _SRGB format textures are never used in practice. OpenGL has an issue which is different from everything else, namely that we do not correctly do the glEnable/Disable on GL_FRAMEBUFFER_SRGB. The QOpenGLExtensions flag is not what we need. We need to know if the sRGB-conversion-on-write is supported or not, not that some framebuffer is sRGB-capable. So do our own query based on the desktop and the ES extension (GL_EXT_sRGB_write_control is something we never checked for, but that is the appropriate GLES extension, supported on the Quest 3 for instance) This is now corrected in the gl backend. This means that the colors will no longer be "too bright" with OpenGL ES and multiview on the Quest 3 for example. Unlike OpenGL, Vulkan and D3D automatically convert in shader reads and writes when the shader resource view or the render target view has a _SRGB format. (which we get by default since we pass on the texture format) Getting a second linear->sRGB conversion on the already sRGB data generated by e.g. Qt Quick 3D is just wrong. Allow solving this by a new function that can be optionally called to say we want (RGBA8, srgb=false), i.e. VK_FORMAT_R8G8B8A8_UNORM, for the views. Of course, reality is more complicated. D3D11 for instance does not allow "casting" a fully typed texture, we'd need to use a _TYPELESS format for that (possibly with other consequences), so skip D3D11. For D3D12 this should work from Windows 1703 on. Implementing for Metal is also left as a future exercise - it is neither needed at the moment within Qt, nor is it trivial, because view textures have to be created explicitly in Metal, normally we just work with the MTLTexture as-is, not with views. Task-number: QTBUG-122288 Task-number: QTBUG-122614 Change-Id: I8aea4e892b308d48f0bf18bdef481e460fbc9d47 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix build with gcc-14Allan Sandfeld Jensen2024-02-141-3/+3
| | | | | | | | | | Work-around SiC change made to qfloat16 when using native floats. Pick-to: 6.7 6.6 6.5 Change-Id: I981505e6eff7277ad14512b56fad334be6e79016 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* rhi: Add an autotest for multiviewLaszlo Agocs2024-01-151-1/+180
| | | | | | | Fixes: QTBUG-119742 Change-Id: Id4dba72eadfac74e1dd9ef57d90774c6a8bf8bdd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make sample count selection logic be closer to Qt 5Laszlo Agocs2023-12-061-2/+62
| | | | | | | | Pick-to: 6.6 6.5 Fixes: QTBUG-119148 Change-Id: Ia119ab3ced9da08853c608aa256bde08a6fd8d4e Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qrhi: Exercise a readonly storage buffer in the simple testLaszlo Agocs2023-11-081-1/+1
| | | | | | | | | | | ...not only in the tessellation-related ones (that are skipped with D3D). The checked-in .qsb file is generated with a patched shadertools that fixes a bug regarding readonly storage buffers and HLSL. Change-Id: Iafbad4e81875d7b4f877435b9b1e6078019d52ac Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Skip Vulkan on Android in QRhi autotestLaszlo Agocs2023-10-231-1/+2
| | | | | | | Fixes: QTBUG-118220 Change-Id: I78b4b8b85f316f087ab7a01c1ee0c4fad46c632a Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* rhi: vulkan: Include multiViewCount in renderpass compatibilityLaszlo Agocs2023-07-051-0/+53
| | | | | Change-Id: I3185ce27c52c138053fee4805eccbe3575b9433a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vulkan: expose the instance in the nativeHandles queryLaszlo Agocs2023-05-301-0/+2
| | | | | | | | | | | | | | | Mainly for completeness, but it has practical uses: someone retrieving a QRhi instance from somewhere should be able to tell the QVulkanInstance, and so the VkInstance, used by that QRhi without resorting to investigating other objects (e.g. retrieving the instance from the QWindow). This provides symmetry to other 3D APIs and QRhi backends where just a single QRhi instance is sufficient to get the MTLDevice, ID3D11Device/Context, etc. i.e. all that is needed to work with the 3D API directly. Change-Id: I5a8b9871a543ea648c76b868bf6ff7be5f2098f2 Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io> Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
* rhi: Make it a QPA-style private but semi-public APILaszlo Agocs2023-05-211-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qrhi.h, qshader.h, qshaderdescription.h (and qshaderbaker.h from shadertools; done separately) become "RHI APIs", following the concept of QPA APIs. Mirror completely what is done for QPA headers, but using the "rhi" prefix for the headers. This involves updating syncqt to handle the new category of headers. (a note on the regex: matching everything starting with "qrhi" is not acceptable due to incorrectly matching existing and future headers, hence specifying the four header names explicitly) There is going to be one difference to QPA: the documentation for everything RHI is going to be public and part of the regular docs, not hidden with \internal. In addition to the header renaming and adding the comments and documentation notes and warnings, there is one significant change here: there is no longer a need to do API-specific includes, such as qrhid3d11[_p].h, qrhivulkan[_p].h, etc. These are simply merged into a single header that is then included from qrhi.h. This means that users within Qt, and any future applications can just do #include <rhi/qrhi.h> (or rhi/qshader.h if the QRhi stuff is not relevant), no other headers are needed. There are no changes to functionality in this patch. Only the documentation is expanded, quite a lot, to eliminate all qdoc warnings and make the generated API docs complete. An example, with a quite extensive doc page is added as well. Task-number: QTBUG-113331 Change-Id: I91c749826348f14320cb335b1c83e9d1ea2b1d8b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* rhi: Add another resource update batch autotestLaszlo Agocs2023-04-271-0/+82
| | | | | | | | | | Exercise the validity of update batches, i.e. that one can safely commit it in later frames as well, as long as all related buffers and textures stay valid. Change-Id: Ia943e4b37141fe17253eeae32010e0f8d92c1583 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Make it safe to always call deleteLater on a resourceLaszlo Agocs2023-04-181-1/+25
| | | | | | | | | | | | | | | | | | | ...even when the QRhi is already gone. This should not happen in well-written applications and libraries, but we handle this gracefully in the regular dtor and destroy() for resources that register themselves to their creator QRhi, so by registering everything we can offer this to all QRhiResource subclasses. We still want to differentiate between native resource owning QRhiResources and others (that do not create native graphics objects), so do this via a flag passed to registerResource(). This way the behavior with QT_RHI_LEAK_CHECK=1 does not change. Pick-to: 6.5 Fixes: QTBUG-112914 Change-Id: I9bafc81ef7a4ae76f356fc5f6248628d1f8791e0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Remove readback result type aliasLaszlo Agocs2023-04-121-6/+6
| | | | | | Change-Id: I1b14d3230ab4011506892c64ea03d5431d82a90d Reviewed-by: Christian Strømme <christian.stromme@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Android: skip two qrhi tests to enable Android 12 in CIAssam Boudjelthia2023-03-131-0/+12
| | | | | | | | | This is expected to be temporary and to be investigated afterwards. Task-number: QTBUG-108844 Pick-to: 6.5 Change-Id: I0a571dad2b99ceaa0fd48e5cdd81057e49e55ddf Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* rhi: Metal tessellation shader input output interface blocksBen Fletcher2023-03-091-0/+318
| | | | | | | | | | | | | | | | | | | | | | | | | Add support for shader input output interface blocks in Metal tessellation pipelines. This feature is builtin to other rhi supported tessellation backends (OpenGL/Vulkan). Metal tessellation is implemented as compute pipelines for vert and tesc, and a render pipeline for tese and frag. The shader conversion from GLSL is handled by SPIRV-Cross, which has a particular way of doing things. Rhi must setup the vertex inputs for the tese - frag render pipeline to read from buffers written by the tesc compute pipeline, following SPIRV-Cross conventions. This includes ensuring correct memory alignment per MSL Specification. In order to enable input output interface blocks, reflection of struct members of QShaderDescription::InOutVariable is required. Reflection of QShaderDescription::BuiltinVariable array dimensions is also required to support variable size tese builtin input gl_ClipDistance. An acompanying patch to QtShaderTools is required. Change-Id: Id94e86caef211485afc187bb79fe3d0619d02cf0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Add workaround for threeDimTexture case failing with some driversLaszlo Agocs2023-03-071-11/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not relevant for the CI as that does not run with any real Vulkan implementation. (and Lavapipe works if that's used) As the investigation in the Jira issue shows, there is no proper conclusion yet on why rendering to a slice of a 3D texture breaks the content of other slices that have image data written to them before that render pass targeting the slice. It would seem that transitioning to COLOR_ATTACHMENT_OPTIMAL has some unexpected consequences for slices that are not targeted by the render pass with Mesa on Intel. (NB rendering to a given 3D texture slice works via VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT; and how often this is needed in practice is unclear, typical volume rendering cases will anyway likely just upload data to the slices of a 3D texture, not rendering to them) The problem is still clearly visible in the tex3d manual test (when run on affected Linux machines), this we keep unchanged for the time being so that the issue can be examined further. However, the autotest is changed to prevent the issue from occurring (render to slice first, then upload to other slices) since it causes confusion when the test is run locally on various developer machines. Pick-to: 6.5 Task-number: QTBUG-111772 Change-Id: I4dc4c2413f8c518f377a33065992ad786a5ff44f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Clean up 1D and 3D texture feature flagsLaszlo Agocs2023-03-071-10/+16
| | | | | | | | | | | | | | Separate 1D mipmap generation support from rendering into an 1D texture. Those are two independent features, so have a separate feature flag for both instead of using just one. This will then be symmetric with the 3D texture features, where now we have a new flag to report support for generating mipmap for 3D textures. (whereas 3D texture as a render target is already covered by RenderTo3DTextureSlice) Change-Id: Ie5e1f056a7d1c341d90cd7fc522877a3f2da3290 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add support for half precision vertex atttributesBen Fletcher2023-02-271-0/+149
| | | | | | | | | | | | | | | | | | | Runtime support is indicated via QRhi::Feature::HalfAttributes. OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in implementations that support the extension GL_ARB_half_float_vertex. Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this feature. Note that D3D does not support the half3 type. D3D backends pass half3 as half4. tst_qrhi auto unit test included. Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Android: SKIP cases failing on Android 12 CI with 16GB RAMRami Potinkara2023-02-201-0/+4
| | | | | | | | | | | | | | | SKIP tst_QRhi::tessellation(Vulkan) SKIP tst_QOpenGLWidget::reparentHidden() SKIP tst_qvulkan cases Task-number: QTBUG-108844 Task-number: QTBUG-111235 Task-number: QTBUG-111236 Task-number: QTQAINFRA-5391 Task-number: QTQAINFRA-4733 Pick-to: 6.5 Change-Id: Id227367477173b6ad4cf9433af8eab5976596e70 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Update recent rhi autotest to skip on D3D12 as wellLaszlo Agocs2023-02-141-1/+1
| | | | | Change-Id: I4da78cd0cd1fd5015bc28bf01e59884abafa6995 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Metal SPIRV-Cross buffer size buffersBen Fletcher2023-02-141-0/+297
| | | | | | | | | | | | | When SPIRV-Cross encounters a GLSL storage buffer runtime sized array, it generates MSL code which expects a "buffer size buffer" containing a list of storage buffer sizes to be bound. This patch adds RHI backend support for Metal "buffer size buffers" on compute and graphics (including tessellation) pipelines. Includes unit tests. An accompanying patch to qtshadertools is required. Change-Id: I9392bfb21803e1a868d7de420fedc097a8452429 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add D3D12 supportLaszlo Agocs2023-02-071-9/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The optional nice-to-haves DebugMarkers, Timestamps, PipelineCache are not yet implemented (features reported as false, to be implemented later, although buffer/texture resource name setting already works as-is, regardless of DebugMarkers). - Mipmap generation for 3D textures is missing. Won't matter much given that 3D textures are not used in Qt for anything atm. For generating mipmaps for 2D (or 2D array) textures, the MiniEngine compute shader and approach is used. 3D support for the mipmap generator may be added later. 1D textures / arrays are supported except for mipmap generation, and so the OneDimensionalTextureMipmaps feature is reported as false. - Qt Quick and Qt Quick 3D are expected to be fully functional. (unforeseen issues are not impossible, of course) - Uses minimum feature level 11.0 when requesting the device. It is expected to be functional on resource binding tier 1 hardware even, although this has not been verified in practice. - 2 frames in flight with the usual resource buffering (QRhiBuffer::Dynamic is host visible (UPLOAD) and always mapped and slotted, other buffers and textures are device local (DEFAULT). Requests 3 swapchain buffers. Swapchains are mostly like with D3D11 (e.g. FLIP_DISCARD and SCALING_NONE). - The root signature generation is somewhat limited by the SPIR-V binding model and that we need to map every binding point using the nativeResourceBindingMap from the QShader. Thus the root signature is laid out so each stage has its own set of resources, with shader register clashes being prevented by setting the visibility to a given stage. Sampler handling is somewhat suboptimal but we are tied by the binding model and existing API design. It is in a fairly special situation due to the 2048 limit on a shader visible sampler heap, as opposed to 1000000 for SRVs and UAVS, so the approach we use for textures (just stage the CPU SRVs on the (per-frame slot) shader visible heap as they are encountered, effectively treating the heap as a ring buffer) would quickly lead to having to switch heaps many times with scenes with many draw calls and sampledTexture/sampler bindings in the srb. Whereas static samplers, which would be beautiful, are impossible to utilize safely since we do not have that concept (i.e. samplers specified upfront, tied to the graphics/compute pipeline) in the QRhi API, and an srb used at pipeline creation may change its associated resources, such as the QRhiSampler reference, by the time the shader resources are set for the draw call (or another, compatible srb may get used altogether), so specifying the samplers at root signature creation time is impossible. Rather, the current approach is to treat each sampler as a separate root parameter (per stage) having a descriptor table with a single entry. The shader visible sampler heap has exactly one instance of each unique sampler encountered during the lifetime of the QRhi. - Shader-wise no different from D3D11, works with HLSL/DXBC 5.0 (i.e. existing .qsb files with DXBC in them work as-is). But unlike D3D11, this one will try to pick 6.7, 6.6, ..., down to 5.0 from the QShader, in that order. - Uses D3D12MA for suballocating. As a result it can report vmem allocation statistics like the Vulkan backend, and it does more since the DXGI memory usage (incl. implicit resources) is also reported. This is optional technically, so we also have the option of going straight with the heavyweight CreateCommittedResource() instead. That is what we do if the adapter chosen reports it's software-based or when QT_D3D_NO_SUBALLOC=1 is set. - PreferSoftwareRenderer (picking the WARP device) and the env.var. QT_D3D_ADAPTER_INDEX work as with the D3D11 backend. - It is not unexpected that with large scenes that generate lots of draw calls with multiple textures/samplers per call the performance may be slightly below D3D11 (probably mostly due to descriptor management). Similarly, the reported memory usage will be higher, which is partly natural due to creating heaps, descriptor pools, staging areas, etc. upfront. Will need to be evaluated later how these can be tuned. Change-Id: I5a42580bb65f391ebceaf81adc6ae673cceacb74 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* rhi: vk: Fix up some legacy queue (family) index inconsistenciesLaszlo Agocs2022-12-161-2/+0
| | | | | | | | | | | | | | | Relevant mainly if we want to consistently expose these as the theoretically correct uint32_t/quint32 from Qt Quick's QSGRendererInterface. (not that int is not sufficient for indexing the typical 3-4 families and 2-16 queues per family) Some checks are not actually needed since the family index must always be valid after create(). Pick-to: 6.5 Task-number: QTBUG-108895 Change-Id: I474ccea51a81e7a096281604ff79b7db4cdd2484 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Buffer readback fixes and unit testBen Fletcher2022-12-141-0/+123
| | | | | | | | | | | | | | | | Fixes issues with readback of storage buffers modified on GPU for D3D and Metal. Adds unit test for storage buffer readback. D3D * Fixes issue where QRhiBufferReadbackResult::completed callback could be called twice on buffer readback completion. Metal * Fixes issue where buffer readback occurred prior to command buffer being committed. Change-Id: If55ac005f4438d66d2f65ea2e1ee0d5686c884ff Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Add support for 1D texturesBen Fletcher2022-11-151-0/+510
| | | | | | | Support for 1D textures on Vulkan, OpenGL, Metal, and D3D. Change-Id: Ie74ec103da9cfcbf83fa78588cf8cfc1bd6e104f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* rhi: metal: Add support for tessellationLaszlo Agocs2022-09-011-0/+163
| | | | | Change-Id: Ie8d226a6a959aa5e78284ea72505fd26aec1e671 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: tst_qrhi: Check for OpenGL cap on the platformLaszlo Agocs2022-08-161-37/+11
| | | | | | | | | | | | | | | | | | | | | | | Running tst_qrhi -platform eglfs will pass on RPi4 / Mesa 22. This does not test Vulkan of course since the platform plugin cannot create a Vulkan instance. Running tst_qrhi -platform vkkhrdisplay will enable Vulkan but will still try OpenGL since the autotest does not query the platform integration about OpenGL support. Make this nicer by skipping most of the GL test if the platform integration we have cannot handle OpenGL stuff anyway. For some tests the data-driven approach has to be removed since doing QFETCH without any rows will crash. These two OpenGL-specific tests now check OpenGL support directly and QSKIP if needed. While we are at it, fix up the Vulkan instance API version as well. Pick-to: 6.4 Change-Id: I2891c04540bc2dfd0ccf475629bd23542bff15f5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: gl: Avoid magic adjustments to the context/window formatLaszlo Agocs2022-08-011-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...by removing the entire adjustedFormat() helper. Qt Quick has never used this, which indicates it is not that useful. Same goes for Qt Multimedia or Qt 3D. Ensuring depth and stencil is requested is already solved by using QSurfaceFormat::setDefaultFormat() or by adjusting the formats everywhere as appropriate. The helper function's usages are in the manual tests that use it as a shortcut, and in the GL backend itself. Remove it and leave it up the client to set the depth or stencil buffer size, typically in the global default surface format. (which in fact many of the mentioned manual tests already did, so some of calls to window->setFormat(adjustedFormat()) were completely unnecessary) By not having the built-in magic that tries to always force depth and stencil, we avoid problems that arise then the helper cannot be easily invoked (thinking of widgets and backingstores), and so one ends up with unexpected stencil (or depth) in the context (where the GL backend auto-adjusts), but not in the window (which is not under QRhi's control). It was in practice possible to trigger EGL_BAD_MATCH failures with the new rhi-based widget composition on EGL-based systems. For example, if an application with a QOpenGLWidget did not set both depth and stencil (but only one, or none), it ended up failing due to the context - surface EGLConfig mismatches. On other platforms this matters less due to less strict config/pixelformat management. Pick-to: 6.4 Change-Id: I28ae2de163de63ee91bee3ceae08b58e106e1380 Fixes: QTBUG-104951 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Clean up some inconsistenciesLaszlo Agocs2022-07-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the offsets are already quint32 in the API (vertex input attributes, dynamic offsets, offsets in draw calls), matching the reality of the underlying 3D APIs, but many buffer-related functions use int as of now, simply because that used to be the default choice, and the same goes for sizes (such as buffer or range sizes). This is not quite consistent and should be cleaned up if for nothing else then just to make the classes consistent, but also because no 3D API use a signed type for offsets, sizes, and strides. (except OpenGL for some) When it comes to strides (for vertex inputs and raw image texture uploads), those are already all quint32s. This is straightforward because most of the 3D APIs use 32-bit uints for these regardless of the architecture. Sizes and offsets are often architecture-dependent (Vulkan, Metal), but there is at least one API where they are always 32-bit even on 64-bit Windows (UINT == unsigned int, D3D11). In addition, we do not really care about buffer or texture data larger than 4 GB, at least not without realistic use cases and real world testing, which are quite unlikely to materialize for now (esp. since we still have the width/height of 2D textures limited to 16 or 32K in many cases even on desktops, whereas 2GB+ buffers are not guaranteed in practice even when an API seemingly allows it). In any case, the important change here is the signed->unsigned switch. A number of casts can now be removed here and there in the backends, because the offsets and sizes are now unsigned as well, matching the underlying API reality. The size can be potentially increased later on with minimal effort, if that becomes necessary for some reason. Change-Id: I404dbc365ac397eaeeb3bd2da9ce7eb98916da5f Reviewed-by: Inho Lee <inho.lee@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Keep track of pipeline creation timesLaszlo Agocs2022-07-051-0/+34
| | | | | | | | | | | | | | | | | | | | | Make our QRhiMemAllocStats struct a bit more generic, drop the memory allocation part in the naming, and use the same getter and struct for reporting some important timings. (we are free to rename for now, there are no users in other modules yet) The time spent in graphics (or compute) pipeline creation has a special relevance in particular with the modern APIs (as it is the single biggest potentially time consuming blocking operation), but also highly interesting with others like D3D11 simply because that's where we do the expensive source-to-intermediate compilation is HLSL source is provided. In order to see the effects of the various caching mechanisms (of which there can be confusingly many, on multiple levels), the ability to see how much time we spent on pipeline creation e.g. until we render the first view of an application can be pretty essential. Task-number: QTBUG-103802 Change-Id: I85dd056a39db7e6b25fb1f9d02e4c94298d22b41 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make it possible to query the backend name beforehandLaszlo Agocs2022-07-051-0/+1
| | | | | | | | | | | | | | | | The goal is to make it possible to implement QSGRhiSupport::backendName() in Qt Quick with just a single line: return QString::fromUtf8(QRhi::backendName(m_rhiBackend)); instead of duplicating the strings and the logic. Similarly, QBackingStoreRhiSupport can now drop its apiName() helper entirely. Change-Id: Ia8cbb1f1243539ed4d7a98e71dcc2ed56b017e40 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* rhi: Make QRhiRenderTarget's rp getter functional with swapchainsLaszlo Agocs2022-04-261-0/+1
| | | | | | | | | | | | | | | | | swapchain->currentFrameRenderTarget()->renderPassDescriptor() is not functional at the moment, it returns null. This is because no backend ensures that the internal renderpass descriptor object is exposed via that getter in a QRhiSwapChainRenderTarget. Whereas in a QRhiTextureRenderTarget this would work by design because there the setter must be called by the user. Fix this up, providing better API symmetry, and also reducing the need to pass along QRhiRenderPassDescriptor objects seprately alongside a QRhiRenderTarget in some places, e.g. in Qt Quick. Change-Id: I42c4e9aaee3202c1d23bd093d840af80c5f8cd0f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add a feature flag for non-fill polygon modesLaszlo Agocs2022-04-221-1/+2
| | | | | | | | It's one thing that this is not part of OpenGL ES, but it is optional even with Vulkan, with some mobile GPUs not offering the feature at all. Change-Id: I4e2c6642eccb0793e69074b4b6eeb2b7cef3516e Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Add explicit subclass for RTs from swapchainsLaszlo Agocs2022-04-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | We want to enable gaining access to the underlying resource(s) by inspecting a QRhiRenderTarget. This is not currently possible for swapchains since there is nothing that references the actual QRhiSwapChain. To clean this up, make an explicit, new QRhiSwapChainRenderTarget subclass. Thus the logic already used in a couple of places to examine the resources attached to a QRhiTextureRenderTarget can now work with swapchain render targets too, by branching based on the resourceType(). This eliminates the somewhat odd setup where a "RenderTarget" resource is QRhiRenderTarget corresponding (but not exposing!) a swapchain, whereas a "TextureRenderTarget" is a QRhiTextureRenderTarget which is a subclass of QRhiRenderTarget. Now we correctly have an (abstract) base and two subclasses, one for each type of render targets. Besides, it allows us to clean up the oddly named Q...ReferenceRenderTarget classes in the backends, which initially tried to indicate that this "render target" merely references (or, in practice, is) a swapchain. We can now have a nice and symmetrical Q...SwapChainRenderTarget and Q...TextureRenderTarget naming scheme. Change-Id: Ib07e9be99a316eec67b94de0860e08f5f4638959 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d11/vulkan: Allow passing in an array range overrideLaszlo Agocs2022-03-241-1/+6
| | | | | | | | | | | | | | | | | | Only (straightforwardly) implementable with modern APIs, and only really exists to handle special platform cases, such as when a video framework gives us a D3D texture array with D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE which is only possible to use as a shader resource if the SRV selects a single array layer. Has no effect on the normal usage of texture arrays, where all array layers are exposed, and it is the shader that selects the layer when sampling or loading via the sampler2DArray. That continues to be the standard way to work with texture arrays. Change-Id: I0a656b605da21f50239b38abb83067e0208c1dbe Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* tst_qrhi: use OpenGL instead of raster pipeline on webOSJanne Juntunen2022-02-101-0/+3
| | | | | | | | | | Raster pipeline is not supported on webOS OSE: trying to use it causes an exit(1). Fixes: QTBUG-100654 Pick-to: 6.3 Change-Id: I00325fc1330a2d0d4abfdee054343ecfac767309 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add the long-pending probe() helper, with backing for MetalLaszlo Agocs2022-02-091-0/+2
| | | | | | | | | | | | | | | | | | | | | There is a TODO for this in Qt Quick from the 6.0 times. To decide upfront if Metal can be expected to function, or if a fallback to OpenGL needs to be triggered (especially important with macOS virtual machines, where, unlike any real macOS system, Metal may not be present at all), the scenegraph calls create() and then drops the result. The idea to make this less wasteful was back then to add a dedicated probing function which can, possibly, perform the checks in a more lightweight manner than full initialization. Implement this now, focusing on Metal. Brought to attention by QTBUG-100441: printing warnings about not having an MTLDevice is confusing in a Metal-less macOS VM, because it is not an actual error, only part of the probing at scenegraph initialization. We can now avoid printing confusing warnings there. Change-Id: Ie52c36af9224bedc3f5e4c23edb486d961c9f216 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make sure pixelSize() to a texture rt is always up to dateLaszlo Agocs2022-01-251-24/+42
| | | | | | | | | This is an issue for QQuickWindow in practice, although it is not hit by our current tests. Pick-to: 6.3 Change-Id: Ia73704c1af6a82b2689ce7b844d3b0eb9a17ec18 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Add queries for vertex input/output limitsLaszlo Agocs2022-01-121-0/+5
| | | | | | | | | | Mainly because we do have legacy code in the Qt 5 graphical effects that tries to dynamically determine the max number of varyings. Make it easier to port such code. Change-Id: I846cab2c2fe7b4cd473b5ced0146ca36f1c8169b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Improve the handling of HDR capable texture formatsLaszlo Agocs2022-01-111-146/+237
| | | | | | | | | | | Add some sort of autotest for both RGBA16F and the new RGB10A2. The latter is introduced particularly because ideally we should have a texture format that corresponds to the D3D/Vulkan swapchain color buffer format with HDR10. Change-Id: I1e1bbb7c7e32cb3db89275900811c0bcaeac39d6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add support for separate image and sampler objectsLaszlo Agocs2022-01-061-0/+127
| | | | | | | | | | | | | | | | | | | | | For Direct 3D, Metal, and Vulkan this is natively supported. (and makes no difference in particular for D3D and Metal because they do not have the legacy combined image sampler concept anyways) With OpenGL it will work too, but this relies on SPIR-Cross magic and is still using a combined sampler (e.g. a sampler2D) in the GLSL shader. The GL backend walks back and forth in the mapping tables from the shader baker in order to make this work, which is presumably slightly more expensive than combined image samplers. Do note that combined image samplers (i.e. sampler2D in the shader and QRhiShaderResourceBinding::sampledTexture() in code) continue to be the primary, recommended way for any user of the rhi for the time being. Change-Id: I194721bc657b1ffbcc1bb79e6eadebe569a25087 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Drop the profiler for nowLaszlo Agocs2022-01-041-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | The system we inherited from the original Qt 5.14 introduction of QRhi is a text stream based solution where resource creation and frame timings are sent in a comma-separated format to a QIODevice. This, while useful to get insights about the number of resources at a given time, is not actively helpful. The frameworks built on top (Qt Quick, Qt Quick 3D) are expected to provide solutions for logging timings in a different way (e.g. via the QML Profiler). Similarly, tracking active resources and generating statistics from that is better handled on a higher level. The unique bits, such as the Vulkan memory allocator statistics and the GPU frame timestamps, are converted into APIs in QRhi. This way a user of QRhi can query it at any time and do whatever it sees fit with the data. When it comes to the GPU timestamps, that has a somewhat limited value due to the heavy asynchronousness, hence the callback based API. Nonetheless, this is still useful since it is the only means of reporting some frame timing data (an approx. elapsed milliseconds for a frame) from the GPU side. Change-Id: I67cd58b81aaa7e343c11731f9aa5b4804c2a1823 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Auto-rebuild rt by tracking attachment id and generationLaszlo Agocs2021-12-101-0/+45
| | | | | | | | | | | | | | | | | | | | | | | Unlike the shader resource binding lists that automatically recognize in setShaderResources() when a referenced QRhiResource has been rebuilt in the meantime (create() was called i.e. there may be completely different native objects underneath), QRhiTextureRenderTarget has no such thing. This leads to an asymmetric API and requires also rebuilding the rt whenever an attachment is rebuilt: rt = rhi->newTextureRenderTarget({ { texture } }) rt->create() cb->beginPass(rt, ...) texture->setPixelSize(...) texture->create() rt->create() // this should not be needed cb->beginPass(rt, ...) Avoid having to do that second rt->create(). Change-Id: If14eaa7aac3530950498bbdf834324d0741a7c4d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add a more sophisticated resource update autotest caseLaszlo Agocs2021-11-271-0/+214
| | | | | | | | | | | | This time exercising series of buffer updates and texture uploads within proper, on-screen frames. (particularly interesting for dynamic buffers in case the double (or more) buffering and having multiple frames in flight involves special bookkeeping for these - using 'offscreen' frames like in other test cases does not necessarily exercise all of this) Change-Id: Id470919d27037359a1f0346a50a2a0e3966f5cd2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Expose the maximum uniform buffer range limitLaszlo Agocs2021-11-101-0/+2
| | | | | | | | Pick-to: 6.2 Task-number: QTBUG-97715 Change-Id: I7f0a52c410b9b77f735fb3b7fd33141674bb0cda Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>