Hardware-Accelerated OpenGL on Asus X101CH running Windows XP

  ·  7 min read

Good Old Times #

I bought this old Asus netbook a couple of months ago for ~20 bucks after I saw an ad for a used netbook in good condition. Seeing its picture reminded me of my childhood. I remember I had an eee pc asus netbook just like this that I used to play Vice City with maybe 20 FPS.

Memories…

At the time I was using Windows XP, but this one is running Windows 7.

Surprisingly its previous owner took good care of it. There are no scratches or missing keys, and they had also swapped the slow HDD with a faster SSD. The only hardware problem is the dead battery, and I doubt that I can find a replacement. I also got a laptop bag as a gift (a really small one).

The netbook has a “Windows 7 Starter” sticker on it but I guess the owner didn’t like its restrictions, so they installed the professional edition instead.

The netbook came with a bloated Windows 7 installation that also had a legacy antivirus software on it which was basically choking the system. More than 75% RAM usage on start and a constant 40% - 50% CPU usage. Despite the SSD upgrade it was borderline unusable (not that netbooks were known to be fast anyway). I re-installed the Windows 7 Starter edition but even then on fresh boot it was using about ~60% of the 1 GB RAM.

Asus is still providing drivers for this model by the way.

I decided to try linux first. The aren’t many 32-bit linux distros lying around however. My first choice was arch linux 32-bit which didn’t even let me install software because of broken signatures, unless I set “SigLevel = Never” in /etc/pacman.conf.

Yes I know that this is bad practice but I am not super worried about security when this thing can’t even connect to WiFi properly.

The experience wasn’t great. On cold boot with XFCE desktop the system was eating somewhere between 350 and 400 MB RAM (which is tiny by today’s standards but on a 1 GB RAM it is still a lot!). And there are no GPU drivers, so everything on the monitor needs to be CPU-rendered. I can’t play 720p videos without constant stutter.

Maybe I should have tried void linux too, but I imagine it would suffer from similar issues.

As much as linux people (a group that includes me) like to proclaim that linux can bring back old devices, the truth is that there is maintenance headache for supporting older devices, and it is better to spend developer time in supporting newer hardware.

My dreams of programming a 25.6 GFLOPS GPU were shattered, which was really the main reason why I bought this netbook.

But maybe this was a blessing in disguise.

I decided to completely ditch linux and install Windows XP instead. I still needed to somehow get the GPU working.

Fun fact: Asus never intended this netbook to be used with anything prior to Windows 7.

Funner fact: the netbook wouldn’t even let me install XP.

Machines Can Fix Themselves Now #

I remember back in university a professor once told me that the main difference between computers and humans is that we humans can fix our own issues, meanwhile the computers always need someone else to come in and write the right code.

Well, that doesn’t seem to be the case anymore.

I got inspired by Simon Willison’s experience with Fable, and decided that I am also going to try Fable, albeit for a different problem.

Here are the issues:

  • Asus X101CH was designed to run Windows 7 (preferably Starter), not XP.
  • Official drivers are provided but only for Windows 7.
  • Window XP cannot be installed because it bluescreens with error code 0x0000007B (and it cannot be fixed by changing the BIOS mode).
  • I need the GPU to work to reduce CPU usage.
  • I also want to program the GPU using OpenGL.

