Skip to content

Commit 3232760

Browse files
committed
Fix Intel HD 4000
1 parent 150d544 commit 3232760

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/backend/mode_gpu.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,22 @@
277277
'highp float decode32(highp vec4 rgba) {',
278278
(endianness == 'LE' ? '' : ' rgba.rgba = rgba.abgr;'),
279279
' rgba *= 255.0;',
280-
' highp float sign = rgba.a > 127.0 ? -1.0 : 1.0;',
281-
' highp float exponent = 2.0 * integerMod(rgba.a, 128.0) + (rgba.b > 127.0 ? 1.0 : 0.0);',
282-
' highp float res;',
283-
' if (abs(exponent) < EPSILON) {',
284-
' res = sign * 0.0;',
280+
' int r = int(rgba.r+0.5);',
281+
' int g = int(rgba.g+0.5);',
282+
' int b = int(rgba.b+0.5);',
283+
' int a = int(rgba.a+0.5);',
284+
' int sign = a > 127 ? -1 : 1;',
285+
' int exponent = 2 * (a > 127 ? a - 128 : a) + (b > 127 ? 1 : 0);',
286+
' float res;',
287+
' if (exponent == 0) {',
288+
' res = float(sign) * 0.0;',
285289
' } else {',
286-
' exponent -= 127.0;',
287-
' res = exp2(exponent);',
288-
' res += integerMod(rgba.b, 128.0) * exp2(exponent-7.0);',
289-
' res += rgba.g * exp2(exponent-15.0);',
290-
' res += rgba.r * exp2(exponent-23.0);',
291-
' res *= sign;',
290+
' exponent -= 127;',
291+
' res = exp2(float(exponent));',
292+
' res += float(b > 127 ? b - 128 : b) * exp2(float(exponent-7));',
293+
' res += float(g) * exp2(float(exponent-15));',
294+
' res += float(r) * exp2(float(exponent-23));',
295+
' res *= float(sign);',
292296
' }',
293297
' return res;',
294298
'}',
@@ -306,12 +310,12 @@
306310
' highp float mantissa_part3 = integerMod(F * exp2(7.0-exponent), 128.0);',
307311
' exponent += 127.0;',
308312
' vec4 rgba;',
309-
' rgba.a = 128.0 * sign + floor(exponent/2.0);',
313+
' rgba.a = 128.0 * sign + exponent/2.0;',
310314
' rgba.b = 128.0 * integerMod(exponent, 2.0) + mantissa_part3;',
311315
' rgba.g = mantissa_part2;',
312316
' rgba.r = mantissa_part1;',
313317
(endianness == 'LE' ? '' : ' rgba.rgba = rgba.abgr;'),
314-
' rgba /= 255.0;',
318+
' rgba *= 0.003921569;',
315319
' return rgba;',
316320
'}',
317321
'// Dragons end here',

0 commit comments

Comments
 (0)