summaryrefslogtreecommitdiffstats
path: root/src/render/graphicshelpers/graphicscontext.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move Renderer specific classes into new folderPaul Lemire2018-03-191-975/+0
| | | | | | | | This is another step toward isolating the renderer from the render aspect Change-Id: I4031675b961d6645b65bbe05cf62d150993038b0 Task-number: QTBUG-61151 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Perform Shader loading within framePaul Lemire2018-03-161-4/+10
| | | | | | | | | | | | | | | - CommandThread has been improved to not use an exec loop and properly instantiate its own GL context + GraphicsContext that is bound to an offscreen surface - The dirtyShaderGathering job has been renamed and now performs the loading of shaders and their introspection. It is also run before the materiaparameter gathering, so that these jobs and the following can assume a shader is ready Change-Id: I6d99b3a104bd96530dc45f4b05d3aaac09d2d077 Reviewed-by: Mike Krus <mike.krus@kdab.com> Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Split GraphicsContext in twoPaul Lemire2018-03-161-1093/+26
| | | | | | | | | - GraphicsContext is now a stateless wrapper around GL calls - SubmissionContext is a GraphicsContext + caches and states used to render a frame Change-Id: I147b56dfd4c403911faadc0e9821fff9a892f71c Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Doc: Fix documentation warnings for Qt 3D RenderTopi Reinio2018-02-281-0/+5
| | | | | | | | | | | | | This change fixes multiple QDoc warnings for Qt 3D Render that are related to how Clang parses the source code and the \fn QDoc commands. A number of changes are related to preventing documentation for private classes from generating warnings. We still have a number of 'No documentation for ...' warnings left - those are not addressed in this change. Change-Id: Ic92a729496a81e7869060811ed7dd23408cff833 Reviewed-by: Martin Smith <martin.smith@qt.io>
* Load textures in a single framePaul Lemire2018-02-281-5/+2
| | | | | | | | | | | | | | | | | Because of texture sharing, Qt3D compares functor before executing them. Instead of blindly loading a TextureImage functor which could turn out to not be used, Qt3D required 2 frames to fully update a texture. This behavior has been removed, now when a texture image functor is updated, it updates the texture in one frame. It is assumed that the user is responsible for declaring only TextureImage that he is actually going to use. Any scene that uses OnDemand rendering and frequently changes a texture image functor can be used to test this. (ex-painted-cube is a good example for KDAB) or paintedtexture-cpp in manual tests Change-Id: I8c2f13876244a862633e10e472e2b49cbd6e126b Task-number: QTBUG-63561 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Revert "Keep rendering in sync with aspect jobs by adding barriers"Paul Lemire2018-02-281-2/+13
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 46319648436814afb5a77755dde6681e304befaf. We want to be able to render one set of RenderViews for frame n while concurrently building RenderViews for frame n + 1. The reverted commit removed that behavior which reduced the CPU time available to prepare a frame. This would cause on some scenes a failure to meet the ~10ms budget we have to prepare a frame. This is therefore a regression. The root cause behind this regression is that a job cannot be executed until all the jobs which have been previously launched have completed. The proposed solution would be to instead add an OpenGL command thread that can be used to load graphics resources required for the RenderViews directly when required. This would in turn allow to cache RenderViews and keep the concurrent behavior of RenderView submission and creation. With that goal in mind, the following patches will be rebased and updated https://codereview.qt-project.org/#/c/189309/ https://codereview.qt-project.org/#/c/189310/ Change-Id: I4879047c45986a0e615e3aef7b7352f82a04a9da Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Fix color scaling in copyGLFramebufferDataToImageAnders Hafreager2018-02-221-3/+3
| | | | | | | | | | | | | | | | | Previous implementation used a component conversion for QAbstractTexture::RGBA32F (when GL_TYPE is GL_FLOAT) which results in a non-linear mapping from [0,1] to [0,127]. A non-linear mapping should only be used for some GL_TYPE other than GL_FLOAT. See https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/ glReadPixels.xhtml for more. This change maps color linearly to the range [0,255] when QAbstractTexture::TextureFormat is QAbstractTexture::RGBA32F. Task-number: QTBUG-66514 Change-Id: I4aa36b59acd193c7342ba4b0577f132e0c19ef85 Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Merge remote-tracking branch 'origin/5.9' into 5.10Sean Harmer2018-02-051-9/+8
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/render/backend/trianglesvisitor.cpp src/render/backend/uniform.cpp src/render/jobs/calcboundingvolumejob.cpp src/render/jobs/pickboundingvolumejob.cpp src/render/jobs/pickboundingvolumeutils.cpp Change-Id: Ib8305011c51710a3538c0b29f7022388f5244a38
| * Fix array of textures in shader parameterMauro Persano2018-02-021-4/+3
| | | | | | | | | | | | Task-number: QTBUG-61759 Change-Id: I2c61f9cf41124816d10da90783c7fb9ff6088fc4 Reviewed-by: Mike Krus <mike.krus@kdab.com>
| * Compile failing shaders once only and avoid asserting on failureLaszlo Agocs2018-02-011-5/+5
| | | | | | | | | | | | | | | | | | | | | | This way a material with a broken shader will fail once (and won't be retried unless the shader code gets changed), and the application will continue gracefully, without asserting. Task-number: QTBUG-65936 Change-Id: I7003e8c6f7d9094280d7757c1020b485f93e3b37 Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | Keep rendering in sync with aspect jobs by adding barriersSvenn-Arne Dragly2018-02-021-13/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes sure that jobs that depend on a specific state of the renderer (such as context being initialized) never run before this is the case. This reduces the number of possible race conditions and checks we need to do to ensure the jobs and the renderer are in the correct state. This way we no longer swap buffers when nothing has been rendered, which in turn makes sure that we only draw one frame when the render policy is OnDemand and there are no changes. This change also adds a number of assertions on pointers to resources to make it easier to detect missing job dependencies. Finally, this change overhauls the job dependencies in Renderer and RenderViewBuilder. Task-number: QTBUG-66024 Change-Id: I3e4e9dd0dd53b5c88f5c1b17d68df42f28eae794 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2018-01-221-1/+2
|\| | | | | | | | | | | | | Conflicts: src/render/backend/renderer.cpp Change-Id: I691f54cd6daef8a966df37d447164c94badce34c
| * Don't insert nullptr shader programs into the shader cacheVolker Krause2018-01-121-1/+2
| | | | | | | | | | | | | | | | This can happen when the shader program fails to compile/link, and will subsequently trigger an assert in the shader cache. Change-Id: I4c4093d89a8a0f5ed1970012258be5efe8ec29c9 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Make BlitFramebuffer rectangles follow Qt conventionsLaszlo Agocs2017-12-121-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | ...and add some minimal documentation since this now needs to be documented. [ChangeLog] (Q)BlitFramebuffer has been corrected to treat the source and destination rectangles to be in the usual Qt coordinate system with Y at top. Task-number: QTBUG-65123 Change-Id: Id129e515db69d334ce5534abcb9ebf49fe0d49ab Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Enable BlitFramebuffer with non-output render targetsLaszlo Agocs2017-12-111-36/+77
| | | | | | | | | | | | Task-number: QTBUG-65080 Change-Id: I711f58e67906af048a64eb7d0e2f66c8a96dd14f Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-10-311-11/+8
|\| | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/render/backend/renderview.cpp src/render/backend/renderview_p.h Change-Id: I6c1122632f2c481da31a63e3abd42b760d1ff211
| * Render next frame if texture data is not availableHarald Vistnes2017-10-091-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Texture data from generators may not be available in the current frame and the next frame should be rendered immediately, even in OnDemand rendering. The problem was that this information was not propagated back to the renderer, it was just silently ignored inside GraphicsContext::setParameters. Added a bool return type to GraphicsContext::setParameters so that the renderer could check for errors. Task-number: QTBUG-63561 Task-number: QTBUG-59752 Change-Id: I18fb6f8236bf47d3eeab07d879dffaa599665e6b Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
| * Fix race in rendererPaul Lemire2017-10-061-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | All buffers are uploaded to GPU before the frame submission takes place. If during frame submission we check for a CPU buffer whether it's dirty, we end up (rightfully) with a race condition as we are preparing for frame n+1 already. There must have been a left over when the above changes were made as the UBO/SSBO code paths would, during rendering, check whether a CPU buffer was dirty, and if so try to upload, causing a race. Removed these code paths which aren't needed. Change-Id: I713a92b881335ecfb30f24bd7485a7bac29be4b7 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Rely on the attribute type for the binding pointKevin Ottens2017-09-221-15/+7
| | | | | | | | | | | | | | | | Stop reading the buffer type from the buffer object and instead use the attribute type to determine the binding point. Change-Id: I95856776297252c6e332f842c2b5362d1467e420 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Explicitly pass binding point on buffer creationKevin Ottens2017-09-221-9/+7
| | | | | | | | | | | | | | | | | | This way we don't rely on the buffer type member in those case, this can be all determined from the current context anyway. It also prevents forcing a single use for a buffer. Change-Id: I8c5ec3878bd36ddbfd257adfb218561d44f18823 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Hardcode a binding point for buffer downloadsKevin Ottens2017-09-221-1/+1
| | | | | | | | | | | | | | | | For downloading the data from a buffer, similarly to uploads, the binding point doesn't really matter so always use the same binding point. Change-Id: I5950e58ff8a0acc719ea784cdf2fb2370077c868 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Hardcode a binding point for buffer uploadsKevin Ottens2017-09-221-3/+2
| | | | | | | | | | | | | | | | | | | | | | For uploading the data in a buffer, the binding point doesn't really matter so always use the same binding point. This is the first step toward finally deprecating QBuffer::type, this is going to be a long journey it seems. Change-Id: Icad36d35764cbc25d249a651b80ebbce6b34828d Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Merge branch '5.9' into 5.10Sean Harmer2017-09-121-1/+1
|\| | | | | | | Change-Id: Id6a3d4ec579a2f2a2e559c22a2293d0e184f0bdf
| * Properly handle byte strideWieland Hagen2017-09-081-1/+1
| | | | | | | | | | | | | | | | If a specific byte stride is given by the user, we should expect that he knows how the buffers look. Change-Id: I0ee9a92bf628d3f3fda935e9cd83e7c1150cd089 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-09-011-1/+8
|\| | | | | | | Change-Id: Ic4220f9957266c374f751d3612c60b81e9cea193
| * Don't create GL textures when format is not setMauro Persano2017-08-311-1/+8
| | | | | | | | | | | | | | | | | | | | | | For textures where the format was not set (this may happen, for instance, for a Texture2D without TextureImage children), don't try to create a GL texture or the underlying OpenGL calls will fail. Also avoid trying to set the corresponding uniform while rendering. Change-Id: I17d95e2a2f1f1a1e5c22a0296c8641c4873e9e7f Task-Id: QTBUG-62654 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | BlitFramebuffer framegraph nodeJuan José Casafranca2017-08-231-0/+62
| | | | | | | | | | | | | | | | This node allows to copy the content from one FBO to another or to screen Task-number: QTBUG-58162 Change-Id: I6016c46d9d538a012c2f641116ed766dd70ad021 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Merge branch '5.9' into devSean Harmer2017-08-191-5/+5
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/render/backend/renderer.cpp src/render/backend/renderview.cpp src/render/graphicshelpers/graphicscontext_p.h src/render/graphicshelpers/graphicshelperes2_p.h src/render/graphicshelpers/graphicshelpergl2_p.h src/render/graphicshelpers/graphicshelpergl3_2_p.h src/render/graphicshelpers/graphicshelpergl3_3_p.h src/render/graphicshelpers/graphicshelpergl4_p.h src/render/graphicshelpers/graphicshelperinterface_p.h src/render/jobs/pickboundingvolumejob.cpp tests/auto/animation/clipanimator/tst_clipanimator.cpp tests/auto/auto.pro tests/manual/manual.pro Also disabled the QQmlMetaType codepaths following commit 49a11e882059ee1729f776722e085dd21d378c36 in qtdeclarative. The QQmlMetaType codepaths will be re-enabled once a qt5.git integration has succeeded. Change-Id: Ia654d75425e6d406c472d19864383612208cad2b
| * RenderCapture: read back from the correct framebufferPaul Lemire2017-07-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | Up until now, RenderCapture would read back from the back buffer. In cases where it's used within a RenderTargetSelector, it should instead read back from the ColorAttachment0 of the framebuffer. Later on we might allow to specify the ColorAttachment. Change-Id: I9ca94333184338b2fdb79c5c2668d5929ac8d405 Task-number: QTBUG-61547 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* | Ensure integer attributes get configured properlySean Harmer2017-08-101-8/+16
| | | | | | | | | | | | | | | | For joint indices. Change-Id: If3de9c6e7053a5f445604e776f73e2ff843b0be8 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Extend standard uniforms to cover skinningPaletteSean Harmer2017-08-101-30/+30
| | | | | | | | | | | | | | | | | | | | This requires obtaining the skinning palette uniform from the entity. Up until now the standard uniforms only needed the entity's world transform. Now we need more, refactor the affected functions to pass in a pointer to the entity we are creating render commands for. Change-Id: Iba3c34159e798857682b9962266da1367ce9095c Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Fix: set renderer dirty flag on initializationPaul Lemire2017-07-281-0/+1
| | | | | | | | | | Change-Id: I9c164409e3ced5d78182542ae060692e0f65d3ac Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/devSean Harmer2017-07-111-1/+5
|\ \
| * | Merge remote-tracking branch 'origin/5.9' into devAndy Nichols2017-07-111-1/+5
| |\| | | | | | | | | | Change-Id: I4ceccd338a937a2ada231f568ed02c7a87bd6e80
| | * Add warnings to readFramebufferMäättä Antti2017-06-201-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | This allows detecting problems with the render capture if the capture fails. Change-Id: I20f630eb9a1adb677513ff225d21c7e338c57809 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | | Add a GLES 3.2 graphics helperLaszlo Agocs2017-07-071-2/+8
|/ / | | | | | | | | | | | | | | ...providing glFramebufferTexture. Other than that, it is identical to the ES 3.0 backend for now. Change-Id: Iaae0b5e613ca39f495ef16154999321dc97755aa Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Add uniform buffer support for GLES 3.0+Laszlo Agocs2017-07-061-2/+2
| | | | | | | | | | | | | | | | | | Also, GLES 3 only has glMapBufferRange so pass in a size to mapBuffer() from now on. Task-number: QTBUG-61729 Change-Id: I0a049811a6daff5dd6a83d535509f4266eb01c53 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Add renderbuffer support for FBO attachments with OpenGL ESLaszlo Agocs2017-07-051-8/+24
| | | | | | | | | | | | | | | | | | | | Only relevant for QRenderTargetOutput::DepthStencil, which is the common case for offscreen render targets when the depth/stencil content is not interesting afterwards. Task-number: QTBUG-61721 Change-Id: I9ceff09f24f1c93bb37452d1e3a2f96385bfe6c4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Enable QtGui's shader program binary disk cacheLaszlo Agocs2017-06-301-1/+1
| | | | | | | | | | | | Change-Id: I76f1ea563b8a662b3dd19c621ab53ec517d25b3f Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Add optional QRect parameter to QRenderCapture::requestCaptureMauro Persano2017-06-211-16/+16
|/ | | | | | | | | Add optional QRect parameter ot QRenderCapture::requestCapture in order to capture only part of the buffer. Task-number: QTBUG-61068 Change-Id: I24605725764a07bd5f6a84637aaaab035ec9e3c7 Reviewed-by: Antti Määttä <antti.maatta@qt.io>
* Fix small memory leak in GraphicsContextMauro Persano2017-06-091-0/+2
| | | | | | | | Release GraphicsHelperInterface instances on destruction. Task-number: QTBUG-61293 Change-Id: I989aefb9102dd8772288d8a46cd47dbe3d16e8c0 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Fix Buffer uploadingPaul Lemire2017-05-081-2/+4
| | | | | | | | | | | | We used to load buffer data when creating it. This led to cases where we would not take into account immediately buffer updates after creation. This would then results in artifacts that would pop up on screen as actual buffer data and count would be different Change-Id: I5a2fad4fb5d7c1e1542cd0bf87ded16a111bc613 Task-number: QTBUG-60429 Reviewed-by: Oleg Evseev <ev.mipt@gmail.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Optimize partial data update support for QBufferOleg Evseev2017-05-041-11/+25
| | | | | | | | | | Now both QBuffer setData/functor and partial data update can be called without unexpected behavior. Optimize applying sequential updates. Change-Id: I5d3a8bcb7eb6eeb3ae33f0fbedbb34acedd1c000 Reviewed-by: Oleg Evseev <ev.mipt@gmail.com> Reviewed-by: Dmitry Volosnykh <dmitry.volosnykh@gmail.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* fixed graphicscontext applyUniform for uint uniform types.Daniel Bulla2017-05-041-4/+4
| | | | | Change-Id: I20e4146ba004a9b7f0cd823aa5ceaf2ed4a7103a Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Fix resolving of render target format in GraphicsContextAndy Maloney2017-03-141-1/+2
| | | | | | | | | | | The GraphicsContext render target format was not being resolved properly when the alphaBufferSize was -1. Also initialize the member var storing the render buffer format. Change-Id: I939ccf29f6cf9ef66befe5deee7ce94e2dc19a26 Task-number: QTBUG-59456 Reviewed-by: Antti Määttä <antti.maatta@qt.io>
* QMemoryBarrier cleanupPaul Lemire2017-02-161-1/+1
| | | | | | | | | | | -rename barriertypes to waitOperation -in QML introduce a waitFor property -remove the Barrier suffix for the enum values -rename BarrierType to Operation Task-number: QTBUG-58878 Change-Id: Idc65f44b09e632509cd74286de26fea02e6b6dee Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Merge branch '5.8' into 5.9Sean Harmer2017-02-101-9/+8
|\ | | | | | | | | | | | | | | Conflicts: src/render/io/qsceneloader.cpp src/render/picking/objectpicker.cpp Change-Id: Ic36138954381820196eb81c5c59e6a91e7f40f33
| * Enable blitFramebuffer with ES2 when it is supportedAntti Määttä2017-02-081-9/+8
| | | | | | | | | | | | Task-number: QTBUG-57573 Change-Id: Ie1be0282fbab6e4346a81f37eff7597b932da07e Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Transfers gpu buffer data to cpuJuan José Casafranca2017-01-311-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added some code to retrieve the data in the gpu back to a cpu pointer in the opengl helpers. Added a framegraph node which specifies if any data must be downloaded from the gpu Added a flag in the buffer object to specify if the data from that buffer must be downloaded. Added a job to send the data back to the frontend. Added a path in the renderer to download the gpu data. Task number: QTBUG-57727 Change-Id: I315a9221e5116c7d07f818e00c654fe1901144f4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | ShaderProgram: store and send log and status to frontendPaul Lemire2017-01-251-6/+11
| | | | | | | | | | | | Change-Id: I00b02f8b73ecf1194b4c4db7b60a95ee7cc3df22 Task-number: QTBUG-57615 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>