Skip to content

Commit 74cb194

Browse files
committed
Fix FLOAT texture sampling precision problems on some mobile GPUs
1 parent 97d320d commit 74cb194

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

webrender/res/prim_shared.glsl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@
1010
#else
1111
precision mediump sampler2DArray;
1212
#endif
13+
14+
// Sampler default precision is lowp on mobile GPUs.
15+
// This causes RGBA32F texture data to be clamped to 16 bit floats on some GPUs (e.g. Mali-T880).
16+
// Define highp precision macro to allow lossless FLOAT texture sampling.
17+
#define HIGHP_SAMPLER_FLOAT highp
18+
#else
19+
#define HIGHP_SAMPLER_FLOAT
1320
#endif
21+
#else
22+
#define HIGHP_SAMPLER_FLOAT
1423
#endif
1524

1625
#define PST_TOP_LEFT 0
@@ -118,7 +127,7 @@ ivec2 get_resource_cache_uv(int address) {
118127
address / WR_MAX_VERTEX_TEXTURE_WIDTH);
119128
}
120129

121-
uniform sampler2D sResourceCache;
130+
uniform HIGHP_SAMPLER_FLOAT sampler2D sResourceCache;
122131

123132
vec4[2] fetch_from_resource_cache_2(int address) {
124133
ivec2 uv = get_resource_cache_uv(address);
@@ -137,10 +146,10 @@ vec4[2] fetch_from_resource_cache_2(int address) {
137146
#define VECS_PER_GRADIENT 3
138147
#define VECS_PER_GRADIENT_STOP 2
139148

140-
uniform sampler2D sLayers;
141-
uniform sampler2D sRenderTasks;
149+
uniform HIGHP_SAMPLER_FLOAT sampler2D sLayers;
150+
uniform HIGHP_SAMPLER_FLOAT sampler2D sRenderTasks;
142151

143-
uniform sampler2D sData32;
152+
uniform HIGHP_SAMPLER_FLOAT sampler2D sData32;
144153

145154
// Instanced attributes
146155
in ivec4 aData0;

0 commit comments

Comments
 (0)