aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rusak <lorusak@gmail.com>2018-05-25 01:15:13 -0700
committerRainer Hochecker <fernetmenta@online.de>2018-05-25 10:22:08 +0200
commit1ba4b5d3e1825cf5b0d22e96e5dc877da32ed325 (patch)
tree29b2d9452da002021846b46d774c6c9d737968df
parent7462ec309ebfab6534ea8f8da698de39c8555c9e (diff)
OpenGLES: fix limited range for gui
-rw-r--r--system/shaders/GLES/2.0/gles_shader_multi.frag4
-rw-r--r--system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag4
-rw-r--r--system/shaders/GLES/2.0/gles_shader_texture.frag4
-rw-r--r--system/shaders/GLES/2.0/gles_shader_texture_noblend.frag4
-rw-r--r--xbmc/rendering/gles/GLESShader.cpp10
-rw-r--r--xbmc/rendering/gles/GLESShader.h5
-rw-r--r--xbmc/rendering/gles/RenderSystemGLES.cpp103
-rw-r--r--xbmc/rendering/gles/RenderSystemGLES.h3
8 files changed, 118 insertions, 19 deletions
diff --git a/system/shaders/GLES/2.0/gles_shader_multi.frag b/system/shaders/GLES/2.0/gles_shader_multi.frag
index 49202d2848..7f76358124 100644
--- a/system/shaders/GLES/2.0/gles_shader_multi.frag
+++ b/system/shaders/GLES/2.0/gles_shader_multi.frag
@@ -30,4 +30,8 @@ varying vec4 m_cord1;
void main ()
{
gl_FragColor.rgba = (texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy)).rgba;
+#if defined(KODI_LIMITED_RANGE)
+ gl_FragColor.rgb *= (235.0-16.0) / 255.0;
+ gl_FragColor.rgb += 16.0 / 255.0;
+#endif
}
diff --git a/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag b/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag
index c01ecd29e7..062f292f28 100644
--- a/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag
+++ b/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag
@@ -31,4 +31,8 @@ uniform lowp vec4 m_unicol;
void main ()
{
gl_FragColor.rgba = m_unicol * texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy);
+#if defined(KODI_LIMITED_RANGE)
+ gl_FragColor.rgb *= (235.0-16.0) / 255.0;
+ gl_FragColor.rgb += 16.0 / 255.0;
+#endif
}
diff --git a/system/shaders/GLES/2.0/gles_shader_texture.frag b/system/shaders/GLES/2.0/gles_shader_texture.frag
index 82b60d9a02..e664330ffd 100644
--- a/system/shaders/GLES/2.0/gles_shader_texture.frag
+++ b/system/shaders/GLES/2.0/gles_shader_texture.frag
@@ -29,4 +29,8 @@ varying vec4 m_cord0;
void main ()
{
gl_FragColor.rgba = vec4(texture2D(m_samp0, m_cord0.xy).rgba * m_unicol);
+#if defined(KODI_LIMITED_RANGE)
+ gl_FragColor.rgb *= (235.0-16.0) / 255.0;
+ gl_FragColor.rgb += 16.0 / 255.0;
+#endif
}
diff --git a/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag b/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag
index 7072a167f0..1752c4cc03 100644
--- a/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag
+++ b/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag
@@ -28,4 +28,8 @@ varying vec4 m_cord0;
void main ()
{
gl_FragColor.rgba = vec4(texture2D(m_samp0, m_cord0.xy).rgba);
+#if defined(KODI_LIMITED_RANGE)
+ gl_FragColor.rgb *= (235.0-16.0) / 255.0;
+ gl_FragColor.rgb += 16.0 / 255.0;
+#endif
}
diff --git a/xbmc/rendering/gles/GLESShader.cpp b/xbmc/rendering/gles/GLESShader.cpp
index 8053fabecc..bf23ef7fe9 100644
--- a/xbmc/rendering/gles/GLESShader.cpp
+++ b/xbmc/rendering/gles/GLESShader.cpp
@@ -27,18 +27,24 @@
using namespace Shaders;
-CGLESShader::CGLESShader( const char *shader ) : CGLSLShaderProgram("gles_shader.vert", shader)
+CGLESShader::CGLESShader( const char *shader, std::string prefix)
{
m_proj = nullptr;
m_model = nullptr;
m_clipPossible = false;
+
+ VertexShader()->LoadSource("gles_shader.vert");
+ PixelShader()->LoadSource(shader, prefix);
}
-CGLESShader::CGLESShader(const char *vshader, const char *fshader) : CGLSLShaderProgram(vshader, fshader)
+CGLESShader::CGLESShader(const char *vshader, const char *fshader, std::string prefix)
{
m_proj = nullptr;
m_model = nullptr;
m_clipPossible = false;
+
+ VertexShader()->LoadSource(vshader, prefix);
+ PixelShader()->LoadSource(fshader, prefix);
}
void CGLESShader::OnCompiledAndLinked()
diff --git a/xbmc/rendering/gles/GLESShader.h b/xbmc/rendering/gles/GLESShader.h
index 054dba17e8..fdb688bd49 100644
--- a/xbmc/rendering/gles/GLESShader.h
+++ b/xbmc/rendering/gles/GLESShader.h
@@ -21,12 +21,13 @@
#pragma once
#include "xbmc/guilib/Shader.h"
+#include <string>
class CGLESShader : public Shaders::CGLSLShaderProgram
{
public:
- CGLESShader( const char *shader = 0 );
- CGLESShader(const char *vshader, const char *fshader);
+ CGLESShader( const char *shader, std::string prefix);
+ CGLESShader(const char *vshader, const char *fshader, std::string prefix);
void OnCompiledAndLinked();
bool OnEnabled();
void Free();
diff --git a/xbmc/rendering/gles/RenderSystemGLES.cpp b/xbmc/rendering/gles/RenderSystemGLES.cpp
index 4ef6905692..e1634f61f3 100644
--- a/xbmc/rendering/gles/RenderSystemGLES.cpp
+++ b/xbmc/rendering/gles/RenderSystemGLES.cpp
@@ -89,7 +89,7 @@ bool CRenderSystemGLES::InitRenderSystem()
m_bRenderCreated = true;
- InitialiseShader();
+ InitialiseShaders();
return true;
}
@@ -138,6 +138,7 @@ bool CRenderSystemGLES::DestroyRenderSystem()
glFinish();
PresentRenderImpl(true);
+ ReleaseShaders();
m_bRenderCreated = false;
return true;
@@ -148,7 +149,16 @@ bool CRenderSystemGLES::BeginRender()
if (!m_bRenderCreated)
return false;
- m_limitedColorRange = CServiceBroker::GetWinSystem()->UseLimitedColor();
+ bool useLimited = CServiceBroker::GetWinSystem()->UseLimitedColor();
+
+ if (m_limitedColorRange != useLimited)
+ {
+ ReleaseShaders();
+ InitialiseShaders();
+ }
+
+ m_limitedColorRange = useLimited;
+
return true;
}
@@ -453,9 +463,16 @@ void CRenderSystemGLES::ResetScissors()
SetScissors(CRect(0, 0, (float)m_width, (float)m_height));
}
-void CRenderSystemGLES::InitialiseShader()
+void CRenderSystemGLES::InitialiseShaders()
{
- m_pShader[SM_DEFAULT] = new CGLESShader("gles_shader.vert", "gles_shader_default.frag");
+ std::string defines;
+ m_limitedColorRange = CServiceBroker::GetWinSystem()->UseLimitedColor();
+ if (m_limitedColorRange)
+ {
+ defines += "#define KODI_LIMITED_RANGE 1\n";
+ }
+
+ m_pShader[SM_DEFAULT] = new CGLESShader("gles_shader.vert", "gles_shader_default.frag", defines);
if (!m_pShader[SM_DEFAULT]->CompileAndLink())
{
m_pShader[SM_DEFAULT]->Free();
@@ -464,7 +481,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_default.frag - compile and link failed");
}
- m_pShader[SM_TEXTURE] = new CGLESShader("gles_shader_texture.frag");
+ m_pShader[SM_TEXTURE] = new CGLESShader("gles_shader_texture.frag", defines);
if (!m_pShader[SM_TEXTURE]->CompileAndLink())
{
m_pShader[SM_TEXTURE]->Free();
@@ -473,7 +490,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_texture.frag - compile and link failed");
}
- m_pShader[SM_MULTI] = new CGLESShader("gles_shader_multi.frag");
+ m_pShader[SM_MULTI] = new CGLESShader("gles_shader_multi.frag", defines);
if (!m_pShader[SM_MULTI]->CompileAndLink())
{
m_pShader[SM_MULTI]->Free();
@@ -482,7 +499,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_multi.frag - compile and link failed");
}
- m_pShader[SM_FONTS] = new CGLESShader("gles_shader_fonts.frag");
+ m_pShader[SM_FONTS] = new CGLESShader("gles_shader_fonts.frag", defines);
if (!m_pShader[SM_FONTS]->CompileAndLink())
{
m_pShader[SM_FONTS]->Free();
@@ -491,7 +508,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_fonts.frag - compile and link failed");
}
- m_pShader[SM_TEXTURE_NOBLEND] = new CGLESShader("gles_shader_texture_noblend.frag");
+ m_pShader[SM_TEXTURE_NOBLEND] = new CGLESShader("gles_shader_texture_noblend.frag", defines);
if (!m_pShader[SM_TEXTURE_NOBLEND]->CompileAndLink())
{
m_pShader[SM_TEXTURE_NOBLEND]->Free();
@@ -500,7 +517,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_texture_noblend.frag - compile and link failed");
}
- m_pShader[SM_MULTI_BLENDCOLOR] = new CGLESShader("gles_shader_multi_blendcolor.frag");
+ m_pShader[SM_MULTI_BLENDCOLOR] = new CGLESShader("gles_shader_multi_blendcolor.frag", defines);
if (!m_pShader[SM_MULTI_BLENDCOLOR]->CompileAndLink())
{
m_pShader[SM_MULTI_BLENDCOLOR]->Free();
@@ -509,7 +526,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_multi_blendcolor.frag - compile and link failed");
}
- m_pShader[SM_TEXTURE_RGBA] = new CGLESShader("gles_shader_rgba.frag");
+ m_pShader[SM_TEXTURE_RGBA] = new CGLESShader("gles_shader_rgba.frag", defines);
if (!m_pShader[SM_TEXTURE_RGBA]->CompileAndLink())
{
m_pShader[SM_TEXTURE_RGBA]->Free();
@@ -518,7 +535,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_rgba.frag - compile and link failed");
}
- m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR] = new CGLESShader("gles_shader_rgba_blendcolor.frag");
+ m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR] = new CGLESShader("gles_shader_rgba_blendcolor.frag", defines);
if (!m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR]->CompileAndLink())
{
m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR]->Free();
@@ -527,7 +544,7 @@ void CRenderSystemGLES::InitialiseShader()
CLog::Log(LOGERROR, "GUI Shader gles_shader_rgba_blendcolor.frag - compile and link failed");
}
- m_pShader[SM_TEXTURE_RGBA_BOB] = new CGLESShader("gles_shader_rgba_bob.frag");
+ m_pShader[SM_TEXTURE_RGBA_BOB] = new CGLESShader("gles_shader_rgba_bob.frag", defines);
if (!m_pShader[SM_TEXTURE_RGBA_BOB]->CompileAndLink())
{
m_pShader[SM_TEXTURE_RGBA_BOB]->Free();
@@ -538,7 +555,7 @@ void CRenderSystemGLES::InitialiseShader()
if (IsExtSupported("GL_OES_EGL_image_external"))
{
- m_pShader[SM_TEXTURE_RGBA_OES] = new CGLESShader("gles_shader_rgba_oes.frag");
+ m_pShader[SM_TEXTURE_RGBA_OES] = new CGLESShader("gles_shader_rgba_oes.frag", defines);
if (!m_pShader[SM_TEXTURE_RGBA_OES]->CompileAndLink())
{
m_pShader[SM_TEXTURE_RGBA_OES]->Free();
@@ -548,7 +565,7 @@ void CRenderSystemGLES::InitialiseShader()
}
- m_pShader[SM_TEXTURE_RGBA_BOB_OES] = new CGLESShader("gles_shader_rgba_bob_oes.frag");
+ m_pShader[SM_TEXTURE_RGBA_BOB_OES] = new CGLESShader("gles_shader_rgba_bob_oes.frag", defines);
if (!m_pShader[SM_TEXTURE_RGBA_BOB_OES]->CompileAndLink())
{
m_pShader[SM_TEXTURE_RGBA_BOB_OES]->Free();
@@ -564,6 +581,64 @@ void CRenderSystemGLES::InitialiseShader()
}
}
+void CRenderSystemGLES::ReleaseShaders()
+{
+ if (m_pShader[SM_DEFAULT])
+ m_pShader[SM_DEFAULT]->Free();
+ delete m_pShader[SM_DEFAULT];
+ m_pShader[SM_DEFAULT] = nullptr;
+
+ if (m_pShader[SM_TEXTURE])
+ m_pShader[SM_TEXTURE]->Free();
+ delete m_pShader[SM_TEXTURE];
+ m_pShader[SM_TEXTURE] = nullptr;
+
+ if (m_pShader[SM_MULTI])
+ m_pShader[SM_MULTI]->Free();
+ delete m_pShader[SM_MULTI];
+ m_pShader[SM_MULTI] = nullptr;
+
+ if (m_pShader[SM_FONTS])
+ m_pShader[SM_FONTS]->Free();
+ delete m_pShader[SM_FONTS];
+ m_pShader[SM_FONTS] = nullptr;
+
+ if (m_pShader[SM_TEXTURE_NOBLEND])
+ m_pShader[SM_TEXTURE_NOBLEND]->Free();
+ delete m_pShader[SM_TEXTURE_NOBLEND];
+ m_pShader[SM_TEXTURE_NOBLEND] = nullptr;
+
+ if (m_pShader[SM_MULTI_BLENDCOLOR])
+ m_pShader[SM_MULTI_BLENDCOLOR]->Free();
+ delete m_pShader[SM_MULTI_BLENDCOLOR];
+ m_pShader[SM_MULTI_BLENDCOLOR] = nullptr;
+
+ if (m_pShader[SM_TEXTURE_RGBA])
+ m_pShader[SM_TEXTURE_RGBA]->Free();
+ delete m_pShader[SM_TEXTURE_RGBA];
+ m_pShader[SM_TEXTURE_RGBA] = nullptr;
+
+ if (m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR])
+ m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR]->Free();
+ delete m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR];
+ m_pShader[SM_TEXTURE_RGBA_BLENDCOLOR] = nullptr;
+
+ if (m_pShader[SM_TEXTURE_RGBA_BOB])
+ m_pShader[SM_TEXTURE_RGBA_BOB]->Free();
+ delete m_pShader[SM_TEXTURE_RGBA_BOB];
+ m_pShader[SM_TEXTURE_RGBA_BOB] = nullptr;
+
+ if (m_pShader[SM_TEXTURE_RGBA_OES])
+ m_pShader[SM_TEXTURE_RGBA_OES]->Free();
+ delete m_pShader[SM_TEXTURE_RGBA_OES];
+ m_pShader[SM_TEXTURE_RGBA_OES] = nullptr;
+
+ if (m_pShader[SM_TEXTURE_RGBA_BOB_OES])
+ m_pShader[SM_TEXTURE_RGBA_BOB_OES]->Free();
+ delete m_pShader[SM_TEXTURE_RGBA_BOB_OES];
+ m_pShader[SM_TEXTURE_RGBA_BOB_OES] = nullptr;
+}
+
void CRenderSystemGLES::EnableGUIShader(ESHADERMETHOD method)
{
m_method = method;
diff --git a/xbmc/rendering/gles/RenderSystemGLES.h b/xbmc/rendering/gles/RenderSystemGLES.h
index 18e2c9d83e..946db71595 100644
--- a/xbmc/rendering/gles/RenderSystemGLES.h
+++ b/xbmc/rendering/gles/RenderSystemGLES.h
@@ -83,7 +83,8 @@ public:
std::string GetShaderPath(const std::string &filename) override { return "GLES/2.0/"; }
- void InitialiseShader();
+ void InitialiseShaders();
+ void ReleaseShaders();
void EnableGUIShader(ESHADERMETHOD method);
void DisableGUIShader();