Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3DCore - High CPU Usage
Forum Updated to NodeBB v4.3 + New Features

Qt3DCore - High CPU Usage

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 749 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • webzoidW Offline
    webzoidW Offline
    webzoid
    wrote on last edited by webzoid
    #1

    I've got a weird issue when trying to display a 3D model in my QWidgets app on Windows whereby the CPU usage creeps up past 30% when absolutely nothing is going on.

    Steps to recreate:

    1. Create a new Qt Widgets Application
    2. Target Qt 5.11.3 for MSVC 2015 32bit
    3. Append the following to the QT += section .pro file 3dcore 3drender 3dextras
    4. Paste the following code into MainWindow.cpp (under ui->setupUi(this);):
    QColor bg = this->palette().background().color();
    
    // Create the view
    Qt3DExtras::Qt3DWindow* view = new Qt3DExtras::Qt3DWindow();
    view->defaultFrameGraph()->setClearColor(bg);
    
    // Create the container widget
    QWidget* container = QWidget::createWindowContainer(view);
    this->setCentralWidget(container);
    
    // Create a root entity
    Qt3DCore::QEntity* root = new Qt3DCore::QEntity;
    
    // Create a scene camera
    Qt3DRender::QCamera* camera = view->camera();
    camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
    camera->setPosition(QVector3D(0, 0, 8.0f));
    camera->setUpVector(QVector3D(0, 1, 0));
    camera->setViewCenter(QVector3D(0, 0, 0));
    
    // Set up the scene lighting
    Qt3DCore::QEntity* light = new Qt3DCore::QEntity(root);
    
    Qt3DRender::QPointLight* point = new Qt3DRender::QPointLight(light);
    point->setColor("silver");
    point->setIntensity(1);
    light->addComponent(point);
    Qt3DCore::QTransform* lightTransform = new Qt3DCore::QTransform(light);
    lightTransform->setTranslation(camera->position());
    light->addComponent(lightTransform);
    
    Qt3DCore::QEntity* model = new Qt3DCore::QEntity(root);
    Qt3DRender::QMesh* mesh = new Qt3DRender::QMesh();
    mesh->setSource(QUrl::fromLocalFile("my_model.obj"));
    
    Qt3DExtras::QPhongMaterial* material = new Qt3DExtras::QPhongMaterial;
    material->setDiffuse(QColor(Qt::darkGray));
    
    Qt3DCore::QTransform* transform = new Qt3DCore::QTransform;
    transform->setScale(1.0);
    transform->setRotation(QQuaternion::fromEulerAngles(0.0, 0.0, 0.0));
    
    model->addComponent(mesh);
    model->addComponent(transform);
    model->addComponent(material);
    
    view->setRootEntity(root);
    
    transform->setRotation(QQuaternion::fromEulerAngles(0, 0, 0));
    

    My understand (from various forum posts) was that the performance on the Qt3DCore side had been improved with recent releases of Qt however this definitely does not seem to be the case.

    JKSHJ 1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by
      #2

      I ran into a similar issue when I was using Qt 5.6. Switching to Qt 5.12 solved the problem.

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • webzoidW Offline
        webzoidW Offline
        webzoid
        wrote on last edited by
        #3

        @JohanSolo Unfortunately switching to 5.12 made no difference.

        Even with the simple example above, with 5.12.5 I'm seeing > 40%.

        1 Reply Last reply
        0
        • webzoidW webzoid

          I've got a weird issue when trying to display a 3D model in my QWidgets app on Windows whereby the CPU usage creeps up past 30% when absolutely nothing is going on.

          Steps to recreate:

          1. Create a new Qt Widgets Application
          2. Target Qt 5.11.3 for MSVC 2015 32bit
          3. Append the following to the QT += section .pro file 3dcore 3drender 3dextras
          4. Paste the following code into MainWindow.cpp (under ui->setupUi(this);):
          QColor bg = this->palette().background().color();
          
          // Create the view
          Qt3DExtras::Qt3DWindow* view = new Qt3DExtras::Qt3DWindow();
          view->defaultFrameGraph()->setClearColor(bg);
          
          // Create the container widget
          QWidget* container = QWidget::createWindowContainer(view);
          this->setCentralWidget(container);
          
          // Create a root entity
          Qt3DCore::QEntity* root = new Qt3DCore::QEntity;
          
          // Create a scene camera
          Qt3DRender::QCamera* camera = view->camera();
          camera->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
          camera->setPosition(QVector3D(0, 0, 8.0f));
          camera->setUpVector(QVector3D(0, 1, 0));
          camera->setViewCenter(QVector3D(0, 0, 0));
          
          // Set up the scene lighting
          Qt3DCore::QEntity* light = new Qt3DCore::QEntity(root);
          
          Qt3DRender::QPointLight* point = new Qt3DRender::QPointLight(light);
          point->setColor("silver");
          point->setIntensity(1);
          light->addComponent(point);
          Qt3DCore::QTransform* lightTransform = new Qt3DCore::QTransform(light);
          lightTransform->setTranslation(camera->position());
          light->addComponent(lightTransform);
          
          Qt3DCore::QEntity* model = new Qt3DCore::QEntity(root);
          Qt3DRender::QMesh* mesh = new Qt3DRender::QMesh();
          mesh->setSource(QUrl::fromLocalFile("my_model.obj"));
          
          Qt3DExtras::QPhongMaterial* material = new Qt3DExtras::QPhongMaterial;
          material->setDiffuse(QColor(Qt::darkGray));
          
          Qt3DCore::QTransform* transform = new Qt3DCore::QTransform;
          transform->setScale(1.0);
          transform->setRotation(QQuaternion::fromEulerAngles(0.0, 0.0, 0.0));
          
          model->addComponent(mesh);
          model->addComponent(transform);
          model->addComponent(material);
          
          view->setRootEntity(root);
          
          transform->setRotation(QQuaternion::fromEulerAngles(0, 0, 0));
          

          My understand (from various forum posts) was that the performance on the Qt3DCore side had been improved with recent releases of Qt however this definitely does not seem to be the case.

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @webzoid said in Qt3DCore - High CPU Usage:

          Steps to recreate:

          I tried to follow your steps on Qt 5.13.0 for MSVC 2017 32-bit, but the window was blank.

          So I ran the Basic Shapes Example on Qt 5.13.0 for MSVC 2017 32-bit. Sitting idly, the CPU did not exceed 4%.

          I have a Intel Core i7 4710HQ @ 2.50GHz + 2048MB ATI AMD Radeon R9 M265X. What hardware are you using? What happens when you run the Basic Shapes example?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          1
          • webzoidW Offline
            webzoidW Offline
            webzoid
            wrote on last edited by webzoid
            #5

            @JKSH I'm assuming that you replaced "my_model.obj" with an alternative?

            I've just run the Basic Shapes example and my current CPU usage is at 52.1%!!! Yikes!

            My machine is an Intel Core i5-2500 @ 3.30GHz + dual AMD Radeon HD 7500 graphics cards + 16GB RAM.

            Maybe I need a driver update but I have also seen this on many customers machines.

            a27b5221-2b0c-4a5e-b109-32d60431863f-image.png

            ** UPDATE **

            Ok, so one thing I didn't highlight is that I'm running 3 displays from those dual graphics cards. Interestingly, if I have the Qt example application running on the primary display, the CPU usage is high. If I move the Qt window to one of the other displays then the CPU usage drops by about 30% to around the 24% region.

            Weirdness!

            JKSHJ 1 Reply Last reply
            0
            • webzoidW webzoid

              @JKSH I'm assuming that you replaced "my_model.obj" with an alternative?

              I've just run the Basic Shapes example and my current CPU usage is at 52.1%!!! Yikes!

              My machine is an Intel Core i5-2500 @ 3.30GHz + dual AMD Radeon HD 7500 graphics cards + 16GB RAM.

              Maybe I need a driver update but I have also seen this on many customers machines.

              a27b5221-2b0c-4a5e-b109-32d60431863f-image.png

              ** UPDATE **

              Ok, so one thing I didn't highlight is that I'm running 3 displays from those dual graphics cards. Interestingly, if I have the Qt example application running on the primary display, the CPU usage is high. If I move the Qt window to one of the other displays then the CPU usage drops by about 30% to around the 24% region.

              Weirdness!

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by JKSH
              #6

              @webzoid said in Qt3DCore - High CPU Usage:

              @JKSH I'm assuming that you replaced "my_model.obj" with an alternative?

              Ah, no I didn't notice that your code needs my_model.obj. (Suggestion: When you want others to reproduce a problem that you're seeing, it's best to use examples that don't require others to create their own resource files)

              I've just run the Basic Shapes example and my current CPU usage is at 52.1%!!! Yikes!

              OK, since you can reproduce your problem on an official example, let's stick to this. Use this example when you submit a bug report.

              My machine is an Intel Core i5-2500 @ 3.30GHz + dual AMD Radeon HD 7500 graphics cards + 16GB RAM.

              That should certainly be enough to run the Basic Shapes example comfortably.

              Ok, so one thing I didn't highlight is that I'm running 3 displays from those dual graphics cards. Interestingly, if I have the Qt example application running on the primary display, the CPU usage is high. If I move the Qt window to one of the other displays then the CPU usage drops by about 30% to around the 24% region.

              Weirdness!

              24% still seems quite high. What happens if you only have a single display connected to your GPU?

              I just noticed this on a different machine:

              Specs:

              • Intel i7-7770 3.6 GHz
              • 16 GB DDR4 RAM
              • 3071MB NVIDIA GeForce GTX 1080 Ti
              • 1920 x 1080 display
              • Qt 5.13.1 for MSVC 2017 32-bit

              Behaviour for the Basic Shapes example when idle:

              Mode CPU Usage
              Debug mode 4%
              Release mode 17%

              Would you be happy to open a report at https://bugreports.qt.io/ ? (Provide as much details as you can, using an official example)

              EDIT: I left the Basic Shapes example running in Release mode while I did other things. I noticed that the CPU activity dropped to 2% after a while and stayed at 2%, even when I move the camera around rapidly.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • webzoidW Offline
                webzoidW Offline
                webzoid
                wrote on last edited by
                #7

                @JKSH Yes, I will happily report this as a bug.

                Given that it can be recreated with one of the examples then I shouldn't need to add too much extra detail.

                Thanks for your help.

                J 1 Reply Last reply
                0
                • webzoidW webzoid

                  @JKSH Yes, I will happily report this as a bug.

                  Given that it can be recreated with one of the examples then I shouldn't need to add too much extra detail.

                  Thanks for your help.

                  J Offline
                  J Offline
                  jack_lou
                  wrote on last edited by
                  #8

                  @webzoid Ihave the same problem,is there a solution?

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved