Slow Qt pointcloud performance in scene3d

I see major performance issues in a QML application that I wrote to show a point cloud in Scene3d. At 1,000 points / sec, this is good, but at 10,000 it basically stops my entire computer. The goal is to stand up to millions of points (this is what the old application is, a Qt / VTK mixture could do before slowing down.)

I worry that I am not uploading processing to another thread or not processing properly .... This is my first Qt project and new to all of this.

Basically, I create a circular dotbuffer (each dot is 32 bytes), which I copy in to QByteArrayin user QGeometry, on Entity. This object has material that triggers the vertex and fragment shader.

Is there something I can do to improve performance?

material :

import Qt3D.Core 2.0
import Qt3D.Render 2.0

Material {
    effect: Effect {
        techniques: Technique {
            renderPasses: RenderPass {
                shaderProgram: ShaderProgram {
                    vertexShaderCode: loadSource("qrc:/shaders/pointcloud.vert")
                    fragmentShaderCode: loadSource("qrc:/shaders/pointcloud.frag")
                }
                renderStates: [
                    PointSize { sizeMode: PointSize.Programmable } //supported since OpenGL 3.2
                ]
            }
            graphicsApiFilter {
                api: GraphicsApiFilter.OpenGL
                profile: GraphicsApiFilter.CoreProfile
                majorVersion: 4
                minorVersion: 3
            }
        }
    }
        // some parameters...
}

My shaders are pretty simple:

vertex

#version 430

layout(location = 1) in vec3 vertexPosition;

out VertexBlock
{
    flat vec3 col;
    vec3 pos;
    vec3 normal;
} v_out;

uniform mat4 modelView;
uniform mat3 modelViewNormal;
uniform mat4 mvp;
uniform mat4 projectionMatrix;
uniform mat4 viewportMatrix;

uniform float pointSize;
uniform float maxDistance;

void main()
{
    vec3 vertexNormal = vec3(1.0, 1.0, 1.0);
    v_out.normal = normalize(modelViewNormal * vertexNormal);
    v_out.pos    = vec3(modelView * vec4(vertexPosition, 1.0));

    float c      = (vertexPosition[0]*vertexPosition[0] + vertexPosition[1]*vertexPosition[1])*maxDistance;
    v_out.col    = vec3(c,c,0.5);

    gl_Position = mvp * vec4(vertexPosition, 1.0);
    gl_PointSize = viewportMatrix[1][1] * projectionMatrix[1][1] * pointSize / gl_Position.w;
}

fragment

#version 430

in VertexBlock
{
    flat vec3 col;
    vec3 pos;
    vec3 normal;
} frag_in;

out vec4 colour;

void main()
{
    colour = vec4(frag_in.col, 1.0);
}

Renderer

import Qt3D.Core 2.0
import Qt3D.Render 2.0

import "Cameras"

RenderSettings {
    id: root

    property CameraSet cameraSet: CameraSet {
        id: cameraSet
    }

    property real userViewWidth: 0.79
    property real topOrthoViewHeight: 0.79

    activeFrameGraph: Viewport {
        id: viewport
        normalizedRect: Qt.rect(0.0, 0.0, 1.0, 1.0)

        RenderSurfaceSelector {
            ClearBuffers {
                buffers : ClearBuffers.ColorDepthBuffer
                clearColor: theme.cSceneClear

                NoDraw {}
            }

            Viewport {
                id: userViewport
                normalizedRect: Qt.rect(0, 0, userViewWidth, 1.0)

                CameraSelector {
                    id: userCameraSelectorViewport
                    camera: cameraSet.user.camera
                }
            }
            // Two other viewports...
        }
    }
}

Entity

Entity {
    property PointBuffer buffer: PointBuffer {
        id: pointBuffer
    }

    PointsMaterial {
        id: pointsMaterial
        dataBuffer: pointBuffer
    }

    Entity {
        id: particleRenderEntity
        property GeometryRenderer particlesRenderer: GeometryRenderer {
            instanceCount: buffer.count
            primitiveType: GeometryRenderer.Points
            geometry: PointGeometry { buffer: pointBuffer }
        }

        components: [
            particlesRenderer
            , pointsMaterial
        ]
    }
}
+4
source share
1 answer

Found a problem, and it was not in the originally published information.

In fact, I had it instanceCount: buffer.count, but in my geometry I write the entire buffer in one step. Therefore, I effectively blocked the size of my buffer.

The solution was to establish instanceCount: 1

I was puzzled by this line before, even deleting it, but I suspect that it does not matter by default. And I did not understand the QML docs about exactly what this would do.

, , SphereGeometry, . , , . ( , Geometry Shader.)

+2

Source: https://habr.com/ru/post/1667673/


All Articles