summaryrefslogtreecommitdiffstats
path: root/src/gui/vulkan/qvulkanwindow.cpp
Commit message (Collapse)AuthorAgeFilesLines
* vulkan: Make setEnabledFeatures2Modifier an overloadLaszlo Agocs2024-02-131-7/+6
| | | | | | Pick-to: 6.7 Change-Id: I74087324e4ea54af0165f3e30b73b2df61104a41 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QVulkanWindow::setEnabledFeatures2Modifier(): pass parameter by valueIvan Solovev2024-02-121-2/+2
| | | | | | | | | | | | | | The method takes an std::function as a parameter, so it makes sense to pass it by value to avoid copying when passing lambdas. Amends bd78047df34fda3a56b8db069fc97280831ac696 Found in 6.7 API review Pick-to: 6.7 Change-Id: Ic0608a176bfd26b5b44fae48f29d84737e81a413 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QVulkanWindow: sync surface size logic with QRhiLaszlo Agocs2023-12-041-1/+27
| | | | | | | | | | | | | The legacy QWindow convenience subclass does not have the robust logic that was later implemented for the Vulkan backend of QRhi. (i.e., never trust the QWindow; problem with QVulkanWindow is that it half-trusts those values still, which leads to the classic pixel-size-differs-by-one problem) Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-118568 Change-Id: I5f83999e86a9907efe08b38ca069bae20152a4e0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QVulkanWindow: Add a way to control post-1.0 Vulkan featuresLaszlo Agocs2023-11-061-18/+63
| | | | | | | | | | | | | | | | | | | | | | So now instead of filling out a VkPhysicalDeviceFeatures and sending it in via VkDeviceCreateInfo::pEnabledFeatures, we rather create a VkPhysicalDeviceFeatures2, which contains a VkPhysicalDeviceFeatures (for 1.0 stuff) and a pNext chain, and chain it via pNext to the VkDeviceCreateInfo. QVulkanWindow will not do anything with post-1.0 features by default. (in this regard it deviates from the QRhi Vulkan backend which already tackles 1.1, 1.2, and 1.3 features as well, but this is not going to change) However, applications may want to enable some of those still. To enable this, add a new callback. When set, the callback is invoked and the alternative behavior described above is activated. Fixes: QTBUG-117966 Change-Id: I8560a6b23421f545ee760e714cbe2ec2f6078406 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* qvulkanwindow: use qimage rvalue overalods moreAnton Kudryavtsev2023-10-311-1/+1
| | | | | | Pick-to: 6.6 Change-Id: I71bb0df5dbf1993284ec907f637a8696898dddb1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Do automatic r-b swap in QVulkanWindow's grab for BGRA8Laszlo Agocs2023-10-301-1/+10
| | | | | | | | | | | | | | While it would also be acceptable to leave this conversion to the user, the returned image's format (that it's QImage::Format_RGBA8888) is not documented. That needs to be corrected in any case. Then, we may just as well add and document that for the most commonly used swapchain color buffer format the r-b swap is performed automatically. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-118244 Change-Id: I7ec8324ec3a0f5c1f2a7a592501d5ff59e3e8cc5 Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Unity Build: Resolve a variable redefinition errorAmir Masoud Abdol2023-07-031-3/+3
| | | | | | | | | | | The `qvk_sampleCounts` variable is defined in `qrhivulkan.cpp` as well. This causes an issue when building with unity build. To resolve the problem, I renamed the variable in `qvulkanwindow.cpp`. Fixes: QTBUG-114918 Pick-to: 6.5 6.6 Change-Id: I0b38c6b3e30792dd6f770d4dea8cb4c7789961d1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-2/+2
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Skip potentially costly features in QVulkanWindowLaszlo Agocs2022-08-041-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QVulkanWindow has recently been updated both in 5.15 and 6.x to start enabling at least the 1.0 core features, because modern validation layers are likely to complain if a feature is used without the corresponding flag enabled upon device creation, even if the driver does not actually care. There is a catch here however, namely that some features may be true opt-in flags, e.g. robustBufferAccess, and when enabled, they may incur a performance penalty. So we will keep that one feature disabled even when it is reported as supported. It is unfortunate that VkPhysicalDeviceFeatures mixes together flags that are most likely used only to query if some feature is supported by the implementation while not serving as a real toggle (because opting in/out is meaningless for the implementations in practice), and flags that have significant effects when the feature is enabled, for example when it comes to performance. As QVulkanWindow only cares about 1.0, and 1.1+ features are to be handled by the application via the features-modifier callback, we can get away by just disabling robustBufferAccess and passing in everything else supported as-is for vkCreateDevice. Task-number: QTBUG-105158 Pick-to: 6.4 Change-Id: I963402ab50f6e5d3fa6824680f69cff8568b669a Reviewed-by: Andy Nichols <andy.nichols@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>
* QtGui: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: I1945741794c25679a9d94c0d68c8642e2c823502 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QVulkanWindow: fix QByteArray::count deprecation warningMårten Nordheim2022-03-171-1/+1
| | | | | | | By using QBA::size Change-Id: I716c0e27230cd46e92ca5521d9a19cb296e221bd Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Convert Vulkan instance setup from Qt Quick into a Gui helperLaszlo Agocs2022-02-151-1/+1
| | | | | | | | | Make it possible to reuse what's in QSGRhiSupport from other modules as well. Both Gui (texture-based widget/backingstore composition) and Multimedia are potential users of this in the future. Change-Id: I1b50cc5efd6811e9bc95f6287b9576931d4bcc44 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* QVulkanWindow: make it possible to override the enabled featuresLaszlo Agocs2022-01-201-2/+46
| | | | | | | | | | | | | | | We already have a precedent for this: the QueueCreateInfoModifier callback. Following the pattern, add a EnabledFeaturesModifier that can alter the VkPhysicalDeviceFeatures that is passed to vkCreateDevice(). [ChangeLog][QtGui][QVulkanWindow] QVulkanWindow can now invoke a callback to alter the VkPhysicalDeviceFeatures object used to create the Vulkan device. This allows enabling 1.1, 1.2, and extension features. Fixes: QTBUG-99803 Change-Id: I5ede0c6bc3430cbb304d4961eb9e44faad5ce4d7 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Enable all supported 1.0 device features in QVulkanWindowLaszlo Agocs2022-01-201-0/+23
| | | | | | | | | | [ChangeLog][QtGui][QVulkanWindow] QVulkanWindow is now enabling all Vulkan 1.0 features reported as supported from the physical device. Pick-to: 6.2 6.3 5.15 Task-number: QTBUG-99803 Change-Id: Ib9cfcd449904c67b07e0e2d4ade5bcaeb4cb0ce6 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix queue passed to vkQueuePresentLaszlo Agocs2022-01-201-1/+1
| | | | | | | | | | | | | | | | | We do not test actively test setups where a separate graphics and present queue is used because there is no combined queue at all. (it won't be tested because we neither want to nor have the possibility to do so) However, QVulkanWindow (unlike, say, QRhi's Vulkan backend) attempts to support this. It turns out the argument passed to vkQueuePresent is wrong: the present is to be submitted to the present queue. So fix this up. Pick-to: 6.3 6.2 5.15 Fixes: QTBUG-73470 Change-Id: Ic9b589aba52e3326637216b98a074e27fdc3e3b9 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* codechecker: Add assert for implicit conditionEskil Abrahamsen Blomfeldt2021-06-181-0/+1
| | | | | | | | | | Since memReq is initialized inside the loop, codechecker complained that we might use uninitialized data if count == 0. So we assert that this is not the case to get rid of the warning. Change-Id: I82152942d2bb61723e9e41489c87bfde9f8bec15 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* vulkan: Update legacy tests and examples to the modern validation layerLaszlo Agocs2021-05-311-1/+1
| | | | | | Fixes: QTBUG-88388 Change-Id: Ib072f203ada5d692dea8d35da2b24db0deac0297 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Handle maxImageCount 0 in QVulkanWindowLaszlo Agocs2021-01-041-3/+5
| | | | | | | | | Take the logic we use in QRhi's Vulkan backend. Pick-to: 6.0 5.15 Fixes: QTBUG-85791 Change-Id: Ifdc2b3d351af71fbc86e20abcede902303e41fc4 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Doc: Fix documentation warnings for Qt GUITopi Reinio2020-08-281-7/+7
| | | | | | | | | | | | * Drop deprecation warnings for now-dropped items * Use the 'qt6' define and a new \nothing doc macro to conditionally document items on Qt 6 * Add a custom module header for docs that pulls in also Vulkan headers * Add \internal command for internal classes/functions * Move QtGUI-related code snippets from widgets to gui docs Change-Id: Ieb386b96631a49568d09059906d307c45c01d93a Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-12/+12
| | | | | | | Task-number: QTBUG-84469 Change-Id: I366e845249203d80d640355a7780ac2f91a762f1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QVulkanWindow: Fix setQueueCreateInfoModifier signatureLaszlo Agocs2020-03-101-1/+1
| | | | | | | ...per API review. Change-Id: I4a5a1cc895eac32f21f8a830507b841318509992 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* QVulkanWindow: Remove queueCreateInfoModifier getterLaszlo Agocs2020-03-031-13/+0
| | | | | | | | This is inconsistent with the other similar functions in QVulkanWindow, we do not provide getters for those either. Change-Id: If764b49f4b26ff14a2fa908b8d5b37429047250c Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Add environment variables for customizing VulkanPaul Olav Tvete2020-01-061-0/+9
| | | | | | | | | | | | | | | | | QT_VULKAN_INSTANCE_EXTENSIONS to specify additional instance extensions. QT_VULKAN_INSTANCE_LAYERS to specify additional instance layers. QT_VULKAN_DEVICE_EXTENSIONS to specify additional device extensions. These will apply to all QVulkanWindows and everything that uses RHI, including Qt Quick with the Vulkan RHI backend. Task-number: QTBUG-80499 Change-Id: I912495affa987d62a9823d55d06d6a8209f6adc6 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-1/+1
| | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Vulkan: Add platform hooks before presentingJohan Klokkhammer Helsing2019-10-081-0/+4
| | | | | | | | | | This allows the Wayland plugin to circumvent the frame callback handling of the driver (which blocks until the frame is presented, potentially forever, if the window is minimized). Task-number: QTBUG-78000 Change-Id: Ia7d347019dfeae3bfcfad3d0cca3f4fffdc8c7a9 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-051-8/+8
|\ | | | | | | Change-Id: I554a2762890391b3b6013c8b82211a8386a4ced8
| * Convert a few sizeof(array)/sizeof(element0) fors to range forsAlbert Astals Cid2019-10-041-8/+8
| | | | | | | | | | | | | | | | Increases readability Change-Id: I81ea915517fd2cd6bc2780f37ba8d8097c63f44b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | QVulkanWindow: Allow to change queues to createFrank Richter2019-09-241-12/+80
| | | | | | | | | | | | | | | | | | | | | | | | This allows users to request queues beyond the default graphics queue without having to completely reimplement Vulkan device initialization or giving up the convenience of QVulkanWindow. [ChangeLog][QtGui] Extended QVulkanWindow to allow user to specify additional queues to be created. Change-Id: I96d8d4bcc4da3ffedca3d25c87547669f5b18e40 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* | QVulkanWindow: Add function to retrieve graphics queue family indexFrank Richter2019-09-021-0/+17
|/ | | | | Change-Id: I51e4a006e82fbcd998815da3de6daa80558a973f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Doc: Move literal code block to a separate fileCristian Maureira-Fredes2018-10-151-80/+3
| | | | | | | | | | | We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QVulkanWindow: Fix some load/store ops in the default renderpassLaszlo Agocs2018-09-121-2/+2
| | | | | | | | Stencil is - very likely - cleared just like depth. Also, switch to STORE_OP_STORE for the multisample buffer, for correctness. Change-Id: I31b56658286205af8551018115ca2abbe541be67 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QVulkanWindow: Fix bogus stage masks in readbackLaszlo Agocs2018-09-121-1/+1
| | | | | Change-Id: I08882a02204c95272b100647923c9903f825912c Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix device local alloc in hellovulkantextureLaszlo Agocs2018-09-121-0/+5
| | | | | | | | | | Running with QT_VK_FORCE_STAGE_TEX does not work at all with recent NVIDIA drivers due to QVulkanWindow's and the example's naive way of picking the memory index. Enhance this and add a warning note to the QVulkanWindow docs as well. Change-Id: I7f200e11d982b56e3da3b71ee3915bd7bfca5cc1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Revise an incorrect QVulkanWindow doc noteLaszlo Agocs2018-09-061-9/+5
| | | | | | | | | | | | | Applying the transformation in question has no effect on the winding order. Rewrite that section. While all the examples are correct, clarify the rules for the geometry they use since the winding order varies. Fix up the triangle example code to use front=CCW for clarity (even though it does not matter much since culling is off there). Change-Id: Icb968c76cc9fa918a5608d3c66b4fccd5668175e Reviewed-by: Christian Stromme <christian.stromme@qt.io>
* Fix redundant Vulkan logging category definitionLaszlo Agocs2017-11-031-22/+22
| | | | | | Task-number: QTBUG-64124 Change-Id: Ic8f9a7f62e3c00dba5f345037c45fb45908be848 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QVulkanWindow: return QMatrix4x4 by valueMarc Mutz2017-05-221-3/+3
| | | | | | | The function never returns nullptr, so return the matrix by value. Change-Id: I7c1eeb43b9693866049763565b575348ddd35548 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QVulkanWindow: use QVector, not QSet, for small int setMarc Mutz2017-05-221-4/+5
| | | | | | | | | | Apart from being more efficient to construct and test, for the expected very small number of entries, the example code itself shows that a sorted vector is much more useful than an unordered set. Change-Id: Ic5e38df0176ac4be08eac6a89c2e1cabab2a9020 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QVulkanWindow: fix fatal warning on Clang 4Shawn Rutledge2017-05-031-1/+1
| | | | | | | | | | | | | | | qtbase/src/gui/vulkan/qvulkanwindow.cpp:1882:42: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] VkClearColorValue clearColor = { 0.0f, 0.0f, 0.0f, 1.0f }; ^~~~~~~~~~~~~~~~~~~~~~ { } 1 error generated. VkClearColorValue is a union, so it wants to be clear that we are initializing only one of the union's members, apparently. (Even though initing more than one wouldn't make sense.) Change-Id: Id4afa3ddc1b4ce7e24e681fb93c0ee9083c41e08 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Fix some capitalization issues in QVulkan docsLaszlo Agocs2017-04-041-3/+3
| | | | | | | ...and remove see-alsoing wrappers that do not get a doc page. Change-Id: Ia26aeef3c142b15a47e650dfc7f64ad7339cc80d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* doc: Fix several qdoc warnings in new softwareMartin Smith2017-03-311-34/+40
| | | | | | | | | | This change fixes several common qdoc warnings in this new software. However, because vulkan/vulkan.h is not always available, a few typedefs were also added to define some standard vulkan types for clang to see when vulkan.h is not available. Change-Id: Id3db8c0a59b0c415829c1873a868aba0e84fe21c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Clarify the front face winding order in the Vulkan examplesLaszlo Agocs2017-03-261-0/+4
| | | | | | | | | After applying the correction matrix the front face is CW, not CCW. The examples work either way but fix them up to avoid reader confusion. Change-Id: I491e6dc17c21897a59f36d32061e937f2b6c4c9d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QVulkanWindow: Add missing device wait after user codeLaszlo Agocs2017-03-261-6/+17
| | | | | | | | | | In a multi-threaded setup it is not unlikely that releaseSwapChainResources() will wait for and submit any remaining frame building. Hence a wait is necessary also after invoking the user's implementation. Change-Id: I3c963c05c1c3981980da5e4ff9c572df24a1e473 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add missing class doc for QVulkanWindowRendererLaszlo Agocs2017-03-231-4/+24
| | | | | | | | The functions are documented but the class does not show up in the docs without the \class. Change-Id: I8a7e4c82ba11354855ca272e5c6be59cf1419f14 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Introduce QVulkanWindowLaszlo Agocs2017-03-221-0/+2678
A convenience subclass of QWindow that provides a Vulkan-capable window with a double-buffered FIFO swapchain. While advanced use cases are better served by a custom QWindow subclass, many applications can benefit from having a convenient helper that makes getting started easier. Add also three examples of increasing complexity, and a variant that shows embeddeding into widgets via QWindowContainer. [ChangeLog][QtGui] Added QVulkanWindow, a convenience subclass of QWindow. Task-number: QTBUG-55981 Change-Id: I6cdc9ff1390ac6258e278377233fd369a0bfeddc Reviewed-by: Andy Nichols <andy.nichols@qt.io>