[Webkit-unassigned] [Bug 255987] REGRESSION (iOS 15.4): Poor game render performance with "WebGL via Metal"

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Apr 28 17:39:00 PDT 2023


https://bugs.webkit.org/show_bug.cgi?id=255987

Kyle Piddington <kpiddington at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kpiddington at apple.com

--- Comment #7 from Kyle Piddington <kpiddington at apple.com> ---
Hello, thanks for the detailed report! I've begun taking a look at your shaders. One thing that jumps out to me from the start is that the shaders in this sample declare a lot of global variables.  Here's a snippet from the declaration of one of the fragment shaders. 



#version 100
​
    precision highp float;
precision highp int;
uniform         vec4 _MainLightPosition;
... /* rest of uniforms are declared*/
/* Global variables */
vec4 u_xlat0;
bool u_xlatb0;
vec4 u_xlat1;
vec3 u_xlat2;
vec3 u_xlat3;
vec3 u_xlat4;
float u_xlat5;
vec4 u_xlat6;
bool u_xlatb6;
vec2 u_xlat7;
vec3 u_xlat8;
vec3 u_xlat9;
vec3 u_xlat10;
vec3 u_xlat11;
vec3 u_xlat12;
vec3 u_xlat14;
float u_xlat18;
vec3 u_xlat20;
float u_xlat31;
bool u_xlatb31;
float u_xlat39;
bool u_xlatb39;
float u_xlat41;
int u_xlati41;
float u_xlat42;
int u_xlati42;
float u_xlat43;
int u_xlati43;
bool u_xlatb43;
float u_xlat44;
bool u_xlatb44;
float u_xlat45;
...
/* Other helper functions*/

void main()
{
...
}


In the shaders this demo runs, the global variables are only used in 'main', which makes me wonder if we can optimize this case a bit. Non-constant Global variables in the Metal backend are expensive, and tend to add a lot of memory pressure to a shader. We assume, perhaps naively, that they could be modified in any function at any time. 

As a potential solution, we could write a translator pass for ANGLE that could lower a global variable used in one function to a local variable. While we continue to investigate this performance hit, can you tell us more about these global variables? Are these generated by Unity, or part of your own custom shader code?

Thanks again for the reproduction and your quick responses! 


​
​

-- 
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/20230429/06102b61/attachment.htm>


More information about the webkit-unassigned mailing list