Commit db2e1a3f authored by Dmitry Kazakov's avatar Dmitry Kazakov

Implement two debugging features (can be activated on Performance tab)

1) Enable openGL logging. Enable this option to find out the currently requested FPS for openGL updates.
   It also tells the percentage of the glSync busy reports. If the value is zero
   then glSync doesn't work for some reason.

2) Disable vector optimizations. Completely disables all Vc optimizations.
   Needed for AMD CPUs.

Ref T694
parent 81a9004e
......@@ -146,6 +146,7 @@ set(kritaui_LIB_SRCS
kra/kis_kra_savexml_visitor.cpp
opengl/kis_opengl.cpp
opengl/kis_opengl_canvas2.cpp
opengl/kis_opengl_canvas_debugger.cpp
opengl/kis_opengl_image_textures.cpp
opengl/kis_texture_tile.cpp
opengl/kis_texture_tile_update_info.cpp
......
......@@ -588,6 +588,12 @@ void PerformanceTab::load(bool requestDefault)
sliderSwapSize->setValue(cfg.maxSwapSize(requestDefault) / 1024);
lblSwapFileLocation->setText(cfg.swapDir(requestDefault));
{
KisConfig cfg2;
chkOpenGLLogging->setChecked(cfg2.enableOpenGLDebugging(requestDefault));
chkDisableVectorOptimizations->setChecked(cfg2.enableAmdVectorizationWorkaround(requestDefault));
}
}
void PerformanceTab::save()
......@@ -604,6 +610,12 @@ void PerformanceTab::save()
cfg.setMaxSwapSize(sliderSwapSize->value() * 1024);
cfg.setSwapDir(lblSwapFileLocation->text());
{
KisConfig cfg2;
cfg2.setEnableOpenGLDebugging(chkOpenGLLogging->isChecked());
cfg2.setEnableAmdVectorizationWorkaround(chkDisableVectorOptimizations->isChecked());
}
}
void PerformanceTab::selectSwapDir()
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>711</width>
<height>407</height>
<width>753</width>
<height>554</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
......@@ -249,6 +249,20 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkOpenGLLogging">
<property name="text">
<string>Enable OpenGL logging</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDisableVectorOptimizations">
<property name="text">
<string>Disable vector optimizations (for AMD CPUs)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -269,15 +283,15 @@
</widget>
<customwidgets>
<customwidget>
<class>KisSliderSpinBox</class>
<class>KisDoubleSliderSpinBox</class>
<extends>QWidget</extends>
<header location="global">kis_slider_spin_box.h</header>
<header>kis_slider_spin_box.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KisDoubleSliderSpinBox</class>
<class>KisSliderSpinBox</class>
<extends>QWidget</extends>
<header>kis_slider_spin_box.h</header>
<header location="global">kis_slider_spin_box.h</header>
<container>1</container>
</customwidget>
</customwidgets>
......
......@@ -1615,3 +1615,23 @@ void KisConfig::setCustomColorSelectorColorSpace(const KoColorSpace *cs)
KisConfigNotifier::instance()->notifyConfigChanged();
}
bool KisConfig::enableOpenGLDebugging(bool defaultValue) const
{
return (defaultValue ? false : m_cfg.readEntry("enableOpenGLDebugging", false));
}
void KisConfig::setEnableOpenGLDebugging(bool value) const
{
m_cfg.writeEntry("enableOpenGLDebugging", value);
}
void KisConfig::setEnableAmdVectorizationWorkaround(bool value) const
{
m_cfg.writeEntry("amdDisableVectorWorkaround", value);
}
bool KisConfig::enableAmdVectorizationWorkaround(bool defaultValue) const
{
return (defaultValue ? false : m_cfg.readEntry("amdDisableVectorWorkaround", false));
}
......@@ -462,6 +462,12 @@ public:
bool toolOptionsInDocker(bool defaultValue = false) const;
void setToolOptionsInDocker(bool inDocker);
void setEnableOpenGLDebugging(bool value) const;
bool enableOpenGLDebugging(bool defaultValue = false) const;
void setEnableAmdVectorizationWorkaround(bool value) const;
bool enableAmdVectorizationWorkaround(bool defaultValue = false) const;
template<class T>
void writeEntry(const QString& name, const T& value) {
m_cfg.writeEntry(name, value);
......
......@@ -64,6 +64,8 @@
#include "kis_coordinates_converter.h"
#include "canvas/kis_display_filter.h"
#include "canvas/kis_display_color_converter.h"
#include "kis_opengl_canvas_debugger.h"
#define NEAR_VAL -1000.0
#define FAR_VAL 1000.0
......@@ -312,8 +314,11 @@ void KisOpenGLCanvas2::paintGL()
cfg.writeEntry("canvasState", "OPENGL_PAINT_STARTED");
}
KisOpenglCanvasDebugger::instance()->nofityPaintRequested();
QPainter gc(this);
gc.beginNativePainting();
renderCanvasGL();
if (d->glSyncObject) {
......@@ -404,7 +409,10 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
bool KisOpenGLCanvas2::isBusy() const
{
return Sync::syncStatus(d->glSyncObject) == Sync::Unsignaled;
const bool isBusyStatus = Sync::syncStatus(d->glSyncObject) == Sync::Unsignaled;
KisOpenglCanvasDebugger::instance()->nofitySyncStatus(isBusyStatus);
return isBusyStatus;
}
inline void rectToVertices(QVector3D* vertices, const QRectF &rc)
......
/*
* Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_opengl_canvas_debugger.h"
#include <QGlobalStatic>
#include <QElapsedTimer>
#include <QDebug>
#include "kis_config.h"
struct KisOpenglCanvasDebugger::Private
{
Private()
: fpsCounter(0),
fpsSum(0),
syncFlaggedCounter(0),
syncFlaggedSum(0),
isEnabled(true) {}
QElapsedTimer time;
int fpsCounter;
int fpsSum;
int syncFlaggedCounter;
int syncFlaggedSum;
bool isEnabled;
};
Q_GLOBAL_STATIC(KisOpenglCanvasDebugger, s_instance)
KisOpenglCanvasDebugger::KisOpenglCanvasDebugger()
: m_d(new Private)
{
KisConfig cfg;
m_d->isEnabled = cfg.enableOpenGLDebugging();
if (m_d->isEnabled) {
m_d->time.start();
}
}
KisOpenglCanvasDebugger::~KisOpenglCanvasDebugger()
{
}
KisOpenglCanvasDebugger*
KisOpenglCanvasDebugger::instance()
{
return s_instance;
}
void KisOpenglCanvasDebugger::nofityPaintRequested()
{
if (!m_d->isEnabled) return;
m_d->fpsSum += m_d->time.restart();
m_d->fpsCounter++;
if (m_d->fpsCounter > 100 && m_d->fpsSum > 0) {
qDebug() << "Requested FPS:" << qreal(m_d->fpsCounter) / m_d->fpsSum * 1000.0;
m_d->fpsSum = 0;
m_d->fpsCounter = 0;
}
}
void KisOpenglCanvasDebugger::nofitySyncStatus(bool isBusy)
{
if (!m_d->isEnabled) return;
m_d->syncFlaggedSum += isBusy;
m_d->syncFlaggedCounter++;
if (m_d->syncFlaggedCounter > 500 && m_d->syncFlaggedSum > 0) {
qDebug() << "glSync effectiveness:" << qreal(m_d->syncFlaggedSum) / m_d->syncFlaggedCounter;
m_d->syncFlaggedSum = 0;
m_d->syncFlaggedCounter = 0;
}
}
/*
* Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __KIS_OPENGL_CANVAS_DEBUGGER_H
#define __KIS_OPENGL_CANVAS_DEBUGGER_H
#include <QScopedPointer>
class KisOpenglCanvasDebugger
{
public:
KisOpenglCanvasDebugger();
~KisOpenglCanvasDebugger();
static KisOpenglCanvasDebugger* instance();
void nofityPaintRequested();
void nofitySyncStatus(bool value);
private:
struct Private;
const QScopedPointer<Private> m_d;
};
#endif /* __KIS_OPENGL_CANVAS_DEBUGGER_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment