PLAY PODCASTS
0x5f3759df - ein WTF für mehr FPS (gpn20)

0x5f3759df - ein WTF für mehr FPS (gpn20)

Chaos Computer Club - archive feed · Sebastian Ritterbusch

May 20, 202254m 57s

Audio is streamed directly from the publisher (cdn.media.ccc.de) as published in their RSS feed. Play Podcasts does not host this file. Rights-holders can request removal through the copyright & takedown page.

Show Notes

Im Source von Quake III Arena von 1999 findet sich ein auf den ersten Blick kurioser Algorithmus <tt>Q_rsqrt</tt> mit "<i>evil floating point bit level hacking</i>" zur schnellen und genauen Berechnung des Kehrwerts von Quadratwurzeln, der ein Grund für die schnelle Grafik des Spiels ist. Was für Prinzipien stecken hinter der Konstruktion des Verfahrens, und warum ist die Idee des Algorithmus über 20 Jahre später immer noch relevant? https://github.com/id-Software/Quake-III-Arena/blob/master/code/game/q_math.c /* Copyright (C) 1999-2005 Id Software, Inc., GPLv2 */ float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; } about this event: https://cfp.gulas.ch/gpn20/talk/DJHG7X/

Topics

gpn20912022Sciencegulaschprogrammiernachtgpnentropia