Skip to content

Commit

Permalink
Make sure precision is always specified in varying. (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swordfish90 authored Dec 22, 2022
1 parent d74108e commit 45f4e88
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions libretrodroid/src/main/cpp/shadermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
namespace libretrodroid {

const std::string ShaderManager::defaultShaderVertex =
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
"#define HIGHP highp\n"
"#else\n"
"#define HIGHP mediump\n"
"precision mediump float;\n"
"#endif\n"
"\n"
"attribute vec4 vPosition;\n"
"attribute vec2 vCoordinate;\n"
"uniform mediump float vFlipY;\n"
Expand All @@ -29,8 +36,8 @@ const std::string ShaderManager::defaultShaderVertex =
"uniform vec2 textureSize;\n"
"\n"
"varying mediump float screenMaskStrength;\n"
"varying vec2 coords;\n"
"varying vec2 screenCoords;\n"
"varying HIGHP vec2 coords;\n"
"varying HIGHP vec2 screenCoords;\n"
"void main() {\n"
" coords.x = vCoordinate.x;\n"
" coords.y = mix(vCoordinate.y, 1.0 - vCoordinate.y, vFlipY);\n"
Expand All @@ -40,9 +47,15 @@ const std::string ShaderManager::defaultShaderVertex =
"}\n";

const std::string ShaderManager::defaultShaderFragment =
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
"#define HIGHP highp\n"
"#else\n"
"#define HIGHP mediump\n"
"precision mediump float;\n"
"#endif\n"
"\n"
"uniform lowp sampler2D texture;\n"
"varying vec2 coords;\n"
"varying HIGHP vec2 coords;\n"
"void main() {\n"
" vec4 tex = texture2D(texture, coords);"
" gl_FragColor = vec4(tex.rgb, 1.0);\n"
Expand Down Expand Up @@ -128,8 +141,8 @@ const std::string ShaderManager::defaultSharpFragment =
"uniform HIGHP vec2 textureSize;\n"
"uniform mediump float screenDensity;\n"
"\n"
"varying vec2 coords;\n"
"varying vec2 screenCoords;\n"
"varying HIGHP vec2 coords;\n"
"varying HIGHP vec2 screenCoords;\n"
"\n"
"void main() {\n"
" mediump vec2 threshold = vec2(1.0 / screenDensity);\n"
Expand Down

0 comments on commit 45f4e88

Please sign in to comment.