summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhivulkan_p.h
Commit message (Collapse)AuthorAgeFilesLines
* rhi: vulkan: Fix multiview with depth attachment onlyLaszlo Agocs2024-05-021-2/+2
| | | | | | | | | | Also change a confusing argument naming (begin-end vs. first-last). Relevant in particular for the depth texture generation pass of Qt Quick 3D (XR) with multiview rendering enabled. Change-Id: I18746581cddfa96127de2d07853164b1c88b070b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add support for resolving depth-stencilLaszlo Agocs2024-04-031-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* rhi: Make it possible to discard depth/stencil even when using a textureLaszlo Agocs2024-03-141-0/+1
| | | | | | | | | | 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/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: vulkan: Query and enable multiview features when API is 1.1Laszlo Agocs2024-02-021-1/+4
| | | | | | | | Meaning a Vulkan implementation that is not 1.0, not 1.2, not 1.3, but 1.1. This does not have the 1.2+ versioning mechanisms. Change-Id: I9d9346d505162adc0e03aa04217930d41c72027f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make sample count selection logic be closer to Qt 5Laszlo Agocs2023-12-061-1/+1
| | | | | | | | 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: vulkan: Print vma statistics on out of device memoryLaszlo Agocs2023-09-261-0/+1
| | | | | | | | | | | | | | | | Following a vmaCreate* it makes sense to test for VK_ERROR_OUT_OF_DEVICE_MEMORY and print the allocator statistics in order to give an idea of the application's (video) memory usage. For instance when running on a Raspberry Pi 4, this helps to indicate that the application is just too big for the device, and is more informative then just a Failed to create image: -2 message. Pick-to: 6.6 6.5 Change-Id: I666e2358303894efab9d12d2b3a3d98f0bd3a5b6 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
* Add stereo support for DirectX12 and Vulkan backendsIlya Doroshenko2023-09-051-0/+3
| | | | | Change-Id: Id12723d6c392e25935ccb265c58af91aff968984 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: vulkan: Include multiViewCount in renderpass compatibilityLaszlo Agocs2023-07-051-0/+2
| | | | | Change-Id: I3185ce27c52c138053fee4805eccbe3575b9433a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vulkan: Implement multiview supportLaszlo Agocs2023-06-221-0/+1
| | | | | | Fixes: QTBUG-114771 Change-Id: I8408b84c5ce01df94d68167d557393af919864d3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vulkan: Shuffle post-1.0 phys.dev.feature queriesLaszlo Agocs2023-06-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Make it so that what we query with regards to 1.1, 1.2, and 1.3 features are stored for later use. This will be relevant for e.g. multiview where the multiview field will need to be checked when deciding if the feature is supported at run time. All this is only really compatible with Vulkan 1.2 and newer. Vulkan 1.1 does not have the 1.2 approach, i.e. there is no VkPhysicalDeviceVulkan11Features in Vulkan 1.1 (!). That is a struct added in Vulkan 1.2. In 1.1 one had the feature (extension) specific structs, such as VkPhysicalDeviceMultiviewFeatures in case of multiview. That we do not bother with at the moment. Then again that's nothing new. The existing code to enable all features with a few exceptions, that's already tied to the 1.2+ way of working with physical device features, and not quite compatible with a pure 1.1 (not 1.0, not 1.2+) implementation (which should be hopefully rare out there). Pick-to: 6.6 Change-Id: I661f2634651d28edd9b5feec66a423220920f894 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* rhi: Make it a QPA-style private but semi-public APILaszlo Agocs2023-05-211-23/+970
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: vk: Fix up some legacy queue (family) index inconsistenciesLaszlo Agocs2022-12-161-2/+2
| | | | | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+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: Stop hardcoding the Vulkan backend's desired instance extensionsLaszlo Agocs2021-01-181-0/+3
| | | | | | | | | Instead, have a static function in QRhiVulkanInitParams then Qt Quick and anyone else who creates a QVulkanInstance that is then used in combination with QRhi can query. Change-Id: I046e0d84541fc00f5487a7527c97be262221527f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* RHI: Use QT_BEGIN_LICENSE:LGPL headerKai Köhne2021-01-151-11/+14
| | | | | | | Task-number: QTBUG-90321 Pick-to: 6.0 Change-Id: If3b0841f3e9139bb1911c6a5d03a16daf8c1b3d6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: vk: Alter command buffer strategyLaszlo Agocs2020-10-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reports on the Web have it that there's nothing guaranteeing a driver does any actual freeing of resources then doing vkFreeCommandBuffer for a command buffer from a command pool that does not have VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, thus leading to continuously growing resource usage with our current allocate/free pattern. It could be that this is the source of out of memory problems we are seeing on some Android devices. Instead of just going straight for said command pool flag and doing ResetCommandBuffer for the command buffers individually, take one step further and use per-slot (slot being 0 or 1 if QVK_FRAMES_IN_FLIGHT is 2) command pools. The current pool is reset in each beginFrame/beginOffscreenFrame, moving all allocated command buffers to the initial state (while other command buffers with the other pool are not affected). This may be (while impossible to tell from just guessing based on the spec) our best approach to command buffer allocation since a Vulkan implementation can likely just use some simple per pool allocator, knowing that we never want to free or reset individual command buffers, but we rather only reset the whole pool at once. The option of importing an existing VkCommandPool when creating the QRhi instance is now gone, but there was probably no point in offering that in the first place. When it comes to VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT it will not be set unless releaseCachedResources() (in Qt Quick this is hooked into QQuickWindow::releaseResources()) was called. What this does in practice is unknown, but have an option to set it now and then if the application really wants. While we are at it, rename secondaryCbs to activeSecondaryCbStack to indicate what it really is. (it's a stack as each call to beginExternal() pushes a new one, while each endExternal() pops) Change-Id: I2e5c1fad26d794e1f56c778e38f750998d706d84 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Enable specifying just an adapter or phys devLaszlo Agocs2020-06-261-0/+4
| | | | | | | | | Required by OpenXR. A VkPhysicalDevice or an adapter LUID + feature level pair should be adoptable while leaving the rest (device, queue, etc. setup) to QRhi as normal. Change-Id: Iada0972671b037b4efb03e7831b7c9b8c5f2393d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vulkan: Sanitize device extension handlingLaszlo Agocs2020-03-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of qputenv("QT_VULKAN_DEVICE_EXTENSIONS", "VK_KHR_get_memory_requirements2;VK_NV_ray_tracing"); one can now do params.deviceExtensions = { "VK_KHR_get_memory_requirements2", "VK_NV_ray_tracing" }; on the QRhiVulkanInitParams passed to QRhi::create(). The environment variable stays important for Qt Quick applications, which provide no configurability for the QRhi construction (yet). On the other hand, applications using QRhi directly can now also use the new approach to specify the list of device extensions to enable. In addition, take QVulkanInfoVector<QVulkanExtension> into use. There is no reason not to rely on the infrastructure provided by QVulkanInstance. This also implies showing an informative warning for unsupported extensions, instead of merely failing the device creation. (applications will likely not be able to recover of course, but at least the reason for failing is made obvious this way) Task-number: QTBUG-82435 Change-Id: Ib47fd1a10c02be5ceef2c973e61e896c34f92fa3 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* RHI: Remove old native texture APIPaul Olav Tvete2020-01-061-6/+0
| | | | | | Task-number: QTBUG-78570 Change-Id: I8c4850828ac03319ac923a26c2e985883956c286 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: vulkan: Expose the VkRenderPass via the usual mechanismsLaszlo Agocs2019-08-291-0/+5
| | | | | | | | | Qt Quick in turn will expose it via QSGRendererInterface. Essential when adding custom Vulkan rendering into a Qt Quick application because the custom pipeline state objects will need to reference a VkRenderPass. Change-Id: Idf4092cfc3937830fb8123164081059b0d8d030e Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Introduce the Qt graphics abstraction as private QtGui helpersLaszlo Agocs2019-06-131-0/+85
Comes with backends for Vulkan, Metal, Direct3D 11.1, and OpenGL (ES). All APIs are private for now. Shader conditioning (i.e. generating a QRhiShader in memory or on disk from some shader source code) is done via the tools and APIs provided by qt-labs/qtshadertools. The OpenGL support follows the cross-platform tradition of requiring ES 2.0 only, while optionally using some (ES) 3.x features. It can operate in core profile contexts as well. Task-number: QTBUG-70287 Change-Id: I246f2e36d562e404012c05db2aa72487108aa7cc Reviewed-by: Lars Knoll <lars.knoll@qt.io>