Ubuntu on the Razer Blade Stealth (late 2016)

I received my Razer Blade Stealth (late 2016) last week. I needed to install Ubuntu to work on some of my projects and to use as my “private stuff” OS (as-opposed to my “company stuff OS”, which is Windows). So I installed Ubuntu as a dual boot alongside Windows 10. Here is how I did it.

  1. Shrink the Windows partition.
  2. Download the Ubuntu 16.10 iso file.
  3. Create a bootable Ubuntu USB drive using UNetbootin.
  4. Install Ubuntu.

Then, you’ll probably notice Ubuntu gets stuck in a suspend/resume loop when you close and reopen the lid. To fix this, add “button.lid_init_state=open” to the grub boot parameters and update grub.

Atom plugins for C++ development

I work a lot on Ubuntu, and Linux is one of the targets of Minko. As soon as Github’s Atom was released, I wanted to test it as an actual development environment for such C++ applications.

Here are two plugins I think are major additions to Atom for C++ development.


Autocomplete is a major feature for any IDE. In the case of C++, it’s even more important because of the complexity of the language. The autocomplete-clang plugin uses clang static analysis to parse headers. It then extends Atom’s autocomplete feature to properly autocomplete C++.


The plugin works great. It’s less tightly integrated than VisualStudio’s Intellisense. So it’s not as fast. Still, the lack of speed is not a big issue compared to the ease the plugin brings. Using pre-compiled headers should speed things up, but I haven’t tried them yet: I guess it says a lot about how not much of a problem this lack of performance might be…


Compiling your code to check its syntax is not a very efficient process. You keep Alt-Tabing between your editor and the terminal where you run compilation. It’s a given clang’s output is a lot more readable than GCC’s. Still, it’s not as integrated as VisualStudio real-time analysis.


The linter-clang plugin fixes that. Once again, it uses clang’s static analysis to check your code and properly report errors in real-time. No need to try to compile your code: linter-clang will check for errors as you type and will report them visually directly in the editor, just like Eclipse or VisualStudio do it.

Using those plugins with Minko

Both those plugins will need to call clang with the proper flags. And those flags depend on your very project. In the case of autocomplete-clang, those flags can be setup in a .clang_complete files at the root of your project (this method is actually inspired from Vim’s popular clang autocomplete plugin). But linter-clang does not support .clang_complete files, so I made a patch available here (that patch will hopefully be merged soon as you can read here).

To generate such .clang_complete files, Minko’s build system has been updated with a “clang-complete” action. This action will automatically create the .clang_complete files for each Minko project (the core framework, the plugins, the tutorials…) or your own project with a single command line :

Instead of solution/project files, this premake action will generate .clang_complete files with each project’s specific flags.

XPS 13 “Developer Edition” Microphone Fix

It seems the microphone doesn’t work out of the box on the XPS 13 “Developer Edition”. Worse, you’ll actually need to re-compile your kernel to make it work… at least the patches are easy to find thanks to Dell’s “Project Sputnik” leader Barton George:

I used those on the Linux 4.0.2 (stable) kernel, recompiled, installed… and voilà! The microphone works!

Hopefully those fixes will soon be in the kernel main line…

XPS13 “Developer Edition”: Updating the graphics driver

Update: I previously indicated to use the “xorg-edgers” PPA. But it’s far too brutal since it will update a lot of other things (such as the X server) and it might just break. I now recommend using the Oibaf PPA to update only the drivers.

Following my article about a few “out of the box” fixes for the XPS 13 “Developer Edition”, I wanted to upgrade the Intel graphics driver and Mesa. Indeed, I noticed some issues with 3D apps:

  • most games were incredibly slow, or at least a lot slower than what ohter got with the same hardware on Windows (and OpenGL performance are supposed to be on-par or close – if not better – on Linux now);
  • WebGL was not available neither on Chromium nor Firefox, even through their latest stable version.

The pre-installed version of Mesa (10.1.3) is pretty old (May 2014). You can upgrade it to the latest version along with the latest Intel drivers using the “xorg-edgers” PPA the Oibaf “Updated and Optimized Open Graphics Drivers” PPA.

Updating the i915 drivers and Mesa should give you a very important performance boost on 3D apps. I noticed “Counter Strike: Global Offensive” went from barely playable to completely smooth. I also noticed WebGL is now properly available on both Firefox and Chrome.

XPS13 Developer Edition Fixes

I recently bought a brand new XPS 13 “Developer Edition” that I want to use as my main machine for development. I’m very happy to see Dell building machines fit for Linux. The Dell XPS 13 has many very very good reviews. And it’s even better when it comes with Ubuntu pre-installed with all the good drivers (or close…).

dell xps13

It’s too soon to draw any conclusions yet: I’ve been using the computer for only 1 day. Still, I must say it works overall very good and I’m satisfied so far (except for the one or two quirks listed below). Especially by the gorgeous incredible “infinity display”, which packs a 3200×1800 touchscreen in a 13′” screen that fits in 11″ case. The XPS 13 “Developer Edition” comes with Ubuntu pre-installed, and it also comes with a “factory reset” feature you come to expect from a brand such as Dell. So if you brick your Ubuntu install, you can easily reset it without much hassle.

The only problem I encountered is some trackpad freezes that happen to be very annoying. It gives you the feeling the rig is not responsive when it’s actually pretty fast. To fix this, I applied this kernel patch:

