tag:blogger.com,1999:blog-52038304184613099212024-03-08T11:59:05.824+02:00Oliver's BlogThis machine will, will not communicate; These thoughts and the strain I am under...Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.comBlogger46125tag:blogger.com,1999:blog-5203830418461309921.post-53237369011834666022012-09-22T14:02:00.002+03:002012-09-22T14:02:26.688+03:00Dante and WaffleChad Versace's <b><a href="http://www.x.org/wiki/Events/XDC2012/Proceedings#Waffle">XDC2012 Waffle Presentation</a></b> included a demo of Dante running with a Waffle backend with dynamic switching of the window system (X11 && GLX) or Wayland (using an environment variable.)<br />
<br />
I definitely intend to research and hopefully even contribute to Waffle in the future.<br />
<br />
Chad quickly wrote 95% (or more) of the Waffle backend. I provided some guidance and a small patch to stubbed-out X11 input. Together, we managed to pull this together <i>just</i> under the wire! Chad, you're awesome! :-)<br />
<br />
<iframe width="640" height="360" src="http://www.youtube.com/embed/BdLEn6lji-U?feature=player_detailpage" frameborder="0" allowfullscreen></iframe><br />
Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com1Kaiserstraße 9, 90403 Nuremberg, Germany49.45203 11.0767549.2868735 10.760893000000001 49.6171865 11.392607tag:blogger.com,1999:blog-5203830418461309921.post-69843086012490573992012-09-21T06:45:00.000+03:002012-09-21T06:45:49.620+03:00XDC2012 Dante Presentation/Mesa Performance<iframe width="640" height="360" src="http://www.youtube.com/embed/PYGeXko_xf0?feature=player_detailpage" frameborder="0" allowfullscreen></iframe>Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com2Kaiserstraße 9, 90403 Nuremberg, Germany49.45203 11.0767549.2868735 10.760893000000001 49.6171865 11.392607tag:blogger.com,1999:blog-5203830418461309921.post-35504138720766232322012-08-17T08:18:00.001+03:002012-08-17T08:18:54.338+03:00Prebuilt Android APKsI have quickly uploaded a <i>Dante-debug.apk</i> and some basic info to <a href="http://dante.mobi/" target="_blank">http://dante.mobi/</a><br />
<br />
Debug in the APK context means the code is not signed with a key, so you need to enable installation of such packages in the Android <i>Settings</i> menu. The code is compiled with optimizations, but do not expect anything above single-digit frames per second presently.<br />
<br />
Optimization is something I'm working towards, but the fact remains that many of the current generation devices simply do not have the GPU horsepower to run the game at an acceptable (greater than or equal to 30 fps) rate. Memory is another major killer; you need as much as possible available.<br />
<br />
Currently the <i>Dante</i> icon will launch the Doom 3 game to the main menu. However, at least on my device it's not possible to launch the single-player campaign (aka game/mars_city1) due to memory requirements. Again, this is something that will be improved in the future.<br />
<br />
You need to make the directory and copy your Doom 3 <i>*.pk4</i> files into <i>/sdcard/Android/data/com.game.dante/base</i> from your CDs or DVD. You <i style="font-weight: bold;"><u>must also copy</u></i> <i>pak000_gl2progs.pk4</i> into the same directory otherwise the game <u style="font-style: italic; font-weight: bold;">will not run!</u> This file contains the GLSL shaders required by <i>Dante</i>.<br />
<br />
The APK package is not guaranteed to run on your specific device. You're welcome to file a issue about it on <i>Github</i> but please check for duplicates first. It's also not my fault if the APK destroys your device, kills your kitten, or causes the Mayan Apocalypse.<br />
<br />
I'll write up some detailed instructions for compiling and installing <i>Dante</i> on Android later this week or early next week for those who wish to do this or don't trust installing my APK package.<br />
<br />
Happy hacking!Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com17tag:blogger.com,1999:blog-5203830418461309921.post-35802483890664986522012-08-12T19:17:00.001+03:002012-08-12T19:17:55.855+03:00Dante with AndroidWith much thanks to <a href="https://plus.google.com/108396638562408971291/posts" target="_blank">Krzysztof 'kkszysiu' Klinikowski</a> we now have mostly working support for Android devices in <a href="https://github.com/omcfadde/dante" target="_blank">Dante</a>. That is to say, the code is there, the build scripts are there, but it's still not an easy process for the user to build their own <i>Dante.apk</i> package for their phone/tablet.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-9yWQfFLLXcU/UCfReT_ZICI/AAAAAAAAAdQ/ZR-PJ4xPTHU/s1600/SC20120811-210818.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="http://3.bp.blogspot.com/-9yWQfFLLXcU/UCfReT_ZICI/AAAAAAAAAdQ/ZR-PJ4xPTHU/s400/SC20120811-210818.jpg" width="400" /></a></div>
<br />
<div>
I am considering writing a detailed how-to guide on setting up the Android SDK and NDK, creating the standalone toolchain, and running the build. It's not really difficult, it's just tedious to execute all of the commands required for the Android build.</div>
<div>
<br /></div>
<div>
I have shell scripts which do <i>most</i> (but not all) of the work checked into Git, however you still need to know how to use them, how to modify them to point to your NDK and standalone toolchain, and finally how to transfer the <i>Doom 3</i> media assets onto your device. Right now the process is definitely not very easy nor streamlined.<br />
<br />
<i>We are not yet at a point where this is user friendly!</i> You're welcome to visit us in the <i>#dante</i> IRC channel on <i>irc.freenode.net</i> if you really want to build your own packages, get involved in the development, or just see what's happening in real-time. Okay, this is a free-time project, so you may have to idle a bit and the channel is not always active.<br />
<br />
<ul>
<li>Performance is currently bad. I am aware of this and it's something we're working on improving in various ways. It's unlikely to happen overnight.</li>
<li>Touchscreen input is also bad but I expect this will improve fairly quickly. Adding <i>good</i> on-screen controls to be able to move and look around I see as a much more difficult problem. Perhaps one that will be solved with a wearable device (such as a phone or mini-tablet) a Bluetooth wireless controller, and the <a href="http://www.kickstarter.com/projects/1523379957/oculus-rift-step-into-the-game" target="_blank">Oculus Rift</a>. I'll have to wait for my unassembled prototype in November to find out...</li>
<li>Audio support currently does not exist, though progress is being made in this area.</li>
</ul>
<div>
You can see the bugs and planned enhancements/features on <a href="https://github.com/omcfadde/dante/issues" target="_blank">Dante's Github Issue Tracker</a>.</div>
<div>
<br /></div>
<div>
Happy Hacking!</div>
</div>Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com12tag:blogger.com,1999:blog-5203830418461309921.post-55245495816852290982012-08-02T23:42:00.002+03:002012-08-02T23:42:52.906+03:00Don't Panic! Doom 3 Repository RenameI have decided to rename my Doom 3 repository (aka "idTech4 ES2.0", aka "Oliver's Doom", aka "omcfadde's Doom", ...) to an easier to remember name.<br />
<br />
Going forward, the repository will be named "Dante" (based on <i>Dante's Inferno</i> and it's fitting description of the Doom 3 game.) <a href="https://github.com/omcfadde/dante">Dante</a> journeyed through Hell, guided by the Roman poet Virgil.<br />
<br />
Hopefully this will make it much easier to uniquely and easily identify my repository. Unfortunately for those of you who already have clones of the <i>idtech4</i> repository from Github, you will need to adjust the remote origin to point to the new address. I apologize for any inconvenience.<br />
<br />
Don't worry, the project is continuing as usual; the <u>only</u> change is the repository name. :-)Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com9tag:blogger.com,1999:blog-5203830418461309921.post-85752048197245674112012-08-01T23:02:00.000+03:002012-08-02T01:16:46.080+03:00Doom 3: Blinn-Phong vs PhongWithout going into the technical and implementation details of each shading algorithms I would like to request comments from people as to which you prefer visually.<br />
<br />
Unmodified Doom 3 uses the Blinn-Phong shading model, which is an approximation of the more computationally expensive Phong shading model.
Both images are using a fixed exponent of 16.0f, however it's possible to adjust the exponent based on material type in both shading models. Currently, this is not done.<br />
<br />
A higher exponent produces a tight specular highlight (for example chrome metal) while a lower exponent will produce a broader highlight (for example matte paint or skin tones.)
<br />
<br />
Please note that some tuning of the exponent may be required for the Phong model due differences in lighting calculation.<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-FEGcsy-gQCs/UBmJXDdO2_I/AAAAAAAAAcM/qzlVPuzLTa4/s1600/doom3_blinn_phong.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="360" src="http://2.bp.blogspot.com/-FEGcsy-gQCs/UBmJXDdO2_I/AAAAAAAAAcM/qzlVPuzLTa4/s640/doom3_blinn_phong.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Doom 3: Blinn-Phong (16.0f)</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-mwtvJL-dJjw/UBmJtgJX1LI/AAAAAAAAAcY/-72YffuZuKo/s1600/doom3_phong.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="http://1.bp.blogspot.com/-mwtvJL-dJjw/UBmJtgJX1LI/AAAAAAAAAcY/-72YffuZuKo/s640/doom3_phong.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Doom 3: Phong (16.0f)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-UOoAGmZVRM0/UBmqdZBcd_I/AAAAAAAAAc8/plZRcLkN0wU/s1600/doom3_phong_4.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="http://1.bp.blogspot.com/-UOoAGmZVRM0/UBmqdZBcd_I/AAAAAAAAAc8/plZRcLkN0wU/s640/doom3_phong_4.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Doom 3: Phong (4.0f)</td></tr>
</tbody></table>Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com17tag:blogger.com,1999:blog-5203830418461309921.post-84891995175706139712012-07-24T07:45:00.001+03:002012-07-24T07:47:06.608+03:00idTech 4 (aka Doom 3) ES2.0I've pushed my Doom 3 ES2.0 branch onto <a href="https://github.com/omcfadde">GitHub</a> including the GLSL shaders. These shaders could also be used as a template to write new ARB programs for the <a href="http://wiki.iodoom3.org/Minimum_Assets">minimum assets</a> required by <i>iodoom3</i>. The shaders are licensed as GPLv3 and Doom 3 is licensed as GPLv3 + additional terms as defined by <i>id Software.</i><br />
<div>
<br /></div>
<div>
Things are starting to liven up over on #iodoom3 (Freenode) and we'll hopefully start seeing some cool things very soon. :-)</div>
<div>
<br /></div>
<div>
I've put a PayPal donate button on my blog; many people don't realize the time and effort that goes into these hobby projects. If this project, or other projects of mine have been useful to you, please do <a href="http://omcfadde.blogspot.fi/">make a donation </a>(even if it's a "gold coin donation" 1-2€ or 1-2$)<br />
<br />
I'll stop shamelessly pimping myself out now and get ready for my day job.</div>
<div>
<br /></div>
<div>
Happy hacking!</div>Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com27Eteläesplanadi 24, 00130 Helsinki, Finland60.1665856 24.943555360.1586861 24.9238143 60.1744851 24.9632963tag:blogger.com,1999:blog-5203830418461309921.post-77553577201066264372012-05-11T01:45:00.000+03:002012-05-11T01:45:00.065+03:00Doom 3 for Nokia N900I'm sick with a cold, but since I ran out of movies to watch I thought it best to try to distract myself by seeing whether the N900 could run my Doom 3 branch. It turns out the answer is "yes, but very slowly."<br />
<br />
I suspect due to the completely non-optimized code, poor choice of formats (should be using <i>RGB565</i>), and avoid using <i>highp</i> everywhere in the shaders.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Ks6AzIkHg1c/T6xEPGfub4I/AAAAAAAAAXs/mqcN2Ch8qDc/s1600/20120510_232726.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="300" src="http://3.bp.blogspot.com/-Ks6AzIkHg1c/T6xEPGfub4I/AAAAAAAAAXs/mqcN2Ch8qDc/s400/20120510_232726.jpg" width="400" /></a></div>
<br />
Nevertheless, it does run despite the currently poor performance and few rendering bugs...Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com7tag:blogger.com,1999:blog-5203830418461309921.post-59154221726193598762012-04-28T00:35:00.000+03:002012-05-08T00:54:44.278+03:00Doom 3 and ES2I spent some time hacking on Doom 3 adding support for EGL and OpenGL ES2.0; obviously there is still a significant amount of work to be completed before this looks even remotely like the game. Some of you might make out the text console in this image, rendered with the incorrect shader. :-) Phoronix, go nuts... :-)<br />
<br />
(Updated again 2012-05-07: Doom 3 is nothing without stencil shadow volumes!)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-MwrjPOSU7jE/T6hD8asqu7I/AAAAAAAAAXY/D-_-L-Nw-_I/s1600/shot00006.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="221" src="http://1.bp.blogspot.com/-MwrjPOSU7jE/T6hD8asqu7I/AAAAAAAAAXY/D-_-L-Nw-_I/s400/shot00006.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-PX3g72sKnAQ/T6hEDxFci5I/AAAAAAAAAXg/0e74b130Lys/s1600/shot00007.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="221" src="http://1.bp.blogspot.com/-PX3g72sKnAQ/T6hEDxFci5I/AAAAAAAAAXg/0e74b130Lys/s400/shot00007.png" width="400" /></a></div>
<br />
<br />
<br />
(Updated 2012-05-07: I discovered and fixed a little bug in the modelViewProjection matrix...)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-86_dRaqn298/T6fcEy6ATRI/AAAAAAAAAXM/K825DiducXQ/s1600/shot00001.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="354" src="http://3.bp.blogspot.com/-86_dRaqn298/T6fcEy6ATRI/AAAAAAAAAXM/K825DiducXQ/s640/shot00001.png" width="640" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-I1Q6mFIuwE8/T5sQoF1vtII/AAAAAAAAAXA/kBfC8cKuLwc/s1600/shot00001.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="355" src="http://2.bp.blogspot.com/-I1Q6mFIuwE8/T5sQoF1vtII/AAAAAAAAAXA/kBfC8cKuLwc/s640/shot00001.png" width="640" /></a></div>
<br />Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com13tag:blogger.com,1999:blog-5203830418461309921.post-84585355616183438962012-04-25T20:26:00.000+03:002012-04-25T20:48:12.815+03:00Google Calendar Bug-FixesI have discovered some bugs in my <a href="http://omcfadde.blogspot.com/2012/04/from-fetchmailprocmail-to-google.html">previous entry</a> regarding Google Calendar synchronization. Firstly there is a bug in the locking mechanism causing it to sometimes hang while running <i>fetchmail</i>. The following is the corrected <i>.procmailrc</i> entries:<br />
<br />
<pre>#
# === Google Calendar (from Microsoft Exchange; iCalendar) ===
#
:0 c:
* H ?? ^Content-Type: multipart/(alternative|mixed)
* B ?? ^Content-Type: text/calendar
{
:0 Wac: Mail/multipart.lock
| munpack -q -t -C ~/Mail/.munpack 2> /dev/null
:0 Wac: Mail/multipart.lock
| /home/oliver/bin/calendar.sh
:0 Wac: Mail/multipart.lock
| rm -f ~/Mail/.munpack/*
}</pre>
<br />
I discovered the second bug when synchronizing a particular <i>iCalender</i> format file containing several <b>BEGIN:VEVENT</b> blocks. Events are expected to have a <b>UID</b> field. I do not know whether this should be unique within the scope of your entire calendar, but it <i>must</i> be unique within the scope <b>BEGIN:VCALENDAR</b> block (i.e. the entire <i>iCalender</i> file.)<br />
<br />
Exchange, in all its infinite stupidity decides to assign the same <b>UID</b> to every <b>VEVENT</b>, and as soon as you attempt to upload it to Google Calender via WebDav you will receive a cryptic error message:<br />
<b>500 Server error code: ........</b> <i>(Pseudo-random characters)</i><br />
<br />
You'll receive an even less helpful error message when trying the "Import Calendar" feature of the web interface: <br />
<b>Failed to import events: Could not upload your events because you do not have sufficient access on the target calendar.</b><br />
<br />
What is the solution? Well, funnily enough a <i>Unique Identifier</i> (<b>UID</b>) should actually be unique! Changing those <b>UID</b>s to some unique values and uploading the file again works perfectly! (Anything works, I used <i>echo $RANDOM | md5sum | cut -d ' ' -f 1</i> i.e. MD5 hash of a pseudo-random number.)<br />
<br />
I am only aware of one such formatted calendar entry in my dataset, so I adjusted it manually. However, I'd feel safer using <i>sed</i> or <i>awk</i> to replace each "<b>UID</b>" with a <i>real</i> unique identifier.
I'll post such a modified <i>calendar.sh</i> in the second part, whenever I feel like playing with <i>awk</i> again! You could always beat me to it... Happy hacking!Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com5tag:blogger.com,1999:blog-5203830418461309921.post-14220482718440340142012-04-22T17:45:00.000+03:002012-04-25T20:50:05.481+03:00Doom 3 GLSLI recently implemented a GLSL renderer backend for Doom 3. Yes, there are already a couple of backends existing (e.g. raynorpat's) unfortunately these did not run successfully on my hardware and had serious rendering and pixel errors.
<br />
<br />
These images are from the first implementation of my backend, where I had accidentally called <i>normalize()</i> on a vector which was almost normalized. The result is pixel-imperfection when compared to the standard ARB2 backend, and the cost of pointless normalization in the fragment shader.
<br />
<br />
You can also see the importance of running a comparison or image-diff program when implementing a new backend. Can you see the differences between the first two images immediately, with the naked eye? I couldn't.
<br />
<br />
<a href="http://3.bp.blogspot.com/-LbXNRfqfxaY/T5QVgSGXqhI/AAAAAAAAAV8/oR3RZTaAmc8/s1600/shot00009.png"><img border="0" height="150" src="http://3.bp.blogspot.com/-LbXNRfqfxaY/T5QVgSGXqhI/AAAAAAAAAV8/oR3RZTaAmc8/s200/shot00009.png" width="200" /></a>
<a href="http://2.bp.blogspot.com/-16qsBlCU8eM/T5QVnw44BZI/AAAAAAAAAWI/Jxjqyz6HU1E/s1600/shot00010.png"><img border="0" height="150" src="http://2.bp.blogspot.com/-16qsBlCU8eM/T5QVnw44BZI/AAAAAAAAAWI/Jxjqyz6HU1E/s200/shot00010.png" width="200" /></a>
<a href="http://2.bp.blogspot.com/-w-SqMYb1AKI/T5QVsySEXdI/AAAAAAAAAWU/fdx_PRorlwM/s1600/shot00009_shot00010.png"><img border="0" height="150" src="http://2.bp.blogspot.com/-w-SqMYb1AKI/T5QVsySEXdI/AAAAAAAAAWU/fdx_PRorlwM/s200/shot00009_shot00010.png" width="200" /></a><br />
<br />
Finally, here is the backend running the <i>hellhole</i> level. The black regions are areas that would be rendered by the (currently unimplemented in GLSL) <i>heatHaze</i> shader. Not bad for an <i>i965</i> GPU.
<br />
<br />
<a href="http://4.bp.blogspot.com/-gc-rLHKzG7o/T5QV1cmUoFI/AAAAAAAAAWg/HGidgzepprY/s1600/shot00019.png"><img border="0" height="300" src="http://4.bp.blogspot.com/-gc-rLHKzG7o/T5QV1cmUoFI/AAAAAAAAAWg/HGidgzepprY/s400/shot00019.png" width="400" /></a>
<br />
<br />
Just for the laughs, here is what happens when Doom 3 decides to try LSD; or fails to pass initialized texture coordinates from the vertex program to the fragment program in the ARB2 backend.
<br />
<br />
<a href="http://4.bp.blogspot.com/-iIHAIbobM5Y/T5QY5SwE5_I/AAAAAAAAAW0/tjjkzVpRcOA/s1600/shot00008.png"><img border="0" height="300" src="http://4.bp.blogspot.com/-iIHAIbobM5Y/T5QY5SwE5_I/AAAAAAAAAW0/tjjkzVpRcOA/s400/shot00008.png" width="400" /></a>Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com5tag:blogger.com,1999:blog-5203830418461309921.post-34882915472700679762012-04-20T21:45:00.000+03:002012-04-25T20:47:56.562+03:00From fetchmail/procmail to Google CalendarI spent many hours scouring Google before finally figuring out how to implement this easily. Calendar synchronization is very important to me; I want to be able to look at my phone, my tablet, or my browser and see my entire schedule (otherwise I'd never show up anywhere.)<br />
<br />
<i>.procmailrc</i>:<br />
<blockquote>
<pre>:0 Wc: Mail/multipart.lock
* H ?? ^Content-Type: multipart/(alternative|mixed)
* B ?? ^Content-Type: text/calendar
{
:0 Wac:
| munpack -q -t -C ~/Mail/.munpack 2> /dev/null
:0 Wac:
| /home/oliver/bin/calendar.sh
:0 Wc:
| rm -f ~/Mail/.munpack/*
}
</pre>
</blockquote>
This beautiful undocumented recipe is actually quite simple, but perhaps needs some explanation. From <i>man procmailrc</i>:<br />
<br />
<pre>A line starting with ':' marks the beginning of a recipe.
It has the following format:
:0 [flags] [ : [locallockfile] ]</pre>
<pre></pre>
<pre> zero or more conditions (one per line)<zero (one="" conditions="" line)="" more="" or="" per="">
exactly one action line<exactly action="" line="" one=""></exactly></zero></pre>
<br />
<b>W</b> means wait until the program finishes and ignore any failure messages. <b>a</b> means the preceding recipe must have successfully completed before <i>procmail</i> will execute this recipe. Finally, <b>c</b> means carbon-copy (this recipe does not handle delivery of the mail, so it must proceed further through the chain of recipes.)<br />
<br />
It may be more appropriation to use <b>f</b> (this pipe is a filter) instead. I am new to <i>procmail</i> configuration; <b>c</b> works for me.<br />
<br />
First match messages containing a <i>Content-Type</i> header of either <i>multipart/alternative</i> or <i>multipart/mixed</i>, second check the message body for a <i>Content-Type</i> of <i>text/calendar</i> (which is the data we want.) If these conditions are true unpack the MIME multipart message into separate files with <i>munpack</i> into a temporary directory. Proceed and run <i>calendar.sh</i> which does the magic, and finally clean up after ourselves.<br />
<br />
<i>calendar.sh</i>:<br />
<blockquote>
<pre>#!/bin/bash
http_proxy=http://proxy.example.com:8080
CALENDAR_ID='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@group.calendar.google.com'
for i in ~/Mail/.munpack/*; do
if [ -n "$(grep 'BEGIN:VCALENDAR' ${i} 2> /dev/null)" ]; then
expect -dc \
"spawn /usr/bin/cadaver -p ${http_proxy/http:\/\/} \
https://www.google.com/calendar/dav/${CALENDAR_ID}/events ; \
expect \"dav:\" ; \
send \"put ${i}\\r\" ; \
expect \"dav:\" ;
send \"bye\\r\""
fi
done</pre>
</blockquote>
<i>Newlines have been inserted into the script so that it doesn't break layouts on other pages; you will need to fix those if copying this script.</i><br />
<br />
I use <i>expect</i> and <i>cadaver</i> to upload the <a href="http://en.wikipedia.org/wiki/ICalendar">iCalender</a> file extracted by <i>munpack</i> to Google Calendar via their <a href="http://support.google.com/calendar/bin/answer.py?hl=en&answer=99358#sunbird">WebDav interface</a>.
Finding the CALENDAR_ID is a little confusing. You can find it from the "Settings" option when you login to the Google Calender via a browser. You must use the public Calendar Address, not the Private Address, but <b><i>you do not need to share the calender publicly</i></b>; Google will request your login details via WebDav. This is easiest to configure in <i>.netrc</i>. <i>chmod 600</i> the file for some additional safety.
<br />
<blockquote>
<pre>machine www.google.com
login john.doe
password example123</pre>
</blockquote>
The login should not include the <i>@gmail.com</i> otherwise it will fail. Happy hacking!Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com4tag:blogger.com,1999:blog-5203830418461309921.post-79283694168604236512012-04-20T20:47:00.000+03:002012-04-20T20:47:04.221+03:00Fun with UTF-8I finally decided to configure my computers for UTF-8, mostly due to the frustration of attempting to determine which Finnish character should have been displayed (and the probable annoyance of Finns having their names mangled by my mail client.)<br />
<ul>
<li><i>/etc/locale.gen</i> is useful for generating only the locales you actually need. I selected English (US and UK), Finnish, and Swedish as UTF-8, ISO-8859-1, and ISO-8859-15 (where appropriate.)</li>
<li><i>.bashrc</i>: export LANG=en_US.UTF-8</li>
<li>Setup <i>.Xdefaults</i>:</li>
</ul>
<blockquote>
<pre>XTerm*Background: Black
XTerm*Foreground: White
XTerm*UTF8: 2
XTerm*utf8Fonts: 2</pre>
</blockquote>
Actually the UTF-8 options are not required due to the way I am launching terminals from my window manager, but it does not cause any damage. Black terminal background is mandatory!<br />
<br />
The fun part was figuring out why my xterm, specified in <i>.ratpoisonrc</i> as <b>bind c exec xterm -u8</b> did not launch a UTF-8 terminal. I then realized that Ratpoison was launching <b>xterm</b> from a bare-metal shell and the <b>LANG</b> environment variable was never set; quickly changing the binding to <b>bind c exec xterm +lc -u8</b> (switch off automatic selection of encoding and respect my <b>-u8</b> option) resolved the final issue.<br />
<br />
Now I can happily read the ä's, ö's, and Å's from a language I do not understand (excluding a few keywords and phrases.) Cool!Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com0Helsinki, Finland60.1665856 24.943555360.1586861 24.9238143 60.1744851 24.9632963tag:blogger.com,1999:blog-5203830418461309921.post-85471198879799592462012-01-30T21:13:00.001+02:002012-01-30T21:20:22.133+02:00STOP ACTA...I suspect that I'll be receiving quite a few more hits here given the recent retweets. Unfortunately I haven't had much time to update my blog... In fact, I may not have <i>any</i> time in the future.<br />
<br />
On a more positive note, I am much more active on Twitter, so you can follow me there (@omcfadde)<br />
<br />
Of course the topics we're discussing, SOPA, ACTA, etc are definitely not pleasant or positive. Let's show them we mean business and that we <b>will not</b> accept these agreements!<br />
<br />
<b><a href="http://www.stopacta.info/">STOP ACTA</a></b><br />
<br />
<i>Updates (possibly) coming in the future.</i><br />
<br />
<hr /><br />
Epäilen, että tulen saa melkoisesti lisää osumia tässä äskettäisten retweets. Valitettavasti minulla ei ole ollut paljon aikaa päivittää blogiin ... Itse en ehkä ole mitään aikaa jatkossa.<br />
<br />
Myönteistä huomata, olen paljon enemmän aktiivisia Twitterissä, jotta voit seurata minua sinne (@omcfadde)<br />
<br />
Tietenkin aiheita olemme keskustelleet, SOPA, ACTA jne. eivät varmasti miellyttävä tai positiivinen. Katsotaanpa näytä heille että olemme tosissamme ja että me ei hyväksy näitä sopimuksia!<br />
<br />
<b><a href="http://www.stopacta.info/">STOP ACTA</a></b> (In Englanti - Lue!)<br />
<br />
<i>Päivitykset (mahdollisesti) tulossa tulevaisuudessa.</i>Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com0Helsinki, Finland60.169845 24.9385508000000360.169845 24.93855080000003 60.169845 24.93855080000003tag:blogger.com,1999:blog-5203830418461309921.post-49051311903568722552011-08-09T22:38:00.001+03:002011-08-09T22:48:51.355+03:00<i>I was originally going to post this as a tweet, but verbosity got the better of me. Colleagues whom I have worked with (you know who you are) will attest to this fact...</i><br />
<br />
I frequently consider how things may have turned differently based on my own choices; jumping directly into employment versus attending university. Choosing a career as a software engineer as apposed to pursuing interests in chemistry and biology.<br />
<br />
I like to think that all-in-all everything worked out okay... On the other hand, there are so many possibilities that I will no longer be able to explore, and that is very disappointing. I will likely never know what it would be like to attend a university, graduate with a PhD (which would probably be in computer science, chemistry and/or biology -- the two being closely related.)<br />
<br />
I have even contemplated the idea of assembling a small team for developing small to medium scale games. I don't think there is a way for a small group to compete with triple-A titles, which again is disappointing. Of course this is a pipe-dream. I don't know artists capable of creating the media required, nor any software engineers who would be willing to participate project which has an unknown chance of commercial success. I think these kinds of projects are a Euro short and a decade late.<br />
<br />
Well, maybe not a decade late, but at least I don't have the means to bankroll such an endeavor from my personal account. Perhaps it would be interesting to sketch out a graph of my life based on decisions made and not made and see what the projections look like...<br />
<br />
If only for more productive hours in the day; but that is another brain-dump entirely.Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com1Helsinki, Finland60.169812499999992 24.9382401000000360.031373499999994 24.70242710000003 60.30825149999999 25.17405310000003tag:blogger.com,1999:blog-5203830418461309921.post-36412163207221666102011-07-11T20:58:00.000+03:002011-07-11T20:58:03.607+03:00Using dlopen() for fast engine prototyping...I recently became tired of the cycle of hacking on the renderer, starting the whole engine, checking where and how it's failing, exiting the engine and the pointless time wasted during this process. Typically it's only a specific area I'm working on, thus perhaps one or two C source code files are actually changed, so it doesn't make sense to reload the entire engine and all media assets.<br />
<br />
I started working on a smaller project for rapid-fire prototyping, μEngine. Currently it's a pretty basic project. It provides the basic framework for detecting that a shared object has changed, unloading the current version from memory, loading the new library, resolving the required symbols, and continuing the "rendering" loop <i>(which actually doesn't perform any OpenGL rendering yet.)</i><br />
<br />
Here's an example of the engine running:<br />
<br />
<pre>~/uengine/src (master) $ make && ./uengine
make: Nothing to be done for `all'.
... .libs/libuengine.so
0xdeadbeef
0xdeadbeef
0xdeadbeef
0xdeadbeef
... .libs/libuengine.so
0xcafebabe
0xcafebabe
0xcafebabe
0xcafebabe
... .libs/libuengine.so
0x0
$ </pre><br />
While the engine was running, I edited <i>libuengine.c</i>, which is compiled by Automake into a shared object:<br />
<br />
<pre>$ sed -i 's/0xdeadbeef/0xcafebabe/' libuengine.c && make
CC libuengine.lo
CCLD libuengine.la</pre><br />
Now I want to terminate the program (and I'm too lazy to have written a signal handler yet) so μEngine's main-loop is setup to terminate when <i>dlsym_main</i> returns a zero value.<br />
<br />
<pre>$ sed -i 's/0xcafebabe/0x0/' libuengine.c && make
CC libuengine.lo
CCLD libuengine.la</pre><br />
μEngine also links with <i>libengine</i> (which provides all of the math/geometry/etc functionality for Trinity), <i>libdecl</i> (which provides access to <i>id Software</i> style declaration files), and <i>liblwo2</i> (which, well, loads LWO2 model files.)<br />
<br />
This little experiment is far from complete. I still need to setup an OpenGL and GLX context, handle X11 input, and keep track of any ARB fp/vp or GLSL programs loaded. GPU programs will be reloaded in much the same way as the shared object itself.<br />
<br />
There is of course a few frames delay between invocation of <i>make</i> and the new library being loaded, because should <i>stat</i> fail to obtain the file modification time (because it's still being written out) μEngine just continues with the old shared library until <i>stat</i> succeeds. The modification time is checked every "frame."<br />
<br />
I think this should help with faster prototyping, since μEngine has the ability to access all of the assets and <i>libengine</i> library functions that Trinity can, but without the requirement of loading all the assets for a full world map into memory at start up.Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com0Helsinki, Finland60.169812499999992 24.9382401000000360.031373499999994 24.70242710000003 60.30825149999999 25.17405310000003tag:blogger.com,1999:blog-5203830418461309921.post-54399716372827165802011-05-28T22:55:00.000+03:002011-05-28T22:55:04.748+03:00More BSP compiler hacking...I've started working on my engine's BSP compiler (based on Q3Map2/XMAP2) looking to add proper shader parsing and areaportal detection. Currently the shaders are all parsed by <i>libdecl</i> which avoids duplication of code between the engine and utilities.<br />
<br />
The engine does <b>not yet</b> use portal based rendering (which is why you can see light clipping through the wall in the images.) The BSP compiler has portal debugging enabled, which outputs an extra surface with a translucent shader for areaportal visualization and debugging.<br />
<br />
This is a very simple demo map, however you can already see several issues. The BSP compiler needs to carve the polygons into discrete areas (e.g. the floor polygon should not span two areas.) There are still a few areaportal bugs in the BSP compiler, and of course the engine must be updated to use areaportal based rendering.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-NdIK4impimU/TeFNTvEjtXI/AAAAAAAAATw/zPFGzAY5VRA/s1600/shot0003.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="150" src="http://3.bp.blogspot.com/-NdIK4impimU/TeFNTvEjtXI/AAAAAAAAATw/zPFGzAY5VRA/s200/shot0003.png" width="200" /></a></div> Image showing light leaking through the wall/areaportal.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-ugDv24aeZMQ/TeFNVuNmEpI/AAAAAAAAAT0/Zd9k_w1QMsk/s1600/shot0004.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="150" src="http://3.bp.blogspot.com/-ugDv24aeZMQ/TeFNVuNmEpI/AAAAAAAAAT0/Zd9k_w1QMsk/s200/shot0004.png" width="200" /></a></div>Image showing the triangles rendered; the floor and walls should be carved at the areaportal boundary.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Who knows, maybe I'll even get this finished before id Tech 4 is (hopefully) released under the GNU General Public License.Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com0tag:blogger.com,1999:blog-5203830418461309921.post-892247224882752712011-04-22T19:57:00.000+03:002011-04-22T19:57:44.431+03:00HP LaserJet Pro CP1525nw ReviewI received the CP1525nw on Thursday, and it turns out this is a really great printer for GNU/Linux (which probably means the other HP network-compatible printers are good, too.)<br />
<br />
Basically I unpacked it, plugged in Ethernet and power cables, it fetched an IP address from DHCP and displayed it on the small LCD. You can do some basic configuration through this LCD/few-button interface, but it's not worth the trouble; just note the IP address, enter it into a browser, and setup from there.<br />
<br />
You can't setup the wireless via the LCD interface (unless you make use of this silly PIN code system which my router doesn't support anyway.)<br />
<br />
Everything is configurable over the web interface, and by default mostly everything is enabled and unsecured. I disabled features I wouldn't use, configured the wireless, assigned a static IP, and secured the interface with a password.<br />
<br />
Note that while you can configure the wireless it won't actually become active until the Ethernet cable is disconnected. You can't use both interfaces (Ethernet and WiFi) at the same time.<br />
<br />
Everything went very smoothly and you <b>don't</b> need any proprietary software, even for setup, which is wonderful. :-)<br />
<br />
Complaints thus far, although I haven't had the chance to use it much due to only having a few sheets of blank paper lying around, are as follows:<br />
<ul><li>No duplex printing, although you can of course manually duplex your documents by printing even/odd pages in separate jobs.</li>
<li>Paper tray is a bit small: 150 sheets. It would be nice to have a 500 sheet tray which would accomidate an entire ream of paper.</li>
</ul>Not big issues, and the print quality is very good, so I would recommend this printer. CUPS configuration was quick and painless, and CUPS has a built-in driver.Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com10tag:blogger.com,1999:blog-5203830418461309921.post-55443662715657058342011-04-09T14:17:00.000+03:002011-04-09T14:17:11.152+03:00Ultrasonic modem updateI did a little more digging into underwater ultrasonic digital communication. There is a <a href="http://oai.dtic.mil/oai/oai?verb=getRecord&metadataPrefix=html&identifier=ADA499556">publication from DTIC</a> which looks interesting. It includes some rather boring source code, but provides a lot of good advice in the text.<br />
<br />
Available for purchase is <i><a href="http://www.springerlink.com/content/f655n1w00677jgk5">An Ultrasonic Sensor Based Low-Power Acoustic Modem for Underwater Communication in Underwater Wireless Sensor Networks</a></i> by Heungwoo Nam and Sunshin An. It's €25 for the publication, so I'll probably purchase it (unless some anonymous person with access would email me.)<br />
<br />
Of course, this is leading to the ultimate conclusion of setting up an EE workbench and buying a bunch of expensive equipment (solder station, oscilloscope, function generator, multimeter, etc.)<br />
<br />
I seem to have expensive hobbies. :-( I should really spend some money on a good vacation, which I sorely need.Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com1tag:blogger.com,1999:blog-5203830418461309921.post-13745928171643073122011-04-07T09:35:00.001+03:002011-04-07T09:48:18.706+03:00Printer for Home Office...Dear Lazyweb,<br />
<br />
I'm currently looking for a printer for my home so that I don't have to wait until I'm at the office and use the printers there... Unfortunately it seems many laser printers (especially Canon, which Verkkokauppa are pushing to sell) either don't have Linux support, or have only proprietary drivers. What ever happened to just accepting a Postscript file?<br />
<br />
Canon are especially nasty in that they provide a "source" package, which is really just the source code for some of the utilities, but the core library is still proprietary. <i>Every time I see a shared object or binary inside a source package, I die a little inside...</i><br />
<br />
Besides Xerox printers (very expensive) HP seem to have a couple of good options:<br />
<ul><li><a href="http://www.verkkokauppa.com/popups/prodinfo.php?id=17822">HP LaserJet Pro CP1525n Color Printer</a> (Ethernet)</li>
<li><a href="http://www.verkkokauppa.com/popups/prodinfo.php?id=18267">HP LaserJet Pro CP1525n<b>w</b> Color Printer</a> (Ethernet + 802.11b/g/n)</li>
</ul>Both accept the following languages:<br />
<ul><li>HP PCL 6</li>
<li>HP PCL 5c</li>
<li>HP Postscript Level 3 Emulation</li>
</ul>According to this <a href="http://ubuntuforums.org/showpost.php?p=10511826&postcount=8">forum post</a> it looks like it should work out-of-the-box with CUPS, <b>without any proprietary drivers</b> which is a precondition for my purchase...<br />
<br />
Verkkokauppa have a rather silly return policy. Maybe this was inaccurate as I only asked one of their sales people, but apparently should you purchase something from their shop in person, then you do not have the option to return it (except if the product is defective.) However, should you purchase online (even to pick-up from the store) you have a 2 week return period...<br />
<br />
I am leaning towards the CP1525nw because it seems like it will work with CUPS without proprietary crap, and the wireless network feature means I can put the printer in a walk-in closet or similar and keep it out of the way. Unfortunately it's a 1-2 week order time from the supplier.<br />
<br />
It seems a reasonable deal for around the €200 to €300 range.Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com11tag:blogger.com,1999:blog-5203830418461309921.post-16031118640543425652011-04-03T13:13:00.000+03:002011-04-03T13:13:30.471+03:00Expression parsing and evaluation...Something which has been annoying for me for a while was the lack of proper expression parsing in <i>libdecl</i>, my engine's declaration parsing library.<br />
<br />
This library is responsible for parsing the <a href="http://www.iddevnet.com/doom3/sounds.php">sound</a> and <a href="http://www.iddevnet.com/doom3/materials.php">table/material</a> declarations as defined by id Software, and making them available to the renderer (or other backend: sound engine, etc) in easy to read structures guaranteed to have sane and correct values. <i>libdecl</i> is the component which will complain about your syntax, the backend doesn't have to care about any of this. Really makes the code look a lot nicer. :-)<br />
<br />
I was debating the best way to parse expressions, because they can either be very simple, or quite complicated. I realized that I could not rely on line terminators, because it's very common to see an expression span multiple lines with all kinds of tabs and white-space in the file... Of course the lexer ignores white-space, but keeps track of the line count.<br />
<br />
After a bit of thinking about this, I decided to rip out the current shunting yard algorithm from the renderer, move it into <i>libdecl</i>, clean it up and rework it quite a bit. Now, it does the following:<br />
<ol><li>Get a token from the lexer,</li>
<li> Check this token matches our expected rules,</li>
<ol><li>the token is an operator or operand, or</li>
<li>the token is a table name. (Detected from 1st-pass.)</li>
</ol><li> If our checks pass, go ahead with the normal algorithm, otherwise,</li>
<li>Push the token back to the lexer, and return the completed expression in Postfix notation.</li>
</ol>Here's a hypothetical example that I wrote with more comments than necessary...<br />
<hr /><pre>/* "material" keyword is optional when inside the material directory */
material textures/screenBlur
{
sort postProcess
/* first stage */
{
if glslPrograms != 0 &&
!isMultiplayer /* don't blur the screen in multi-player */
map textures/blur /* any image format supported */
}
/* ... */
}</pre><hr />Obviously simply parsing the "if" expression until the end of the line would fail, furthermore, "if" expressions may be written as <i>if ...</i> or <i>if (...)</i>, so matching on parentheses won't work either.<br />
<br />
It turns out the easiest thing to do is first a pre-pass which only looks at tables (so that we know "foobarTable" is valid), then a secondary pass which looks at everything (sounds, tables, materials.)<br />
<br />
In this example "glslPrograms" and "isMultiplayer" are built-in variables which the parser correctly detects as operands. Therefore we'll only stop parsing after reading the "map" token, realize it's not a valid operator or operand, push it back to the lexer, and return the expression (after some processing.)<br />
<br />
This solution seems to be quite elegant, despite the 2-pass algorithm, and handles all the cases correctly.<br />
<br />
The next step is to get rid of static stack allocation. Some expressions are very long, so the stack is setup for 64 elements, but this is ridiculous for "<i>time * 0.001</i>" (for example.)Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com1tag:blogger.com,1999:blog-5203830418461309921.post-76775835382284331442011-03-23T11:58:00.001+02:002011-03-23T21:33:57.377+02:00The Matrix at your local Apotek?Couldn't help but laugh when I opened these (Paracetamol and Ibuprofen) as I usually buy a different brand of Ibuprofen which is your standard white pill.<br />
<br />
<a href="http://goo.gl/photos/oO9cvRuj8P" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="320" src="https://lh3.googleusercontent.com/_SwNjMGn1QH0/TYkRMWGUmWI/AAAAAAAAAQI/RkMHaHrFv0I/s320/matrix_reallife.jpg" width="313" /></a><br />
<br />
<i>That's</i> why they are cost approximately 8 euros for 30 tablets! Damn, I don't need it decorated like an Easter egg, as long as it works...Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com0tag:blogger.com,1999:blog-5203830418461309921.post-47411943411469738912011-02-20T05:47:00.000+02:002011-02-20T05:47:42.661+02:00New home for Revenge (Radeon Reverse Engineering Tool)Thanks to Marek Olšák for having a backup copy of my Git repository online! The hard drive containing much of my personal code which was on <i>people.freedesktop.org</i> (until those directories were lost) is half way around the world.<br />
<br />
Revenge now has a new home on <a href="http://gitorious.org/omcfadde/revenge">http://gitorious.org/omcfadde/revenge</a>.<br />
<br />
I have bumped the version to 2.0.0, which introduces some minor configure.ac fixes: mostly <i>PKG_CHECK_MODULES</i> for <i>libpci</i>, <i>sdl</i>, and <i>zlib</i>. I have also updated email addresses and revenge.sh for non-developers.<br />
<br />
Honestly I do not expect this code to get much interest now that we have documentation from AMD; but it's useful for historical/nostalgic reasons.<br />
<br />
If I were to do it over again today: I would start with the kernel MMIO tracer (which would deal with the fglrx kernel module) then extend this to handle dumping MMIO access from a userspace process too. The kernel is the perfect place to do so, and would be far more reliable than userspace.<br />
<br />
If you have any questions or bug reports, feel free to ask them here and I will try to provide you with timely answers/fixes.Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com1tag:blogger.com,1999:blog-5203830418461309921.post-58054451305839711052011-02-19T15:12:00.000+02:002011-02-19T15:12:32.499+02:00Math function micro-optimization...<b>Preamble for <a href="http://planet.freedesktop.org/">planet.freedesktop.org</a></b><br />
<br />
Sorry about the poor formatting on <a href="http://planet.freedesktop.org/">planet.freedesktop.org</a>; it seems it and BlogSpot don't quite get along, therefor you won't see any color hilights. It looks much better (and easier to read) on my actual blog page, honest!<br />
<br />
Updated version includes float-to-int optimization and comments; sorry if this bumps this rather long post to the top again; this is not my intention. planet.freedesktop.org admins: is there some way to disable bumping when a post is updated? (Perhaps selectively, in case the bump is important. e.g. updated dates for an event.)<br />
<hr /><br />
This analysis was performed using a modified version of <a href="http://www.lomont.org/">Chris Lomont's</a> inverse square-root testing code. The <a href="http://www.lomont.org/math/papers/2003/invsqrt.pdf">accompanying publication</a> is worth reading before looking at any of this data.<br />
<br />
I've started looking into whether there would be any performance difference in a few optimized math functions should <b>-fstrict-aliasing</b> be enabled. I did not believe strict-aliasing would have much of an effect on these optimized functions (and it turns out I was correct) but the benefit is seen when compiling other code which includes these inline functions.<br />
<br />
Without strict-aliasing compatibility, including the header file containing the incompatible functions/macros taints the entire file, meaning you cannot use <b>-fstrict-aliasing</b> where it may be helpful for your general code.<br />
<br />
<hr /><br />
Here are the results for the standard <i>1.0 / sqrt(x)</i> frequently used in graphics engines. Even though today's renderers typically use carefully crafted SIMD functions for the critical path, this is still useful for quickly normalizing vectors in game code, etc.<br />
<br />
The Lomont version of the function is a tiny bit faster and a tiny bit more accurate, but nothing to write home about.<br />
<br />
Clearly it can be seen that this micro-optimization is an excellent for x86 and x86_64. Don't try it on ARM; it's <i>far</i> slower than just taking the hit on <i>1.0 / sqrt(x)</i><br />
<br />
I don't know whether this optimization could be modified for ARM; any assembly experts out there?<br />
<blockquote><div style="color: red;"><b>Timing Exact function<br />
1752 ms used for 100000000 passes, avg 1.752e-05 ms</b></div><div style="color: green;"><b>Timing Carmack function<br />
463 ms used for 100000000 passes, avg 4.63e-06 ms<br />
Timing Carmack function (strict-aliasing)<br />
455 ms used for 100000000 passes, avg 4.55e-06 ms<br />
Timing Lomont function<br />
453 ms used for 100000000 passes, avg 4.53e-06 ms<br />
Timing Lomont function (strict-aliasing)<br />
455 ms used for 100000000 passes, avg 4.55e-06 ms</b></div></blockquote><hr />The absolute value function is mostly used for comparisons (e.g. <i>fabs(y - x) > epsilon</i> and some other specialized functions: finding on which side of a plane an AABB resides, it's distance from said plane, AABB radius, etc. Therefor it's useful to optimize this function where possible...<br />
<blockquote><div style="color: green;"><b>Timing Exact fabsf function<br />
268 ms used for 100000000 passes, avg 2.68e-06 ms</b></div><div style="color: red;"><b>Timing Bit-Masking fabsf function<br />
304 ms used for 100000000 passes, avg 3.04e-06 ms<br />
Timing Bit-Masking fabsf function (strict-aliasing)<br />
305 ms used for 100000000 passes, avg 3.05e-06 ms</b></div></blockquote>However, apparently it's quite a bit faster to just call libc's <i>fabsf</i> function! I saw this originally in the Quake 3 Arena source code, so maybe things were different with the compilers and hardware of the time.<br />
<hr />These macros/functions are used when you want to know the sign of a float (i.e. is the value positive or negative) without performing any comparison (for performance reasons.) It seems that the strict-aliasing versions perform about identical to the macros.<br />
<blockquote><div style="color: red;"><b>Timing Exact float sign bit not set function<br />
327 ms used for 100000000 passes, avg 3.27e-06 ms</b></div><div style="color: green;"><b>Timing FLOATSIGNBITNOTSET macro<br />
313 ms used for 100000000 passes, avg 3.13e-06 ms<br />
Timing Bit-Masking float sign bit not set function (strict-aliasing)<br />
312 ms used for 100000000 passes, avg 3.12e-06 ms</b></div><br />
<div style="color: red;"><b>Timing Exact float sign bit set function<br />
342 ms used for 100000000 passes, avg 3.42e-06 ms</b></div><div style="color: green;"><b>Timing FLOATSIGNBITSET macro<br />
305 ms used for 100000000 passes, avg 3.05e-06 ms<br />
Timing Bit-Masking float sign bit set function (strict-aliasing)<br />
305 ms used for 100000000 passes, avg 3.05e-06 ms</b></div></blockquote><hr />Don't use "<i>d = (int) f</i>" if you want fast code. <i>fld</i> and <i>fistp</i> work nicely on x86 and x86_64.<br />
<blockquote><div style="color: red;"><b>Timing Exact float-to-int function<br />
1252 ms used for 100000000 passes, avg 1.252e-05 ms</b></div><div style="color: green;"><b>Timing Fast float-to-int function<br />
336 ms used for 100000000 passes, avg 3.36e-06 ms</b></div><br />
Done. By Chris Lomont 2003. Modified by Oliver McFadden 2011</blockquote>These measurements were taken on my laptop with an <i>Intel(R) Core(TM)2 Duo CPU P9500 @ 2.53GHz</i> processor and the test program compiled with <i>gcc version 4.4.5 (Debian 4.4.5-6)</i><br />
<br />
<hr /><br />
Whether this makes any huge difference in frames-per-second is debatable, really I had a bit of time and was bored. :-) Anyway, I wouldn't say anything until testing under real-world conditions.<br />
<br />
It does look like the bit-masking <i>fabs</i> can be thrown away, though, and the fast float-to-int is a major win (although beware of possible rounding differences.)Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com9tag:blogger.com,1999:blog-5203830418461309921.post-75984432953761810292011-02-19T14:44:00.000+02:002011-02-19T14:44:46.636+02:00Looking for a copy of my Revenge toolDear Lazyweb,<br />
<br />
If anyone happens to have a copy of the Revenge (Radeon Reverse-Engineering Tool) Git repository, tarball, or code in any format, please comment on this post.<br />
<br />
I know one released tarball was named "revenge-1.0.1.tar.gz", but it is unfortunately lost due to the home directories being lost on people.freedesktop.org. I believe there were newer versions, too.<br />
<br />
I am reasonably (~90%) sure that I have the Git repository stored on one of my computers, unfortunately the computer in question is currently half the world away, and not online.<br />
<br />
Perhaps this post will serve as a reminder to backup your code in more than one location (excluding your workstation.) Yeah, my bad. :-(Oliver McFaddenhttp://www.blogger.com/profile/06947239359915728130noreply@blogger.com3