summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhi.h
Commit message (Collapse)AuthorAgeFilesLines
* rhi: Make it possible to discard depth/stencil even when using a textureLaszlo Agocs2024-03-141-1/+2
| | | | | | | | | | 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-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+9
| | | | | | | [ChangeLog][RHI] Add support for short and ushort vertex attributes Change-Id: I6111a02d442bbad2ec9667ac0336107dd3ab7b62 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add the more appropriate srb class name as an aliasLaszlo Agocs2023-12-061-0/+5
| | | | | | | | | | | | | | | 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: Add a flag to suppress D3D11 smoke test warningsLaszlo Agocs2023-11-081-1/+2
| | | | | | | | | | | | | | | | | | | 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>
* Make static data-members constexprTimur Pocheptsov2023-10-191-4/+4
| | | | | | | | | | | While a minor issue, it's possible to use them in a way requiring a definition, triggering a linker error. We can either make them inline or constexpr. Pick-to: 6.6 6.5 Fixes: QTBUG-118170 Change-Id: Ia3dede91b989b295c3e792691d534648581a27c2 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: add a way to test Display P3 with the manual testLaszlo Agocs2023-08-151-1/+2
| | | | | | | | | | | 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: Enhance the hdr info struct and add a manual testLaszlo Agocs2023-08-031-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...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: Enable registering cleanup callbacks with a keyLaszlo Agocs2023-07-311-0/+2
| | | | | | | | | And the ability to deregister. Going to be required by QRhiWidget. Change-Id: If185cbed2faa042098ac1f6bb1d6daaffd834377 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d12: Implement multiview supportLaszlo Agocs2023-06-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+6
| | | | | | Fixes: QTBUG-114770 Change-Id: Ibb1ced7f19d15a5116c60e95fd3e6b86ace63155 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add QRhiSwapChainHdrInfo::maxPotentialColorComponentValueTor Arne Vestbø2023-06-111-0/+1
| | | | | | | | | | | 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>
* rhi: Make it a QPA-style private but semi-public APILaszlo Agocs2023-05-211-0/+1974
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>