summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2020-11-30 10:09:59 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-01 14:24:23 +0000
commit2484939ec1f82464b4675746940a3a45d1934cae (patch)
tree4d75df7b8de4be2b319c5f3ffc0b57f6b6f252d5
parentce8633cad20de91361f800cd4f5b6d81ccbe64cc (diff)
RHI: restore QBufferCapture feature
Also fix manual test to import Qt3D.Core 2.9 since QBuffer was moved to core in Qt 6 and accessType property was introduce with revision 9. Change-Id: I449f413fd161fe4660cef61708cd641e429c1c81 Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit 10adc1c93c80dba4535a3cf22c5095d788ae0a43) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer.cpp11
-rw-r--r--src/plugins/renderers/rhi/renderer/renderer_p.h2
-rw-r--r--tests/manual/buffercapture-qml/BufferSetterScene.qml5
-rw-r--r--tests/manual/buffercapture-qml/CMakeLists.txt3
-rw-r--r--tests/manual/buffercapture-qml/ComputeMaterial.qml35
-rw-r--r--tests/manual/buffercapture-qml/gl43/bufferSetter.comp (renamed from tests/manual/buffercapture-qml/bufferSetter.comp)0
-rw-r--r--tests/manual/buffercapture-qml/gl45/bufferSetter.comp68
-rw-r--r--tests/manual/buffercapture-qml/resources.qrc3
8 files changed, 109 insertions, 18 deletions
diff --git a/src/plugins/renderers/rhi/renderer/renderer.cpp b/src/plugins/renderers/rhi/renderer/renderer.cpp
index 953412b72..c6190403b 100644
--- a/src/plugins/renderers/rhi/renderer/renderer.cpp
+++ b/src/plugins/renderers/rhi/renderer/renderer.cpp
@@ -2028,7 +2028,7 @@ void Renderer::cleanupRenderTarget(const Qt3DCore::QNodeId &renderTargetId)
}
// Called by SubmitRenderView
-void Renderer::downloadGLBuffers()
+void Renderer::downloadRHIBuffers()
{
const std::vector<Qt3DCore::QNodeId> downloadableHandles = std::move(m_downloadableBuffers);
for (const Qt3DCore::QNodeId &bufferId : downloadableHandles) {
@@ -2128,12 +2128,6 @@ Renderer::submitRenderViews(const std::vector<RHIPassInfo> &rhiPassesInfo)
m_lastFrameCorrect.storeRelaxed(
0); // something went wrong; make sure to render the next frame!
- // if (renderView->isDownloadBuffersEnable())
- // {
- // RHI_UNIMPLEMENTED;
- ////* downloadGLBuffers();
- // }
-
frameElapsed = timer.elapsed() - frameElapsed;
qCDebug(Rendering) << Q_FUNC_INFO << "Submitted RHI Passes " << i + 1 << "/"
<< rhiPassesCount << "in " << frameElapsed << "ms";
@@ -2801,6 +2795,9 @@ bool Renderer::executeCommandsSubmission(const RHIPassInfo &passInfo)
}
}
}
+
+ if (rv->isDownloadBuffersEnable())
+ downloadRHIBuffers();
}
if (Q_LIKELY(inDraw))
diff --git a/src/plugins/renderers/rhi/renderer/renderer_p.h b/src/plugins/renderers/rhi/renderer/renderer_p.h
index 7992aff2b..e30aa9d90 100644
--- a/src/plugins/renderers/rhi/renderer/renderer_p.h
+++ b/src/plugins/renderers/rhi/renderer/renderer_p.h
@@ -252,7 +252,7 @@ public:
void updateTexture(Texture *texture);
void cleanupTexture(Qt3DCore::QNodeId cleanedUpTextureId);
void cleanupShader(const Shader *shader);
- void downloadGLBuffers();
+ void downloadRHIBuffers();
struct RHIPassInfo
{
diff --git a/tests/manual/buffercapture-qml/BufferSetterScene.qml b/tests/manual/buffercapture-qml/BufferSetterScene.qml
index 2b2b2a85a..53dfd136c 100644
--- a/tests/manual/buffercapture-qml/BufferSetterScene.qml
+++ b/tests/manual/buffercapture-qml/BufferSetterScene.qml
@@ -49,7 +49,7 @@
****************************************************************************/
import QtQuick 2.2 as QQ2
-import Qt3D.Core 2.0
+import Qt3D.Core 2.9
import Qt3D.Render 2.9
import Qt3D.Input 2.0
import Qt3D.Extras 2.0
@@ -92,9 +92,8 @@ Entity {
Buffer {
id: graphBuffer
objectName: "buffer"
- type: Buffer.VertexBuffer
- data: initGraphBuffer()
accessType: Buffer.ReadWrite
+ data: initGraphBuffer()
}
ComputeMaterial {
diff --git a/tests/manual/buffercapture-qml/CMakeLists.txt b/tests/manual/buffercapture-qml/CMakeLists.txt
index d385de583..f1f5657fe 100644
--- a/tests/manual/buffercapture-qml/CMakeLists.txt
+++ b/tests/manual/buffercapture-qml/CMakeLists.txt
@@ -26,7 +26,8 @@ set(resources_resource_files
"BufferSetterScene.qml"
"ComputeFrameGraph.qml"
"ComputeMaterial.qml"
- "bufferSetter.comp"
+ "gl43/bufferSetter.comp"
+ "gl45/bufferSetter.comp"
"main.qml"
)
diff --git a/tests/manual/buffercapture-qml/ComputeMaterial.qml b/tests/manual/buffercapture-qml/ComputeMaterial.qml
index 05c56901c..90da19554 100644
--- a/tests/manual/buffercapture-qml/ComputeMaterial.qml
+++ b/tests/manual/buffercapture-qml/ComputeMaterial.qml
@@ -48,8 +48,8 @@
**
****************************************************************************/
-import Qt3D.Core 2.0
-import Qt3D.Render 2.0
+import Qt3D.Core 2.9
+import Qt3D.Render 2.9
Material {
property Buffer dataBuffer;
@@ -60,8 +60,13 @@ Material {
]
ShaderProgram {
- id: computeShader
- computeShaderCode: loadSource("qrc:/bufferSetter.comp")
+ id: computeShaderGL43
+ computeShaderCode: loadSource("qrc:/gl43/bufferSetter.comp")
+ }
+
+ ShaderProgram {
+ id: computeShaderGL45
+ computeShaderCode: loadSource("qrc:/gl45/bufferSetter.comp")
}
effect: Effect {
@@ -69,7 +74,7 @@ Material {
Technique {
renderPasses: [
RenderPass {
- shaderProgram: computeShader
+ shaderProgram: computeShaderGL43
// We set the buffer as the parameter data
parameters: [
Parameter { name: "input"; value: dataBuffer }
@@ -85,6 +90,26 @@ Material {
majorVersion: 4
minorVersion: 3
}
+ },
+ Technique {
+ renderPasses: [
+ RenderPass {
+ shaderProgram: computeShaderGL45
+ // We set the buffer as the parameter data
+ parameters: [
+ Parameter { name: "input"; value: dataBuffer }
+ ]
+ }
+ ]
+ filterKeys: [
+ FilterKey { name: "type"; value: "compute" }
+ ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.RHI
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 1
+ minorVersion: 0
+ }
}
] // techniques
}
diff --git a/tests/manual/buffercapture-qml/bufferSetter.comp b/tests/manual/buffercapture-qml/gl43/bufferSetter.comp
index d7c383669..d7c383669 100644
--- a/tests/manual/buffercapture-qml/bufferSetter.comp
+++ b/tests/manual/buffercapture-qml/gl43/bufferSetter.comp
diff --git a/tests/manual/buffercapture-qml/gl45/bufferSetter.comp b/tests/manual/buffercapture-qml/gl45/bufferSetter.comp
new file mode 100644
index 000000000..56b1c0799
--- /dev/null
+++ b/tests/manual/buffercapture-qml/gl45/bufferSetter.comp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Juan José Casafranca.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#version 450 core
+
+layout (local_size_x=32) in;
+
+layout (std430, binding = 3) buffer InputBuffer
+{
+ uint d[];
+};
+
+layout(std140, binding=4) uniform custom_uniforms {
+ int inputSize;
+};
+
+void main()
+{
+ if (gl_GlobalInvocationID.x < inputSize)
+ d[gl_GlobalInvocationID.x] = d[gl_GlobalInvocationID.x] + gl_GlobalInvocationID.x * 2;
+}
diff --git a/tests/manual/buffercapture-qml/resources.qrc b/tests/manual/buffercapture-qml/resources.qrc
index 167957feb..54b297c26 100644
--- a/tests/manual/buffercapture-qml/resources.qrc
+++ b/tests/manual/buffercapture-qml/resources.qrc
@@ -1,9 +1,10 @@
<RCC>
<qresource prefix="/">
<file>BufferSetterScene.qml</file>
- <file>bufferSetter.comp</file>
<file>main.qml</file>
<file>ComputeFrameGraph.qml</file>
<file>ComputeMaterial.qml</file>
+ <file>gl43/bufferSetter.comp</file>
+ <file>gl45/bufferSetter.comp</file>
</qresource>
</RCC>