Game Design, Programming and running a one-man games business…

Optimising my ‘dumb’ textures

I have this class in my code called ‘smart texture’. I’ve had it for several games now. It basically lets me tell a sprite to use “gun.dds”, and it transparently converts that to the LPDIRECT3DTEXTURE9  and doesn’t mention it. It keeps ‘gun.dds’ in memory, and if I ever lose the screen (alt+tab), and need to rebuild stuff, it will replace the invalid surface pointer the next time it gets drawn with a fresh copy.

MAGIC.

Trouble is, that means keeping a list of every smart texture, so that I don’t miss any when recovering from alt+tab. That’s easy, but I ended up using texturedsprites (with a built-in smart texture) everywhere, and thus the list, for a full battle could be 20,000 textures long.

F**k.

So here I am, effectively keeping a record of me trying to fix this…

It’s 5.35PM Sunday. The wonders of aqtime show me that when I ditch the current level and load in a new one, I am killing off about 8,000 smart textures. Every one is going through it’s destructor and removing itself from the smart textured list. This sucks. I need this to be faster. First instinct is to speed up the destructor, but obviously that’s treating the symptom, not the cause. The real problem is 8,000 smart textures. That isn’t so smart, when 2,000 of them are probably pointing to the exact SAME surface in directx… I need to rethink this system, and NOT break any other code…

I *do* have a system called GUI_TextureCache which does some ‘fixed’ storing of textures I use all the time, like UI stuff, buttons etc. This is obviously a similar task to what I want to do here, in that I need a dynamic dumping ground for commonly used textures pointers. I’m concluding that the cleanest way to handle a fix would be within my SmartTexture itself. it can do some clever caching, and then nobody will ever know any code changed!

Realisation that this means I still keep all these smart textures knocking about, with their ‘gun.dds’ strings. That offends me, as a programmer, but tbh, even ‘longcomplextexturefilename.dds’ is only 30 characters, so with 2,000 units I’m wasting 60k here. Big deal.

Right, so the plan is when I call SmartTexture::SetTexture(“gun.dds”) it may, or may not add itself to a list of textures that would need rebuilding, based on if its already in the list.

Problem: I can’t do that, because it means checking the whole list every time I call SetTexture(). That might even be *slower*. However, my current ‘SetTexture’ goes through a list to grab the pointer, how slow is that? It looks like currently its about half as much time as all those smarttexture destructors, so it might be a win. Plus my SetTexture() stuff uses a MRU caching system which could make ti super fast when loading in 100 identical units…

5.50PM Actually realising I’ll need a totally new class to handle this. it needs to be done a different way, not with existing smart textures. Balls. Surely it can be done? Hold on.. Surely its just a matter of indirection. The purpose of a smart texture is to hold a surface pointer it can rebuild if needed, but it doesn’t have to hold a direct link. It could actually hold an indirect link.  One more piece of pointer indirection is trivial. I just add a new CLoadedTexture class that handles rebuilds, and the smarttextures can point at those, meaning no need to keep a list of them at all, as their pointers never go invalid or need rebuilding.

6.25PM everything coded except the actual rebuild() calls for alt+tab. I’ll comment the errors out for a quick test… GAH, it crashes immediately. fixed easily enoguh, and the code RUNS! hurrah, but it doesn’t seem AMAZINGLY faster,. Quick! to aqtime! what the hell… it’s slower?…

6.35OM. Hah! looking at it backwards, it’s about 75% faster. how much time does that knock off loading in a new level now? 5.28 seconds down to 2.1 seconds. That’s pretty good. I’ll code in the rebuilding stuff and give it a quick test…

6.50PM Alt+tab doesnt work, I get just a black window, but that may be something else. I’ve checked in my current code, and am investigating alt+tab issues now. It looks like the restore code hasn’t worked on this new game at all yet. I consider my (dumb) smart texture code fixed :D

 

Show Me The Games bundle last day etc…

The SMTG bundle runs out tonight at midnight. If you missed the earlier blog post, then I suggest just going here:

http://www.showmethegames.com/bundle1.php

And checking it out. It’s five hgh quality indie games, on a sort-of-strategy theme, than are bundled together for $28.50.

On the topic of SMTG, that brings me to the question of the sites future. I’m really please that SMTG is up and running, that it gets some traffic, that it looks nice, and that it has the support of so many developers.

That’s the good side.

