From 6cc19ebc7da6e17680caf933c1f73e231903c7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 19 Nov 2010 21:22:10 +0100 Subject: [PATCH] OpenGL rendering debug Renders same geometry with polygon mode lines and the shader colorizes the fragments. Enabled with environment variable KWIN_GL_DEBUG=1 --- scene_opengl.cpp | 27 ++++++++++++++++++++------- scene_opengl.h | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 210ed73a66..138a06250b 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -179,6 +179,8 @@ SceneOpenGL::SceneOpenGL( Workspace* ws ) qWarning() << "NO VSYNC! glXGetVideoSync(&uint) isn't 0 but" << glXGetVideoSync( &sync ); } + debug = qstrcmp( qgetenv( "KWIN_GL_DEBUG" ), "1" ) == 0; + // scene shader setup GLPlatform::instance()->detect(); if( GLPlatform::instance()->supports( GLSL ) ) @@ -189,7 +191,7 @@ SceneOpenGL::SceneOpenGL( Workspace* ws ) m_sceneShader->bind(); m_sceneShader->setUniform( "sample", 0 ); m_sceneShader->setUniform( "displaySize", QVector2D(displayWidth(), displayHeight())); - m_sceneShader->setUniform( "debug", 1 ); + m_sceneShader->setUniform( "debug", debug ? 1 : 0 ); m_sceneShader->bindAttributeLocation( 0, "vertex" ); m_sceneShader->bindAttributeLocation( 1, "texCoord" ); m_sceneShader->unbind(); @@ -1598,22 +1600,27 @@ void SceneOpenGL::Window::performPaint( int mask, QRegion region, WindowPaintDat } } - texture.bind(); - texture.enableUnnormalizedTexCoords(); - // paint the content if ( !(mask & PAINT_DECORATION_ONLY) ) { - prepareStates( Content, data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader ); if( !vertexBuffer ) vertexBuffer = new GLVertexBuffer( GLVertexBuffer::Stream ); vertexBuffer->setUseShader( sceneShader ); + texture.bind(); + texture.enableUnnormalizedTexCoords(); + prepareStates( Content, data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader ); renderQuads( mask, region, data.quads.select( WindowQuadContents )); restoreStates( Content, data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader ); + texture.disableUnnormalizedTexCoords(); + texture.unbind(); + if( static_cast(scene)->debug ) + { + glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + renderQuads( mask, region, data.quads.select( WindowQuadContents )); + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + } } - texture.disableUnnormalizedTexCoords(); - texture.unbind(); if( sceneShader ) { data.shader->unbind(); @@ -1678,6 +1685,12 @@ void SceneOpenGL::Window::paintDecoration( const QPixmap* decoration, TextureTyp SceneOpenGL::Window::decorationVertices->render( region, GL_TRIANGLES ); restoreStates( decorationType, data.opacity * data.decoration_opacity, data.brightness, data.saturation, data.shader ); decorationTexture->unbind(); + if( static_cast(scene)->debug ) + { + glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + SceneOpenGL::Window::decorationVertices->render( region, GL_TRIANGLES ); + glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + } } void SceneOpenGL::Window::makeDecorationArrays( const WindowQuadList& quads, const QRect& rect ) const diff --git a/scene_opengl.h b/scene_opengl.h index 2f8971f670..5b7e802eb3 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -98,6 +98,7 @@ class SceneOpenGL bool init_ok; bool selfCheckDone; GLShader* m_sceneShader; + bool debug; }; class SceneOpenGL::Texture