зеркало из https://github.com/mozilla/gecko-dev.git
abab286bf9
We have encountered issues on some platforms due to a large number of if statements in shaders. The shader optimizer previously generated code with a large number of if statements, due to the way in which it optimized switch statements. Previously the optimizer output 2 if statements for every case in a switch. First it ORs the "fallthrough" var with the case's condition. Then sets the fallthrough var to false if the "break" var is true. Then conditionally executes the case's instructions if fallthrough is true. For example: switch (uMode) { case 0: gl_Position = vec4(0.0); break; case 1: gl_Position = vec4(1.0); break; } becomes: bool break_var = bool(0); bool fallthrough_var = (0 == uMode); if (break_var) fallthrough_var = bool(0); if (fallthrough_var) { gl_Position = vec4(0.0, 0.0, 0.0, 0.0); break_var = bool(1); }; fallthrough_var = (fallthrough_var || (1 == uMode)); if (break_var) fallthrough_var = bool(0); if (fallthrough_var) { gl_Position = vec4(1.0, 1.0, 1.0, 1.0); break_var = bool(1); }; This update removes one of these ifs, by ANDing the fallthrough_var with !break_var rather than conditionally setting it to false. eg: bool break_var = bool(0); bool fallthrough_var = (0 == uMode); if (fallthrough_var) { gl_Position = vec4(0.0, 0.0, 0.0, 0.0); break_var = bool(1); }; fallthrough_var = (fallthrough_var || (1 == uMode)); fallthrough_var = (fallthrough_var && !(break_var)); if (fallthrough_var) { gl_Position = vec4(1.0, 1.0, 1.0, 1.0); break_var = bool(1); }; This is logically equivalent but uses half as many if statements, which helps to avoid driver bugs on some platforms. Differential Revision: https://phabricator.services.mozilla.com/D103713 |
||
---|---|---|
.. | ||
WinToast | ||
aom | ||
cups | ||
dav1d | ||
js/d3 | ||
libwebrtc | ||
msgpack | ||
pipewire | ||
prio | ||
python | ||
rlbox | ||
rust | ||
sipcc | ||
sqlite3 | ||
webkit/PerformanceTests | ||
moz.build |