From c9cffe61291d265e05f05087275daa6625b1aea2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 25 May 2016 10:33:01 +0200 Subject: [PATCH] D3D12: Experiment with dropping QImage data once the upload is queued But do not enable it yet. We would lose the ability to enable mipmapping later on which is annoying since property values can get set after the first bind() for some reason. Needs some more investigation later on. Change-Id: If4ffbc762f05dc2a3bbd811bccd6cffba0b66fc6 Reviewed-by: Andy Nichols --- src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp index ce0c0e53dd..0bb4138b01 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp @@ -43,6 +43,8 @@ QT_BEGIN_NAMESPACE +#define RETAIN_IMAGE + void QSGD3D12Texture::create(const QImage &image, uint flags) { // ### atlas? @@ -97,10 +99,16 @@ void QSGD3D12Texture::bind() // Called when the texture material updates the pipeline state. if (!m_createPending && hasMipmaps() != m_createdWithMipMaps) { +#ifdef RETAIN_IMAGE m_engine->releaseTexture(m_id); m_id = m_engine->genTexture(); Q_ASSERT(m_id); m_createPending = true; +#else + // ### this can be made working some day (something similar to + // queueTextureResize) but skip for now + qWarning("D3D12: mipmap property cannot be changed once the texture is created"); +#endif } if (m_createPending) { @@ -116,6 +124,10 @@ void QSGD3D12Texture::bind() m_engine->createTexture(m_id, m_image.size(), m_image.format(), createFlags); m_engine->queueTextureUpload(m_id, m_image); + +#ifndef RETAIN_IMAGE + m_image = QImage(); +#endif } // Here we know that the texture is going to be used in the current frame