Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EGL #11982

Merged
merged 6 commits into from
Sep 14, 2023
Merged

EGL #11982

Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/shaders/endoftrackshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ using namespace mixxx;

void EndOfTrackShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
attribute vec4 position;
attribute float gradient;
varying float vgradient;
attribute highp vec4 position;
attribute highp float gradient;
varying highp float vgradient;
void main()
{
vgradient = gradient;
Expand All @@ -15,12 +15,12 @@ void main()
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
uniform vec4 color;
varying float vgradient;
uniform highp vec4 color;
varying highp float vgradient;
void main()
{
float minAlpha = 0.5 * color.w;
float maxAlpha = 0.83 * color.w;
float minAlpha = 0.5f * color.w;
float maxAlpha = 0.83f * color.w;
gl_FragColor = vec4(color.xyz, mix(minAlpha, maxAlpha, max(0.,vgradient)));
}
)--");
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/rgbashader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void RGBAShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec4 color;
varying vec4 vcolor;
attribute highp vec4 position;
attribute highp vec4 color;
varying highp vec4 vcolor;
void main()
{
vcolor = color;
Expand All @@ -16,7 +16,7 @@ void main()
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
varying vec4 vcolor;
varying highp vec4 vcolor;
void main()
{
gl_FragColor = vcolor;
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/rgbshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void RGBShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec3 color;
varying vec3 vcolor;
attribute highp vec4 position;
attribute highp vec3 color;
varying highp vec3 vcolor;
void main()
{
vcolor = color;
Expand All @@ -16,7 +16,7 @@ void main()
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
varying vec3 vcolor;
varying highp vec3 vcolor;
void main()
{
gl_FragColor = vec4(vcolor,1.0);
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/textureshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void TextureShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec3 texcoor;
varying vec3 vTexcoor;
attribute highp vec4 position;
attribute highp vec3 texcoor;
varying highp vec3 vTexcoor;
void main()
{
vTexcoor = texcoor;
Expand All @@ -17,7 +17,7 @@ void main()

QString fragmentShaderCode = QStringLiteral(R"--(
uniform sampler2D sampler;
varying vec3 vTexcoor;
varying highp vec3 vTexcoor;
void main()
{
gl_FragColor = texture2D(sampler, vTexcoor.xy);
Expand Down
4 changes: 2 additions & 2 deletions src/shaders/unicolorshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ using namespace mixxx;
void UnicolorShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute highp vec4 position;
void main()
{
gl_Position = matrix * position;
}
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
uniform vec4 color;
uniform highp vec4 color;
void main()
{
gl_FragColor = color;
Expand Down
12 changes: 6 additions & 6 deletions src/shaders/vinylqualityshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void VinylQualityShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec3 texcoor;
varying vec3 vTexcoor;
attribute highp vec4 position;
attribute highp vec3 texcoor;
varying highp vec3 vTexcoor;
void main()
{
vTexcoor = texcoor;
Expand All @@ -17,11 +17,11 @@ void main()

QString fragmentShaderCode = QStringLiteral(R"--(
uniform sampler2D sampler;
uniform vec4 color;
varying vec3 vTexcoor;
uniform highp vec4 color;
varying highp vec3 vTexcoor;
void main()
{
gl_FragColor = vec4(color.xyz, texture2D(sampler, vTexcoor.xy) * 0.75);
gl_FragColor = vec4(color.xyz, texture2D(sampler, vTexcoor.xy) * 0.75f);
}
)--");

Expand Down
28 changes: 19 additions & 9 deletions src/waveform/waveformwidgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ WaveformWidgetFactory::WaveformWidgetFactory()
m_openGLVersion = pContext->isOpenGLES() ? "ES " : "";
m_openGLVersion += majorVersion == 0 ? QString("None") : versionString;

if (majorVersion * 100 + minorVersion >= 201) {
if (pContext->isOpenGLES()) {
// Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0
if (pContext->isOpenGLES()) {
if (majorVersion * 100 + minorVersion >= 200) {
m_openGlesAvailable = true;
} else {
}
} else {
if (majorVersion * 100 + minorVersion >= 201) {
m_openGlAvailable = true;
}
}
Expand Down Expand Up @@ -1168,14 +1171,17 @@ QString WaveformWidgetFactory::buildWidgetDisplayName() const {
extras.push_back(tr("legacy"));
}
if (isOpenGlAvailable() || isOpenGlesAvailable()) {
if (WaveformT::useOpenGLShaders()) {
if (WaveformT::useOpenGles()) {
if (WaveformT::useOpenGLShaders()) {
extras.push_back(QStringLiteral("GLSL ES"));
} else {
extras.push_back(QStringLiteral("GLES"));
}
} else if (WaveformT::useOpenGLShaders()) {
extras.push_back(QStringLiteral("GLSL"));
} else if (WaveformT::useOpenGl()) {
extras.push_back(QStringLiteral("GL"));
}
if (WaveformT::useOpenGles()) {
extras.push_back(QStringLiteral("ES"));
}
}
QString name = WaveformT::getWaveformWidgetName();
if (extras.isEmpty()) {
Expand All @@ -1187,8 +1193,12 @@ QString WaveformWidgetFactory::buildWidgetDisplayName() const {
// static
QSurfaceFormat WaveformWidgetFactory::getSurfaceFormat() {
QSurfaceFormat format;
format.setVersion(2, 1);
format.setProfile(QSurfaceFormat::CoreProfile);
// Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0, default is 2.0
// format.setVersion(2, 1);
// Core and Compatibility contexts have been introduced in openGL 3.2
// From 3.0 to 3.1 we have implicit the Core profile and Before 3.0 we have the
// Compatibility profile
// format.setProfile(QSurfaceFormat::CoreProfile);

// setSwapInterval sets the application preferred swap interval
// in minimum number of video frames that are displayed before a buffer swap occurs
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/filteredwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::FilteredWaveformWidget final : public allshader::WaveformWidget
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/hsvwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::HSVWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/lrrgbwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::LRRGBWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/rgbwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::RGBWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/simplewaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::SimpleWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down