summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhi.cpp
Commit message (Collapse)AuthorAgeFilesLines
* rhi: Add support for resolving depth-stencilLaszlo Agocs2024-04-031-2/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+4
| | | | | | | Simplifies maintenance of code paths that rely on Metal. Change-Id: I1d1f705fffc14dbafde346eeb555b43be6d5be54 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* rhi: vulkan: metal: Ensure ms color data is written out on PreserveColorLaszlo Agocs2024-03-141-3/+16
| | | | | | | | Fixes: QTBUG-123211 Pick-to: 6.7 6.6 Change-Id: Id037f8c5a69c2b0ec18d92fe8bb5a34a0a2b0ea0 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* rhi: Make it possible to discard depth/stencil even when using a textureLaszlo Agocs2024-03-141-0/+24
| | | | | | | | | | Also implement this for OpenGL ES since it can be relevant with tiled architectures wrt performance. Task-number: QTBUG-122669 Change-Id: I90dcfe4f5f9edbb8dfb51189d46b89ef2c7a7c06 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add basic support for specifying a view format for a textureLaszlo Agocs2024-03-121-0/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* rhi: add support for short and ushort vertex attributesAurélien Brooke2024-03-011-4/+32
| | | | | | | [ChangeLog][RHI] Add support for short and ushort vertex attributes Change-Id: I6111a02d442bbad2ec9667ac0336107dd3ab7b62 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Doc: Fix QDoc warnings for overloadsPaul Wicking2024-02-141-0/+2
| | | | | Change-Id: I9a77b6ea0026748c7f97f73b327118f7a9212d52 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Improve description of QRhiTextureSubresourceUploadDescription::setImageArtem Dyomin2024-02-131-0/+1
| | | | | | | | | | The format of QImage is not considered upon texture loading, it should be documented. Pick-to: 6.7 6.6 6.5 Change-Id: I795c8a82a71ecdba5407f7e4ce940f7d538ff924 Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
* Doc: QRhi correctionsPaul Wicking2024-02-091-1/+2
| | | | | | | | | | | | | | * There's no convenience header for the `QRhi` class, so add the `\inheaderfile` command to specify the correct include. * The `QRhi` class belongs to the `QtGuiPrivate` module; use the correct name. * QDoc needs to know about the QtGuiPrivate module. Add basic documentation for the private module. Task-number: QTBUG-121855 Task-number: QTBUG-121991 Change-Id: I1ffd729a5f9c928f4cf91ce7127f40c7733fc42f Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QRhi: fix a bad variable name in documentation exampleAurélien Brooke2024-01-261-1/+1
| | | | | Change-Id: I127dcaebc4d4a9d00e0cec924b0a4168a3970a71 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add the more appropriate srb class name as an aliasLaszlo Agocs2023-12-061-0/+8
| | | | | | | | | | | | | | | We will not have time to roll out the proper name change in 6.7, even though we are not bound by compatibility promises. In the absence of a holistic migration that covers all Qt modules, just add the new name with using. The proper solution would be the reverse: the name changes everywhere and the old class name becomes available via using; but for now we can live with the reverse, which still allows new code (such as new examples, and future application code) use the more descriptive name. Change-Id: I18e791f4f93cb9b4fae8ec21aeb99b4bf93662f1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make sample count selection logic be closer to Qt 5Laszlo Agocs2023-12-061-0/+35
| | | | | | | | 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>
* rhi: Add a flag to suppress D3D11 smoke test warningsLaszlo Agocs2023-11-081-0/+11
| | | | | | | | | | | | | | | | | | | Applicable to D3D11 only, although the flag is general enough that other backends could use it if it made sense for them. This allows Qt Quick to state that warnings about QRhi::create() failures that lead to retrying with a different set of flags (PreferSoftwareRenderer to get to use the WARP software rasterizer) should be suppressed and turned to regular categorized debug prints. Other users, e.g. an application directly working with QRhi may not want this. A create() failure must be complemented by an unconditional qWarning since normally that is pretty serious error. Hence the opt-in flag. Task-number: QTBUG-117926 Change-Id: I808bd1670b631e2068b566ab08589e1783f62ca5 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Map DXGI_ADAPTER_FLAG_SOFTWARE onto the driverInfo's CpuDeviceLaszlo Agocs2023-09-141-3/+5
| | | | | | Fixes: QTBUG-116756 Change-Id: I6218ea3f59716873853b8bf83b18e0a799eedcc3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add stereo support for DirectX12 and Vulkan backendsIlya Doroshenko2023-09-051-3/+2
| | | | | Change-Id: Id12723d6c392e25935ccb265c58af91aff968984 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: add a way to test Display P3 with the manual testLaszlo Agocs2023-08-151-1/+5
| | | | | | | | | | | Extended linear Display P3 + FP16 is likely the thing to use on platforms such as VisionOS and iOS (and optionally on macOS) and perhaps iOS). Enable testing this on macOS with the hdr manual test. Change-Id: I67f0bdbadae8c7ebccae7de008f12fd8d9135529 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Expand lastCompletedGpuTime docsLaszlo Agocs2023-08-141-15/+46
| | | | | Change-Id: Ic66796a5be2dc5c8feca504e68ede2046491bd76 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: gl: Implement lastCompletedGpuTime()Laszlo Agocs2023-08-141-3/+6
| | | | | | | Only for OpenGL 3.3+ (not ES). Change-Id: I016ba934d7f5038b3d56f8d0c62e72b3921d86c6 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add stereo support for Dx11 RHIIlya Doroshenko2023-08-091-2/+2
| | | | | Change-Id: I10ef8f80b4b4bcb91fc99ab4ab77f2ac031dbd33 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Enhance the hdr info struct and add a manual testLaszlo Agocs2023-08-031-25/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...while sharing the related code between the d3d backends. The isHardCodedDefaults flag is not used in practice and is now removed. Add the luminance behavior and SDR white level (for Windows) to help creating portable 2D/3D renderers that composite SDR and HDR content. (sadly the Windows HDR and Apple EDR behavior is different, as usual) The new test application is expected to run with the command-line argument "scrgb" or "sdr". It allows seeing SDR content correction (on Windows) in action, and has some simple HDR 3D content with a basic, optional tonemapper. Also shows the platform-dependent HDR-related screen info. With some helpful tooltips even. Additionally, it needs a .hdr file after the 'file' argument. The usual -d, -D, -v, etc. arguments apply to select the 3D API. For example, to run with D3D12 in HDR mode: hdr -D scrgb file image.hdr The same in non-HDR mode: hdr -D sdr file image.hdr Change-Id: I7fdfc7054cc0352bc99398fc1c7b1e2f0874421f Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Run cleanup callbacks before the pending deletesLaszlo Agocs2023-07-311-2/+2
| | | | | | | | | If a callback deleteLaters a QRhiResource that should still be handled and not left unreleased. Swap the order. Pick-to: 6.6 6.5 Change-Id: I8419a28a9db5bb59f768ab5820dfaf593464d6d2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Enable registering cleanup callbacks with a keyLaszlo Agocs2023-07-311-0/+32
| | | | | | | | | And the ability to deregister. Going to be required by QRhiWidget. Change-Id: If185cbed2faa042098ac1f6bb1d6daaffd834377 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add a note to sampler docs about mipmapsLaszlo Agocs2023-07-281-0/+8
| | | | | | | Fixes: QTBUG-115521 Pick-to: 6.6 Change-Id: I774cdc4d1b9e09624a9b5f9969eae5085b40a6c0 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi doc: Make getShader in the snippets more compactLaszlo Agocs2023-07-121-3/+1
| | | | | | | | One line is better than three. Pick-to: 6.6 Change-Id: Ib738ec18b51accead3897b450b26207b3fba87d8 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: gl: metal: Enable depth-stencil correctly with multiviewLaszlo Agocs2023-06-281-0/+11
| | | | | | | | | | | | | | | After fixing the data type for D24S8, we can now implement attaching depth and stencil (with the same texture). For Metal we need to set a stencil flag correctly. This allows using D24S8 in the manual test, which is likely the format that is going to be commonly used when setting up multiview with Qt Quick. Fixes: QTBUG-114904 Change-Id: Ife425c6cb3e09bfe40092c841b78f7a93bb6a4cd Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Use a depth/stencil texture in the multiview manual testLaszlo Agocs2023-06-281-0/+20
| | | | | | | | ...and expand the docs a bit. Task-number: QTBUG-114896 Change-Id: I969c3aa2fa72a242e275e4b6dd996df20d1cd2ab Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: metal: Add support for multiview renderingLaszlo Agocs2023-06-271-6/+12
| | | | | | | | | | | | | | Some shortcomings and unexpected problems are not unlikely. The basic feature, with 2 views going to a texture array's 0 and 1 elements, seems to be working with macOS, also with MSAA. Instanced drawing has not been verified. (relevant because layered rendering works via instancing in Metal and the QRhi backend has to adjust the instance count in every draw call) Fixes: QTBUG-114774 Change-Id: I3655e0d2c658b88c4cd6b52a32f94134324e4ac9 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vulkan: Fix multisample resolve with multiviewLaszlo Agocs2023-06-261-5/+29
| | | | | | Task-number: QTBUG-114790 Change-Id: I3afccc3f7ae2d05aa9aa0e0943aeadc080016f0e Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d12: Implement multiview supportLaszlo Agocs2023-06-221-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This relies on qsb being able to invoke dxc instead of fxc when the request HLSL (shader model) version is 6.1. (6.1 is required for SV_ViewID) This currently works only when conditioning offline with qsb (or via CMake), because qsb can easily invoke dxc instead of fxc. When shipping HLSL inside the .qsb package (so when -c is not specified or running the external tool fails), this won't work since the D3D12 backend still uses D3DCompile(), not IDxcCompiler. Support for that will be investigated separately. We also need to bump to ID3D12Device2 and ID3D12GraphicsCommandList1. With Windows 10 version 1703 being quite old now, this should not be a problem at run time. There are however issues at build time, namely that MinGW and MinGW/LLVM and similar seems to have ancient Windows SDK headers according to the CI test runs. None of the MSVC configurations have this in the CI, they have reasonable versions of d3d12.h and similar. Therefore, one important aspect of this change is that the D3D12 backend of QRhi will only be available from now on when the SDK headers are new enough (meaning ID3D12Device2 is declared, which is a several years old type now). Otherwise, QRhi::create() will simply fail when asking for D3D12 with a helpful warning message about the Qt build being crippled. Implementation-wise, there are surprises in store as well: The way the PSO is created needs to be revamped to follow the extensible approach that uses a pipeline state stream description. Both the graphics and compute pipeline creation is changed to use CreatePipelineState() and the associated machinery. This is only really essential for graphics pipelines since we know have to include data for view instancing (multiview). For compute the result is the same as before. Additionally, the view count must now be baked into the QRhiGraphicsPipeline. This means that applications must call setMultiViewCount() with the same value (typically 2) *both* on the render target's color attachment and on the pipeline. Backends that do not care about the pipeline's view count (GL, Vulkan) will of course ignore it, but if it's not set correctly D3D12 will fail. The manual test is updated accordingly. Fixes: QTBUG-114772 Change-Id: I93db7313377e711c2faeb956815899b12132d23b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Introduce multiview starting with OpenGL (ES)Laszlo Agocs2023-06-221-0/+80
| | | | | | Fixes: QTBUG-114770 Change-Id: Ibb1ced7f19d15a5116c60e95fd3e6b86ace63155 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Adjust some HDR-related docs and notesLaszlo Agocs2023-06-211-0/+32
| | | | | | Pick-to: 6.6 Change-Id: I3b5709358fc572ad2214527b19d027c93a0af745 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: D3D-related doc cleanupsLaszlo Agocs2023-06-211-20/+25
| | | | | | Pick-to: 6.6 Change-Id: I46f1b10c49841719bf54e52b58ee565b963ca21c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi doc: Fix a repeating typoLaszlo Agocs2023-06-161-39/+39
| | | | | | Pick-to: 6.6 Change-Id: I2025d559be357a6825cdcae4cb0f0931a89864ab Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add QRhiSwapChainHdrInfo::maxPotentialColorComponentValueTor Arne Vestbø2023-06-111-2/+4
| | | | | | | | | | | Knowing the maximum potential component value can be useful to potentially (sic) opt out of an HDR code path if the maximum color component value will be too low to make the additional processing overhead worth it. Pick-to: 6.6 Change-Id: Ib1e1b7a745b236e1d137a1e7daf1248f1572e184 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Doc: Fix documentation warnings for Qt GuiTopi Reinio2023-05-301-13/+6
| | | | | | | | | | | | | | | | | | | * Fix file quoting in RHI Window example * Add missing \inmodule commands for QRhi Classes * Add missing dependency to qtshadertools * Remove documentation for non-existent overload of QRhiGraphicsPipeline::setTargetBlends() Other fixed warnings: src/gui/rhi/qrhi.cpp: * warning: clang couldn't find function when parsing \fn void setUsage(UsageFlags u) * warning: clang couldn't find function when parsing \fn virtual bool QRhiSwapChain::isFormatSuported(Format f) Change-Id: I73ff7896c3d5c8bb491368e941b32c8026a47191 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* rhi: Make it a QPA-style private but semi-public APILaszlo Agocs2023-05-211-301/+2726
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 enablers for testing reducing the resource update poolsLaszlo Agocs2023-04-271-3/+10
| | | | | | | | ...which comes at the expense of performance. Therefore this is currently an environment variable-based opt-in solution. Change-Id: If884de041f619fef0929ac2cfbdd035092723d51 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Properly squeeze in trimOpListsLaszlo Agocs2023-04-271-0/+28
| | | | | | | | | ...and improve the comments since it is not directly obvious why things are done the way they are. Pick-to: 6.5 Change-Id: I6aa5f09b1b2f7f3fc18f74a4af2977d24278aae6 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Improve nextResourceUpdateBatch docsLaszlo Agocs2023-04-271-2/+19
| | | | | | | | | Mention something some parts of Qt Quick rely on: that the update batch objects stay valid across frames. Change-Id: I2a21c19ceaa0c73a95062cc9b5cc3f4d1020e8a5 Reviewed-by: Christian Strømme <christian.stromme@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Improve deferred delete docsLaszlo Agocs2023-04-261-0/+22
| | | | | Change-Id: I533e44d73ad1aebf72ef2e28c90c51f5effb8977 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* rhi: Replace the temporary GPU time query API with a saner oneLaszlo Agocs2023-04-181-39/+62
| | | | | | | | | | | | | | | | | | | | | | | Modeled after Metal's cb.GPUStart/EndTime. Implemented with timestamp queries for other APIs. Implemented for Metal, D3D11, Vulkan for now. No more callback, just a getter on the command buffer which returns the latest known value, referring to some previous frame. This makes it a lot more usable than the original solution that is not really used anywhere at the moment. Now works for offscreen "frames" as well, this was not implemented before. Opt in with a new QRhi::create() flag because we cannot tell in advance if the getter will be called or not, and this way we can skip recording the timestamps by default. The cost is probably minimal, though. Qt Quick will set this automatically when running with QSG_RHI_PROFILE=1. Change-Id: I903779984a4e0bbf1d03806d04bf61571ce23d72 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Make it safe to always call deleteLater on a resourceLaszlo Agocs2023-04-181-5/+16
| | | | | | | | | | | | | | | | | | | ...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 unused init flagLaszlo Agocs2023-04-121-2/+0
| | | | | Change-Id: I289452f39fd161da0e0d7bf329e0922df6bbde8a Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Move generic setup code out of create()Laszlo Agocs2023-04-121-14/+18
| | | | | Change-Id: I5222dd5479fe5c23b20bd08a2908a85be4d25e45 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Remove readback result type aliasLaszlo Agocs2023-04-121-2/+2
| | | | | | Change-Id: I1b14d3230ab4011506892c64ea03d5431d82a90d Reviewed-by: Christian Strømme <christian.stromme@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* rhi: Metal tessellation shader input output interface blocksBen Fletcher2023-03-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* rhi: Clean up 1D and 3D texture feature flagsLaszlo Agocs2023-03-071-4/+12
| | | | | | | | | | | | | | 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/+29
| | | | | | | | | | | | | | | | | | | 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>
* rhi: Make some op== and qHash hidden friendsLaszlo Agocs2023-02-221-168/+42
| | | | | | Change-Id: I0ba829b5b3df7ebff2fe7da81424e2623a895325 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Do some internal doc fixesLaszlo Agocs2023-02-211-20/+57
| | | | | Change-Id: Iefcf06ffc251d160e838ae12729314b29d4f36a1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>