The bad side is that the site earns $0, and actually costs some bandwidth, plus also the site takes time to develop further. Frankly, I don’t have the time to dedicate enough effort to constantly add content, and I can’t afford to hire a full time (or even decent part-time)  site manager to handle it. I like to have total control over stuff, so I’m not looking for a volunteer, I prefer to pay people and then tell them what to do :D

So although SMTG works very well, and definitely drives sales to developers etc, I’m unsure what will happen to it next. I’ll continue to add new games that I think are really awesome, and I hope to find some time to add features and improve upon it over time, but it’s not going to grow like Steam or even Moddb, because of lack of time. Maybe when my next game has shipped I’ll get a lot more free time and spend a few months on it, but I already have to find time for top-secret-side-project #1 as it is… Ho hum.

AQTime

Yesterady I bought AQTime. It’s $600. That ain’t cheap. It’s profiling software, so basically its something that helps me write faster code. I’ve used it before, and it’s extremely good. I hope I can make my new game faster and smaller-memory-footprint than GSB by using it.

Already I’ve found out that some code that I thought was fast (searchlights) is in fact scarily slow. What’s more, I know the exact lines of code that cause the problem and it’s likely easily fixed. yay!

Plus fog of war code is done and dusted. Double yay.

I hope to have some interesting screenshots to show off in a few weeks. I’ve done the flashy graphics stuff before the gameplay balancing and level design, which means early screenshots of GTB will look nicer than the frankly awful early GSB ones :D

Also… there was a fox in the field opposite the house yesterday. It seemed to be just prowling about, midday, in the sun. Who needs springwatch when you have a fox? :D

This is what they want (as tiswas used to say)

I got a lot of grief from various parts of the web for daring (how dare I!!) even mentioning the topic of games pricing, and the value of an indie game. Apparently, this topic is as off limits as anti-semitism or saying that The Phantom Menace was cool.

Meh.

Free markets conspire to give people what we want. We get exactly what we deserve in so many ways. People don’t care about politics, so we get corrupt politicians. People don’t care about eating healthily, so we get hormone boosted beef and…

People like games where you just click stuff and spam your friends. So we get farmville. And to go one stage further…

People LIKE to argue about the price of games, DRM and piracy. Trust me, I know, I have blog traffic stats. I know what gets people reading, and commenting. A tiny fraction of people get abusive and angry, but then this is the internet and as charlie brooker has said, you could give people online a free massage and they’d moan at you.

It would be simpler, and pretty boring to have a blog where I just talked about vertex buffers, never said anything about the games industry was bad or could be improved, and just had some cat pictures. But that would be boring to type and you wouldn’t read it. 99% of games developers talk purely in tedious bullshit marketing cliches about “How we are excited to work with our partners to bring this compelling new SKU to the market”. I’m pretty sure we have enough people doing that already :D

xkcd gets it...

 

First Solar Payment

Sooo.. at long last I’ve just made the first deposit payment for getting my much-talked-about solar panels installed. This has been at least 5 years in the making. ‘Sheesh’ etc…

This is what I’m getting:

A 2.15kWp system.

10 x MPE 215 PS05 schuco modules. Total area 14.96 square meters installed in 2 rows of 5 at ground level. (roof is unsuitable).

A sunny boy SB2500HF-30 Inverter.

The quote says that it should generate 1845.56 kWh per year. They calculate that if I use all that power (and I will) it will save me £230.70 a year based on 12.5p/unit electricity cost (bound to rise dramatically over the lifetime of the panels). (however my current provider charges 11.52p/unit).

edit: just investigated and in the last year we used 4,134 kwh, so this set of panels is slightly under half my total usage.  I bet that’s because we have an electric cooker…

In addition, the feed in tariff would pay 1,845 * 43.3p = £799.13 a year.

Total income is thus £1,029.82 per year.

Total installation cost is £10,608.

Assume the panels are worthless after 20 years, I’ll earn £21,216 over that, which would be a gain of £11,000. I can see that the performance of the panels will degrade by then, but I strongly suspect energy prices will rise enough to more than compensate. I also can’t see the feed-in tariff being reduced or abolished for existing installs by any government of any color.

Obviously the panels may not generate the described amount. There is some shading in the garden (bah!). And I’m not going to cry into my tea if the output is below maximum.

Interestingly, the cost of the panels+inverter dropped about £1,000 in the last 8 months. Also of interest is that VAT on them is charged at only 5% (although tbh, if the government really want to kickstart a domestic renewables industry that needs to be 0, not 5%).

Fun fun.

No point in me talking about my new game today. People are swooning over E3 videos :D