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. Measuring frame rendering time

Measuring frame rendering time

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 2.4k 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.
  • Kent-DorfmanK Offline
    Kent-DorfmanK Offline
    Kent-Dorfman
    wrote on last edited by
    #9

    I just noticed something. You should not call update() from within paintGL(). It works the other way around: update(), whether called implicitly or explicitly, calls paintGl() to render the scene...paintGL() is a virtual callback, not a slot.

    public:
        render_time;
    void paintGl() {
        begin_time=now()
        // do stuff
        render_time = now() - begin_time
    }
    

    The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

    mrjbomM 2 Replies Last reply
    1
    • Kent-DorfmanK Kent-Dorfman

      I just noticed something. You should not call update() from within paintGL(). It works the other way around: update(), whether called implicitly or explicitly, calls paintGl() to render the scene...paintGL() is a virtual callback, not a slot.

      public:
          render_time;
      void paintGl() {
          begin_time=now()
          // do stuff
          render_time = now() - begin_time
      }
      
      mrjbomM Offline
      mrjbomM Offline
      mrjbom
      wrote on last edited by mrjbom
      #10

      @Kent-Dorfman, do you suggest not calling update() at all?
      If I don't call it from paintGL() or other places, then my frames don't update(sometimes abruptly update themselves).

      1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        I just noticed something. You should not call update() from within paintGL(). It works the other way around: update(), whether called implicitly or explicitly, calls paintGl() to render the scene...paintGL() is a virtual callback, not a slot.

        public:
            render_time;
        void paintGl() {
            begin_time=now()
            // do stuff
            render_time = now() - begin_time
        }
        
        mrjbomM Offline
        mrjbomM Offline
        mrjbom
        wrote on last edited by
        #11

        @Kent-Dorfman, @nagesh, The documentation says: The signals aboutToCompose() and frameSwapped() will be emitted when the composition is starting and ending.

        What happens if I start measuring the time when aboutToCompose() happens and end the change when frameSwapped() happens, so I get the frame rendering time?

        1 Reply Last reply
        0
        • nageshN Offline
          nageshN Offline
          nagesh
          wrote on last edited by
          #12

          @mrjbom calling update will schedule the paint event for the processing which means internally it triggers paintGL().
          For constant update of frames you can do it with the QTimer slot call update()
          or as soon as new frame is available call update()

          As per QT doc
          in frameSwapped()

          This signal is emitted after the potentially blocking buffer swap has been done. 
          Applications that wish to continuously repaint synchronized to the vertical refresh,
           should issue an update() upon this signal. This allows for a much smoother experience 
          compared to the traditional usage of timers.
          

          I feel frame rendering is happening in paintGL()

          mrjbomM 1 Reply Last reply
          1
          • nageshN nagesh

            @mrjbom calling update will schedule the paint event for the processing which means internally it triggers paintGL().
            For constant update of frames you can do it with the QTimer slot call update()
            or as soon as new frame is available call update()

            As per QT doc
            in frameSwapped()

            This signal is emitted after the potentially blocking buffer swap has been done. 
            Applications that wish to continuously repaint synchronized to the vertical refresh,
             should issue an update() upon this signal. This allows for a much smoother experience 
            compared to the traditional usage of timers.
            

            I feel frame rendering is happening in paintGL()

            mrjbomM Offline
            mrjbomM Offline
            mrjbom
            wrote on last edited by
            #13

            @nagesh said in Measuring frame rendering time:

            I feel frame rendering is happening in paintGL()

            In paintGL, the frame is being prepared. So it is useless to measure time there.

            1 Reply Last reply
            0
            • nageshN Offline
              nageshN Offline
              nagesh
              wrote on last edited by
              #14

              @mrjbom read the description for paintGL()
              https://doc.qt.io/qt-5/qopenglwidget.html
              it says.. paintGL() - Renders the OpenGL scene. Gets called whenever the widget needs to be updated.

              What does your function
              sceneManager->callDrawScene() doing?

              mrjbomM 1 Reply Last reply
              0
              • nageshN nagesh

                @mrjbom read the description for paintGL()
                https://doc.qt.io/qt-5/qopenglwidget.html
                it says.. paintGL() - Renders the OpenGL scene. Gets called whenever the widget needs to be updated.

                What does your function
                sceneManager->callDrawScene() doing?

                mrjbomM Offline
                mrjbomM Offline
                mrjbom
                wrote on last edited by
                #15

                @nagesh It draws the current scene. The usual functions that are usually found in paintGL().

                In any case, if I measure the time only within paintGL (), then the time is constantly different from the previous one.
                Probably because QElapsedTimer reads the time within the operating system, not my application, so due to the task switching by the operating system, it is different.
                How can I measure the time regardless of the task switching by the operating system?

                Kent-DorfmanK 1 Reply Last reply
                0
                • nageshN Offline
                  nageshN Offline
                  nagesh
                  wrote on last edited by
                  #16

                  @mrjbom There is class in qt QOpenGLTimerQuery
                  https://doc.qt.io/qt-5/qopengltimerquery.html

                  Whether it's applicable for your requirement not sure.

                  mrjbomM 1 Reply Last reply
                  0
                  • mrjbomM mrjbom

                    @nagesh It draws the current scene. The usual functions that are usually found in paintGL().

                    In any case, if I measure the time only within paintGL (), then the time is constantly different from the previous one.
                    Probably because QElapsedTimer reads the time within the operating system, not my application, so due to the task switching by the operating system, it is different.
                    How can I measure the time regardless of the task switching by the operating system?

                    Kent-DorfmanK Offline
                    Kent-DorfmanK Offline
                    Kent-Dorfman
                    wrote on last edited by Kent-Dorfman
                    #17

                    @mrjbom Dude! We've been over this. You cannot accurately measure the time spent in a call that takes nanoseconds or microseconds to complete. you are not using a realtime OS. Either research the science of RTOS or give up on getting consistent numbers.

                    The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

                    1 Reply Last reply
                    1
                    • nageshN nagesh

                      @mrjbom There is class in qt QOpenGLTimerQuery
                      https://doc.qt.io/qt-5/qopengltimerquery.html

                      Whether it's applicable for your requirement not sure.

                      mrjbomM Offline
                      mrjbomM Offline
                      mrjbom
                      wrote on last edited by
                      #18

                      @nagesh Got it! This is what I need.
                      To be more precise, QOpenGLTimeMonitor () helped me.
                      Thank you for your help.

                      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