<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EntBlog</title>
	<atom:link href="http://entland.homelinux.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://entland.homelinux.com/blog</link>
	<description>Code, 3D, Games, Linux and much more...</description>
	<lastBuildDate>Wed, 26 Feb 2014 22:13:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>The technology behind Noesis Gui</title>
		<link>http://entland.homelinux.com/blog/2012/02/08/the-technology-behind-noesis-gui/</link>
		<comments>http://entland.homelinux.com/blog/2012/02/08/the-technology-behind-noesis-gui/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 03:37:26 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Noesis]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=544</guid>
		<description><![CDATA[A brief overview of the technology complexities we faced in NoesisGui]]></description>
			<content:encoded><![CDATA[<div class="img-shadow"><a href="http://www.noesisengine.com/noesis_gui_features.htm"><img src="http://entland.homelinux.com/images/noesis.png" alt="NoesisGUI"/></a></div>
<p>As many of you know, in recent years I have been working at <a href="http://www.noesisengine.com">Noesis Technologies</a> in charge of the technology. We have been very excited these days because we are ready to release our first public software, our internal <strong>user interface technology</strong> released as a middleware called <a href="http://www.noesisengine.com/noesis_gui_features.htm">NoesisGui</a>. This week we are starting to roll out the SDK to participants in the private beta program and as many of you have asked questions about technical details I though it would be a good idea posting here a brief overview of the technology complexities we faced in NoesisGui.</p>
<p><span id="more-544"></span></p>
<p>At the beginning of the development of NoesisEngine, in 2009, we were evaluating different options we had for the user interface and neither of them really satisfied us. We were looking for a GUI that was fully portable, flash-like and fully GPU accelerated. We discussed and decided to develop, in parallel with the rest of our projects, our own technology for rendering user interfaces. One of the big troubles we were aware of was the editor. We didn’t have the resources to implement an editor so we started to evaluate using an already established format. Our first option was parsing swf files but we really didn’t like that option because flash without action script is useless and we didn’t want to interpret action script because we were looking for a native c++ solution. Apart from that, swf is a binary proprietary format and depending on a proprietary tool for editing our resources didn’t appeal us at all. Other options were equally insufficient for us: qt, xul, wxWidgets, windows form, etc. And then we discovered <a href="http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language">xaml</a>. Xaml is an open declarative xml-based language format developed by Microsoft. Xaml is used extensively in several Microsoft products like <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation">WPF</a>, <a href="http://www.silverlight.net/">Silverlight</a> or the <a href="http://en.wikipedia.org/wiki/Metro_%28design_language%29">Metro UI</a>. Thanks to its great versatility, we finally chose xaml for NoesisGui. There are excellent editors like <a href="http://en.wikipedia.org/wiki/Microsoft_Expression_Blend">Microsoft Expression Blend</a>, Visual Studio, <a href="http://kaxaml.com/">Kaxaml</a> or <a href="http://blogs.msdn.com/b/llobo/archive/2008/08/25/xamlpadx-4-0.aspx">XamlPad</a> and being a xml format it can be edited by hand allowing easy integration with external tools and pipelines. </p>
<p>And that is basically NoesisGui, a xaml interpreter that renders using hardware graphics. Let’s dive into the details.</p>
<table align="center">
<tr>
<td>
<div class="img-shadow"><img src="http://entland.homelinux.com/images/noesisgui/duck.jpg"/></div>
</td>
</tr>
<div class="clearer"></div>
</table>
<h4>Xaml Interpreter</h4>
<p>Xaml is a declarative xml-based format with lots of quite interesting features like routed events and dependency properties. It is so powerful that you can even write user interfaces with animations, reactions to events or visual transitions without touching a single line of code.</p>
<p>The first step performed to visualize a xaml in NoesisGui is converting it to our native format. In Noesis we have an universal object model based on reflection and every object loaded at runtime must be stored in that format. This conversion is usually performed offline and the result is an optimal binary blob that loads super fast on each target platform.</p>
<p>At runtime we maintain two trees. The first one represents the logic part and it is the one you interact with. This tree is stored directly inside the binary blob. The second tree stores the visual representation. It contains the nodes you see on screen. This tree is the result of expanding the logic tree with visual templates. For example, a button depending on its skin may be represented with a rounded rect or with an ellipsoid. This template mechanism is what allows skinning and it is usually applied at load time. When the visual tree is ready it contains all the instructions to render itself on screen. The rendering part is done by our vector graphic library. This is where the interesting stuff begins.</p>
<h4>Vector Graphics Library</h4>
<p>VGL is our <a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics">SVG</a>-compliant renderer. We experimented with different implementations like <a href="http://www.khronos.org/openvg/">openvg</a> and <a href="http://en.wikipedia.org/wiki/Direct2D">direct2d</a> although we finally opted for an implementation on top of our directx /opengl gpu renderer. This ended up being the most portable and flexible solution. In this implementation all calculations run inside the gpu through different shaders. A combinatory of approximately one hundred shaders is needed to cover all cases. </p>
<p>The most important challenge faced here was that everything can be animated. For example, geometries may need tessellation on each frame or ramp stop points may be animated. To improve the stress in the communication between cpu and gpu different caching and compression mechanisms were implemented. For example, ramps are heavily compressed on the cpu side and geometry vertices are stored in float16 whenever possible.</p>
<p>Another important aspect to consider is minimizing the number of batches that are sent to the graphics card. For that purpose our vector library uses a very aggressive batching mechanism. You can draw elements in the order you desire because this algorithm will sort the primitives to minimize the number of draw calls.</p>
<table align="center">
<tr>
<td>
<div class="img-shadow"><img src="http://entland.homelinux.com/images/noesisgui/tiger.jpg"/></div>
</td>
</tr>
<div class="clearer"></div>
</table>
<h4>Tessellation</h4>
<p>After the visual tree is updated we need to generate primitives compatible with the gpu, that is, triangles. This is performed in two steps:</p>
<ul>
<li><strong>Flattening</strong>: where curves are converted into straight segments.</li>
<li><strong>Triangulation</strong>: where contours coming from the flattening step are converted into triangles.</li>
</ul>
<p>The triangulation step is critical and can easily become a bottleneck. We tried different implementations:</p>
<ul>
<li>
An <a href="http://zrusin.blogspot.com/2006/07/hardware-accelerated-polygon-rendering.html">implementation</a> using the stencil buffer. We discarded this technique because it is very fill-rate hungry and caching the results in images was not memory efficient. Besides that we were already using the stencil buffer for other purposes.
</li>
<li>
We tried more <a href="http://http.developer.nvidia.com/GPUGems3/gpugems3_ch25.html">gpu alternatives</a> but we found all of them too complex and unable to implement all the svg features. And for portability purposes we did not want to use complex shaders.
</li>
<li>
After all the mentioned problems we ended up using a pure cpu solution and implemented a polygon tessellation algorithm based on <a href="http://oss.sgi.com/cgi-bin/cvsweb.cgi/projects/ogl-sample/main/gfx/lib/glu/libtess/">libtess</a> but with several memory optimizations. This chosen solution allowed us to cache static geometry very efficiently.
</li>
</ul>
<table align="center">
<tr>
<td>
<div class="img-shadow"><img src="http://entland.homelinux.com/images/noesisgui/tux_wire.jpg"/></div>
</td>
</tr>
<div class="clearer"></div>
</table>
<h4>Threading Architecture</h4>
<p>The task of rendering a single frame on NoesisGui is subdivided into many small jobs that are processed by a task scheduler:</p>
<ul>
<li>All the logic always happens in the thread of the caller. Logic actions that change the visual representation (for example clicking a button) are packed in a job.</li>
<li>The job that calculates the new visual representation needs each changed path to be tessellated. A job for each tessellation is created.</li>
<li>Render commands are sent to the GPU with a job.</li>
</ul>
<p>Dependencies between jobs form a graph that represents the full frame execution. The more cores are available in the host the faster that graph is consumed. All this complexity is hidden from the point of view of the sdk client that receives a single API with two asynchronous methods, <em>Update</em>() and <em>Render</em>().</p>
<p>For the task scheduler we use <a href="http://threadingbuildingblocks.org/">tbb</a>, an Intel library that also comes with an interesting scalable allocator.</p>
<table align="center">
<tr>
<td>
<div class="img-shadow"><img src="http://entland.homelinux.com/images/noesisgui/timeline.jpg"/></div>
</td>
</tr>
<div class="clearer"></div>
</table>
<h4>Antialiasing</h4>
<p>High visual quality is a very important aspect where we compete with traditional software rasterizers that render with an almost perfect antialiasing algorithm. NoesisGui offers two solutions for fighting aliasing:</p>
<ul>
<li>NoesisGui is compatible with MSAA surfaces. We take into account sub-pixel information to properly flatten curves, render glyphs or displace paths. MSAA is usually very fast on modern gpus although not so fast on mobile devices. Also MSAA requires a lot of more memory. That is why we experimented with other options.
</li>
<li>When a MSAA surface is not available or when MSAA is too inefficient we extrude the contours of the path to get an approximation of pixel coverage on each pixel. This technique is mentioned in the <a href="http://www.rorydriscoll.com/2012/01/08/ui-anti-aliasing/">CodeItNow</a> blog. The problem with this technique is that shapes are slightly altered.
</li>
</ul>
<p>Definitely, antialiasing is an unsolved problem which needs more experiments to get 100% satisfactory results when MSAA is disabled. What is really frustrating here is that this problem could be easily solved if we had access in the pixel shader to the pixel coverage calculated by the rasterizer.</p>
<h4>Font rendering</h4>
<p>The appearance of fonts is crucial to improve the quality of any GUI. <a href="http://www.freetype.org/">Freetype</a> is the third-party we are using for rendering font glyphs. We experimented with different text rendering techniques to end up implementing the following ones:</p>
<ul>
<li>We opted for disabling hinting as much as possible because it deforms the aspect of the font. In NoesisGUI only vertical hinting is considered and horizontal sub-pixel displacements are allowed. The reasoning behind this is perfectly explained in a <a href="http://www.antigrain.com/research/font_rasterization/index.html">document</a> from the excellent <a href="http://www.antigrain.com/">AGG project</a>.
</li>
<li>When rendering on LCD displays <a href="http://www.grc.com/cleartype.htm">sub-pixel font rendering</a> technology is used. This technique can be implemented in hardware as detailed in <a href="http://forum.beyond3d.com/archive/index.php/t-19046.html">beyond3d forums</a>.
</li>
<li>As the rest of paths, stroking can be applied to text. For example, by stroking text without filling the interior, you can achieve an outline effect.
</li>
</ul>
<table align="center">
<tr>
<td>
<div class="img-shadow"><img src="http://entland.homelinux.com/images/noesisgui/font.jpg"/></div>
</td>
</tr>
<div class="clearer"></div>
</table>
<h4>Conclusion</h4>
<p>I have highlighted the most interesting features of NoesisGUI. Of course, we offer the rest of features you would expect in a decent sdk (like profiling information, memory hooking or filesystem abstraction) and that I am not mentioning here because I do not want to bore you.</p>
<p>After all the time working on this part of Noesis engine, we are confident that NoesisGui is one of the most powerful, if not the most, GUIs for real-time applications. We encourage you to test it and give us feedback. Beta program is already <a href="http://www.noesisengine.com/noesis_gui_licensing.htm">available for free!</a> And as always, comments are welcome here or in my twitter account.</p>
<p>&nbsp;&nbsp;<br />
<a href="https://twitter.com/noesisengine" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @noesisengine</a><br />
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script><br />
<a href="https://twitter.com/EntTwit" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @EntTwit</a><br />
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p>
<div class="clearer"></div>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2012/02/08/the-technology-behind-noesis-gui/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Twitter</title>
		<link>http://entland.homelinux.com/blog/2011/09/26/twitter/</link>
		<comments>http://entland.homelinux.com/blog/2011/09/26/twitter/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 16:12:17 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=531</guid>
		<description><![CDATA[Whoops, long time since my last post! It&#8217;s been exciting days this last year working very hard in different projects starting an own small business with my partners. Next week we are going to shed light on at least one of them. I have several draft articles pending to be published here. As soon as [...]]]></description>
			<content:encoded><![CDATA[<div class="img-shadow"><img src="http://entland.homelinux.com/images/twitter.jpg" alt="twitter bird"/></div>
<p>Whoops, long time since my last post! It&#8217;s been exciting days this last year working very hard in different projects starting an own small business with my partners. Next week we are going to shed light on at least one of them.</p>
<p>I have several draft articles pending to be published here. As soon as I have time I will recover energy for this blog.</p>
<p>Meanwhile, you can follow me on my twitter account: <a href="http://twitter.com/#!/EntTwit">@EntTwit</a></p>
<div class="clearer"></div>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2011/09/26/twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Art of Multiprocessor Programming</title>
		<link>http://entland.homelinux.com/blog/2010/07/05/the-art-of-multiprocessor-programming/</link>
		<comments>http://entland.homelinux.com/blog/2010/07/05/the-art-of-multiprocessor-programming/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 12:36:59 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=494</guid>
		<description><![CDATA[The Art of Multiprocessor Programming Author: Maurice Herlihy &#038; Nir Shavit Pages: 508 Published: 2008 Multiprocessor is everywhere now. After a period of uncertainty and fear we are starting to grasp multiprocessor architectures. We have started to forget about threads and started to think about tasks / jobs to decompose algorithms. The book The Art [...]]]></description>
			<content:encoded><![CDATA[<div class="img-shadow"><a href="http://www.amazon.com/dp/0123705916/ref=nosim?tag=ent0c-20"><img src="http://entland.homelinux.com/images/books/TheArtOfMultiprocessorProgramming.png" alt="The Art of Multiprocessor Programming book image"/></a></div>
<p><strong>The Art of Multiprocessor Programming<br />
Author: Maurice Herlihy &#038; Nir Shavit<br />
Pages: 508<br />
Published: 2008</strong></p>
<p>Multiprocessor is everywhere now. After a period of uncertainty and fear we are starting to grasp multiprocessor architectures. We have started to forget about threads and started to think about tasks / jobs to decompose algorithms. The book <a href="http://www.amazon.com/dp/0123705916/ref=nosim?tag=ent0c-20">The Art of Multiprocessor Programming</a> will help you to have a solid background to implement a powerful multithreading architecture in your application.</p>
<p>The book is written as a textbook and each chapter at the end includes exercises that practice the presented concepts. In spite of the fact that this book may seem too academic in some sections, it is written and structured precisely. Java language is used in all samples although there is an appendix at the end of the book which describes the basic techniques using C# and C++ (using <a href="http://en.wikipedia.org/wiki/POSIX_Threads">POSIX Threads</a>). This book is definitely not for copying code but it is to understand deep details. After reading you should be prepared to start implementing these techniques yourself although I would recommend to use a good middleware (like <a href="http://www.threadingbuildingblocks.org/">TBB</a>). Both actions are complementary to this book.</p>
<p>The book is structured in three parts. The content of the first part is definitions of mutual exclusion, fairness, memory models, shared memory and it may be hard to read. The second part is dedicated to real implementation. Firstly, basic tools like spin locks, monitors and semaphores are studied and implemented. Next, high-level containers are implemented using different techniques (mutexes, lock-free algorithms, etc): linked lists, concurrent queues, concurrent stacks, concurrent hashes, skip lists and priority queues. The chapter 16 is quite interesting. It is dedicated to <a href="http://en.wikipedia.org/wiki/Futures_and_promises">futures</a> and scheduling. Implementations like the <a href="http://en.wikipedia.org/wiki/Cilk">Cilk Scheduler</a> are described and implemented. The last part of the book (although included in the practice section) is dedicated to further experimental techniques like <a href="http://en.wikipedia.org/wiki/Transactional_memory">Transactonal Memory</a>. It is good to see a working implementation of it.</p>
<p>I strongly recommend this book for the core programmers of your team, for those who will be in direct contact with the multithreading architecture. Although I would prefer a version of the book in C and I found some bugs and errors (probably due to being the first revision) I have not found other better book.</p>
<p><strong>Rating: 7 / 10</strong></p>
<div class="clearer"></div>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2010/07/05/the-art-of-multiprocessor-programming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code Bloat Hunting</title>
		<link>http://entland.homelinux.com/blog/2010/02/06/code-bloat-hunting/</link>
		<comments>http://entland.homelinux.com/blog/2010/02/06/code-bloat-hunting/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 00:39:47 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=466</guid>
		<description><![CDATA[I have dedicated the last few days of work to face a problem that is getting bigger and bigger. Although we have a quite modular codebase, use interfaces whenever possible to hide implementation details and apply most of the recipes recommended in classic books, our linking times have started to be a problem in some [...]]]></description>
			<content:encoded><![CDATA[<div class="img-shadow"><img src="http://entland.homelinux.com/images/escher.jpg" alt="Image with lots of books"/></div>
<p>I have dedicated the last few days of work to face a problem that is getting bigger and bigger. Although we have a quite modular codebase, use interfaces whenever possible to hide implementation details and apply most of the recipes recommended in <a href="http://www.amazon.com/dp/0201633620/ref=nosim?tag=ent0c-20">classic books</a>, our <strong>linking times</strong>  have started to be a problem in some of our libraries. Linking times is not the only problem. Our binary sizes are becoming really fat.</p>
<p>After a thoroughly study with the help of tools like <a href="http://aras-p.info/projSizer.html">Sizer</a>, <a href="http://gameangst.com/?p=320">Symbol Sort</a> (I strongly recommend reading the articles associated to this tool: <a href="http://gameangst.com/?p=46">1</a>, <a href="http://gameangst.com/?p=226">2</a>, <a href="http://gameangst.com/?p=212">3</a>, <a href="http://gameangst.com/?p=222">4</a>, <a href="http://gameangst.com/?p=224">5</a>, <a href="# http://gameangst.com/?p=246">6</a> and passing all them to your co-workers) we discovered lot of code bloating generated by improper template usage. The template is a powerful tool that can be easily misused although I am not against using it. We use template metaprogramming in lots of places like reflection, annotations, uri-like dependency properties, serialization and more places where it is worth it.  The problem with templates is that normally declarations and definitions go in the same header file. With that structure a compiler is normally forced (although some <a href="http://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html">compilers</a> allow customization) to generate template instances in each obj file. Redundancy is eliminated in the linking phase, of course taking time. This is one of the faces of template bloating. The other face appears when you templatize functions when it is not strictly necessary. And you pay for it in the final size of your binaries.</p>
<p>Trying to solve all this, we applied a solution that although yet not standard seems to work in all compilers we tested: exporting <a href="http://anteru.net/2008/11/19/318/">explicit template instantiations</a>. This technique applies when you have a template that is to be instantiated for only a few known types. Those instantiations are exported from a dll. This allows even hiding big functions in the .cpp without having to show them in the header. With this solution you have the best of both worlds: short functions can be inlined by the compiler and large functions instead of being instantiated in each compilation unit are referenced as an exported symbol. By the way, a <a href="http://msdn.microsoft.com/en-us/library/by56e477.aspx">special behavior</a> of Visual Studio (to me, it is a bug) has the effect of non inlining functions being defined outside the class when exporting the template. We had to move our definitions (that we usually have pseudo hidden in a .inl file) to inside the class declaration.</p>
<p>We applied this strategy in several places reducing the bloatage by a considerable factor. For example, the vector library seems an ideal target because you normally only instantiate that library for a few types (float, double, int) and &#8220;big&#8221; functions like Invert() for 4&#215;4 matrices can be hidden and exported from the dll. Another good candidate is std::string (instances for chat and wchar_t). Although, at least in MSVC, this job is already being done by the crt (not tested in other platforms).</p>
<p>I hope you find this useful. Thanks for reading and welcome to all the new subscribers since my last post!</p>
<div class="clearer"></div>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2010/02/06/code-bloat-hunting/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Documentation Challenge</title>
		<link>http://entland.homelinux.com/blog/2009/07/28/the-documentation-challenge/</link>
		<comments>http://entland.homelinux.com/blog/2009/07/28/the-documentation-challenge/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 19:58:51 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=407</guid>
		<description><![CDATA[Documentation is the part of the development process where usually less time and money is invested. Few resources implies a poor infrastructure for something that, as the project gets bigger and bigger, becomes a very important part of the overall process. I want to share in this post the approach we are following for a [...]]]></description>
			<content:encoded><![CDATA[<div class="img-shadow"><img src="http://entland.homelinux.com/images/Documentation.jpg" alt="Image with lots of books"/></div>
<p>Documentation is the part of the development process where usually less time and money is invested. Few resources implies a poor infrastructure for something that, as the project gets bigger and bigger, becomes a very important part of the overall process.</p>
<p>I want to share in this post the approach we are following for a project I have been involved with for over two years. This project (I will be able to give details about it very soon) is mainly a framework composed of libraries to be used by other companies. Basically, a work from developers to developers, clearly a context where documentation becomes very important.</p>
<p><span id="more-407"></span></p>
<p>The main objectives we tried to achieve with this architecture:</p>
<ul>
<li>Documentation must be located in the code repository. This means that each development branch has its own documentation that is integrated in the same way that the code.</li>
<li>Documentation generation must be part of the building process. We use our build pipeline for everything: compile versions, test versions, compile data packages, generate installers, distribute symbols and, of course, build documentation. This means that the source of the documentation must be a very basic representation, easy to edit, that later is converted to a pdf, doc, html by the building process. This point implies that the documentation can be easily distributed to clients or even generated by themselves.</li>
<li>Access to current documentation must be integrated into the development environment. In the same way I can review bugs in the bugtracker, stories in the task manager and browse the source code I must be able to read the current documentation from a web browser without having to rebuilt it manually.</li>
</ul>
<p>We make the distinction between two kind of documentation: <strong>API Documentation</strong> and <strong>Technical Articles</strong>.</p>
<p><strong>API documentation</strong> are those documents where class usage is described: description for each function, for each parameter, enumerations, etc. <a href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</a> seems the perfect fit for this purpose. But after several projects using it we opted for not using it in this project because we considered it a waste of time. Doxygen may be really useful to generate documentation for a library that is distributed without sources but one of the pillars of our development philosophy is to always provide source code to clients. This way, they can choose how to compile it: one dll, several dlls, one lib&#8230; and tweak the different configurations. Another good rule that we follow is that code must document itself. Doxygen would force us to write code like this:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> MemoryManager<span style="color: #008080;">:</span> <span style="color: #0000ff;">public</span> MemoryAllocator
<span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">/// Allocates memory on a specified alignment boundary</span>
    <span style="color: #666666;">/// \param size Size in bytes of the block requested by the user</span>
    <span style="color: #666666;">/// \param alignment The alignment value, which must be an integer power of 2</span>
    <span style="color: #666666;">/// \return A pointer to the new allocated block of memory</span>
    <span style="color: #666666;">/// \remarks Thread-safe</span>
    <span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">void</span><span style="color: #000040;">*</span> AlignedAlloc<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">size_t</span> size, <span style="color: #0000ff;">size_t</span> alignment<span style="color: #008000;">&#41;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Quite redundant code, don&#8217;t you think? Obviously <em>AlignedAlloc()</em> allocates memory that is aligned on a boundary, I do not need a comment for that! The same for the function parameters. So we ended up writing documentation for only the parts that are really confusing or need a clarification (for example, the fact that <em>AlignedAlloc()</em> is thread-safe) and using the source code as the documentation itself for both the interface and the implementation. We augment this documentation by using unit tests that serve as example usage for each class. We know this decision is a controversial one and may be in the future we return back to using Doxygen or something similar. But for now, it is working fine.</p>
<p>A <strong>technical article</strong> is like a manual that describes the architecture and philosophy of a specific part of the framework. They provide information to a deeper level than the mere description of classes provided by the API documentation. We usually link to technical articles from API documents. </p>
<p>Although a wiki seems an ideal candidate for writing technical articles we rejected it because it didn&#8217;t satisfy the points enumerated above. Years ago and inspired by the <a href="http://www.gentoo.org/proj/en/gdp/">Gentoo Documentation Project</a> I used <a href="http://www.docbook.org/">DocBook</a> for a similar purpose. I wrote about it in a previous article: <a href="http://entland.homelinux.com/blog/2006/05/02/xml-documentation/">Documentation using XML</a>. And although the results were quite satisfactory I didn&#8217;t want to return to that solution, mainly because a XML format is hard to write, edit, maintain, etc. I think we found a better solution: <a href="http://docutils.sourceforge.net/rst.html">reStructuredText</a>. reStructuredText is part of the DocUtils suite and from very simple what-you-see-is-what-you-get plaintext markup it generates quite good looking documents. Another bonus feature that finally inclined the balance towards reStructuredText is that it perfectly integrates with <a href="http://trac.edgewall.org/">Trac</a> which we have been using since the beginning. Trac is a suite that integrates wiki, bugtracking, source code browsing and task management in a single web program. I like to see trac as a free alternative to <a href="http://www.fogcreek.com/FogBugz/">FogBuz</a>. Trac supports both its own wiki format and reStructuredText allowing us to integrate the documentation located in the repository as part of our wiki infrastructure satisfying the last point mention above. Time will say if this infrastructure will suffice.</p>
<p>Want to comment how do you solve the documentation issues in your project? Please do so. Comments are open. Thanks for reading.</p>
<div class="clearer"></div>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2009/07/28/the-documentation-challenge/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Compile-Time Strings</title>
		<link>http://entland.homelinux.com/blog/2009/04/28/compile-time-strings/</link>
		<comments>http://entland.homelinux.com/blog/2009/04/28/compile-time-strings/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 22:19:40 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[CodeGems]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=346</guid>
		<description><![CDATA[It would be nice if we had such a feature in the C language, wouldn&#8217;t it? The term &#8216;compile-time string&#8217; is referred here as strings that are converted to unique integer identifiers at compile time. At run-time those identifiers are simple integers that can be compared and hashed very fast. In other languages, like for [...]]]></description>
			<content:encoded><![CDATA[<p>It would be nice if we had such a feature in the C language, wouldn&#8217;t it? The term &#8216;compile-time string&#8217; is referred here as strings that are converted to unique integer identifiers at compile time. At run-time those identifiers are simple integers that can be compared and hashed very fast.  In other languages, like for example Smalltalk, the concept of Symbol implements a similar idea. The following post describes a possible implementation of this feature in C/C++.</p>
<p><span id="more-346"></span></p>
<p>Imagine, for example, a generic object factory where object instances are created using unique identifiers. The classical solution here is having a shared-by-all-code header where all the identifiers are declared in a C enumeration. This solution, apart from creating a serious physical dependency where adding a new identifier to the enumeration forces a recompilation for all the project, is unfeasible in modular architectures where modules are isolated. In those architectures having a global header is not an option.</p>
<p>One viable solution may be using strings as identifiers. But strings are heavy objects, hard to compare and prone to typing errors because miswritten symbols would be detected at run-time instead of compile-time. Other equally insufficient solutions to this problem include <a href="http://en.wikipedia.org/wiki/FourCC">FourCC</a> and esoteric template tricks for generating a hash at compile time (desist from it, it is not possible to solve this 100% with templates because strings cannot be used as template parameters and anyway hashing a string is not collision-free. More information in <a href="http://www.usenet.com/newsgroups/comp.lang.c++.moderated/msg05807.html">this usenet thread</a>). Mick West proposes more solutions in his <a href="http://cowboyprogramming.com/2007/01/04/practical-hash-ids/">Practical Hash IDs</a> article.</p>
<p>What follows is an implementation that has been working nicely for me and that satisfactorily fits the requirements for simulating compile-time strings. First let me show you two examples of the usage:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">namespace</span>
<span style="color: #008000;">&#123;</span>
DECLARE_SYMBOL<span style="color: #008000;">&#40;</span>CubeMesh<span style="color: #008000;">&#41;</span>
DECLARE_SYMBOL<span style="color: #008000;">&#40;</span>SphereMesh<span style="color: #008000;">&#41;</span>
DECLARE_SYMBOL<span style="color: #008000;">&#40;</span>DuckMesh<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> CollectNodes<span style="color: #008000;">&#40;</span>Ptr<span style="color: #000080;">&lt;</span>Node<span style="color: #000080;">&gt;</span><span style="color: #000040;">&amp;</span> node<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    Ptr<span style="color: #000080;">&lt;</span>Mesh<span style="color: #000080;">&gt;</span> mesh0 <span style="color: #000080;">=</span> CreateObject<span style="color: #008000;">&#40;</span>S<span style="color: #008000;">&#40;</span>CubeMesh<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Add<span style="color: #008000;">&#40;</span>mesh0<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    Ptr<span style="color: #000080;">&lt;</span>Mesh<span style="color: #000080;">&gt;</span> mesh1 <span style="color: #000080;">=</span> CreateObject<span style="color: #008000;">&#40;</span>S<span style="color: #008000;">&#40;</span>SphereMesh<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Add<span style="color: #008000;">&#40;</span>mesh1<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    Ptr<span style="color: #000080;">&lt;</span>Mesh<span style="color: #000080;">&gt;</span> mesh2 <span style="color: #000080;">=</span> CreateObject<span style="color: #008000;">&#40;</span>S<span style="color: #008000;">&#40;</span>DuckMesh<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>Add<span style="color: #008000;">&#40;</span>mesh2<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">namespace</span>
<span style="color: #008000;">&#123;</span>
DECLARE_SYMBOL<span style="color: #008000;">&#40;</span>FirstMessage<span style="color: #008000;">&#41;</span>
DECLARE_SYMBOL<span style="color: #008000;">&#40;</span>SecondMessage<span style="color: #008000;">&#41;</span>
DECLARE_SYMBOL<span style="color: #008000;">&#40;</span>ThirdMessage<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> ProcessMessage<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> Message<span style="color: #000040;">&amp;</span> msg<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>msg.<span style="color: #007788;">id</span> <span style="color: #000080;">==</span> S<span style="color: #008000;">&#40;</span>FirstMessage<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
       <span style="color: #666666;">/// ...</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>msg.<span style="color: #007788;">id</span> <span style="color: #000080;">==</span> S<span style="color: #008000;">&#40;</span>SecondMessage<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
       <span style="color: #666666;">/// ...</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>msg.<span style="color: #007788;">id</span><span style="color: #000080;">==</span> S<span style="color: #008000;">&#40;</span>ThirdMessage<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
       <span style="color: #666666;">/// ...</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>A symbol represents a compile-time string. They must be declared before being used. The macro for declaring a symbol is hiding an inline function with a static inside itself:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#define DECLARE_SYMBOL(id)\
    inline Symbol __GetSymbol##id() throw()\
    {\
        static size_t sym;\
        if (sym == 0)\
        {\
            sym = GetIdFromString(#id);\
        }\
        return Symbol(sym);\
    }</span></pre></div></div>

<p>The function GetIdFromString() hashes the string, stores it in an internal table and returns the table position for that string (the Symbol class is a simple wrapper around the identifier). This is done only the first time the symbol is requested. For future requests the static ID is returned. This adds a little overhead against using simple integers as symbols. Beware of local static initializations: they are not thread-safe. That is the reason of the manual comparison against 0. GetIdFromString() must be thread-safe for this code to work.</p>
<p>The S macro simply invokes the local function previously generated:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#define S(id) __GetSymbol##id()</span></pre></div></div>

<p>And there you have it. Compile-time strings with negligible (in case you are doing anything more that simply comparing symbols) overhead. In case you need 100% efficient code you could pre-generate a table with the symbols being used by your project (searching for all DECLARE_SYMBOL blocks) and substitute each S() with a really unique identifier generated at compile-time. And that would be so easy if the preprocessor could be extended in a standard way&#8230;</p>
<p>Hope this makes sense. Thank you for reading.</p>
<p>&nbsp;</p>
<div class="hr"></div>
<ol>
<li>
<a href="http://cowboyprogramming.com/2007/01/04/practical-hash-ids/">Practical Hash IDs</a>
</li>
<li>
<a href="http://en.wikipedia.org/wiki/FourCC">FourCC</a>
</li>
<li>
<a href="http://www.usenet.com/newsgroups/comp.lang.c++.moderated/msg05807.html">Compile-time string hash generator</a>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2009/04/28/compile-time-strings/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Andrew Glassner&#8217;s Notebook</title>
		<link>http://entland.homelinux.com/blog/2009/03/09/andrew-glassners-notebook/</link>
		<comments>http://entland.homelinux.com/blog/2009/03/09/andrew-glassners-notebook/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 00:52:37 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Books]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=273</guid>
		<description><![CDATA[Andrew Glassner&#8217;s Notebook Author: Andrew Glassner Pages: 304 Published: 1999 During periods in which I need to stay focused in hard technical problems I try to avoid reading dense books because they distract me from my work. I found this book in my bookshelf, in the stack of unread books , and decided to skim [...]]]></description>
			<content:encoded><![CDATA[<div class="img-shadow"><a href="http://www.amazon.com/dp/1558605983/ref=nosim?tag=ent0c-20"><img src="http://entland.homelinux.com/images/books/AndrewGlassnerNotebook.jpg" alt="Andrew Glassner's Notebook book image"/></a></div>
<p><strong>Andrew Glassner&#8217;s Notebook<br />
Author: Andrew Glassner<br />
Pages: 304<br />
Published: 1999</strong></p>
<p>During periods in which I need to stay focused in hard technical problems I try to avoid reading dense books because they distract me from my work. I found this book in my bookshelf, in the stack of unread books <img src='http://entland.homelinux.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , and decided to skim it a little bit. &#8220;This book is about having fun with computer graphics&#8221;, that&#8217;s the beginning of this book written by Andrew Glassner (editor of the mythical <a href="http://www.amazon.com/dp/0122861663/ref=nosim?tag=ent0c-20">The Graphics Gems</a> series, when the gem series were not a virus, and the classic <a href="http://www.amazon.com/dp/1558602763/ref=nosim?tag=ent0c-20">Principles of Digital Image Synthesis</a> among others). As soon as I started to read the first chapter I couldn&#8217;t stop.</p>
<p>I was expecting to find a book very similar to the Jim Blinn series, the <a href="http://www.amazon.com/dp/1558603875/ref=nosim?tag=ent0c-20">Jim Blinn&#8217;s Corner</a>. And although the structure and the origin is the same, a compilation of articles published by Glassner in a column of the bimonthly magazine IEEE Computer Graphics &#038; Applications, this book is radically different to other books about graphics and mathematics. No formulas, no algorithms, no code in this book. Instead, you will learn about origami and the platonic solids and the teapotahedrom, how to organize the LCD segments of a digital display, the phenomenon of moiré patterns, designing tiles that are aperiodic (I didn&#8217;t know <a href="http://www.uwgb.edu/DutchS/symmetry/aperiod.htm">it was possible</a>) or even how to layout box designs in a single piece of cardboard. After reading this chapter, the next time you unpack a box from Amazon you will pay attention to those little details that usually pass unnoticed. </p>
<p>Apart from the old revised chapters you can find columns that were never published too. Disparate topics, but all of them related to graphics and 3D in some sense. The visual quality of the book is excellent with all the pages in full color and the style of the author is even better. Andrew Glassner is among the best writers in the Computer Graphics field. </p>
<p>I give my full recommendation to this book. Andrew Glassner&#8217;s Notebook will appeal to both novice readers and experienced mathematicians.</p>
<p><strong>Rating: 8 / 10</strong></p>
<div class="clearer"></div>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2009/03/09/andrew-glassners-notebook/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Planet 51 Trailer</title>
		<link>http://entland.homelinux.com/blog/2009/01/16/planet-51-trailer/</link>
		<comments>http://entland.homelinux.com/blog/2009/01/16/planet-51-trailer/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 10:26:08 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Videogames]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=318</guid>
		<description><![CDATA[Since the first day I saw content from Planet51 I knew it was going to rock. I am emotionally attached to this movie because I worked in the Videogame for a few months and because I have worked in the past with several member of the technical team that is behind the movie. I know [...]]]></description>
			<content:encoded><![CDATA[<div class="img-shadow"><img src="http://entland.homelinux.com/images/Planet51.png" alt="Planet51 logotype"/></div>
<p>Since the first day I saw content from Planet51 I knew it was going to rock. I am emotionally attached to this movie because I worked in the Videogame for a few months and because I have worked in the past with several member of the technical team that is behind the movie. I know first hand they are very talented people.</p>
<p>And finally, the trailer is now live: <a href="http://www.sonypictures.com/movies/planet51/">Planet51 trailer</a>!</p>
<p>Congratulations to all the team. All the best for them.</p>
<div class="clearer"></div>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2009/01/16/planet-51-trailer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stripping comments from Shader bytecodes</title>
		<link>http://entland.homelinux.com/blog/2009/01/15/stripping-comments-from-shader-bytecodes/</link>
		<comments>http://entland.homelinux.com/blog/2009/01/15/stripping-comments-from-shader-bytecodes/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 20:37:39 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[CodeGems]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=281</guid>
		<description><![CDATA[In DirectX, when compiling a shader with D3DXCompileShader() a buffer containing the shader bytecodes is received. Apart from the bytecodes, extra content like debug and symbol table information is embedded. That extra information is added in form of comments that probably can be eliminated because you are already processing it at compile-time and it is [...]]]></description>
			<content:encoded><![CDATA[<p>In DirectX, when compiling a shader with <strong>D3DXCompileShader()</strong> a buffer containing the shader bytecodes is received. Apart from the bytecodes, extra content like debug and symbol table information is embedded. That extra information is added in form of comments that probably can be eliminated because you are already processing it at compile-time and it is not needed at run-time when loading the shader.</p>
<p>If you can do without that information the following code will help you to save a few bytes, even halving the size of the byte-code in the best cases.</p>
<p>Although not documented in the DirectX SDK, this CodeGem is not an undocumented hack. The Direct3D shader code format is documented in the <a href="http://msdn.microsoft.com/en-us/library/ms800355.aspx">MSDN</a>, so it probaly won&#8217;t change in future revision of DirectX v9.0 (if there is going to be any more&#8230;)</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">D3DPtr<span style="color: #000080;">&lt;</span>ID3DXBuffer<span style="color: #000080;">&gt;</span> StripComments<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> D3DPtr<span style="color: #000080;">&lt;</span>ID3DXBuffer<span style="color: #000080;">&gt;</span><span style="color: #000040;">&amp;</span> code<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #666666;">// Calculates the new size (without comments)</span>
    <span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> codeData <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000040;">*</span><span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span>code<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetBufferPointer<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> sizeInWords <span style="color: #000080;">=</span> code<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetBufferSize<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">/</span> <span style="color: #0000dd;">4</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> strippedSizeInWords <span style="color: #000080;">=</span> sizeInWords<span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> sizeInWords<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>codeData<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0xffff</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> D3DSIO_COMMENT<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0000ff;">int</span> commentSize <span style="color: #000080;">=</span> codeData<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&gt;&gt;</span> <span style="color: #0000dd;">16</span><span style="color: #008080;">;</span>
            strippedSizeInWords <span style="color: #000040;">-</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #000040;">+</span> commentSize<span style="color: #008080;">;</span>
            i <span style="color: #000040;">+</span><span style="color: #000080;">=</span> commentSize<span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #666666;">// Creates a new buffer with the original code but omitting the comments</span>
    D3DPtr<span style="color: #000080;">&lt;</span>ID3DXBuffer<span style="color: #000080;">&gt;</span> strippedCode<span style="color: #008080;">;</span>
    V<span style="color: #008000;">&#40;</span>D3DXCreateBuffer<span style="color: #008000;">&#40;</span>strippedSizeInWords <span style="color: #000040;">*</span> <span style="color: #0000dd;">4</span>, strippedCode.<span style="color: #007788;">GetPtrForInit</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> strippedCodeData <span style="color: #000080;">=</span> <span style="color: #0000ff;">static_cast</span><span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000040;">*</span><span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span>strippedCode<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>GetBufferPointer<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">size_t</span> offset <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> sizeInWords<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>codeData<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0xffff</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">==</span> D3DSIO_COMMENT<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0000ff;">int</span> commentSize <span style="color: #000080;">=</span> codeData<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&gt;&gt;</span> <span style="color: #0000dd;">16</span><span style="color: #008080;">;</span>
            i <span style="color: #000040;">+</span><span style="color: #000080;">=</span> commentSize<span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0000ff;">else</span>
        <span style="color: #008000;">&#123;</span>
            strippedCodeData<span style="color: #008000;">&#91;</span>offset<span style="color: #000040;">++</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> codeData<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">return</span> strippedCode<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2009/01/15/stripping-comments-from-shader-bytecodes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Three free productivity booster tools</title>
		<link>http://entland.homelinux.com/blog/2008/12/20/three-free-productivity-booster-tools/</link>
		<comments>http://entland.homelinux.com/blog/2008/12/20/three-free-productivity-booster-tools/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 16:30:35 +0000</pubDate>
		<dc:creator>ent</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://entland.homelinux.com/blog/?p=221</guid>
		<description><![CDATA[We, as programmers, see optimization opportunities everywhere, and more when they can be applied to our work tool, the computer. What follows is an enumeration of three tools that will save you precious time in your daily work. To me, they have become indispensable tools. Hope they will become the same for you: Launchy. Launchy [...]]]></description>
			<content:encoded><![CDATA[<p>We, as programmers, see optimization opportunities everywhere, and more when they can be applied to our work tool, the computer. What follows is an enumeration of three tools that will save you  precious time in your daily work. To me, they have become indispensable tools. Hope they will  become the same for you:</p>
<ul>
<li><strong><a href="http://www.launchy.net/">Launchy</a></strong>. Launchy is a keystroke launcher that clones the behaviour of <a href="http://docs.blacktree.com/quicksilver/what_is_quicksilver">Quicksilver</a> in Mac OS. With this tool you will say goodbye to your start menu and desktop icons. Everything is now accessible from a few keystrokes: folders, applications and even websites, all with a simple alt + space. The perfect complement for Launchy is <a href="http://www.tordex.com/startkiller/">StartKiller</a>, a tool for removing the Start button from the taskbar. To me, Launchy is as revolutionary as <a href="http://en.wikipedia.org/wiki/4DOS">4DOS</a> was back in MS-DOS days. How much time did you save? (bonus: and now that you can have a 100% clean desktop it is time to use a decent <a href="http://night-fate.deviantart.com/art/another-world-wallpaper-VIII-93708854">wallpaper</a>&#8230;).</li>
<li><strong><a href="http://www.autohotkey.com/">AutoHotkey</a></strong>. Whatever can not be done with a few launchy keystrokes most likely can be programmed with an AutoHotkey macro.  AutoHotkey incorporate a powerful script language that will allow you to automate almost anything: instant access to disk folders, internet tabs, activate tray programs, change visual studio layouts, send email, check calendar, etc.</li>
<li><strong><a href="http://zabkat.com/">xplorer²</a></strong>. xplorer² is a file manager with enough <a href="http://zabkat.com/x2facts.htm">features</a> to say good bye to Windows Explorer (Microsoft, admit it, it is not designed for advanced file manipulation). Although there is a professional version, the free lite version is enough to me, especially the Tabbed dual-pane interface feature. With AutoHotkey you can easily redirect Win + E to xplorer².</li>
</ul>
<p>And that closes out my small contribution to reduce energy wastage in the world <img src='http://entland.homelinux.com/blog/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' /> . I am sure you can share more gems like these. One more time, thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://entland.homelinux.com/blog/2008/12/20/three-free-productivity-booster-tools/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
