Archive | Operating Systems RSS feed for this section

d3dx – Not that great?

So, you’re writing a game, and you want to take a screenshot. The most common code sample you’ll probably find around the web will look something like this:

LPDIRECT3DSURFACE9 pd3dsBack = NULL;
LPDIRECT3DSURFACE9 pd3dsTemp = NULL;
if (SUCCEEDED(device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pd3dsBack)))
{
    D3DSURFACE_DESC desc;
    pd3dsBack->GetDesc(&desc);
    if (SUCCEEDED(device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pd3dsTemp, NULL))
    {
        if (SUCCEEDED(device->GetRenderTargetData(pd3dsBack, pd3dsTemp)))
        {
            LPD3DXBUFFER pBuf;
            D3DXSaveSurfaceToFileInMemory(&pBuf, D3DXIFF_BMP, t, NULL, NULL);
        }
        pd3dsTemp->Release();
    }
    pd3dsBack->Release();
}

Now what’s wrong with that? You’ll end up with a BMP in pBuf and then you can do stuff with it, like save it. Or you can use the more direct D3DXSaveSurfaceToFile to save direct to disk (although, handy hint, push the buffer to a thread and save it outside of the rendering loop… no pause in the renderer then.

This code only works with non-multisampled displays too. There is way around that, that’s outside the scope of this post. So… what’s wrong using D3DX to save a picture? Let’s consider these issues that I have come up against:

  • It’s slow – very very slow. If you try and save a PNG it’ll take upwards of a second. JPG is faster!? BMP is fastest.
  • It sometimes doesn’t even take the shot – you’ll just get a bunch of zeroes

Yep, something isn’t quite right there. I’m using the November 2008 SDK and I get a bunch of zeroes from the surface in certain circumstances. Why? Well that’s a very good question. I have no idea why. However, if I make use of LockRect and copy the right bits out that way I get a 100% success rate of reading back the BackBuffer.

So, the surface clearly always has the data, but D3DX fails to read it properly. Obviously, without the source code to D3DXSaveSurfaceToFileInMemory I can’t do any more research into the matter. Taksi has some interesting samples on the topic (although it’s geared to copying the pitch data as well and in fact converting pitch, which you won’t always need to do).

Comments { 0 }

HP Proliant ML115 G5

So, yesterday I got myself one of these: HP Proliant ML115 G5 for a cool £109 inc. VAT! Bargain! Has a Dual-core AMD Opteron 1214, 512MB of RAM (which I popped in a £50 OCZ 4GB kit to get that up to a good level) and a 160GB SATA HDD.

Why? Well my old home server (which ran Solaris) popped it’s cloggs a couple of weeks ago and I wanted my desktop computer back!

It’s a nice little machine but has a few issues that people Googling and coming across this might like to hear solutions too:

  1. VMware ESXi 3.5 Update 2 DOES work on this machine. You have to boot it off of a USB pendrive though. Thankfully there is a USB port on the motherboard inside the case! So you can embed a pendrive in there.
  2. FreeBSD 7.0 RELEASE will NOT run. You have to get the latest STABLE snapshot CD (June ’08 onwards) and it will then work.
  3. OpenSolaris 2008.05 snv_86 will NOT boot. The only one that will is snv_95, and even then it won’t detect the network card. It’s expected to be all fixed in snv_97 if the bug reports are to believed (when that will appear, nobody knows).
  4. Solaris 10u5 will NOT run on this machine either, for the same reasons as OpenSolaris.

Personally, I recommend the ESXi route – especially as Update 2 is finally fixed. Other than the fact that non-Windows OS’s have issues on this server, it’s a lovely quiet little box. I mean, almost silent – even with 4 SATA disks inside. The build quality is top notch. For the price, grab a couple and use them for testing out network virtualization setups… one idea I have is on as an iSCSI server and the other as a diskless ESXi. Maybe you could use 3 and test out VMotion :)

Comments { 5 }

ACPI on Open Solaris

They’ve known about this one for over a year – yet they still haven’t fixed it. It appears that if you have an Abit AB-9 QuadGT motherboard the thermal zone monitor (tzmon) will constantly spaff errors at you. To fix this as a once off you can do:

modinfo | fgrep tzmon
# Grab the number from the first column, mine was 124
modunload -i 124

Problem solved. If you want it fixed between reboots, you’ll need to edit the tzmon.conf and then perform an init 6 (don’t just reboot!).

Comments { 0 }

Open Solaris 2008.5 is out

It seems Open Solaris 2008.5 has made an appearance on the Internet. I just installed it onto a new HDD to discover a few odd things.

The main one is lack of things in the SMF database. I had to import the Apache 2.2 manifest into SMF myself. That seems a little odd.

lpackham@opensolaris:~# svccfg
svc:> import /var/svc/manifest/network/http-apache22.xml
svc:> exit
lpackham@opensolaris:~# svcs -a | fgrep apa
disabled       10:56:04 svc:/network/http:apache22
lpackham@opensolaris:~#

Somewhat irritating – but at least it now works.

Comments { 0 }

ginstall fails in MacPorts on Leopard

Yes it does indeed – So I did this in the end:

cd /opt/local/bin
mv ginstall ginstall.old
ln -s /usr/bin/install ginstall

Everything works for me now :)

Comments { 2 }

Vista in death moment

Thank you avast! for breaking my Vista install.

Bit of a shame really – but it upgraded last night and rebooted as normal. I didn’t bother logging back in, went to bed.

Got back to the machine in the morning to Log In. It said Logging Off! So I tried to Log In again and when it got to the desktop, it claimed all my Recycle Bins were corrupt and they needed rebuilding. I couldn’t even run a Command Prompt. No Start Menu, Win+E didn’t work either.

So I hit hard reset and tried to log in again. Same problem.

It appears that avast was blocking access to everything on the machine. It meant I had no premissions to access anything as a logged in user. So I promptly rebooted into Safe Mode and uninstalled it.

Problem gone!

But it does highlight an important point. Just like you don’t trust Microsoft Updates (hence why companies use WSUS to handle updates), don’t trust your AV vendor either. Always test the update on a non-major machine first.

That said – why can’t I trust my AV vendor? I have done for years!

Oh well, gone to a trial of Trend. Have you tried running Vista without AV? I can’t stand the moaning :)

Comments { 0 }