summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhi.cpp
Commit message (Collapse)AuthorAgeFilesLines
* rhi: Drop the zeroing out of resource binding structsv6.0.0-alpha1Laszlo Agocs2020-09-251-8/+0
| | | | | | | | | | This has a non-insignificant cost (since the size is at least 260 bytes) in renderers that construct a lot of these objects per frame. After changing the qHash implementation to be lighter we no longer rely on qHashBits, so zeroing it is not essential anymore. Remove it. Change-Id: If1fbd8dfd46fb3f0e9ea5a3c4794d24b8aeac1ba Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vulkan: Fix mipmap generation for cubemapsLaszlo Agocs2020-09-251-5/+6
| | | | | Change-Id: Ia1aab06214be802aaabc97ffefa28947e11148e3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Reuse buffer/texture op entries in res.update batchesLaszlo Agocs2020-09-231-25/+85
| | | | | | | | More of an enabler for reusing the data in the individual entries since not clearing the QVLA does not give us much on its own. Change-Id: Ief9761f75382c3373cc2bc7b866eb59fdd8b3277 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Report an "optimal capacity" from res.update batchesLaszlo Agocs2020-09-231-0/+24
| | | | | Change-Id: If47eddf3fe7d365c80b0a15712ef155a6898d904 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Do not just pick the first free res.upd. batch all the timeLaszlo Agocs2020-09-231-1/+12
| | | | | | | | | Rather, utilize all the available ones in the pool, picking the next available batch after the one we picked previously (with wrapping over as necessary). Change-Id: I5f26e127a406c2dd07d155712429c72ad4f0f0f1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Support signed integer attributes on QRHIInho Lee2020-09-211-6/+14
| | | | | | | Previous UIntAttributes feature is renamed as IntAttributes. Change-Id: I4b4a87a0eebf37291da832605f7bee8fb2d4e62b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Expose compute threadgroup limits in ResourceLimitsLaszlo Agocs2020-09-181-0/+26
| | | | | | | | | | As OpenGL ES and Vulkan ruin the day with the spec mandated minimum value for max threads per threadgroup being only 128, clients need a way to decide if their compute shader (local_size_*) is suitable for use at run time. Change-Id: I72b4fc97032406340623add82ea4d9544ebe9fdc Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Enhance compute dispatch docsLaszlo Agocs2020-09-171-0/+12
| | | | | | | | These docs are not part of the generated docs due to QRhi being private, but nonetheless keep it useful. Change-Id: Ic46aaa4cd329535c37fffcd514ba354dff4bfb5c Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Improve srb hash perf somewhatLaszlo Agocs2020-09-171-4/+27
| | | | | | | | | Do not qHashBits on the whole data that is at least 260 bytes, a big part of it often unused. Just hash binding/stage/type and the first resource pointer. Change-Id: If9b3dc9acf36edf225302b1216d91e87b652b8ef Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Sanity check the srb in debug buildsLaszlo Agocs2020-09-031-1/+74
| | | | | | | | | | | Instead of cryptic assertions and crashes depending on the backend, show some useful warnings (in debug builds only) when one tries to create an srb with a list where there are duplicated bindings. (a mistake that happens relatively often during the development of frameworks, such as Quick 3D, on top) Change-Id: If1b50a2e8165b001878ad566e048f146e636514f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: gl: Correctly report WideLines for OpenGLLaszlo Agocs2020-08-301-1/+2
| | | | | | | | In core profile contexts a line width other than 1 may not work as expected since it is deprecated in the core profile. Change-Id: I3fc33cf90c65156aa87d04f08518c9ddcfb62625 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Allow compiling source shaders with debug at run timeLaszlo Agocs2020-08-281-1/+28
| | | | | | | | | | Relevant for Qt Quick 3D. As in many cases Quick3D will rely on runtime generated shader code, the translated HLSL will be compiled via D3DCompile() at run time. To make such shaders debuggable, the necessary flag (D3DCOMPILE_DEBUG) should be requestable somehow. Change-Id: I4d5c3b57bf58df8d46556eebb5cf6fb75e9d0afe Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Port QSet to qsizetypeUlf Hermann2020-08-251-1/+1
| | | | | Change-Id: I70ad8fb6908ce3837a723e9a095bee5c166739e4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* rhi: sanityCheckGraphicsPipeline handle no vertex attributesPaul Lemire2020-08-181-7/+1
| | | | | | | | | It is a valid use case to have a vertex shader with no vertex attributes. Using gl_VertexID or gl_InstanceID is enough to generate vertex data out of thin air. Change-Id: If7689914624a84723923fd2d7aef355bda592e24 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Another round of using noexcept instead of pre-C++11 definesAllan Sandfeld Jensen2020-08-131-24/+24
| | | | | | | A few new files were added with old-school defines. Change-Id: Ieb2c71e094e55102f3f39fb9551823f36863f5f4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Allow null resources in srbLaszlo Agocs2020-07-131-14/+128
| | | | | | | | | | In this case the srb represents the layout only, and can still be used to create a pipeline. For setShaderResources() one will then need to use another, layout compatible, srb that references valid resources. Change-Id: I3ea5b63df3be8847540ca4c0c40fbd29dbed8fb7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-3/+3
| | | | | | | 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>
* rhi: add support for D24 / D24S8 formatsJean-Michaël Celerier2020-07-021-0/+6
| | | | | Change-Id: I7ba14d30fa57bcb92cd764aed6c85cde853935b4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add a feature flag for readback format supportLaszlo Agocs2020-06-151-0/+12
| | | | | | | | | Indicate that doing a QRhiResourceUpdateBatch::readBackTexture() for texture formats other than RGBA/BGRA is not necessarily supported at run time. Change-Id: Ie9ca9546a3af9bff142b875f1ecf26bf26bcc442 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: Harmonize create-destroy API pattern with the rest of QtLaszlo Agocs2020-05-281-117/+118
| | | | | | | | | | For historical reasons we use build and release instead of create and destroy. This becomes confusing now that more modules in Qt start taking QRhi into use. Migrate to the more familiar naming, so those who have used QWindow or QOpenGLContext before will find it natural. Change-Id: I05eb2243ce274c59b03a5f8bcbb2792a4f37120f Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QRhiVertexInputAttribute : Add unsigned int formats for vertex inputInho Lee2020-05-271-0/+7
| | | | | | Task-number: QTBUG-83173 Change-Id: I640cd1fe74227d2cc96672d6c7aaac93e1930bcd Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Introduce QRhiTexture::RG8VaL Doroshchuk2020-05-251-0/+5
| | | | | | Change-Id: I58f35b2629bd6464f08cba66e852215472fcbe2a Fixes: QTBUG-84384 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: facilitate compressed atlas textures in gles2 backendEirik Aavitsland2020-05-221-3/+3
| | | | | | | | | | | | | | | Since glCompressedTexImage2D() does not allow zero data, it could not be executed during texture build. Instead it would be done during the first subresource upload. This made atlasing clumsy, since one had to introduce a fake upload of the full texture size before the subtexture uploads. This commits lets the gles2 backend deal with that instead. Introduces the UsedAsCompressedAtlas QRhiTexture::Flag for opting in to this behavior. Task-number: QTBUG-78582 Change-Id: Ib6e4ea637c62cc8a51bd9a4a06e59882f335f2a7 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Store texture handle as 64-bit intEskil Abrahamsen Blomfeldt2020-05-221-9/+5
| | | | | | | | | | | | | | | | | | When storing a void* pointer to the texture handle, we had to ensure that the variable would exist until the build phase, which is error prone and caused errors in QQuickWidget because we copied the texture ID from the FBO into a local variable before passing it into QQuickWindow::setRenderTarget(). The reason for using a void* was that we cannot know the width of the handles in the different backends, but we do know that they are 64-bit at maximum, so instead of storing potentially dangling pointers, we just make it a 64-bit integer and cast it back and forth in the backends. Task-number: QTBUG-78638 Change-Id: I7951e24351ddb209045ab6197d81eb1290b4da67 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add backing format hint to QRhiRenderBufferLaszlo Agocs2020-04-291-4/+21
| | | | | | Task-number: QTBUG-83707 Change-Id: I63548f4ace70af614a2aa082663bb3ae9fbedc25 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Take mip size into account for render target sizeLaszlo Agocs2020-04-231-0/+7
| | | | | | | | Also extend autotesting, both for rendering into a given mip level and for rendering into a given cubemap face. Change-Id: Ida94b71150477ceb50a3b5616d8b7be13174558b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Change qHash() to work with size_t instead of uintLars Knoll2020-04-091-8/+8
| | | | | | | | | | | This is required, so that QHash and QSet can hold more than 2^32 items on 64 bit platforms. The actual hashing functions for strings are still 32bit, this will be changed in a follow-up commit. Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use qsizetype for size related methods in QVarlengthArrayLars Knoll2020-03-141-1/+1
| | | | | Change-Id: Ib94b9a4e6e17da21f592e71a36fd1b97d42dfe62 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* rhi: Add support for arrays of combined image samplersLaszlo Agocs2020-03-051-9/+57
| | | | | | | | | | | | | | | | Introduces a new QRhiShaderResourceBinding function that takes an array of texture-sampler pairs. The existing function is also available and is equivalent to calling the array-based version with array size 1. It is important to note that for Metal one needs MSL 2.0 for array of textures, so qsb needs --msl 20 instead of --msl 12 for such shaders. Comes with an autotest, and also updates all .qsb files for said test with the latest shadertools. Task-number: QTBUG-82624 Change-Id: Ibc1973aae826836f16d842c41d6c8403fd7ff876 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Add a way to communicate back the native image layout for a QRhiTextureLaszlo Agocs2020-03-031-0/+25
| | | | | | | | | | | | | | | | | | | | | Relevant when doing custom rendering combined with QRhi, and only for APIs like Vulkan, where image layouts are a thing. As shown by demo apps, it is not currently possible to implement a correct application that renders or raytraces into a QRhiTexture's backing VkImage, and then uses that QRhiTexture in a QRhi-based render pass. This is because QRhi has no knowledge of the image layout if it changes due to commands recorded by direct Vulkan calls, and not via QRhi itself. So, except for certain simple cases, one will end up with incorrect image layout transitions in the barriers. (at minimum this will be caught by the validation layer) To remedy this, add a simple function taking the layout as int (we already do the opposite in nativeTexture()). Task-number: QTBUG-82435 Change-Id: Ic9e9c1b820b018f3b236742f99fe99fa6de63d36 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: Execute pending host writes on nativeBuffer() queryLaszlo Agocs2020-03-031-5/+3
| | | | | | | | | | | | | Otherwise it is impossible to write an application that pulls out the VkBuffer for a Dynamic QRhiBuffer, and then uses it with custom Vulkan operations that read from the buffer. More precisely, the problem arises only if the buffer in question is not used in combination with any QRhi operations, because in that case there is nothing that would trigger doing the host writes queued up by a resource batch's updateDynamicBuffer(). Task-number: QTBUG-82435 Change-Id: Ieb54422f1493921bc6d4d029be56130cd3a1362a Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Allow querying the native buffer objects behind a QRhiBufferLaszlo Agocs2020-02-211-0/+74
| | | | | | | | | | | | | Modeled after QRhiTexture's NativeTexture query. This becomes valuable in advanced cases of integrating external native rendering code with Qt Quick(3D), because it allows using (typically vertex and index) buffers created by Quick(3D) in the custom renderer as well, without having to duplicate the content by manually creating native buffers with the same vertex and index data. Change-Id: I659193345fa1dfe6221b898043f0b75ba649d296 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Do not rely on unspecified relation between readbacks and FramesInFlightLaszlo Agocs2020-02-211-13/+40
| | | | | | | | | | | | | | | Add a new queriable resource limit value MaxAsyncReadbackFrames. Change the autotest to rely on this instead of relying on the unspecified, works-by-accident relation between readbacks and FramesInFlight. This way even if the behavior diverges in some backend in the future, clients (well written ones, that is), will continue to function correctly. Also clarify the docs for FramesInFlight, and change d3d and gl to return the correct value (which is 1 from QRhi perspective; the expanded docs now explain a bit what this really means and what it does not). Change-Id: I0486715570a9e6fc5d3dc431694d1712875dfe01 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Allow detecting texelFetch supportLaszlo Agocs2020-02-131-0/+5
| | | | | Change-Id: I166c89af99e1289ae60febf2f41fab07eab9f7e8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-02-041-4/+4
|\ | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf examples/widgets/widgets/imageviewer/imageviewer.cpp src/corelib/text/qchar.cpp src/corelib/time/qdatetime.cpp Change-Id: I9762f5c4ff650799219729d6aee79ac07ce9024a
| * Fix 'the the' typo in commentsLinus Jahn2020-02-021-4/+4
| | | | | | | | | | Change-Id: I00fcb1c2374e7ca168b6240f9d41c0323fb0867c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | rhi: Improve isClipDepthZeroToOne() docLaszlo Agocs2020-02-031-9/+24
| | | | | | | | | | | | | | | | Quick 3D is now having a use case for calling this directly, so use this opportunity for enhancing the docs to make it clear what this is about. Change-Id: I19ec956ac25175dbfb754192abaad8d65a6eeb0e Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | rhi: Enable sampler address mode W in the APILaszlo Agocs2020-01-301-8/+10
| | | | | | | | | | | | | | | | | | | | | | Internally this is already supported by all backends. The frontend was just not exposing addressW, instead defaulting to the (arbitrarily chosen) ClampToEdge. Add the parameter to newSampler(), but make it optional, defaulting to the more natural Repeat (because that's what one would get with OpenGL for WRAP_R by default) Change-Id: I0b991d8b649db37d4da86ac8e98ab7845601cf67 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* | Doc: Replace some usages of 0/zero/null with \nullptrSze Howe Koh2020-01-271-2/+2
| | | | | | | | | | Change-Id: Ibe7de11fc6fc41477c35e7d653c6a911855deabb Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | rhi: Add R16F and R32FLaszlo Agocs2020-01-091-0/+6
| | | | | | | | | | | | | | | | Can be relevant for Qt Quick 3D shadows, where the shadow map is R16F. Task-number: QTBUG-81268 Change-Id: Ic33e100929e133d1cbe0b062a15697c82536f62a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* | RHI: Remove old native texture APIPaul Olav Tvete2020-01-061-44/+0
| | | | | | | | | | | | Task-number: QTBUG-78570 Change-Id: I8c4850828ac03319ac923a26c2e985883956c286 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* | RHI: new native texture APIPaul Olav Tvete2019-12-051-0/+67
| | | | | | | | | | | | | | | | | | | | | | | | The new version takes/returns a value that can be unpacked and passed to other functions without knowing which backend is in use. The old API will be removed in a later change when dependent modules have been updated Task-number: QTBUG-78570 Change-Id: I18d928ceef3cb617c0c509ecccb345551a7990af Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* | rhi: Allow testing QRhiRenderPassDescriptors for compatibilityLaszlo Agocs2019-11-271-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For Metal and Vulkan this needs actual work because that's where the concept of renderpass descriptors is relevant. GL and D3D can just return true always. The big benefit of this is that Qt Quick can now compare renderpass descriptors via isCompatible() for its pipeline cache (similarly to how it is already using isLayoutCompatible() for srbs), and so renderpass descriptors for layers (Item.layer, ShaderEffect) will typically be compatible and so can pick up pipelines created by other layers from the cache. Also add autotests for shader resource binding and renderpass descriptor compatibility. Task-number: QTBUG-80318 Change-Id: I0008bc51c4ee13b0113d2c8caf799e1257f18a18 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* | Enable QRhi Metal backend on iOSLaszlo Agocs2019-11-271-6/+2
|/ | | | | | | | | | While we are at it, remove the Border and MirrorOnce wrap modes that have not been supported on OpenGL, because they are unsupported with Metal+iOS as well. Task-number: QTBUG-78580 Change-Id: I0db94b9d3a6125b3bb5d7b1db5d02a42cd94d2c2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* rhi: Enhance swapchain size query docsLaszlo Agocs2019-10-211-2/+24
| | | | | | | | | | | Inspired by a recent Qt Quick fix. Make sure we make it clear that QRhi-based rendering code should base output size calculations (e.g. for setViewport() and similar) on the pixel size reported from QRhiSwapChain, instead of going to the QWindow. Change-Id: I2fc22972162ccc6307ac07ceb7766c746d5f562a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Autotest rendering a triangleLaszlo Agocs2019-10-091-3/+45
| | | | | | | | | Also improve (docs and runtime checks) and test the minimum set of required data to create a graphics pipeline. Task-number: QTBUG-78971 Change-Id: If5c14f1ab1ff3cf70f168fde585f05fc9d28ec91 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: gl: Add a feature flag for reading back non-zero mip levelsLaszlo Agocs2019-10-091-1/+7
| | | | | | | | | The joys of "level - Specifies the mipmap level of the texture image to be attached, which must be 0." for glFramebufferTexture2D in OpenGL ES 2.0. Change-Id: Iaf19502f48d7ba73b26abb72535bfa6696a1e182 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: gl: Switch GetBufferSubData emulation to MapBufferRangeLaszlo Agocs2019-10-091-4/+3
| | | | | | | | | | | | | Use only APIs that are in GLES 3.0. glMapBuffer() is an old OES extension, stop bothering with that. Not the least because ANGLE claims supporting it and then fails the map. (not that we care much about ANGLE, but, for instance, the qrhi autotest is run with ANGLE configurations as well in the CI, so have to still take care of it for the duration of Qt 5.x) Change-Id: I29140402cedffe0430f920ee0c061673257c3aa1 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* rhi: Add support for buffer readbacksLaszlo Agocs2019-10-091-12/+43
| | | | | | | | | | | | | | | | | | | | | | | | | This also marks the beginnings of significantly extending autotesting of the resource and rendering functionality in QRhi. Also involves fixing up the buffer operation lists like we did for textures before. This is to ensure updates and reads on the same batch execute in the correct order. So just have two lists: one with buffer, one with texture operations. Also simplify the struct layouts. No need for those inner structs with many duplicate members. This reduces the size even, since using a union was never an option here. Also switch to a VLA, the size is around 253 KB per batch. The Null backend now keeps track of the QRhiBuffer data so it can return valid results in readbacks. Task-number: QTBUG-78984 Task-number: QTBUG-78986 Task-number: QTBUG-78971 Task-number: QTBUG-78883 Change-Id: I9694bd7fec523a4e71cf8a5c77c828123ebbb3bd Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Add TriangleFan pipeline topologyPaul Olav Tvete2019-10-031-1/+5
| | | | | | | | | | | | Triangle fan drawing is only supported on some platforms. The feature flag QRhi::TriangleFanTopology is set accordingly. In general, TriangleStrip topology will be more efficient on most GPUs. However, if polygon data is already stored as triangle fans, the CPU savings may be more significant. Change-Id: I9704fad751d2119eac8791074f58942dd9315601 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>