Skip to content

Commit

Permalink
Fix regressions in GLES 2.0 support introduced by a405ad8
Browse files Browse the repository at this point in the history
- IOS compiler also doesn't like the vec2 as return Type, thus it's made a out param
  • Loading branch information
m4xw authored and gonetz committed May 31, 2020
1 parent 46d170e commit 4f58d66
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions src/Graphics/OpenGLContext/GLSL/glsl_CombinerProgramBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,8 @@ class ShaderFragmentGlobalVariablesTex : public ShaderPart
"uniform lowp int uScreenSpaceTriangle; \n"
"highp vec2 texCoord0; \n"
"highp vec2 texCoord1; \n"
"highp vec2[5] tcData0; \n"
"highp vec2[5] tcData1; \n"
"highp vec2 tcData0[5]; \n"
"highp vec2 tcData1[5]; \n"
;

if (config.generalEmulation.enableLegacyBlending != 0) {
Expand Down Expand Up @@ -1083,8 +1083,8 @@ class ShaderFragmentHeaderTextureEngine : public ShaderPart
"highp vec2 clampWrapMirror(in highp vec2 vTexCoord, \n"
" in highp vec2 vWrap, in highp vec2 vClamp, \n"
" in lowp vec2 vClampEn, in lowp vec2 vMirrorEn ); \n"
"highp vec2[5] textureEngine0(in highp vec2 texCoord); \n"
"highp vec2[5] textureEngine1(in highp vec2 texCoord); \n"
"void textureEngine0(in highp vec2 texCoord, out highp vec2 tcData[5]); \n"
"void textureEngine1(in highp vec2 texCoord, out highp vec2 tcData[5]); \n"
;
}
};
Expand All @@ -1103,7 +1103,7 @@ class ShaderFragmentHeaderReadMSTex : public ShaderPart
(g_cycleType == G_CYC_COPY || g_textureConvert.useTextureFiltering()))
{
shader <<
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in highp vec2[5] tcData, in lowp int fbMonochrome, in lowp int fbFixedAlpha);\n";
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in highp vec2 tcData[5], in lowp int fbMonochrome, in lowp int fbFixedAlpha);\n";
}
}

