summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qshaderdescription.cpp
Commit message (Collapse)AuthorAgeFilesLines
* rhi doc: Fix a repeating typoLaszlo Agocs2023-06-161-6/+6
| | | | | | Pick-to: 6.6 Change-Id: I2025d559be357a6825cdcae4cb0f0931a89864ab Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Make it a QPA-style private but semi-public APILaszlo Agocs2023-05-211-19/+314
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Metal tessellation shader input output interface blocksBen Fletcher2023-03-091-49/+116
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Support serializing the QShader for qsb versionKaj Grönholm2023-01-071-28/+34
| | | | | | | | | | Support serializing shaders with specific qsb version. The default behavior remains the same, using the latest version. Task-number: QTBUG-101062 Pick-to: 6.5 Change-Id: I090a88c1ccb3be4ac5eee1da4058afaa8bf3111c Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: QShaderDescription storage buffer qualifiers / run time strideBen Fletcher2022-12-111-1/+24
| | | | | | | | | | | | | | | | Add storage buffer memory qualifier and run time array stride information to QShaderDescription::StorageBlock. Memory qualifiers allow more informed selection of RHI resource buffer binding (bufferLoad / bufferStore / bufferLoadStore) function. Run time array stride (for last block member unsized array) allows packing of buffer data for transfer to / from GPU. Without this information, applications must infer or guess which packing rules (std430 / std140) are in use. Change-Id: I676d7e848afefd40d01cdd463c569b07022b683e Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-16/+16
| | | | | | | | | | | | | | | | 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-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-14/+350
| | | | | Change-Id: Ie8d226a6a959aa5e78284ea72505fd26aec1e671 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: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-04-281-7/+7
| | | | | | Task-number: QTBUG-98434 Change-Id: I98c27030c783f968cbf38dc966ce486dc366b302 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Convert string tables in QShaderDescription to use string literals [2/2]Marc Mutz2022-02-091-79/+81
| | | | | | | | | | | Avoid allocating all these strings on load. Part 2: JSON keys. Pick-to: 6.3 6.2 Change-Id: I1724a58d700509c3af90ad1b87cb1bccae1075b8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Convert string tables in QShaderDescription to use string literals [1/2]Christian Strømme2022-02-051-123/+123
| | | | | | | | | Avoid allocating all these strings on load. Part 1: tables. Pick-to: 6.3 6.2 Change-Id: Ibf7af9aea0088efe68b247c68022b98143634616 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* rhi: Enable exposing separate image and sampler objects from the shaderLaszlo Agocs2022-01-031-2/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the following in a QShader/QShaderDescription: - a list of separate images - a list of separate samplers - a list of "combined_sampler_uniform_name" -> [ separate_texture_binding, separate_sampler_binding ] mappings (relevant for GLSL only) On the QShader (and qsb/QShaderBaker) level not having separate image (texture) and sampler objects exposed in the reflection info is not entirely future proof. Right now we benefit strongly from the fact that Vulkan/SPIR-V supports both combined and separate images/samplers, while for HLSL and MSL SPIRV-Cross translates combined image samplers to separate texture and sampler objects, but it is not given that relying on combined image samplers will always be possible in the long run; it is mostly a legacy OpenGL thing that just happens to be supported in Vulkan/SPIR-V due to some benefits with certain implementations/hw, but is not something present in any newer APIs. In addition, before this patch, attempting to run a shader with separate textures and samplers through qsb will just fail for GLSL, even though SPIRV-Cross does have the ability to generate a "fake" combined sampler for each separate texture+sampler combination. Take this into use. This also involves generating and exposing a combined_name->[separate_texture_binding,separate_sampler_binding] mapping table for GLSL, not unlike we have the native binding map for HLSL and MSL. A user (such as, the GL backend of QRhi) would then use this table to recognize what user-provided texture+sampler binding point numbers correspond to which auto-generated sampler2Ds in the GL program. Take the following example: layout(binding = 1) uniform texture2D sepTex; layout(binding = 2) uniform sampler sepSampler; layout(binding = 3) uniform sampler sepSampler2; Inn the reflection info (QShaderDescription) this (assuming a corresponding qtshadertools patch in place) now gives one entry in separateImages() and two in separateSamplers(). Assuming sepTex is used both with sepSampler and sepSampler2, the GLSL output and mapping table from QShaderBaker will have two auto-generated sampler2Ds (and no 'texture2D' or 'sampler'). One immediate benefit is that it is now possible to create a shader that relies only on separate images and samplers, feed it into qsb, generate all the possible targets, and then also feed the SPIR-V binary into a tool or library such as Tint (e.g. to generate WGSL) that canot deal with combined image samplers. Change-Id: I9b19847ea5854837b45d3a23edc788c48502aa15 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: gl: Add some enablers for supporting GL_TEXTURE_EXTERNAL_OESLaszlo Agocs2021-01-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | From QRhi's perspective this consists of two things: - A shader with samplerExternalOES in it cannot go through the standard pipeline. Rather, a QShader with suitable GLSL code in it has to be constructed manually. As this is something useful as an autotest anyway, add a test case to the qshader autotest that demonstrates this. - When it comes to correctly calling glBindTexture, add a QRhiTexture flag. The expectation is that an OpenGL-only client sets this in combination with QRhiTexture::createFrom(), thus wrapping an existing texture that then gets bound to the GL_TEXTURE_EXTERNAL_OES target instead of our usual GL_TEXTURE_2D. For completeness we also add a SamplerExternalOES variable type to QShaderDescription, but the sampler type is not actually used by the QRhi OpenGL backend, as it is the QRhiTexture that defines the texture target. Change-Id: I36b52325deb3703b59186ee3d726d0c3015bfc4b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Another round of using noexcept instead of pre-C++11 definesAllan Sandfeld Jensen2020-08-131-6/+6
| | | | | | | A few new files were added with old-school defines. Change-Id: Ieb2c71e094e55102f3f39fb9551823f36863f5f4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Remove old CBOR-based format from QShaderLaszlo Agocs2020-08-111-210/+17
| | | | | | | | | We only support version 4 and 5 in Qt 6.0. 1 and 2 are already gone (due to being based on binary JSON), now we remove 3 as well. Task-number: QTBUG-81346 Change-Id: I3627dcc0587f1e36f11e93edf7172889e911d64e Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Remove deprecated binary json featureEdward Welbourne2020-07-311-20/+0
| | | | | | | | | Deprecated in 5.15 in favor of CBOR. Fixes: QTBUG-81239 Change-Id: I711d4bd7dd1247f58e77ac9fa53304cbe5028918 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-7/+7
| | | | | | | 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>
* Fix build without features.cborstreamwriterTasuku Suzuki2020-06-061-0/+2
| | | | | Change-Id: I970d21d7ac97a602a5f374f6c89cd4bfdcd847b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use QByteArray instead of QStringJonas Karlsson2020-06-031-37/+56
| | | | | | | | | | Since the variable names in QShaderDescription are later compared to QByteArrays we can gain some performance from not having to convert them to QByteArrays later. Task-Id: QTBUG-83706 Change-Id: Iaf80d0966f45cbb09e7c1000b7854bc488e57bb3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Hotfix for int->qsizetype fallout in QShaderLaszlo Agocs2020-05-051-13/+13
| | | | | | | | The proper solution is to use qint32 everywhere, but that is left as a separate exercise. Change-Id: Id0c06b102b56a1b3b48dd67c6c29c28da7d1f22d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: Use versioning in QShaderDescription serialization as wellLaszlo Agocs2020-03-031-19/+23
| | | | | | | | | | This is the first time that we add something to QShaderDescription after migrating to the non-JSON based serialization system. This now involves checking the "qsb version" when deserializing. Task-number: QTBUG-82624 Change-Id: I2bd875ef21e461559b878dccc5537cdfa43feaa2 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Include an arrayDims vector in InOutVariable tooLaszlo Agocs2020-03-031-1/+22
| | | | | | | | | | | | | | | We use the this struct to describe combined image samplers and storage images as well. Especially with the former, it is not unlikely that we will need arrays, so e.g. layout(binding = 1) uniform samplerCube shadowCubes[8]. In this case the '8' is something that must be reported in to the reflection information. The new arrayDims member is expected to work exactly like the similarly named member in BlockVariable. Task-number: QTBUG-82624 Change-Id: I1fb8b0318906ff4c116c1a7ec23a399c6545c730 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Move away from CBOR in QShaderDescription serializationLaszlo Agocs2020-01-131-0/+235
| | | | | | | | | | | | | | | | | | ...but keep support for deserializing for all older versions in order to play nice with existing .qsb files. The usage of binary JSON and then CBOR is a historical artifact: relying on the QJsonDocument (which we generate for purposes unrelated to binary serialization) was a convenient shortcut. However, writing to and reading from a QDataStream instead (which QShader already does) is trivial. In order not to be limited by potential CBOR requirements in the future, take it all into our own hands. Extend the qshader autotest accordingly. Task-number: QTBUG-81298 Change-Id: If0047b659bd6601ca47b5bbbce1b719630cde01e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Remove QShaderDescription::toBinaryJson(), deprecated fromBinaryJson()Ulf Hermann2020-01-101-29/+8
| | | | | | | | | | Binary Json is deprecated and we should not use it. We can already serialize shaders to CBOR. Push the deprecation warning mechanism to the only user of fromBinaryJson(). Change-Id: I1d56157ab92f74eaab49400be647317e7833e35e Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Deprecate QJsonDocument methods for converting to/from JSON binarySona Kurazyan2020-01-091-2/+8
| | | | | | | | | Also remove the example code for deprecated methods and use CBOR instead where it makes sense. Task-number: QTBUG-81068 Change-Id: Iffb7a4b3d7b16a1e485fc05b3ab2e2468e9e0718 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* rhi: Move to CBOR in QShader and expand the autotestLaszlo Agocs2019-10-291-2/+150
| | | | | | | | | | | | | | | | | | Binary JSON is said to become deprecated. Therefore, add support for CBOR. Binary JSON is still supported for deserialization, so all existing .qsb files will continue to work, as long as the binaryjson feature is enabled in the Qt build. Also makes QShaderDescription comparable. This is important for tests in particular. A nice side effect of using CBOR is that .qsb files become smaller. For a typical Qt Quick material shader this can mean a reduction of 300 bytes or more. Task-number: QTBUG-79576 Change-Id: I5547c0266e3e8128c9653e954e47487352267f71 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Another load() -> loadRelaxed()Laszlo Agocs2019-09-181-1/+1
| | | | | | Change-Id: Iab74325da3bd0a22c1f69856b038d0b5615e4e63 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Mark all rhi docs as internalLaszlo Agocs2019-08-271-6/+12
| | | | | | | | This is private API for the time being. Without this the QRhi* classes show up in the class list in the docs. Change-Id: I662abb9cc8eaae13ffe9266bd6313faa8e138353 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Add compute api and implement for Vulkan and MetalLaszlo Agocs2019-06-171-0/+29
| | | | | | | | | | | | | D3D11 and GL (4.3+, ES 3.1+) will come separately at a later time. Change-Id: If30f2f3d062fa27e57e9912674669225b82a7b93 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* rhi: Remove reserved and since from the shader classesLaszlo Agocs2019-06-171-1/+0
| | | | | | | | | | | | Private API, do not bother with these yet. Change-Id: I77fb8fadee427425759ed42234944b30155db0f5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Introduce the Qt graphics abstraction as private QtGui helpersLaszlo Agocs2019-06-131-0/+1088
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>