diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-02 22:43:31 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-02-02 22:54:13 +0100 |
commit | 677a3f2f8847ed2de49dd60868f9d9487a546f58 (patch) | |
tree | dbd49bc3708a75bec31ce4e44f4e275a89e2cc07 | |
parent | 0534d12b28248cf149a829b122a8c3d1b22b0003 (diff) |
render/gles2: default to highp if available
The spec [1] says that the maximum value for a mediump float
is at least 2¹⁴ in section 4.5.2. However, when using a 4k
resolution texture coordinates will exceed this value. This causes
issues on drivers which implement mediump as a 16-bit [2].
Switch to highp. There's a twist: on GLES2, support for highp is
optional. So we need to guard it with cute GL_FRAGMENT_PRECISION_HIGH
ifdefs.
[1]: https://registry.khronos.org/OpenGL/specs/es/2.0/GLSL_ES_Specification_1.00.pdf
[2]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21082
-rw-r--r-- | render/gles2/shaders/quad.frag | 5 | ||||
-rw-r--r-- | render/gles2/shaders/tex_external.frag | 5 | ||||
-rw-r--r-- | render/gles2/shaders/tex_rgba.frag | 5 | ||||
-rw-r--r-- | render/gles2/shaders/tex_rgbx.frag | 5 |
4 files changed, 20 insertions, 0 deletions
diff --git a/render/gles2/shaders/quad.frag b/render/gles2/shaders/quad.frag index f9712797..97d3a31c 100644 --- a/render/gles2/shaders/quad.frag +++ b/render/gles2/shaders/quad.frag @@ -1,4 +1,9 @@ +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else precision mediump float; +#endif + varying vec4 v_color; varying vec2 v_texcoord; uniform vec4 color; diff --git a/render/gles2/shaders/tex_external.frag b/render/gles2/shaders/tex_external.frag index 05eac503..73909fe0 100644 --- a/render/gles2/shaders/tex_external.frag +++ b/render/gles2/shaders/tex_external.frag @@ -1,6 +1,11 @@ #extension GL_OES_EGL_image_external : require +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else precision mediump float; +#endif + varying vec2 v_texcoord; uniform samplerExternalOES texture0; uniform float alpha; diff --git a/render/gles2/shaders/tex_rgba.frag b/render/gles2/shaders/tex_rgba.frag index c2e17a90..c0a0dea6 100644 --- a/render/gles2/shaders/tex_rgba.frag +++ b/render/gles2/shaders/tex_rgba.frag @@ -1,4 +1,9 @@ +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else precision mediump float; +#endif + varying vec2 v_texcoord; uniform sampler2D tex; uniform float alpha; diff --git a/render/gles2/shaders/tex_rgbx.frag b/render/gles2/shaders/tex_rgbx.frag index 42ddf92f..ae40ad53 100644 --- a/render/gles2/shaders/tex_rgbx.frag +++ b/render/gles2/shaders/tex_rgbx.frag @@ -1,4 +1,9 @@ +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else precision mediump float; +#endif + varying vec2 v_texcoord; uniform sampler2D tex; uniform float alpha; |