diff options
author | sfan5 <sfan5@live.de> | 2018-09-23 00:29:44 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-09-26 23:53:05 +0300 |
commit | a4c5a4486e5897cd6fb5d8136ec1ea031a3e045a (patch) | |
tree | 54ed39626756b306498659f827860946e329275d | |
parent | 9dbab9661c4ed36dca1b655440a02db37cd92af0 (diff) |
vo_gpu: adjust PRNG variant used by GL shaders
Certain low-end Mali GPUs have a rather low precision and overflow
during the PRNG calculations, thereby breaking e.g. deband-grain.
Modify the permute() to avoid this, this does not impact the
quality of PRNG output (noticeably).
This problem was observed on:
GL_VENDOR='ARM', GL_RENDERER='Mali-T720'
GL_VERSION='OpenGL ES 3.1 v1.r15p0-00rel0.bdd9e62cdc8c88e0610a16b5901161e9'
-rw-r--r-- | video/out/gpu/video_shaders.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c index 2b18d172db..342fb39ded 100644 --- a/video/out/gpu/video_shaders.c +++ b/video/out/gpu/video_shaders.c @@ -833,10 +833,14 @@ void pass_color_map(struct gl_shader_cache *sc, // Wide usage friendly PRNG, shamelessly stolen from a GLSL tricks forum post. // Obtain random numbers by calling rand(h), followed by h = permute(h) to // update the state. Assumes the texture was hooked. +// permute() was modified from the original to avoid "large" numbers in +// calculations, since low-end mobile GPUs choke on them (overflow). static void prng_init(struct gl_shader_cache *sc, AVLFG *lfg) { GLSLH(float mod289(float x) { return x - floor(x * 1.0/289.0) * 289.0; }) - GLSLH(float permute(float x) { return mod289((34.0*x + 1.0) * x); }) + GLSLHF("float permute(float x) {\n"); + GLSLH(return mod289( mod289(34.0*x + 1.0) * (fract(x) + 1.0) );) + GLSLHF("}\n"); GLSLH(float rand(float x) { return fract(x * 1.0/41.0); }) // Initialize the PRNG by hashing the position + a random uniform |