Expand Down Expand Up @@ -1305,15 +1305,15 @@ class ShaderFragmentHeaderReadTex : public ShaderPart
if (g_textureConvert.useTextureFiltering()) {
shaderPart +=
"uniform lowp int uTextureFilterMode; \n"
"lowp vec4 readTex(in sampler2D tex, in highp vec2[5] tcData, in lowp int fbMonochrome, in lowp int fbFixedAlpha); \n"
"lowp vec4 readTex(in sampler2D tex, in highp vec2 tcData[5], in lowp int fbMonochrome, in lowp int fbFixedAlpha); \n"
;
}
if (g_textureConvert.useYUVCoversion()) {
shaderPart +=
"uniform lowp ivec2 uTextureFormat; \n"
"uniform lowp int uTextureConvert; \n"
"uniform mediump ivec4 uConvertParams; \n"
"lowp vec4 YUV_Convert(in sampler2D tex, in highp vec2[5] tcData, in lowp int convert, in lowp int format, in lowp vec4 prev); \n"
"lowp vec4 YUV_Convert(in sampler2D tex, in highp vec2 tcData[5], in lowp int convert, in lowp int format, in lowp vec4 prev); \n"
;
}
}
Expand Down Expand Up @@ -1352,7 +1352,7 @@ class ShaderFragmentHeaderReadTexCopyMode : public ShaderPart
;
} else {
m_part =
"lowp vec4 readTex(in sampler2D tex, in highp vec2[5] tcData, in lowp int fbMonochrome, in lowp int fbFixedAlpha); \n"
"lowp vec4 readTex(in sampler2D tex, in highp vec2 tcData[5], in lowp int fbMonochrome, in lowp int fbFixedAlpha); \n"
;
}
}
Expand Down Expand Up @@ -1821,8 +1821,9 @@ class ShaderMipmap : public ShaderPart
ShaderMipmap(const opengl::GLInfo & _glinfo)
{
if (_glinfo.isGLES2) {
"uniform mediump vec2 uTextureSize[2]; \n"
"lowp vec4 TextureMipMap(in sampler2D tex, in highp vec2[5] tcData, in lowp float lod) \n"
m_part =
"uniform mediump vec2 uTextureSize[2]; \n"
"lowp vec4 TextureMipMap(in sampler2D tex, in highp vec2 tcData[5], in lowp float lod) \n"
"{ \n"
" mediump vec2 texSize; \n"
" if (nCurrentTile == 0) \n"
Expand All @@ -1840,7 +1841,7 @@ class ShaderMipmap : public ShaderPart
;
if (config.generalEmulation.enableLOD == 0) {
// Fake mipmap
m_part =
m_part +=
"uniform lowp int uMaxTile; \n"
"uniform mediump float uMinLod; \n"
" \n"
Expand All @@ -1852,7 +1853,7 @@ class ShaderMipmap : public ShaderPart
"} \n"
;
} else {
m_part =
m_part +=
"uniform lowp int uEnableLod; \n"
"uniform mediump float uMinLod; \n"
"uniform lowp int uMaxTile; \n"
Expand Down Expand Up @@ -2069,7 +2070,7 @@ class ShaderReadtex : public ShaderPart
if (m_glinfo.isGLES2) {
shaderPart +=
"uniform mediump vec2 uTextureSize[2]; \n"
"lowp vec4 TextureNearest(in sampler2D tex, in highp vec2[5] tcData) \n"
"lowp vec4 TextureNearest(in sampler2D tex, in highp vec2 tcData[5]) \n"
"{ \n"
" mediump vec2 texSize; \n"
" if (nCurrentTile == 0) \n"
Expand All @@ -2081,7 +2082,7 @@ class ShaderReadtex : public ShaderPart
;
if (g_textureConvert.useYUVCoversion())
shaderPart +=
"lowp vec4 YUV_Convert(in sampler2D tex, in highp vec2[5] tcData, in lowp int convert, in lowp int format, in lowp vec4 prev) \n"
"lowp vec4 YUV_Convert(in sampler2D tex, in highp vec2 tcData[5], in lowp int convert, in lowp int format, in lowp vec4 prev) \n"
"{ \n"
" lowp vec4 texColor; \n"
" if (convert != 0) texColor = prev; \n"
Expand All @@ -2104,7 +2105,7 @@ class ShaderReadtex : public ShaderPart
// 3 point texture filtering.
// Original author: ArthurCarvalho
// GLSL implementation: twinaphex, mupen64plus-libretro project.
"lowp vec4 TextureFilter(in sampler2D tex, in highp vec2[5] tcData) \n"
"lowp vec4 TextureFilter(in sampler2D tex, in highp vec2 tcData[5]) \n"
"{ \n"
" mediump vec2 texSize; \n"
" if (nCurrentTile == 0) \n"
Expand All @@ -2125,7 +2126,7 @@ class ShaderReadtex : public ShaderPart
shaderPart +=
// bilinear filtering.
//"uniform mediump vec2 uTextureSize[2]; \n" NOT NEEDED HERE?
"lowp vec4 TextureFilter(in sampler2D tex, in highp vec2[5] tcData) \n"
"lowp vec4 TextureFilter(in sampler2D tex, in highp vec2 tcData[5]) \n"
"{ \n"
" mediump vec2 texSize; \n"
" if (nCurrentTile == 0) \n"
Expand All @@ -2143,7 +2144,7 @@ class ShaderReadtex : public ShaderPart
;
}
shaderPart +=
"lowp vec4 readTex(in sampler2D tex, in highp vec2[5] tcData, in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"lowp vec4 readTex(in sampler2D tex, in highp vec2 tcData[5], in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"{ \n"
" lowp vec4 texColor; \n"
" if (uTextureFilterMode == 0) texColor = TextureNearest(tex, tcData); \n"
Expand All @@ -2168,7 +2169,7 @@ class ShaderReadtex : public ShaderPart
" return texel / float(uMSAASamples); \n"
"} \n"
" \n"
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in highp vec2[5] tcData, in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in highp vec2 tcData[5], in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"{ \n"
" mediump ivec2 itexCoord; \n"
" if (fbMonochrome == 3) { \n"
Expand Down Expand Up @@ -2206,7 +2207,7 @@ class ShaderReadtexCopyMode : public ShaderPart
if (_glinfo.isGLES2) {
m_part =
"uniform mediump vec2 uTextureSize[2]; \n"
"lowp vec4 TextureNearest(in sampler2D tex, in highp vec2[5] tcData) \n"
"lowp vec4 TextureNearest(in sampler2D tex, in highp vec2 tcData[5]) \n"
"{ \n"
" mediump vec2 texSize; \n"
" if (nCurrentTile == 0) \n"
Expand All @@ -2215,7 +2216,7 @@ class ShaderReadtexCopyMode : public ShaderPart
" texSize = uTextureSize[1]; \n"
" return texture2D(tex, (tcData[0] + 0.5) / texSize); \n"
" } \n"
"lowp vec4 readTex(in sampler2D tex, in highp vec2[5] tcData, in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"lowp vec4 readTex(in sampler2D tex, in highp vec2 tcData[5], in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"{ \n"
" lowp vec4 texColor = TextureNearest(tex, tcData); \n"
" if (fbMonochrome == 1) texColor = vec4(texColor.r); \n"
Expand All @@ -2237,7 +2238,7 @@ class ShaderReadtexCopyMode : public ShaderPart
" return texel / float(uMSAASamples); \n"
"} \n"
" \n"
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in highp vec2[5] tcData, in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"lowp vec4 readTexMS(in lowp sampler2DMS mstex, in highp vec2 tcData[5], in lowp int fbMonochrome, in lowp int fbFixedAlpha) \n"
"{ \n"
" mediump ivec2 itexCoord; \n"
" if (fbMonochrome == 3) { \n"
Expand Down Expand Up @@ -2406,9 +2407,8 @@ class ShaderTextureEngine : public ShaderPart
"} \n"

"uniform highp vec2 uTexSize0; \n"
"highp vec2[5] textureEngine0(in highp vec2 texCoord) \n"
"void textureEngine0(in highp vec2 texCoord, out highp vec2 tcData[5]) \n"
"{ \n"
" highp vec2[5] tcData; \n" // {tc00, tc01, tc10, tc11, frPart}
" mediump vec2 intPart = floor(texCoord); \n"
" highp vec2 tc00 = clampWrapMirror(intPart, uTexWrap0, uTexClamp0, uTexWrapEn0, uTexClampEn0, uTexMirrorEn0); \n"
" highp vec2 tc11 = clampWrapMirror(intPart + vec2(1.0,1.0), uTexWrap0, uTexClamp0, uTexWrapEn0, uTexClampEn0, uTexMirrorEn0); \n"
Expand All @@ -2417,13 +2417,11 @@ class ShaderTextureEngine : public ShaderPart
" tcData[1] = vec2(tcData[0].s, tcData[3].t); \n"
" tcData[2] = vec2(tcData[3].s, tcData[0].t); \n"
" tcData[4] = texCoord - intPart; \n"
" return tcData;"
"} \n"

"uniform highp vec2 uTexSize1; \n"
"highp vec2[5] textureEngine1(in highp vec2 texCoord) \n"
"void textureEngine1(in highp vec2 texCoord, out highp vec2 tcData[5]) \n"
"{ \n"
" highp vec2[5] tcData; \n" // {tc00, tc01, tc10, tc11, frPart}
" mediump vec2 intPart = floor(texCoord); \n"
" highp vec2 tc00 = clampWrapMirror(intPart, uTexWrap1, uTexClamp1, uTexWrapEn1, uTexClampEn1, uTexMirrorEn1); \n"
" highp vec2 tc11 = clampWrapMirror(intPart + vec2(1.0,1.0), uTexWrap1, uTexClamp1, uTexWrapEn1, uTexClampEn1, uTexMirrorEn1); \n"
Expand All @@ -2432,7 +2430,6 @@ class ShaderTextureEngine : public ShaderPart
" tcData[1] = vec2(tcData[0].s, tcData[3].t); \n"
" tcData[2] = vec2(tcData[3].s, tcData[0].t); \n"
" tcData[4] = texCoord - intPart; \n"
" return tcData;"
"} \n"

;
Expand All @@ -2445,7 +2442,7 @@ class ShaderFragmentTextureEngineTex0 : public ShaderPart {
ShaderFragmentTextureEngineTex0(const opengl::GLInfo _glinfo)
{
m_part =
"tcData0 = textureEngine0(vTexCoord0); \n"
"textureEngine0(vTexCoord0, tcData0); \n"
;
}
};
Expand All @@ -2455,7 +2452,7 @@ class ShaderFragmentTextureEngineTex1 : public ShaderPart {
ShaderFragmentTextureEngineTex1(const opengl::GLInfo _glinfo)
{
m_part =
"tcData1 = textureEngine1(vTexCoord1); \n"
"textureEngine1(vTexCoord1, tcData1); \n"
;
}
};
Expand Down

0 comments on commit 4f58d66

Please sign in to comment.