Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualdb123

Posted 26 July 2013 - 08:46 AM

hi, i am working with opengl and qt, but i find some performance problem about wglMakCurrent.

this is the test result which was captured by intel vtune.

[attachment=16973:1.jpg]

 

[attachment=16974:2.jpg]

 

[attachment=16975:3.jpg]

 

i am not use QWidget not QGLWidget because i want to make the rendering code with a same style.

when i render a QT widget with directx9, i send the wid() to my render, and createdevice from this HWND.

if i need a child widget, i will create a new SwapChain for this new widget.

this framework work with directx perfect.

 

but there is a performance question when i make it work with opengl.

 

like directx, i send wid() to opengl render, and create a GLContext by this HWND. this is the initialize code:

                m_HDC = ::GetDC( m_BindWnd );

                PIXELFORMATDESCRIPTOR FormatDesc;
                memset(&FormatDesc, 0, sizeof(PIXELFORMATDESCRIPTOR));
                FormatDesc.nSize		= sizeof(PIXELFORMATDESCRIPTOR);
                FormatDesc.nVersion		= 1;
                FormatDesc.dwFlags		= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI| PFD_DOUBLEBUFFER;
                FormatDesc.iPixelType	= PFD_TYPE_RGBA;
                FormatDesc.cColorBits	= 32;
                FormatDesc.cDepthBits	= 32;
                // FormatDesc.cStencilBits	= 0;
                FormatDesc.iLayerType	= PFD_MAIN_PLANE;

                INT PixelFormat = ChoosePixelFormat( m_HDC, &FormatDesc);
                if (PixelFormat && SetPixelFormat( m_HDC, PixelFormat, &FormatDesc) )
                {
                    m_GLContext = wglCreateContext(m_HDC);

                    if ( m_GLContext && wglMakeCurrent(m_HDC, m_GLContext) )
                    {
                        InitializeGLEW();
                    }
                }

         if a new qwidget created, i will do the same thing for this new qwidget.

 

        when i render them, i will call beginRender and endRender for these warpper object.

        in directx9, i will set the rendertarget to the one which is created by the swapchain.

        in opengl, i will call wglMakeCurrent in BeginRender, call wglMakeCurrent( NULL, NULL ) in EndRender. eg:

            void Viewport::SwapChain()
            {
                if( m_GLContext && m_HDC )
                {
                    ::SwapBuffers( m_HDC );
                }
            }
            
            void Viewport::BeginRender()
            {
                X_ASSERT( m_HDC && m_GLContext );

                BOOL bRet = ::wglMakeCurrent( m_HDC, m_GLContext );

                X_ASSERT( bRet );
            }
            
            void Viewport::EndRender()
            {
                BOOL bRet = ::wglMakeCurrent( NULL, NULL );

                X_ASSERT( bRet );                
            }

          all the codes are in main thread.  In addition to this, i have do nothing. 

          this will be very serious when i drag and move the window.

          smile.png

 

 

---

         this framework is work fine with normal window which is created by windows api.

         but when i use it work with qt, it does not work. work with dx fine....

 


#2db123

Posted 25 July 2013 - 09:21 AM

hi, i am working with opengl and qt, but i find some performance problem about wglMakCurrent.

this is the test result which was captured by intel vtune.

[attachment=16973:1.jpg]

 

[attachment=16974:2.jpg]

 

[attachment=16975:3.jpg]

 

i am not use QWidget not QGLWidget because i want to make the rendering code with a same style.

when i render a QT widget with directx9, i send the wid() to my render, and createdevice from this HWND.

if i need a child widget, i will create a new SwapChain for this new widget.

this framework work with directx perfect.

 

but there is a performance question when i make it work with opengl.

 