Below is the journey that Fable and I undertook together to fix the above issues:

  1. The netbook bluescreens.

    1. The human reports STOP 0x0000007B, INACCESSIBLE_BOOT_DEVICE, and that switching the BIOS from AHCI to IDE changed nothing.
    2. I recognize the real cause: XP’s kernel has no USB boot stack. The BIOS boots the stick, the kernel takes over, the stick vanishes – setup bluescreens on its own boot device.
    3. The standard fix, WinSetupFromUSB, is Windows-only, and there is no working Windows in the house.
    4. So I build an Easy2Boot stick on the Arch box instead: grub4dos in the MBR, NTFS, the ISO kept contiguous.
    5. The human boots it, gets a menu, then a freeze at “press Enter to start setup”. He describes the screen; I go digging.
  2. The freeze needs two fixes, and the second is buried in 2008.

    1. I set E820=0 per the E2B docs, for buggy BIOS memory maps. He retests: “reboots” becomes “hangs forever”. Half a fix.
    2. I find the other half: NTDETECT.COM resets the USB controller it just booted from.
    3. A patched NTDETECT exists but nobody hosts it anymore. I recover it from a 2008 MSFN forum post on the Wayback Machine – the author had pasted the entire binary as a hex dump.
    4. I rebuild the ISO with mkisofs and boot-test it in QEMU before it touches hardware.
    5. The human ferries the stick back to the netbook. XP installs cleanly.
  3. Asus never shipped XP drivers for this generation, so we source them elsewhere.

    1. I find that the Eee PC 1015PX shares the chipset, audio codec, and ethernet chip, and its XP packages are still on Asus’s CDN. Wi-Fi comes from an HP driver package that lists this exact card, confirmed against linux-hardware.org probes of other X101CH units.
    2. The human installs them in order. Everything binds except the ACPI utility; I check its INF – it targets an ACPI device this generation does not have. He uninstalls it, we move on.
  4. The GPU is a PowerVR SGX545 that Intel sold as the GMA 3600.

    1. I stage the only XP driver, the embedded EMGD 1.15.1; the human walks its Java configuration tool with the user guide open. Native 1024x600.
    2. He runs a small GL test app I cross-compiled: GDI Generic 1.1, Microsoft’s software renderer.
    3. I autopsy Intel’s installer under Wine with a scripted auto-clicker and read the unpacked INF: the OpenGL and GLES libraries are commented out, the DLLs absent – same as in the display-only driver floating around.
    4. Intel shipped this chip on XP without OpenGL.
  5. The way in is sideways, through Direct3D.

    1. The human runs dxdiag: every D3D test fails. I read the error codes – fixed-function pipeline failures, and Intel’s notes say the driver is “pure DX9”, shaders only. Possibly irrelevant.
    2. If the shader path works, ANGLE can translate OpenGL ES 2.0 onto it – how Chrome and Firefox did WebGL on XP. I bundle libEGL and libGLESv2 from Firefox 52.9 ESR, the last XP build, plus a shader-triangle test app.
    3. Attempt one, his: missing UCRT DLLs. I add Firefox’s bundled runtime.
    4. Attempt two, his: “D3D compiler module not found”. I trace it – Mozilla’s ANGLE only loads d3dcompiler_47.dll, and Firefox’s copy needs a function XP’s msvcrt does not export.
    5. The fix is his to perform, and it is one rename: copy the XP-safe D3DCompiler_43.dll under the _47 name. Attempt three: a triangle, spinning, in hardware.
  6. The netbook now runs shaders on a GPU whose XP OpenGL support officially never existed.

    1. GL_RENDERER: ANGLE (Intel Atom N2000/D2000 Series Embedded Media and Graphics Driver Direct3D9 vs_3_0 ps_3_0).
    2. Shader Model 3.0. 40 extensions, including FBOs, instancing, and float textures. ~250 fps windowed with vsync off.
    3. He does the driving; I read the maps. He now writes his shaders in C89 with Visual C++ 6.0, which I consider the correct amount of commitment to the bit.

The Triangle #

And here it is: hardware-accelerated rendering on Asus X101CH with Windows XP showing a spinning triangle whose OpenGL ES 2.0 commands get translated to DX9 for the GPU to run:

OpenGL ES 2.0 through ANGLE, translated to Direct3D 9 on the GMA 3600

It gets around 250 FPS in this windowed mode, and drops to 160 FPS in full screen mode, which is still pretty cool!

Fable also wrote me a list of challenges for me to solve, so I’ll be spending the next couple of weekends going through them.