summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvenn-Arne Dragly <s@dragly.com>2018-10-30 12:10:02 +0100
committerAndy Nichols <andy.nichols@qt.io>2018-11-09 09:02:10 +0000
commit10ae9bc43bf7a44ad92b595bb1132ec9767d49b3 (patch)
tree5ac4af4840579b8fe1d712d8a566f2c820db53c8
parentda08fc1354dc0f13e6bb709bc6d8495869a448c3 (diff)
Do not share textures in Dragon if they are used for render targets
Change-Id: I57a3b53ee5b520337efc2bf80d6f729614939fa8 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r--src/runtime/dragon/dragonrenderer.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/runtime/dragon/dragonrenderer.cpp b/src/runtime/dragon/dragonrenderer.cpp
index afe93db..826f04f 100644
--- a/src/runtime/dragon/dragonrenderer.cpp
+++ b/src/runtime/dragon/dragonrenderer.cpp
@@ -357,12 +357,18 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
Immutable<RenderView> renderView;
};
+ QVector<QNodeId> texturesUsedInRenderTargets;
QHash<QSurface *, QVector<SurfaceInfo>> surfaceViews; // ordered
for (const auto &leafNodeId : leafNodes) {
// TODO IMPORTANT make sure the views are ordered correctly regardless of surface differences
const auto &renderView = renderViews[leafNodeId];
SurfaceInfo info { leafNodeId, renderView };
surfaceViews[renderView->surface].push_back(info);
+
+ // We need a list of texture IDs that are used in render targets and hence cannot be shared
+ for (const auto &renderTarget : renderView->attachmentPack.outputs) {
+ texturesUsedInRenderTargets.push_back(renderTarget->textureUuid);
+ }
}
bool preparationsComplete = false;
@@ -403,7 +409,13 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
return Mutable<GLTexture>(createGlTexture(loadedTexture, activeSurface.openGLContext()));
};
- auto compareGLTexture = [](const GLTexture &glTexture, const Immutable<LoadedTexture> &loaded){
+ auto compareGLTexture = [texturesUsedInRenderTargets](const GLTexture &glTexture, const Immutable<LoadedTexture> &loaded){
+ // If a texture is used in a render target, it cannot share GLTexture with other textures
+ // TODO Consider separating the concept of any texture and one that is being rendered to, at least on the backend
+ if (texturesUsedInRenderTargets.contains(glTexture.loadedTexture->texture->peerId())
+ || texturesUsedInRenderTargets.contains(loaded->texture->peerId()))
+ return false;
+
return glTexture.loadedTexture == loaded;
};