DarkPlacesEngine / DarkPlaces

The DarkPlaces Quake engine, created by LadyHavoc. Official Git repository (replaces SVN).
https://icculus.org/twilight/darkplaces/
GNU General Public License v2.0
290 stars 43 forks source link

Improve glsl shader performance #211

Closed uis246 closed 2 weeks ago

uis246 commented 1 month ago

Most optimizations are done by abusing mathematical properties and replacing slow on some hardware(e.g. Inetl) min and max with saturation. For example dot product is in range [-1, 1], so max(0, dot(...)) = sat(dot(...)). In places where this potentially can mess with HDR comments were added.

uis246 commented 1 month ago

Riiight, forgot to rebase.

uis246 commented 1 month ago

There is room for improvement, for example texture matrix, but it will require changing rendering code, so it will not be here for sake of simplicity.

hemebond commented 1 month ago

Seems good; someone else please test run this before merging though.

I've tested it with Quake. I didn't notice any problems. @uis246 if there's any in particular that might be affected please let me know.

uis246 commented 4 weeks ago

I've used only properties of linear algebra(like elements of normalized vector are always in range of [-1, 1]), basic arithmetics, shuffling between registers, using proper built-ins instead of hacks and assumption of samples being in range of [0, 1]. Seems to be it.

uis246 commented 3 weeks ago

So there should be no existing game being affected