diff options
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp')
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp | 71 |
1 files changed, 17 insertions, 54 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp index 3c83f3aa4b..d1f4e46ed0 100644 --- a/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrhivisualizer.cpp @@ -1,43 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> -** Copyright (C) 2016 Robin Burchell <robin.burchell@viroteck.net> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// Copyright (C) 2016 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +// Copyright (C) 2016 Robin Burchell <robin.burchell@viroteck.net> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qsgrhivisualizer_p.h" #include <qmath.h> @@ -98,7 +62,7 @@ void RhiVisualizer::prepareVisualize() QLatin1String(":/qt-project.org/scenegraph/shaders_ng/visualization.frag.qsb")); } - m_fade.prepare(this, m_renderer->m_rhi, m_renderer->m_resourceUpdates, m_renderer->renderPassDescriptor()); + m_fade.prepare(this, m_renderer->m_rhi, m_renderer->m_resourceUpdates, m_renderer->renderTarget().rpDesc); const bool forceUintIndex = m_renderer->m_uint32IndexForRhi; @@ -135,7 +99,7 @@ void RhiVisualizer::visualize() if (m_visualizeMode == VisualizeNothing) return; - QRhiCommandBuffer *cb = m_renderer->commandBuffer(); + QRhiCommandBuffer *cb = m_renderer->renderTarget().cb; m_fade.render(cb); switch (m_visualizeMode) { @@ -163,7 +127,7 @@ void RhiVisualizer::recordDrawCalls(const QVector<DrawCall> &drawCalls, bool blendOneOne) { for (const DrawCall &dc : drawCalls) { - QRhiGraphicsPipeline *ps = m_pipelines.pipeline(this, m_renderer->m_rhi, srb, m_renderer->renderPassDescriptor(), + QRhiGraphicsPipeline *ps = m_pipelines.pipeline(this, m_renderer->m_rhi, srb, m_renderer->renderTarget().rpDesc, dc.vertex.topology, dc.vertex.format, dc.vertex.stride, blendOneOne); if (!ps) @@ -288,7 +252,7 @@ static inline uint aligned(uint v, uint byteAlign) return (v + byteAlign - 1) & ~(byteAlign - 1); } -static bool ensureBuffer(QRhi *rhi, QRhiBuffer **buf, QRhiBuffer::UsageFlags usage, int newSize) +static bool ensureBuffer(QRhi *rhi, QRhiBuffer **buf, QRhiBuffer::UsageFlags usage, quint32 newSize) { if (!*buf) { *buf = rhi->newBuffer(QRhiBuffer::Dynamic, usage, newSize); @@ -311,7 +275,7 @@ QRhiGraphicsPipeline *RhiVisualizer::PipelineCache::pipeline(RhiVisualizer *visu quint32 vertexStride, bool blendOneOne) { - for (int i = 0, ie = pipelines.count(); i != ie; ++i) { + for (int i = 0, ie = pipelines.size(); i != ie; ++i) { const Pipeline &p(pipelines.at(i)); if (p.topology == topology && p.format == vertexFormat && p.stride == vertexStride) return p.ps; @@ -352,7 +316,7 @@ QRhiGraphicsPipeline *RhiVisualizer::PipelineCache::pipeline(RhiVisualizer *visu void RhiVisualizer::PipelineCache::releaseResources() { - for (int i = 0, ie = pipelines.count(); i != ie; ++i) + for (int i = 0, ie = pipelines.size(); i != ie; ++i) delete pipelines.at(i).ps; pipelines.clear(); @@ -363,10 +327,10 @@ void RhiVisualizer::ChangeVis::gather(Node *n) if (n->type() == QSGNode::GeometryNodeType && n->element()->batch && visualizer->m_visualizeChangeSet.contains(n)) { const uint dirty = visualizer->m_visualizeChangeSet.value(n); const bool tinted = (dirty & QSGNODE_DIRTY_PARENT) != 0; - const QColor color = QColor::fromHsvF((rand() & 1023) / 1023.0f, 0.3f, 1.0f); + const QColor color = QColor::fromHsvF((visualizer->m_randomGenerator.generate() & 1023) / 1023.0f, 0.3f, 1.0f).toRgb(); const float alpha = 0.5f; - QMatrix4x4 matrix = visualizer->m_renderer->m_current_projection_matrix; + QMatrix4x4 matrix = visualizer->m_renderer->m_current_projection_matrix[0]; if (n->element()->batch->root) matrix = matrix * qsg_matrixForRoot(n->element()->batch->root); @@ -481,7 +445,7 @@ void RhiVisualizer::BatchVis::gather(Batch *b) if (b->positionAttribute != 0) return; - QMatrix4x4 matrix(visualizer->m_renderer->m_current_projection_matrix); + QMatrix4x4 matrix(visualizer->m_renderer->m_current_projection_matrix[0]); if (b->root) matrix = matrix * qsg_matrixForRoot(b->root); @@ -490,7 +454,7 @@ void RhiVisualizer::BatchVis::gather(Batch *b) QMatrix4x4 rotation; memcpy(dc.uniforms.data + 64, rotation.constData(), 64); - QColor color = QColor::fromHsvF((rand() & 1023) / 1023.0, 1.0, 1.0); + const QColor color = QColor::fromHsvF((visualizer->m_randomGenerator.generate() & 1023) / 1023.0, 1.0, 1.0).toRgb(); float c[4] = { float(color.redF()), @@ -564,7 +528,6 @@ void RhiVisualizer::BatchVis::prepare(const QDataBuffer<Batch *> &opaqueBatches, drawCalls.clear(); - srand(0); // To force random colors to be roughly the same every time.. for (int i = 0; i < opaqueBatches.size(); ++i) gather(opaqueBatches.at(i)); for (int i = 0; i < alphaBatches.size(); ++i) @@ -612,7 +575,7 @@ void RhiVisualizer::ClipVis::gather(QSGNode *node) { if (node->type() == QSGNode::ClipNodeType) { QSGClipNode *clipNode = static_cast<QSGClipNode *>(node); - QMatrix4x4 matrix = visualizer->m_renderer->m_current_projection_matrix; + QMatrix4x4 matrix = visualizer->m_renderer->m_current_projection_matrix[0]; if (clipNode->matrix()) matrix = matrix * *clipNode->matrix(); @@ -711,7 +674,7 @@ void RhiVisualizer::ClipVis::render(QRhiCommandBuffer *cb) void RhiVisualizer::OverdrawVis::gather(Node *n) { if (n->type() == QSGNode::GeometryNodeType && n->element()->batch) { - QMatrix4x4 matrix = visualizer->m_renderer->m_current_projection_matrix; + QMatrix4x4 matrix = visualizer->m_renderer->m_current_projection_matrix[0]; matrix(2, 2) = visualizer->m_renderer->m_zRange; matrix(2, 3) = 1.0f - n->element()->order * visualizer->m_renderer->m_zRange; @@ -837,7 +800,7 @@ void RhiVisualizer::OverdrawVis::prepare(Node *n, RhiVisualizer *visualizer, inputLayout.setAttributes({ { 0, 0, QRhiVertexInputAttribute::Float3, 0 } }); box.ps->setVertexInputLayout(inputLayout); box.ps->setShaderResourceBindings(box.srb); - box.ps->setRenderPassDescriptor(visualizer->m_renderer->renderPassDescriptor()); + box.ps->setRenderPassDescriptor(visualizer->m_renderer->renderTarget().rpDesc); if (!box.ps->create()) return; } |