Hi All and thank you for reading this.
I have a MainWindow with three widgets (QWidget, QDialog and QOpenGLWidget). The QWidget is a navigation bar at the bottom and the QDiaglog is for user input to later serial communitcation. Neither of these are doing anyting right now as it is the early stags of the project. I setup the structure and visual elements with no event handling for now. My main focus is the QOpenGLWidget as this is the view of one of many future cameras. I put in a frame counter in the paintGL () that once it hits 30 frames, give me a duration. Every 30 frames takes roughly 21 seconds. This is very unacceptable.
As background, I have setup the default format as such in main...
QSurfaceFormat format;
format.setProfile ( QSurfaceFormat::CoreProfile );
format.setRenderableType ( QSurfaceFormat::OpenGLES );
format.setSwapBehavior ( QSurfaceFormat::TripleBuffer );
format.setSwapInterval ( 0 ); // 0 = draw to vsync
format.setVersion ( 3, 0 ); // imx6 vivante revision 5.0.11
// must be called before the widget
// or its parent window gets shown
QSurfaceFormat::setDefaultFormat ( format );
QSurfaceFormat format;
format.setProfile ( QSurfaceFormat::CoreProfile );
format.setRenderableType ( QSurfaceFormat::OpenGLES );
format.setSwapBehavior ( QSurfaceFormat::TripleBuffer );
format.setSwapInterval ( 0 ); // 0 = draw to vsync
format.setVersion ( 3, 0 ); // imx6 vivante revision 5.0.11
// must be called before the widget
// or its parent window gets shown
QSurfaceFormat::setDefaultFormat ( format );
To copy to clipboard, switch view to plain text mode
I then setup my subclassed mainwindow through my own initialization function to propagate the items before show(). At the end of this, all items at created and initialized. They have their geomotry, everything is connected and we're ready to to be shown. show() then starts the visual loops and off we go. In the QOpenGLWidget, as standard, I follow the standard three overrides. Here is the top of my class in question...
class AVC8000nano : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit AVC8000nano
( QWidget *parent
= 0 );
~AVC8000nano ( void );
APP_STATUS Initialize ( WhichSetup* structWhichSetup );
void DoWork ( WORKTODO myTask );
bool SetCameraToViewPort ( const WHICH_CAMERA eCamera );
protected:
void initializeGL () Q_DECL_OVERRIDE;
void paintGL () Q_DECL_OVERRIDE;
void resizeGL ( int width, int height );
QOpenGLExtraFunctions* m_OGLES3Functions;
...
class AVC8000nano : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit AVC8000nano ( QWidget *parent = 0 );
~AVC8000nano ( void );
APP_STATUS Initialize ( WhichSetup* structWhichSetup );
void DoWork ( WORKTODO myTask );
bool SetCameraToViewPort ( const WHICH_CAMERA eCamera );
protected:
void initializeGL () Q_DECL_OVERRIDE;
void paintGL () Q_DECL_OVERRIDE;
void resizeGL ( int width, int height );
QOpenGLExtraFunctions* m_OGLES3Functions;
...
To copy to clipboard, switch view to plain text mode
Inside of paintGL(), I do very little...
void AVC8000nano::paintGL ()
{
if ( ( m_bAreWeExitting ) ||
( !m_bInitialized ) )
{
return;
}
QOpenGLContext *oglContext = context ();
if ( !oglContext ) // QOpenGLWidget not yet initialized
{
return;
}
//GLenum enumError;
m_qimage2Paint = m_helperAVC8KV4L2->GrabImage ();
if ( m_qimage2Paint != NULL )
{
qPainter.translate ( m_nDeltaX / 2, m_nDeltaY / 2 );
qPainter.drawImage ( m_rectImage, *m_qimage2Paint );
// if ( ( enumError = m_OGLES3Functions->glGetError () ) != GL_NO_ERROR )
// {
// qDebug ( "OpenGL error: %d.", enumError );
// }
}
#ifdef DEBUG_LIVE_TIMING
m_nFrameGrabbed++;
if ( m_nFrameGrabbed == 30 )
{
gettimeofday ( &m_tv_now, NULL );
m_tk_Diff = TV_SECONDS ( m_tv_now, m_tv_begin );
qDebug ( "30 frames took %lld seconds", m_tk_Diff, m_nFrameGrabbed );
m_nFrameGrabbed = 0;
gettimeofday ( &m_tv_begin, NULL );
}
#endif
delete m_qimage2Paint;
// Schedule composition. Note that this will use QueuedConnection, meaning
// that update() will be invoked on the gui thread.
//update ( m_rectWidget );
}
void AVC8000nano::paintGL ()
{
if ( ( m_bAreWeExitting ) ||
( !m_bInitialized ) )
{
return;
}
QOpenGLContext *oglContext = context ();
if ( !oglContext ) // QOpenGLWidget not yet initialized
{
return;
}
//GLenum enumError;
m_qimage2Paint = m_helperAVC8KV4L2->GrabImage ();
if ( m_qimage2Paint != NULL )
{
QPainter qPainter ( this );
qPainter.translate ( m_nDeltaX / 2, m_nDeltaY / 2 );
qPainter.drawImage ( m_rectImage, *m_qimage2Paint );
// if ( ( enumError = m_OGLES3Functions->glGetError () ) != GL_NO_ERROR )
// {
// qDebug ( "OpenGL error: %d.", enumError );
// }
}
#ifdef DEBUG_LIVE_TIMING
m_nFrameGrabbed++;
if ( m_nFrameGrabbed == 30 )
{
gettimeofday ( &m_tv_now, NULL );
m_tk_Diff = TV_SECONDS ( m_tv_now, m_tv_begin );
qDebug ( "30 frames took %lld seconds", m_tk_Diff, m_nFrameGrabbed );
m_nFrameGrabbed = 0;
gettimeofday ( &m_tv_begin, NULL );
}
#endif
delete m_qimage2Paint;
// Schedule composition. Note that this will use QueuedConnection, meaning
// that update() will be invoked on the gui thread.
QMetaObject::invokeMethod ( this, "update");
//update ( m_rectWidget );
}
To copy to clipboard, switch view to plain text mode
I have placed inside of my /etc/appcontroller.conf file as well as my /etc/profile (appropriately edited) these lines...
env=QT_QPA_PLATFORM=eglfs
env=QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
env=QT_QPA_EGLFS_WIDTH=1920
env=QT_QPA_EGLFS_HEIGHT=1080
env=QT_QPA_EGLFS_PHYSICAL_WIDTH=1920
env=QT_QPA_EGLFS_PHYSICAL_HEIGHT=1080
env=QT_QPA_EGLFS_SWAPINTERVAL=0
env=QT_QPA_PLATFORM=eglfs
env=QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
env=QT_QPA_EGLFS_WIDTH=1920
env=QT_QPA_EGLFS_HEIGHT=1080
env=QT_QPA_EGLFS_PHYSICAL_WIDTH=1920
env=QT_QPA_EGLFS_PHYSICAL_HEIGHT=1080
env=QT_QPA_EGLFS_SWAPINTERVAL=0
To copy to clipboard, switch view to plain text mode
My main point here is the SWAPINTERVAL matching the applications format.setSwapInterval above. I have tested setting these values to 34, 17, 1 and 0. None of these effect the 30 frames in 21 seconds measurement.
For uboot, I set the video args as such for the kernel. Changing the @60 to @30 again makes no diff.
vidargs=acpi=force mxc_hdmi.only_cea=1 video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24 video=mxcfb1
ff video=mxcfb2
ff video=mxcfb3
ff fbmem=32M
So here I am now not sure where to look. Does anyone have any ideas as to where to look next? Thank you for your time.
Cheers,
Pete
Bookmarks