You can safely apply this patch to the 3.13 Linux kernel that comes with the XPS 13/Ubuntu 14.04 mint install. But as I had to re-compile the kernel, I wanted to try the recently released stable Linux 4.0.2 kernel.

If you do so, you’ll also need to patch the Broadcom drivers. And because they’re not compatible with Linux 4.0 kernels, you’ll have to apply a little patch: bcmwl driver fixed for Linux 4.0 kernel.

After upgrading to Linux 4.0, I noticed the overall computer feels a lot faster and responsive. I don’t know why but it just does. It might be related to the fact the old 3.13 kernel was not using the new Intel P-state CPU governor.

Last, I also encountered kernel panic issues at three occasions:

  1. When changing access-points or simply disconnecting the Wi-Fi. This fix seams to do the trick: fix for the bcmwl kernel panic/crash.
  2. When suspending, but I guess it’s related to the Wi-Fi issue.
  3. When running a VirtualBox VM. I had to use VirtualBox 5.0 beta and patch Vagrant to support it.

Update: You can get more out of the XPS13 battery using the following script:

Flyweight design pattern with C++11

To optimize the memory consumtion of the Minko engine, we started by profiling the memory allocations using tools such as the integrated Visual Studio 2013 memory profiler or Massif.

One of the heaviest source of memory allocations was for  std::string  objects. It’s not really a surprising considering one of Minko’s biggest feature is dynamic data binding between the engine data – on the CPU – and the shader data – on the GPU. And “dynamic” means we have to create those bindings according to some naming conventions and explicit declarations made in “effect” files using JSON. Read: we use lots of strings.

We use strings for material property names, but also for the camera properties or the geometry vertex attribute names. It makes the engine very flexible and extensible while keeping some important aspects of strict typing using templates. But it uses a lot of memory because each property names is stored multiple times.

Materials for example are highly likely to share most (if not all) of their property names. If you have 10 of those materials, the property name strings will use 10 times too much memory.

To solve this, I’ve implemented the flyweight design pattern.

Continue reading Flyweight design pattern with C++11

Emscripten doesn’t like CloudFlare

In order to make our websites faster and safer, we’re now using CloudFlare on pretty much any of them. It’s fast, reliable and very easy to setup!

Among other things, CloudFlare will cache but also try optimize the content it serves. Mainly JavaScript, CSS and HTML content of course. As you can imagine, Emscripten generated code is not too happy about this, but the problem is not where you would think (ie not in the “optimized” JavaScript files)!

It turns out our server (possibly because of WordPress but I’m not sure) will serve Emscripten’s *.mem files as text/html. Emscripten *.mem files are the program memory init files. You can read more about them in the “Memory Initialization” Emscripten documentation. *.mem files are now generated by default for -O2 and above. Anyway, CloudFlare will try to “optimize” the *.mem files as if they were HTML and break them.

A simple workaround is to disable the HTML optimizations in the “Performance Settings” of the CloudFlare settings for your domain. A more suitable fix would be to configure your web server to serve *.mem files with the application/octet-stream mime-type.

Exponential Cascaded Shadow Mapping with WebGL

Update: my implementation worked well on “native” OpenGL configuration but suffered from a GLSL-to-HLSL bug in the ANGLE shader cross-compiler used by Firefox and Chrome on Windows. It should now be fixed.

Update 2: you can toggle each cascade frustum using “L” and the camera frustum using “C”.


shadowmappingWebGL Cascaded Shadow Mapping demo powered by Minko

  • arrow keys: rotate around the scene or zoom in/out
  • C: toggle the debug display of the camera frustum
  • L: toggle the debug display of each cascade frustum
  • A: toggle shadow mapping for the 1st light
  • Z: toggle shadow mapping for the 2nd light


Lighting is a very important part of rendering real-time convincing 3D scenes. Minko already provides a quite comprehensive set of components (DirectionalLight, SpotLight, AmbientLight, PointLight) and shaders to implement the Phong reflection model. Yet, without projected shadows, the human eye can hardly grasp the actual layout and depth of the scene.

My goal was to work on directional light projected shadows as part of a broader work to handle sun-light and a dynamic outdoor environment rendering setup (sun flares, sky, weather…).

Full code after the break…

Performance improvements for Minko 3 beta 3

So far, performance has not really been our concerned. We wanted to have a better understanding of what a cross-platform native 3D engine could look like first. Now that beta 2 is about to get shipped, we’re starting some heavy work on the beta 3.

The goal of the beta 3 will be to:

  • get better performances
  • provide a final (and documented) API for all Minko 3.x

It should also add some features regarding the rendering pipeline but I’ll save this for another post.

Anyway, I’ve been working hard to entirely refactor the rendering API to get better performances. Attached is a screenshot of some OpenGL benchmark I’ve made. This benchmark does not use Minko but a tiny 3D engine we’ve built to test a few things regarding OpenGL (ES) performances. Based on this work, we’re backporting our findings inside Minko to get the same (kind of) performances.


Of course, a real-life engine might not be as fast. But still, you can see we’re really going for (IMHO) awesome performances.

If you want to test it on your machine (Windows only sorry) here is a ZIP archive with the exe. You’ll also need the VS13 C++ DLLs. Just let the process run, after a few minutes it should stabilize. Be patient, it can take up to 10/15 minutes before you get a stable figure.

Here are the results on my machine:
– i7 880 @ 3.07ghz / NVIDIA GTX 770
– 60k meshes @ 30fps

Some of the engineers here got more than 100k meshes @ 30fps! Please tell me how it works for you guys!