2010-03-05 20:42:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Fredrik Höglund <fredrik@kde.org>
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
* Copyright © 2018 Alex Nemeth <alex.nemeth329@gmail.com>
|
2010-03-05 20:42:10 +00:00
|
|
|
*
|
|
|
|
* 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; see the file COPYING. if not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BLURSHADER_H
|
|
|
|
#define BLURSHADER_H
|
|
|
|
|
|
|
|
#include <kwinglutils.h>
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
#include <QVector2D>
|
|
|
|
#include <QVector4D>
|
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
|
2011-01-08 18:56:22 +00:00
|
|
|
class QMatrix4x4;
|
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class BlurShader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BlurShader();
|
2010-03-08 20:45:58 +00:00
|
|
|
virtual ~BlurShader();
|
|
|
|
|
|
|
|
static BlurShader *create();
|
2010-03-05 20:42:10 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool isValid() const {
|
|
|
|
return mValid;
|
|
|
|
}
|
2010-03-12 15:56:19 +00:00
|
|
|
|
2011-07-17 15:57:30 +00:00
|
|
|
virtual void setModelViewProjectionMatrix(const QMatrix4x4 &matrix) = 0;
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
virtual void setOffset(float offset) = 0;
|
|
|
|
virtual void setTargetSize(QSize renderTextureSize) = 0;
|
|
|
|
virtual void setBlurRect(QRect blurRect, QSize screenSize) = 0;
|
|
|
|
|
|
|
|
enum SampleType {
|
|
|
|
DownSampleType,
|
|
|
|
UpSampleType,
|
|
|
|
CopySampleType
|
|
|
|
};
|
2010-03-05 20:42:10 +00:00
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
virtual void bind(SampleType sampleType) = 0;
|
2010-03-08 20:45:58 +00:00
|
|
|
virtual void unbind() = 0;
|
|
|
|
|
|
|
|
protected:
|
2011-01-30 14:34:42 +00:00
|
|
|
void setIsValid(bool value) {
|
|
|
|
mValid = value;
|
|
|
|
}
|
2010-03-08 20:45:58 +00:00
|
|
|
virtual void init() = 0;
|
|
|
|
virtual void reset() = 0;
|
|
|
|
|
|
|
|
private:
|
2010-03-12 15:56:19 +00:00
|
|
|
bool mValid;
|
2010-03-08 20:45:58 +00:00
|
|
|
};
|
2010-03-05 20:42:10 +00:00
|
|
|
|
2010-03-08 20:45:58 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GLSLBlurShader : public BlurShader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLSLBlurShader();
|
|
|
|
~GLSLBlurShader();
|
|
|
|
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
void bind(SampleType sampleType) override final;
|
|
|
|
void unbind() override final;
|
|
|
|
void setModelViewProjectionMatrix(const QMatrix4x4 &matrix) override final;
|
|
|
|
void setOffset(float offset) override final;
|
|
|
|
void setTargetSize(QSize renderTextureSize) override final;
|
|
|
|
void setBlurRect(QRect blurRect, QSize screenSize) override final;
|
2010-03-05 20:42:10 +00:00
|
|
|
|
2010-03-08 20:45:58 +00:00
|
|
|
protected:
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
void init() override final;
|
|
|
|
void reset() override final;
|
2010-03-08 20:45:58 +00:00
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
private:
|
Updated the blur method to use the more efficient dual kawase blur algorithm.
Summary:
Updated the old and outdated blur method to use the much more efficient dual kawase blur method.
Now with this we can do virtually infinite blur with very very little performance cost.
The dual kawase blur method is basically downscaling and upscaling an image, but combined with the kawase blur shader.
Comparison: https://i.imgur.com/mh6Cw61.png
Left is old, right is new.
Comparison was done with the strongest blur setting in a VM running on an Intel i7-4790 and a GTX980
We can see here that the performance is even better with this new method.
Reviewers: #plasma, #kwin, graesslin, fredrik
Reviewed By: fredrik
Subscribers: hein, dos, luebking, broulik, romangg, zzag, anthonyfieroni, mart, davidedmundson, fredrik, ngraham, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9848
2018-01-25 17:31:11 +00:00
|
|
|
GLShader *m_shaderDownsample = nullptr;
|
|
|
|
GLShader *m_shaderUpsample = nullptr;
|
|
|
|
GLShader *m_shaderCopysample = nullptr;
|
|
|
|
|
|
|
|
int m_mvpMatrixLocationDownsample;
|
|
|
|
int m_offsetLocationDownsample;
|
|
|
|
int m_renderTextureSizeLocationDownsample;
|
|
|
|
int m_halfpixelLocationDownsample;
|
|
|
|
|
|
|
|
int m_mvpMatrixLocationUpsample;
|
|
|
|
int m_offsetLocationUpsample;
|
|
|
|
int m_renderTextureSizeLocationUpsample;
|
|
|
|
int m_halfpixelLocationUpsample;
|
|
|
|
|
|
|
|
int m_mvpMatrixLocationCopysample;
|
|
|
|
int m_renderTextureSizeLocationCopysample;
|
|
|
|
int m_blurRectLocationCopysample;
|
|
|
|
|
|
|
|
|
|
|
|
//Caching uniform values to aviod unnecessary setUniform calls
|
|
|
|
int m_activeSampleType;
|
|
|
|
|
|
|
|
float m_offsetDownsample;
|
|
|
|
QMatrix4x4 m_matrixDownsample;
|
|
|
|
QSize m_renderTextureSizeDownsample;
|
|
|
|
|
|
|
|
float m_offsetUpsample;
|
|
|
|
QMatrix4x4 m_matrixUpsample;
|
|
|
|
QSize m_renderTextureSizeUpsample;
|
|
|
|
|
|
|
|
QMatrix4x4 m_matrixCopysample;
|
|
|
|
QSize m_renderTextureSizeCopysample;
|
|
|
|
QRect m_blurRectCopysample;
|
|
|
|
|
2010-03-08 20:45:58 +00:00
|
|
|
};
|
|
|
|
|
2010-03-05 20:42:10 +00:00
|
|
|
} // namespace KWin
|
|
|
|
|
|
|
|
#endif
|