summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
Commit message (Collapse)AuthorAgeFilesLines
* Add missing qHash overload for INTEGRITYKimmo Ollila2021-06-162-0/+12
| | | | | | | | | Fixes build issue "no instance of overloaded function "qHash" matches the argument list" on INTEGRITY Pick-to: 6.2 Change-Id: Ia1273587840d55199846dc64d487d194f9a4d565 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* QDebug: add support for QVarLengthArrayMarc Mutz2021-06-131-6/+0
| | | | | | | | | | | | | | Remove a conflicting definition of the same operator from qrhi.cpp. Who knows how many ODR violations this hidden gem may have caused... [ChangeLog][QtCore][QDebug] Can now stream QVarLengthArray objects. [ChangeLog][QtCore][QVarLengthArray] Can now be output via QDebug streaming. Change-Id: I12f7670e32029fa8c96b446e9a98ebf3b9732d0d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* rhi: Use QByteArray for storing data in QGles2BufferRobert Löhning2021-06-082-14/+12
| | | | | | | | | | Mainly to avoid leaking memory again. A possible reduction of memory allocations would be a welcome side effect. This reverts parts of 89f7389494c6fc917f189150e06ed1fcfaa238e8. Change-Id: I65a7529f532175967a4e408450aa55549b77d7e4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Enable reading back slices of 3D texturesLaszlo Agocs2021-06-036-28/+46
| | | | | | Change-Id: I0c687677b7e86b7284130c775718b29aca2cca40 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Avoid debug layer warning when having no vertex inputsLaszlo Agocs2021-05-311-7/+9
| | | | | | | Pick-to: 6.1 Fixes: QTBUG-94064 Change-Id: I03237fcff06225ba41c65c0171d77fb6ae75fcd3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add support for 3D texturesLaszlo Agocs2021-05-3114-203/+587
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Supported on OpenGL (and ES) 3.0+ and everywhere else. Can also be a render target, targeting a single slice at a time. Can be mipmapped, cannot be multisample. Reading back a given slice from a 3D texture is left as a future exercise, for now it is documented to be not supported. Upload is going to be limited to one slice in one upload entry, just like we specify one face or one miplevel for cubemap and mipmapped textures. This also involves some welcome hardening of how texture subresources are described internally: as we no longer can count on a layer index between 0..5 (as is the case with cubemaps), simply arrays with MAX_LAYER==6 are no longer sufficient. Switch to sufficiently dynamic data structures where applicable. On Vulkan rendering to a slice needs Vulkan 1.1 (and 1.1 enabled on the VkInstance). Task-number: QTBUG-89703 Change-Id: Ide6c20124ec9201d94ffc339dd479cd1ece777b0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vk: Switch to the modern validation layer internallyLaszlo Agocs2021-05-311-14/+3
| | | | | | Task-number: QTBUG-88388 Change-Id: Ia30af6c4554594f094af7866ad6e10ed7929de27 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: gl: Add support for importing an existing renderbuffer objectLaszlo Agocs2021-05-197-2/+94
| | | | | | | | | | | | | | | | | | | | | | Normally we only allow creating wrappers for texture objects. These can then be used with a QRhiTextureRenderTarget to allow rendering into an externally created texture. With OpenGL (ES), there are additional, special cases, especially on embedded. Consider EGLImages for example. An EGLImageKHR can be bound to a renderbuffer object (glEGLImageTargetRenderbufferStorageOES), which can then be associated with a framebuffer object to allow rendering into the external buffer represented by the EGLImage. To implement the same via QRhi one needs a way to create a wrapping QRhiRenderBuffer for the native OpenGL renderbuffer object. Here we add a createFrom() to QRhiRenderBuffer, while providing a dummy, default implementation. The only real implementation is in the OpenGL backend, which simply takes a renderbuffer id, without taking ownership. Task-number: QTBUG-92116 Change-Id: I4e68e665fb35a7d7803b7780db901c8bed5740e2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Fix memory leakRobert Löhning2021-05-101-3/+4
| | | | | | | | | | | | The leak can be reproduced by running the test project from QTBUG-63557 with asan, although that report is about yet another leak. [ChangeLog][gui][QRhiGles2] Fixed a memory leak in QRhiGles2 Task-number: QTBUG-63557 Pick-to: 6.1 Change-Id: Ic4d346abb36a5666feb3ceb881865b029f5a6945 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* rhi: gl: Sanity check vertex outputs and fragment inputsLaszlo Agocs2021-05-032-0/+26
| | | | | | | | | | | | | | | | | | | | | | Print a warning if the name for a given location does not match. This is relevant only to OpenGL and only to < 330 GLSL versions: there the location qualifier is simply not present in the actual shader code and all matching is name-based. This leads to hard to discover problems in Qt Quick ShaderEffects for instance, where providing a custom fragment shader but using a built-in vertex shader is common, and one may be tempted to use a name other than qt_TexCoord0 for the input variable in the fragment shader. Unfortunately this breaks, sometimes silently, when not having location qualifiers. (and we won't, neither in GLSL 120 or 150 which are the standard for Qt Quick) Make this situation recognizable by printing a warning to the debug output. Pick-to: 6.1 Task-number: QTBUG-92500 Task-number: QTBUG-93370 Change-Id: I0d0bcc135e23a228783f7633f872e39c4e43bb93 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Add QRhiTexture::RG16 formatLars Knoll2021-04-076-0/+29
| | | | | | | Those are needed to handle 16bit YUV formats in Qt Multimedia. Change-Id: I39c67bf4fcf558487b7819ea38e578f99c12a3ed Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Add support for custom bytes-per-line for uncompressed raw dataLaszlo Agocs2021-03-309-19/+82
| | | | | | | Fixes: QTBUG-90770 Change-Id: Icba328c417bcce256e7b44f1d540af7f8e83376b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: vulkan: Prevent a misplaced assert from triggering in debug buildsLaszlo Agocs2021-03-231-1/+1
| | | | | | | | | | | | | One place where this popped up was the qrhi autotest (in debug builds). This check is meant for VkRenderpass objects for texture render targets, should not bother with it for the "main" renderpass. Amends 19384f2e8f50bad0a0775f7b2e10aff3372bcbb5 Change-Id: I877a2458fe17fe339b4741d4aa8af3fbda4dabcc Pick-to: 6.1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make it possible to clone a QRhiRenderPassDescriptorLaszlo Agocs2021-03-1912-63/+147
| | | | | | | | Pick-to: 6.1 Task-number: QTBUG-91888 Change-Id: Ib6d2e639e6c24f3e9a733c6563dc8a6d6da47719 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Make unreleased resource warnings available in release buildsLaszlo Agocs2021-03-181-4/+7
| | | | | | | | | | | | | | | | ...but tie to an environment variable still. When destroying a QRhi object, it has the ability to print warnings for each QRhiResource that got created from the QRhi and is still alive. This includes only QRhiResources that own native objects underneath. It can be handy to enable this in release builds as well. Therefore, make this possible by setting QT_RHI_LEAK_CHECK=1. In debug builds this continues to be always on. Pick-to: 6.1 Change-Id: I5283676594284fadf2adf4f123b4fc6adb6db1f7 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: metal: Remove most availability guardsLaszlo Agocs2021-03-161-81/+23
| | | | | | | | | Once the deployment target is bumped to 13.0, most guards can be removed. Pick-to: 6.1 Change-Id: I7566a4f2915ada9defa1a4bcee10f75021222b30 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* rhi: metal: Stop using BufferOp for no good reasonLaszlo Agocs2021-03-111-6/+8
| | | | | | | | | | | Do what the Vulkan backend does, and just take the offset and the QRhiBufferData. There is no reason to store a full QRhiResourceUpdateBatchPrivate::BufferOp struct within the backend. Change-Id: I67528029de40320b3e4f031346d40dfc0bb9ab52 Pick-to: 6.1 6.0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: metal: Skip unnecessary writes when updating the entire bufferLaszlo Agocs2021-03-111-1/+4
| | | | | | | | | | | Follow the similar Vulkan change in 20eb40bce92c3e5460cd2540547f3c404fe6dccc and drop the queued up buffer data for a given slot when the current update covers the entire buffer. This is relevant in particular for Qt Quick 3D where such dynamic buffer changes are common. Change-Id: If1e70d78968586b552a5357bc97af10cc61d9611 Pick-to: 6.1 6.0 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: metal: Avoid unused argument warning on iOSLaszlo Agocs2021-03-101-0/+3
| | | | | | Change-Id: I4cb729f3d8dbe7703b89153b742ce2874f35cfd2 Pick-to: 6.1 6.0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* rhi: metal: Use the layer as the single source of truthLaszlo Agocs2021-03-101-8/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...when it comes to the output size. This mirrors what all other backends do. For example, with Vulkan the only source of size is the surface (VkSurfaceKHR), never the QWindow, even though we'd expect that the surface size equals to window_size * dpr, and that's almost always true, but there are exceptions. (e.g. we have seen bugs on Windows with some drivers in high DPI situations where the Vulkan surface did not fully match the window size, yet it is the surface, and only the surface, that matters for rendering, i.e. viewports and such must match the surface, not the native window) With Metal we hit a similar problem on iOS: the QWindow's size*dpr and what we calculate from the CAMetalLayer have a height difference of 1. Mitigate this by making QRhiSwapChain::surfacePixelSize() and the calculation for currentPixelSize() done via the same route (the CAMetalLayer). Otherwise, if there is a mismatch between what the QWindow and the layer says, Qt Quick will think that there is a resize happening (has happened) whenever starting a new frame, and that has far reaching consequences (suboptimal performance, increased memory usage by buffers, etc.) Change-Id: I114df92bf35622c99f2747420fdce401db7705a6 Pick-to: 6.1 6.0 Fixes: QTBUG-91438 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* rhi: gl: Fix missing uniform data with certain command listsLaszlo Agocs2021-03-092-1/+33
| | | | | | | | | | | | | | Following patterns from the other backends is insufficient with OpenGL because we do not use real uniform buffers. There is currently a possibility that a shader program will be bound without following it with setting uniforms. Correct this by having a second level of tracking of the associated srb object in the pipelines. Pick-to: 6.0 6.1 Fixes: QTBUG-91630 Change-Id: I74a012daade826dd22c436bde06381c1233bad11 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* rhi: metal: Present drawables via addScheduledHandler instead of presentDrawableTor Arne Vestbø2021-02-051-3/+7
| | | | | | | | | | | | | | The former API is the recommended way to present drawables -- avoiding WindowServer submission throttling and potential issues with lock-ups when window are not serviced, are being moved to other screens, or users mistakenly call waitUntilCompleted. The scheduled block captures the drawable and retains it until the block is done executing. Change-Id: I99dca2db3bcfbea67c686dd5d97ba5011598997e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: metal: Manually manage drawable lifetimeTor Arne Vestbø2021-02-051-3/+8
| | | | | | | | | | | | | | | | | | | The drawable returned from nextDrawable is autoreleased, which means unless we explicitly retain it we have no guarantee that it will stay alive long enough to be used again in endFrame(). For example, if the user had an autorelease-pool in their custom render code, where the call to beginPass() happens, the drawable would be released when that pool went out of scope. The only reason we didn't hit this yet is due to the default autorelease-pool being at the level of the runloop, so the drawable happened to outlive the rendering of a single frame. An advantage of manually managing the lifetime of the drawable is also that we can release it immediately after being done with it, instead of waiting until the autorelease-pool drains. Change-Id: Ie6fd271adbe1121eb947bb7075142f1a6c81175d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: gl: Attempt reading back floating point formatsLaszlo Agocs2021-02-032-9/+27
| | | | | | | | | ...in the hope that they may work. If not, that's it, but at least we tried. Task-number: QTBUG-76970 Change-Id: I134c5cc4cfb5ad1e6f9edbfcf506df20022e127a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Pipeline cache load/saveLaszlo Agocs2021-01-2213-54/+574
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add QRhi APIs to retrieve and reload the contents of the "pipeline cache". The only API where there is a true pipeline cache is object is Vulkan (VkPipelineCache). For OpenGL, the other backend where we support this, it is simulated with program binaries. The Qt 5 style OpenGL program binary disk cache continues to work like before, but one has now the option to do things in a more modern, graphics API agnostic way, that leads to generating a single blob instead of a large set of files in some system location, allowing easier "pre-baking" of the cache content. It is expected that Qt Quick exposes the two new functions in form if QSG_RHI_ environment variables, thus allowing easy testing and cache file generation. As an example for the performance improvements this can give, consider Vulkan, where we do not have any existing persistent caching mechanism in place: Running BenchmarkDemoQt6.exe --scene flythrough --mode demo creates 18 QRhiGraphicsPipeline objects from Qt Quick and Qt Quick 3D. The total time spent in QRhiGraphicsPipeline::create() during application startup for these 18 pipelines is 35-40 ms on a given Windows (NVIDIA) system. When exporting the pipeline cache contents to a file, and then, in a subsequent run, reloading the cache contents, this is reduced to 5-7 ms on the same system, meaning we get a 6-7x improvement. The generated data is always specific to a given Qt version, RHI backend, graphics device, and driver version. Much of the implementation consists of adding and verifying the appropriate header to the blobs retrieved from the driver, to allow gracefully ignoring data that was generated with a device or driver that differs from the one used at run time. This should provide robustness, even if the Vulkan or OpenGL implementation is for some reason not prepared to identity and reject incompatible cache/program blobs. Fixes: QTBUG-90398 Change-Id: I67b197f393562434f372c7b7377f638abab85cb3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Stop hardcoding the Vulkan backend's desired instance extensionsLaszlo Agocs2021-01-182-10/+41
| | | | | | | | | 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-1529-318/+405
| | | | | | | 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-135-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* rhi: Expose device name, type, and IDsLaszlo Agocs2021-01-1313-2/+221
| | | | | | | | | | | | | | | | ...to the extent it is sensible. We have to make compromises still, meaning some fields will only be applicable with certain APIs. Most of this is already shown upon QRhi::create() as info debug prints, when enabled. Now expose it all through the QRhi API as well. This is useful for printing in qtdiag, and, while it should be avoided as much as possible, to make decisions about disabling 3D rendering features depending on the driver and GPU in use. Change-Id: Iebe1e192965c928b82a094d1c7c50ddf4b38b9a2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-57/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* rhi: vk: Prevent WAW hazard reported from sync validation with offscreen rtLaszlo Agocs2021-01-062-4/+45
| | | | | | | | | | | | ...when a QVkRenderBuffer is used as depth-stencil (i.e. a "throwaway" depth-stencil buffer that is a lazily allocated / transient VkImage under the hood). Such a resource is not tracked by the QRhiPassResourceTracker, so do an explicit barrier in beginPass instead of having it generated by the tracker. Fixes: QTBUG-89764 Change-Id: Ice794f44342175f712ea56f450270cbb8929f516 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: gl: Reset tracked state upon a buffer update or readbackLaszlo Agocs2021-01-061-48/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...encountered in the command list. Move all, previously local, tracking variables into a struct. This allows creating helper functions to reduce error-prone repetition in the executeCommandBuffer() function body. The only real change in the patch is in the handling of Command::BufferSubData and Command::GetBufferSubData: here, instead of calling glBindBuffer directly, use a helper function that also resets the relevant state tracking variables. A subsequent Command::BindVertexBuffer or BindIndexBuffer will therefore correctly rebind the appropriate buffers. This is particularly relevant with certain command stream patterns exercised by some Qt Quick 3D scenes: - A View3D renders a mesh, - another View3D has some 2D Qt Quick content, as well as a model with the same mesh. When both View3Ds use the default Offscreen render mode, the resulting command list consists of segments along the lines of: 1. prepare resources for first View3D 2. render content for first View3D - this binds the vertex and index buffers for the mesh (state is tracked; all 1-4 steps are within the same command list, processed by a single call to executeCommandBuffer()) 3. prepare the content for the "inline" 2D Qt Quick scene - this may update vertex and index buffers, that may lead to adding BufferSubData commands to the list (tracked state (last vertex/index buffer) may need invalidation/updating - and that's where our problem lies) 4. the second View3Ds 3D content is rendered: a model with the same mesh as the last (Quick)3D draw call, so same vertex and index buffers. If #3 did not invalidate and/or update the tracked state, the glBindBuffer calls are (incorrectly) skipped. Fixes: QTBUG-89780 Pick-to: 6.0 Change-Id: Icc933252f3993b8727d192e7ba4aa0f842bab51e Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vk: Fix DS WAW hazard reported from sync validationLaszlo Agocs2021-01-041-10/+23
| | | | | | | | | | | | | | Running with synchronization validation (SDK 1.2.154) we get: Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 1 aspect depth during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR Attempt to fix this with an appropriate subpass dependency. Fixes: QTBUG-89760 Pick-to: 6.0 Change-Id: I67e15a09aab564f63aab646761ccdb1f8b82111d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add QRhiTextureSubresourceUploadDescription QByteArray constructorJonas Karlsson2020-12-292-2/+14
| | | | | Change-Id: I1be4ef1a15c4049f19d0401d6a1a62b3117180a0 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Prevent copy in texture upload with invalid inputLaszlo Agocs2020-12-161-2/+4
| | | | | | | | | | Skip the memcpy when src is null. Also silences a Codechecker warning. Pick-to: 6.0 Change-Id: I5042d725000cb6dff6864408fa9ed9e0ca35145a Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-309-40/+40
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Fix typo in rhiAntti Määttä2020-11-271-1/+1
| | | | | | Pick-to: 6.0 Change-Id: I2e920e8e68b7010b565c422bb26708d172d345e8 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Fix attribute instancing cleanup for OpenGL ESPaul Olav Tvete2020-11-271-0/+9
| | | | | | | | | | | | | The previous attribute instancing patch (6493b93) performed the cleanup too late for the case where the command buffer ends with an EndFrame command and core profile is used. Resetting the attribute divisors needs to be done before the vertex array is unbound. Otherwise the state will be wrong at the start of the next call to executeCommandBuffer(), which is normally the start of the next frame. Change-Id: Ic76695b4d334ed1c1e816e747417d957c387a88b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* RHI: Reset attribute instancing properly for OpenGL ESPaul Olav Tvete2020-11-261-3/+24
| | | | | | | | | | | | Enabling instanced drawing will set glVertexAttribDivisor to 1 for the PerInstance attributes. This is of course a persistent state, because GL, so it will apply to all subsequent draw calls that uses attributes with the same location number, introducing weird and wonderful randomness. Therefore, make sure we set the divisor back to 0 for non-instanced attributes. Change-Id: I2d9115369fa24e8d57396d2a5f88d1435fe98971 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: gl: Do not bother with glDrawBuffers(GL_BACK)Laszlo Agocs2020-11-021-4/+0
| | | | | | | | | | | | | | | | | It's per framebuffer and the color target for the default fbo is never altered. So no need for this call. This is useful because it avoids having to deal with the controversy around GL_BACK (where the GL, but not the ES, spec claims some quite nonsensical things about GL_BACK not being accepted by glDrawBuffers (in the name of stereo support?), nevermind GL_BACK being the default value...), and while what we have in place now seems to be ok with many implementations, it may generate a GL error with others - so just remove the call in order not have to think about this legacy nonsense) Task-number: QTBUG-88070 Change-Id: I051c60a3041865a3434801b57da2b7acb518b8fe Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QRhiBackendCommandList: avoid new[]/delete mismatchFabian Kosmale2020-10-191-1/+1
| | | | | | Change-Id: Iac2645ebd1d42753817078f194ba61520f5f70c9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Further reduce copying in the command bufferLaszlo Agocs2020-10-167-228/+170
| | | | | Change-Id: I2e2ff5f4b8aa91d0accb01108a5199b98c371455 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* rhi: Unroll the res.binding factory functionsLaszlo Agocs2020-10-161-11/+59
| | | | | | | | | Trading typing in a few lines of straightforward code for a full sizeof(QRhiShaderResourceBinding::Data) copy (with less fortunate compilers that do not manage to optimize it away) is a bad deal. Change-Id: If227320f8a9598508c1fe02c4f56e6d75f0a787b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Fix up vertex inputs with matricesLaszlo Agocs2020-10-143-6/+31
| | | | | | | | | | | | In order to prevent too much voodoo in backends like D3D11, the input layout is expected to specify the slice index for vecX that are part of an unrolled matrix. Also deoptimize the instancing manual test to exercise a matrix too instead of just vectors. Change-Id: If2dcbcbc483645ce2420b2f87dda765b95da6e80 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: Add missing \internal doc commandsTor Arne Vestbø2020-10-121-0/+3
| | | | | | Pick-to: 5.15 Change-Id: I09a69a04c6fcd406602e797cbeec59216fecd5d8 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* rhi: Make the new direct buffer update available for non-uniform buffersLaszlo Agocs2020-10-1212-41/+69
| | | | | | | | | | | | | | | | | The original restriction to UniformBuffer was due to the GL backend where there is no GL buffer object for QRhiBuffers with usage UniformBuffer. However, we can still implement this for cases when there is a true GL buffer object underneath. With other backends it should all work as-is already. This becomes useful when one has buffers with usage Vertex that need full updates every frame. (f.ex. instance data) Unfortunately this involves renaming the function. But while at it, add an autotest case as well. Change-Id: Iff59e4509a8bae06654cc92fe8428bd79eb012fb Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Save a few cycles in bindShaderResourcesLaszlo Agocs2020-10-113-121/+144
| | | | | Change-Id: Ib11ea33eb695d4599f4f040415d497aaf19cb15b Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: d3d: Calculate dynamic offset usage upfrontLaszlo Agocs2020-10-112-9/+17
| | | | | | | Also remove an unnecessary buffer type test. Change-Id: I6f8312f03d3fe1729fa9b2eb95f6bfbeeccd0d4f Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vk: Avoid shadowing local variableLaszlo Agocs2020-10-111-5/+6
| | | | | Change-Id: I7ad14ff05a1ff10113f5d3985662970d74e68ead Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* rhi: vk: Skip buffer/texture registration on read-after-readLaszlo Agocs2020-10-111-6/+19
| | | | | Change-Id: I22027cfc227d3c09e446d193e6b2903b8df34eb2 Reviewed-by: Andy Nichols <andy.nichols@qt.io>