like directx, i send wid() to opengl render, and create a GLContext by this HWND. this is the initialize code:

                m_HDC = ::GetDC( m_BindWnd );

                PIXELFORMATDESCRIPTOR FormatDesc;
                memset(&FormatDesc, 0, sizeof(PIXELFORMATDESCRIPTOR));
                FormatDesc.nSize		= sizeof(PIXELFORMATDESCRIPTOR);
                FormatDesc.nVersion		= 1;
                FormatDesc.dwFlags		= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI| PFD_DOUBLEBUFFER;
                FormatDesc.iPixelType	= PFD_TYPE_RGBA;
                FormatDesc.cColorBits	= 32;
                FormatDesc.cDepthBits	= 32;
                // FormatDesc.cStencilBits	= 0;
                FormatDesc.iLayerType	= PFD_MAIN_PLANE;

                INT PixelFormat = ChoosePixelFormat( m_HDC, &FormatDesc);
                if (PixelFormat && SetPixelFormat( m_HDC, PixelFormat, &FormatDesc) )
                {
                    m_GLContext = wglCreateContext(m_HDC);

                    if ( m_GLContext && wglMakeCurrent(m_HDC, m_GLContext) )
                    {
                        InitializeGLEW();
                    }
                }

         if a new qwidget created, i will do the same thing for this new qwidget.

 

        when i render them, i will call beginRender and endRender for these warpper object.

        in directx9, i will set the rendertarget to the one which is created by the swapchain.

        in opengl, i will call wglMakeCurrent in BeginRender, call wglMakeCurrent( NULL, NULL ) in EndRender. eg:

            void Viewport::SwapChain()
            {
                if( m_GLContext && m_HDC )
                {
                    ::SwapBuffers( m_HDC );
                }
            }
            
            void Viewport::BeginRender()
            {
                X_ASSERT( m_HDC && m_GLContext );

                BOOL bRet = ::wglMakeCurrent( m_HDC, m_GLContext );

                X_ASSERT( bRet );
            }
            
            void Viewport::EndRender()
            {
                BOOL bRet = ::wglMakeCurrent( NULL, NULL );

                X_ASSERT( bRet );                
            }

          all the codes are in main thread.  In addition to this, i have do nothing. 

          this will be very serious when i drag and move the window.

          smile.png

 

 

---

         this framework is work fine with normal window which is created by windows api.

         but when i use it work with qt, it does not work. work with dx fine....

 


#1db123

Posted 25 July 2013 - 08:42 AM

hi, i am working with opengl and qt, but i find some performance problem about wglMakCurrent.

this is the test result which was captured by intel vtune.

[attachment=16973:1.jpg]

 

[attachment=16974:2.jpg]

 

[attachment=16975:3.jpg]

 

i am not use QWidget not QGLWidget because i want to make the rendering code with a same style.

when i render a QT widget with directx9, i send the wid() to my render, and createdevice from this HWND.

if i need a child widget, i will create a new SwapChain for this new widget.

this framework work with directx perfect.

 

but there is a performance question when i make it work with opengl.

 

like directx, i send wid() to opengl render, and create a GLContext by this HWND. this is the initialize code:

                m_HDC = ::GetDC( m_BindWnd );

                PIXELFORMATDESCRIPTOR FormatDesc;
                memset(&FormatDesc, 0, sizeof(PIXELFORMATDESCRIPTOR));
                FormatDesc.nSize		= sizeof(PIXELFORMATDESCRIPTOR);
                FormatDesc.nVersion		= 1;
                FormatDesc.dwFlags		= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI| PFD_DOUBLEBUFFER;
                FormatDesc.iPixelType	= PFD_TYPE_RGBA;
                FormatDesc.cColorBits	= 32;
                FormatDesc.cDepthBits	= 32;
                // FormatDesc.cStencilBits	= 0;
                FormatDesc.iLayerType	= PFD_MAIN_PLANE;

                INT PixelFormat = ChoosePixelFormat( m_HDC, &FormatDesc);
                if (PixelFormat && SetPixelFormat( m_HDC, PixelFormat, &FormatDesc) )
                {
                    m_GLContext = wglCreateContext(m_HDC);

                    if ( m_GLContext && wglMakeCurrent(m_HDC, m_GLContext) )
                    {
                        InitializeGLEW();
                    }
                }

         if a new qwidget created, i will do the same thing for this new qwidget.

 

        when i render them, i will call beginRender and endRender for these warpper object.

        in directx9, i will set the rendertarget to the one which is created by the swapchain.

        in opengl, i will call wglMakeCurrent in BeginRender, call wglMakeCurrent( NULL, NULL ) in EndRender. eg:

            void Viewport::SwapChain()
            {
                if( m_GLContext && m_HDC )
                {
                    ::SwapBuffers( m_HDC );
                }
            }
            
            void Viewport::BeginRender()
            {
                X_ASSERT( m_HDC && m_GLContext );

                BOOL bRet = ::wglMakeCurrent( m_HDC, m_GLContext );

                X_ASSERT( bRet );
            }
            
            void Viewport::EndRender()
            {
                BOOL bRet = ::wglMakeCurrent( NULL, NULL );

                X_ASSERT( bRet );                
            }

          all the codes are in main thread.  In addition to this, i have do nothing. 

          this will be very serious when i drag and move the window.

          smile.png


PARTNERS