[Webkit-unassigned] [Bug 235478] WebGL enabling Blend causes high performance drop
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Jan 24 02:52:44 PST 2022
https://bugs.webkit.org/show_bug.cgi?id=235478
--- Comment #3 from Reinis <muiznieks.reinis at gmail.com> ---
I have made a bit of a breakthrough. Issue happens only if I render textures in the scene. Otherwise, it is solid 50 fps
```
export const fragmentShader = `#version 300 es
precision highp float;
precision highp int;
precision highp sampler2DArray;
uniform sampler2DArray textures;
uniform vec2 textureOffsets[128];
uniform float brightness;
uniform float smoothBanding;
uniform vec4 fogColor;
uniform int colorBlindMode;
uniform float textureLightMode;
in vec4 Color;
centroid in float fHsl;
flat in int textureId;
in vec2 fUv;
in float fogAmount;
out vec4 FragColor;
${hslToRgb}
void main() {
vec4 c;
// if (textureId > 0) {
// int textureIdx = textureId - 1;
// vec2 animatedUv = fUv + textureOffsets[textureIdx];
// vec4 textureColor = texture(textures, vec3(animatedUv, float(textureIdx)));
// vec4 textureColorBrightness = pow(textureColor, vec4(brightness, brightness, brightness, 1.0f));
// vec3 mul = 1.0 - (Color.rgb);
// c = textureColorBrightness * vec4(mul, 1.f);
// } else {
c = Color;
// }
vec3 mixedColor = mix(c.rgb, fogColor.rgb, fogAmount);
FragColor = vec4(mixedColor, c.a);
}
`;
```
This is my fragment shader I have commented part and it works smooth.
```
export const initTextureArray = (gl: WebGL2RenderingContext): WebGLTexture | null => {
if (!allTexturesLoaded()) {
return null;
}
const textures = Rasterizer3D.textures;
const textureArray = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D_ARRAY, textureArray);
gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 8, gl.RGBA8, TEXTURE_SIZE, TEXTURE_SIZE, textures.length);
gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D_ARRAY, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
// Set brightness to 1.0d to upload unmodified textures to GPU
const save = Rasterizer3D.brightness;
Rasterizer3D.setBrightness(1.0);
updateTextures(gl);
Rasterizer3D.setBrightness(save);
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D_ARRAY, textureArray);
gl.generateMipmap(gl.TEXTURE_2D_ARRAY);
gl.activeTexture(gl.TEXTURE0);
return textureArray;
};
```
Code responsible for loading `uniform sampler2DArray textures;`
I did notice this bug https://bugs.webkit.org/show_bug.cgi?id=223322 I wonder if it is related. Maybe my textures change internal pixel format that safari doesn't support well?
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220124/3316f0d0/attachment-0001.htm>
More information about the webkit-unassigned
mailing list