diff options
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 54 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 1 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgmaterialshader.cpp | 17 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgmaterialshader.h | 6 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgnode.h | 1 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgadaptationlayer_p.h | 1 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultrendercontext.cpp | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultrendercontext_p.h | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 4 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport.cpp | 89 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport_p.h | 6 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgrhiatlastexture.cpp | 9 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexturematerial.cpp | 2 |
13 files changed, 71 insertions, 124 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 95e6d35c1e..bda0085818 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -930,11 +930,10 @@ static void qsg_wipeBuffer(Buffer *buffer) free(buffer->data); } -static void qsg_wipeBatch(Batch *batch, bool separateIndexBuffer) +static void qsg_wipeBatch(Batch *batch) { qsg_wipeBuffer(&batch->vbo); - if (separateIndexBuffer) - qsg_wipeBuffer(&batch->ibo); + qsg_wipeBuffer(&batch->ibo); delete batch->ubuf; batch->stencilClipState.reset(); delete batch; @@ -944,13 +943,12 @@ Renderer::~Renderer() { if (m_rhi) { // Clean up batches and buffers - const bool separateIndexBuffer = m_context->separateIndexBuffer(); for (int i = 0; i < m_opaqueBatches.size(); ++i) - qsg_wipeBatch(m_opaqueBatches.at(i), separateIndexBuffer); + qsg_wipeBatch(m_opaqueBatches.at(i)); for (int i = 0; i < m_alphaBatches.size(); ++i) - qsg_wipeBatch(m_alphaBatches.at(i), separateIndexBuffer); + qsg_wipeBatch(m_alphaBatches.at(i)); for (int i = 0; i < m_batchPool.size(); ++i) - qsg_wipeBatch(m_batchPool.at(i), separateIndexBuffer); + qsg_wipeBatch(m_batchPool.at(i)); } for (Node *n : qAsConst(m_nodes)) @@ -1008,8 +1006,7 @@ void Renderer::map(Buffer *buffer, int byteSize, bool isIndexBuf) if (m_visualizer->mode() == Visualizer::VisualizeNothing) { // Common case, use a shared memory pool for uploading vertex data to avoid // excessive reevaluation - QDataBuffer<char> &pool = m_context->separateIndexBuffer() && isIndexBuf - ? m_indexUploadPool : m_vertexUploadPool; + QDataBuffer<char> &pool = isIndexBuf ? m_indexUploadPool : m_vertexUploadPool; if (byteSize > pool.size()) pool.resize(byteSize); buffer->data = pool.data(); @@ -2075,11 +2072,7 @@ void Renderer::uploadBatch(Batch *b) ibufferSize = unmergedIndexSize; } - const bool separateIndexBuffer = m_context->separateIndexBuffer(); - if (separateIndexBuffer) - map(&b->ibo, ibufferSize, true); - else - bufferSize += ibufferSize; + map(&b->ibo, ibufferSize, true); map(&b->vbo, bufferSize); if (Q_UNLIKELY(debug_upload())) qDebug() << " - batch" << b << " first:" << b->first << " root:" @@ -2089,9 +2082,7 @@ void Renderer::uploadBatch(Batch *b) if (b->merged) { char *vertexData = b->vbo.data; char *zData = vertexData + b->vertexCount * g->sizeOfVertex(); - char *indexData = separateIndexBuffer - ? b->ibo.data - : zData + (int(useDepthBuffer()) * b->vertexCount * sizeof(float)); + char *indexData = b->ibo.data; quint16 iOffset16 = 0; quint32 iOffset32 = 0; @@ -2103,8 +2094,8 @@ void Renderer::uploadBatch(Batch *b) const uint verticesInSetLimit = m_uint32IndexForRhi ? 0xfffffffe : 0xfffe; int indicesInSet = 0; b->drawSets.reset(); - int drawSetIndices = separateIndexBuffer ? 0 : indexData - vertexData; - const char *indexBase = separateIndexBuffer ? b->ibo.data : b->vbo.data; + int drawSetIndices = 0; + const char *indexBase = b->ibo.data; b->drawSets << DrawSet(0, zData - vertexData, drawSetIndices); while (e) { verticesInSet += e->node->geometry()->vertexCount(); @@ -2138,8 +2129,7 @@ void Renderer::uploadBatch(Batch *b) } } else { char *vboData = b->vbo.data; - char *iboData = separateIndexBuffer ? b->ibo.data - : vboData + b->vertexCount * g->sizeOfVertex(); + char *iboData = b->ibo.data; Element *e = b->first; while (e) { QSGGeometry *g = e->node->geometry(); @@ -2201,9 +2191,7 @@ void Renderer::uploadBatch(Batch *b) if (!b->drawSets.isEmpty()) { if (m_uint32IndexForRhi) { - const quint32 *id = (const quint32 *)(separateIndexBuffer - ? b->ibo.data - : b->vbo.data + b->drawSets.at(0).indices); + const quint32 *id = (const quint32 *) b->ibo.data; { QDebug iDump = qDebug(); iDump << " -- Index Data, count:" << b->indexCount; @@ -2214,9 +2202,7 @@ void Renderer::uploadBatch(Batch *b) } } } else { - const quint16 *id = (const quint16 *)(separateIndexBuffer - ? b->ibo.data - : b->vbo.data + b->drawSets.at(0).indices); + const quint16 *id = (const quint16 *) b->ibo.data; { QDebug iDump = qDebug(); iDump << " -- Index Data, count:" << b->indexCount; @@ -2237,8 +2223,7 @@ void Renderer::uploadBatch(Batch *b) #endif // QT_NO_DEBUG_OUTPUT unmap(&b->vbo); - if (separateIndexBuffer) - unmap(&b->ibo, true); + unmap(&b->ibo, true); if (Q_UNLIKELY(debug_upload())) qDebug() << " --- vertex/index buffers unmapped, batch upload completed..."; @@ -2669,6 +2654,7 @@ bool Renderer::ensurePipelineState(Element *e, const ShaderManager::Shader *sms, ps->setFlags(flags); ps->setTopology(qsg_topology(m_gstate.drawMode)); ps->setCullMode(m_gstate.cullMode); + ps->setPolygonMode(m_gstate.polygonMode); QRhiGraphicsPipeline::TargetBlend blend; blend.colorWrite = m_gstate.colorWrite; @@ -2808,13 +2794,14 @@ static void rendererToMaterialGraphicsState(QSGMaterialShader::GraphicsPipelineS Q_ASSERT(int(QSGMaterialShader::GraphicsPipelineState::OneMinusSrc1Alpha) == int(QRhiGraphicsPipeline::OneMinusSrc1Alpha)); Q_ASSERT(int(QSGMaterialShader::GraphicsPipelineState::A) == int(QRhiGraphicsPipeline::A)); Q_ASSERT(int(QSGMaterialShader::GraphicsPipelineState::CullBack) == int(QRhiGraphicsPipeline::Back)); - + Q_ASSERT(int(QSGMaterialShader::GraphicsPipelineState::Line) == int(QRhiGraphicsPipeline::Line)); dst->srcColor = QSGMaterialShader::GraphicsPipelineState::BlendFactor(src->srcColor); dst->dstColor = QSGMaterialShader::GraphicsPipelineState::BlendFactor(src->dstColor); dst->colorWrite = QSGMaterialShader::GraphicsPipelineState::ColorMask(int(src->colorWrite)); dst->cullMode = QSGMaterialShader::GraphicsPipelineState::CullMode(src->cullMode); + dst->polygonMode = QSGMaterialShader::GraphicsPipelineState::PolygonMode(src->polygonMode); } static void materialToRendererGraphicsState(GraphicsState *dst, @@ -2825,6 +2812,7 @@ static void materialToRendererGraphicsState(GraphicsState *dst, dst->dstColor = QRhiGraphicsPipeline::BlendFactor(src->dstColor); dst->colorWrite = QRhiGraphicsPipeline::ColorMask(int(src->colorWrite)); dst->cullMode = QRhiGraphicsPipeline::CullMode(src->cullMode); + dst->polygonMode = QRhiGraphicsPipeline::PolygonMode(src->polygonMode); } void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms, @@ -3695,7 +3683,7 @@ void Renderer::prepareRenderPass(RenderPassContext *ctx) if (largestVBO * 2 < m_vertexUploadPool.size()) m_vertexUploadPool.resize(largestVBO * 2); - if (m_context->separateIndexBuffer() && largestIBO * 2 < m_indexUploadPool.size()) + if (largestIBO * 2 < m_indexUploadPool.size()) m_indexUploadPool.resize(largestIBO * 2); if (Q_UNLIKELY(debug_render())) { @@ -3727,6 +3715,7 @@ void Renderer::prepareRenderPass(RenderPassContext *ctx) m_gstate.blending = false; m_gstate.cullMode = QRhiGraphicsPipeline::None; + m_gstate.polygonMode = QRhiGraphicsPipeline::Fill; m_gstate.colorWrite = QRhiGraphicsPipeline::R | QRhiGraphicsPipeline::G | QRhiGraphicsPipeline::B @@ -4042,7 +4031,8 @@ bool operator==(const GraphicsState &a, const GraphicsState &b) noexcept && a.stencilTest == b.stencilTest && a.sampleCount == b.sampleCount && a.drawMode == b.drawMode - && a.lineWidth == b.lineWidth; + && a.lineWidth == b.lineWidth + && a.polygonMode == b.polygonMode; } bool operator!=(const GraphicsState &a, const GraphicsState &b) noexcept diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index 241f5748b6..5cfc6c54c6 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -640,6 +640,7 @@ struct GraphicsState int sampleCount = 1; QSGGeometry::DrawingMode drawMode = QSGGeometry::DrawTriangles; float lineWidth = 1.0f; + QRhiGraphicsPipeline::PolygonMode polygonMode = QRhiGraphicsPipeline::Fill; }; bool operator==(const GraphicsState &a, const GraphicsState &b) noexcept; diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp index bd17fd365a..3eb544f94d 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp @@ -684,6 +684,23 @@ bool QSGMaterialShader::updateGraphicsPipelineState(RenderState &state, Graphics */ /*! + \enum QSGMaterialShader::GraphicsPipelineState::PolygonMode + \since 6.4 + \brief Specifies the polygon rasterization mode + + Polygon Mode (Triangle Fill Mode in Metal, Fill Mode in D3D) specifies + the fill mode used when rasterizing polygons. Polygons may be drawn as + solids (Fill), or as a wire mesh (Line). + + \warning OpenGL ES does not support the \c{Line} polygon mode. OpenGL ES + will rasterize all polygons as filled no matter what polygon mode is set. + Using \c{Line} will make your application non-portable. + + \value Fill The interior of the polygon is filled (default) + \value Line Boundary edges of the polygon are drawn as line segments. + */ + +/*! Returns the accumulated opacity to be used for rendering. */ float QSGMaterialShader::RenderState::opacity() const diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.h b/src/quick/scenegraph/coreapi/qsgmaterialshader.h index 566f954b06..a3c8afb875 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialshader.h +++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.h @@ -130,12 +130,18 @@ public: CullBack }; + enum PolygonMode { + Fill, + Line, + }; + bool blendEnable; BlendFactor srcColor; BlendFactor dstColor; ColorMask colorWrite; QColor blendConstant; CullMode cullMode; + PolygonMode polygonMode; // This struct is extensible while keeping BC since apps only ever get // a ptr to the struct, it is not created by them. }; diff --git a/src/quick/scenegraph/coreapi/qsgnode.h b/src/quick/scenegraph/coreapi/qsgnode.h index 19b8cf9354..49dc056c89 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.h +++ b/src/quick/scenegraph/coreapi/qsgnode.h @@ -40,6 +40,7 @@ #ifndef QSGNODE_H #define QSGNODE_H +#include <QtCore/qlist.h> #include <QtQuick/qsggeometry.h> #include <QtGui/QMatrix4x4> diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index aa9f78f2c5..7d71c5248c 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -53,6 +53,7 @@ #include <QtQuick/qsgnode.h> #include <QtQuick/qsgtexture.h> +#include <QtQuick/qquickpainteditem.h> #include <QtCore/qobject.h> #include <QtCore/qrect.h> #include <QtGui/qbrush.h> diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp index 8579cb5e2a..a4337a58ca 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp +++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp @@ -62,7 +62,6 @@ QSGDefaultRenderContext::QSGDefaultRenderContext(QSGContext *context) , m_rhiAtlasManager(nullptr) , m_currentFrameCommandBuffer(nullptr) , m_currentFrameRenderPass(nullptr) - , m_separateIndexBuffer(false) , m_useDepthBufferFor2D(true) , m_glyphCacheResourceUpdates(nullptr) { @@ -87,8 +86,6 @@ void QSGDefaultRenderContext::initialize(const QSGRenderContext::InitParams *par m_maxTextureSize = m_rhi->resourceLimit(QRhi::TextureSizeMax); if (!m_rhiAtlasManager) m_rhiAtlasManager = new QSGRhiAtlasTexture::Manager(this, m_initParams.initialSurfacePixelSize, m_initParams.maybeSurface); - // unlike OpenGL (and like WebGL), QRhi does not guarantee buffer usage types can be mixed - m_separateIndexBuffer = true; m_glyphCacheResourceUpdates = nullptr; diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h index e96bf045b5..a97347eaf0 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h +++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h @@ -120,7 +120,6 @@ public: virtual void initializeRhiShader(QSGMaterialShader *shader, QShader::Variant shaderVariant); int maxTextureSize() const override { return m_maxTextureSize; } - bool separateIndexBuffer() const { return m_separateIndexBuffer; } bool useDepthBufferFor2D() const { return m_useDepthBufferFor2D; } int msaaSampleCount() const { return m_initParams.sampleCount; } @@ -159,7 +158,6 @@ protected: QRhiCommandBuffer *m_currentFrameCommandBuffer; QRhiRenderPassDescriptor *m_currentFrameRenderPass; qreal m_currentDevicePixelRatio; - bool m_separateIndexBuffer; bool m_useDepthBufferFor2D; QRhiResourceUpdateBatch *m_glyphCacheResourceUpdates; }; diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 98823794c4..b96f75ddbd 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -105,10 +105,6 @@ void QSGRenderLoop::cleanup() } delete s_instance; s_instance = nullptr; - -#ifdef ENABLE_DEFAULT_BACKEND - QSGRhiSupport::cleanupDefaultVulkanInstance(); -#endif } QSurface::SurfaceType QSGRenderLoop::windowSurfaceType() const diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 7a2aeab7a6..da83e82b4b 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -39,14 +39,15 @@ #include "qsgrhisupport_p.h" #include "qsgcontext_p.h" -# include "qsgdefaultrendercontext_p.h" +#include "qsgdefaultrendercontext_p.h" #include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquickwindow_p.h> #include <QtGui/qwindow.h> + #if QT_CONFIG(vulkan) -#include <QtGui/qvulkaninstance.h> +#include <QtGui/private/qvulkandefaultinstance_p.h> #endif #include <QOperatingSystemVersion> @@ -54,69 +55,6 @@ QT_BEGIN_NAMESPACE -#if QT_CONFIG(vulkan) -QVulkanInstance *s_vulkanInstance = nullptr; -#endif - -QVulkanInstance *QSGRhiSupport::defaultVulkanInstance() -{ -#if QT_CONFIG(vulkan) - QSGRhiSupport *inst = QSGRhiSupport::instance(); - if (!inst->isRhiEnabled() || inst->rhiBackend() != QRhi::Vulkan) - return nullptr; - - if (!s_vulkanInstance) { - s_vulkanInstance = new QVulkanInstance; - - // With a Vulkan implementation >= 1.1 we can check what - // vkEnumerateInstanceVersion() says and request 1.2 or 1.1 based on the - // result. To prevent future surprises, be conservative and ignore any > 1.2 - // versions for now. For 1.0 implementations nothing will be requested, the - // default 0 in VkApplicationInfo means 1.0. - // - // Vulkan 1.0 is actually sufficient for 99% of Qt Quick (3D)'s - // functionality. In addition, Vulkan implementations tend to enable 1.1 and 1.2 - // functionality regardless of the VkInstance API request. However, the - // validation layer seems to take this fairly seriously, so we should be - // prepared for using 1.1 and 1.2 features in a fully correct manner. This also - // helps custom Vulkan code in applications, which is not under out control; it - // is ideal if Vulkan 1.1 and 1.2 are usable without requiring such applications - // to create their own QVulkanInstance just to be able to make an appropriate - // setApiVersion() call on it. - - const QVersionNumber supportedVersion = s_vulkanInstance->supportedApiVersion(); - if (supportedVersion >= QVersionNumber(1, 2)) - s_vulkanInstance->setApiVersion(QVersionNumber(1, 2)); - else if (supportedVersion >= QVersionNumber(1, 1)) - s_vulkanInstance->setApiVersion(QVersionNumber(1, 2)); - qCDebug(QSG_LOG_INFO) << "Requesting Vulkan API" << s_vulkanInstance->apiVersion() - << "Instance-level version was reported as" << supportedVersion; - - if (inst->isDebugLayerRequested()) - s_vulkanInstance->setLayers({ "VK_LAYER_KHRONOS_validation" }); - - s_vulkanInstance->setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions()); - - if (!s_vulkanInstance->create()) { - qWarning("Failed to create Vulkan instance"); - delete s_vulkanInstance; - s_vulkanInstance = nullptr; - } - } - return s_vulkanInstance; -#else - return nullptr; -#endif -} - -void QSGRhiSupport::cleanupDefaultVulkanInstance() -{ -#if QT_CONFIG(vulkan) - delete s_vulkanInstance; - s_vulkanInstance = nullptr; -#endif -} - QSGRhiSupport::QSGRhiSupport() : m_settingsApplied(false), m_enableRhi(false), @@ -256,21 +194,14 @@ void QSGRhiSupport::applySettings() void QSGRhiSupport::adjustToPlatformQuirks() { #if defined(Q_OS_MACOS) || defined(Q_OS_IOS) - - // ### For now just create a throwaway QRhi instance. This will be replaced - // by a more lightweight way, once a helper function is added gui/rhi. - // A macOS VM may not have Metal support at all. We have to decide at this // point, it will be too late afterwards, and the only way is to see if // MTLCreateSystemDefaultDevice succeeds. if (m_rhiBackend == QRhi::Metal) { QRhiMetalInitParams rhiParams; - QRhi *tempRhi = QRhi::create(m_rhiBackend, &rhiParams, {}); - if (!tempRhi) { + if (!QRhi::probe(m_rhiBackend, &rhiParams)) { m_rhiBackend = QRhi::OpenGLES2; qCDebug(QSG_LOG_INFO, "Metal does not seem to be supported. Falling back to OpenGL."); - } else { - delete tempRhi; } } #endif @@ -574,8 +505,14 @@ void QSGRhiSupport::prepareWindowForRhi(QQuickWindow *window) // always be under the application's control then (since the default // instance we could create here would not be configurable by the // application in any way, and that is often not acceptable). - if (!window->vulkanInstance() && !wd->renderControl) - window->setVulkanInstance(QSGRhiSupport::defaultVulkanInstance()); + if (!window->vulkanInstance() && !wd->renderControl) { + QVulkanInstance *vkinst = QVulkanDefaultInstance::instance(); + if (vkinst) + qCDebug(QSG_LOG_INFO) << "Got Vulkan instance from QVulkanDefaultInstance, requested api version was" << vkinst->apiVersion(); + else + qCDebug(QSG_LOG_INFO) << "No Vulkan instance from QVulkanDefaultInstance, expect problems"; + window->setVulkanInstance(vkinst); + } } #else Q_UNUSED(window); @@ -648,6 +585,8 @@ QSGRhiSupport::RhiCreateResult QSGRhiSupport::createRhi(QQuickWindow *window, QO #endif #if QT_CONFIG(vulkan) if (backend == QRhi::Vulkan) { + if (isDebugLayerRequested()) + QVulkanDefaultInstance::setFlag(QVulkanDefaultInstance::EnableValidation, true); QRhiVulkanInitParams rhiParams; prepareWindowForRhi(window); // sets a vulkanInstance if not yet present rhiParams.inst = window->vulkanInstance(); diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h index 90cc8328f9..101941875e 100644 --- a/src/quick/scenegraph/qsgrhisupport_p.h +++ b/src/quick/scenegraph/qsgrhisupport_p.h @@ -77,7 +77,6 @@ QT_BEGIN_NAMESPACE class QSGDefaultRenderContext; -class QVulkanInstance; class QOffscreenSurface; // Opting in/out of QRhi and choosing the default/requested backend is managed @@ -85,9 +84,6 @@ class QOffscreenSurface; // creating a render loop. A well-written render loop sets up its QRhi and // related machinery using the helper functions in here. // -// cleanup() must be called to perform global (not per thread) cleanup, such -// as, destroying the QVulkanInstance (if one was created in vulkanInstance()). -// // In addition, the class provides handy conversion and query stuff for the // renderloop and the QSGRendererInterface implementations. // @@ -96,8 +92,6 @@ class Q_QUICK_PRIVATE_EXPORT QSGRhiSupport public: static QSGRhiSupport *instance_internal(); static QSGRhiSupport *instance(); - static QVulkanInstance *defaultVulkanInstance(); - static void cleanupDefaultVulkanInstance(); static int chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi); static QImage grabAndBlockInCurrentFrame(QRhi *rhi, QRhiCommandBuffer *cb, QRhiTexture *src = nullptr); static void checkEnvQSgInfo(); diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp index 2a7be48d3d..5541c4f2da 100644 --- a/src/quick/scenegraph/util/qsgrhiatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgrhiatlastexture.cpp @@ -67,8 +67,13 @@ Manager::Manager(QSGDefaultRenderContext *rc, const QSize &surfacePixelSize, QSu , m_rhi(rc->rhi()) { const int maxSize = m_rhi->resourceLimit(QRhi::TextureSizeMax); - int w = qMin(maxSize, qt_sg_envInt("QSG_ATLAS_WIDTH", qMax(512U, qNextPowerOfTwo(surfacePixelSize.width() - 1)))); - int h = qMin(maxSize, qt_sg_envInt("QSG_ATLAS_HEIGHT", qMax(512U, qNextPowerOfTwo(surfacePixelSize.height() - 1)))); + // surfacePixelSize is just a hint that was passed in when initializing the + // rendercontext, likely based on the window size, if it was available, + // that is. Therefore, it may be anything, incl. zero and negative. + const int widthHint = qMax(1, surfacePixelSize.width()); + const int heightHint = qMax(1, surfacePixelSize.height()); + int w = qMin(maxSize, qt_sg_envInt("QSG_ATLAS_WIDTH", qMax(512U, qNextPowerOfTwo(widthHint - 1)))); + int h = qMin(maxSize, qt_sg_envInt("QSG_ATLAS_HEIGHT", qMax(512U, qNextPowerOfTwo(heightHint - 1)))); if (maybeSurface && maybeSurface->surfaceClass() == QSurface::Window) { QWindow *window = static_cast<QWindow *>(maybeSurface); diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp index 82cdd03acc..92f66af011 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.cpp +++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp @@ -309,6 +309,8 @@ int QSGOpaqueTextureMaterial::compare(const QSGMaterial *o) const { Q_ASSERT(o && type() == o->type()); const QSGOpaqueTextureMaterial *other = static_cast<const QSGOpaqueTextureMaterial *>(o); + Q_ASSERT(m_texture); + Q_ASSERT(other->texture()); const qint64 diff = m_texture->comparisonKey() - other->texture()->comparisonKey(); if (diff != 0) return diff < 0 ? -1 : 1; |