"The extremists are running the country because the moderates got shit to do."
- John Stewart
More pages: 1 2 3 4 5 6 7 8 9 10 ... 21 ... 31 ... 41 ... 47
Rewriting from scratch? Yeah, it's a bad idea.
Friday, December 2, 2011 | Permalink

We all know the feeling. We have code that's been lying around for a long time, collected a bit of dust, gotten a bit obsolete perhaps, or gotten twisted up and hacked around. Code that we're just not very happy with. It's a mess. It's ugly. It's fundamentally broken. It's not future proof. It's probably still working and doing its thing for the most parts, but we're not happy with it. So we're bringing up that big "rewrite" idea.

I'm probably just rehashing common knowledge here, but rewriting software from scratch is almost always a bad idea. Yet it is so appealing. And smart people fall into the trap all the time. And we never learn. No amount of experience seems to take the sheen out of the imagined perfect cleaned up code that would result from such an effort.

There are others that have written on this topic before, for instance here. And I could add another example to the list, the Orca driver back when I was at ATI. It was decided that the old OpenGL driver sucked. It was a mess. Nvidia had been producing higher quality drivers, but from my perspective we were catching up and was actually in a pretty decent shape at that point. Of course, I wasn't a driver writer so what did I know? When I heard about the complete rewrite of the OpenGL driver, I was quite skeptic but positive at the same time. But before long I started questioning the wisdom of going down this path. Initially both drivers were maintained in parallel. Fewer bugs were fixed and very little happened in terms of features, but there was hope for the better once the new driver was in good shape. But things were taking longer than expected. Don't it always? Eventually the whole team worked on the new driver. The old driver came to a complete halt. No updates. Month after month. Nvidia was pumping out new cool extensions on a regular basis like always. The new driver wasn't ready to ship. Fun stuff, especially when the next hardware generation came around, like they do on regular basis, and gosh, perhaps we need an OpenGL driver for it? The new one didn't have nearly all the features of the old one, nor was it higher performance. Of course, once the driver was in good enough shape that it could run Doom3 it was all fun again. Soon enough they had optimized it so that it showed a decent performance gain over the old driver. So it was all worth the effort, yay! Except of course, Doom3 was important and the Orca driver wasn't ready for prime time, so some of these optimizations were backported into the old driver, and would you know it, now the old driver was faster again!
Now, I wasn't a driver writer and I didn't have full insight in all the events surrounding this driver, so this story is mostly my causal observation from an ISV relations point of view. Someone on the team might have seen it differently. But still, I believe ATI lost at least a year, if not two, in their OpenGL support. By now that's ancient history, and I was happy that AMD shipped OpenGL 4.2 drivers on release date. But I bet there are people on the team now complaining that the code is a mess.

Anyway, my intention wasn't really to tell that story, but instead tell a story of my own. Some of you may remember my old announcement that I started working on Framework4. It's depressing when I look it up and I realize that was three years ago, and it's still not done! Gosh, I thought it was only two years ago, but it's three. So what prompted me to rewrite my framework? It's not like Framework3 wasn't working. I've been pumping out oodles of demos using it. It's just that it was a bit ugly. It was getting kind of obsolete. DX11 was around the corner and OpenGL was getting a serious overhaul and finally started deprecating things, and I wanted to make this big move into the new age. I had rewritten my framework before, this was my third one. I had great visions about new clean code, using standard coding conventions, with nicer interfaces. In the beginning it was fun of course. I was coding up cool stuff, new SIMD optimized vectors classes, compile time hashes, modern interfaces matching DX11 and OpenGL 3.0+, poking around a little with compute shaders. Soon though I wanted to make a real demo using it. Pretty soon I realized the framework had a pretty long way to go before I could ship a demo using it. So I started fixing up the rendering stuff. I was pretty much just writing code that wasn't that much different from what I was doing in Framework3. "I'll optimize it later anyway, I just want it to work for now." And then came the boring parts. My GUI system. At first I wanted something new, but found that I had no particular visions about what a better one might look like. So I just copied over the old one from Framework3, changed the code to standard conventions, fixed up all the rendering to Framework4 style. Boooooring, but eventually up and running. And I kept running into all those small things, things that I haven't implemented yet, things that separate a running prototype from a releasable demo. So I got kind of bored at the whole thing, and ended up spending less and less time on the project. Of course there are other factors at play here too. The last couple of years have been rather life changing for me. Went from single to having a girlfriend and ultimately married and now I am a father of a two months old baby. I rarely find myself spending whole days coding anymore. Even if I'm free the whole day, it's not like I can sit down 8 hours straight coding like I sometimes used to. I haven't exactly stopped coding though, but whenever I have had a demo idea recently, I've been implementing it in Framework3.

I'm still poking around in Framework4 at times though. Actually, just recently I did some work to bring the OpenGL part into the 4.2 era. But I haven't been able to let go of the feeling that somehow I took the wrong path after all. Perhaps I should've just upgraded Framework3 instead. Back when DX10 was new I opted to just make a D3D10 renderer instead of doing the big rewrite. I felt it was too much work. I suppose it was one of my wiser moves. I had to bend things a little, change a few interfaces to shoehorn it into the Framework3 paradigm, but I got it working. I had to update a bunch of old demos though, but that was actually not that much work. So I've been thinking a little lately, what is it actually that I really wanted with a new framework? And the answer is pretty much this: DX11 rendering. So after contemplating the move for a while I finally gave it a shot yesterday. I implemented a DX11 renderer in Framework3. Basically I just copied the DX10 renderer and search-replaced "D3D10" with "D3D11" and then crunched through all the compile errors until I had a fully working DX11 renderer. This exercise took about an hour. An hour!!! I spent one hour and now I have a fully working DX11 renderer in Framework3. It's ahead of where I am with Framework4.

So now I'm not sure what I will do going forward. For sure I'll replace the DX10 renderer with the DX11 one and let all old DX10 demos run through DX11 API, but with a D3D10 feature level. Perhaps I should just refactor Framework3 to fix all those things I've been unhappy about. Surely I'll have to update all old demos too, but chances are that that's not much work this time around either. Or maybe I'll just copy Framework3 to a new folder and call it Framework4, and then start refactoring things from there?

Moral of the story: Rewriting from scratch is almost never the right way to go. It's easy to overestimate the benefits and underestimate the effort necessary to get there.

[ 23 comments | Last comment by Yanko (2014-09-13 02:19:48) ]

I'm now officially a father
Friday, October 7, 2011 | Permalink

On October 1 our son was born. It's a big little boy, 4.320kg and 53cm at birth. The guy is pooping for three, but after close to a week I'm getting used to the diaper routine. Sleep is getting manageable and some sense of normality is setting in after a quite chaotic first few days.



He's the cutest thing I ever saw, especially when he tries to squeeze both his hands into his mouth, then poor little daddy's heart just melts.

[ 29 comments | Last comment by BaToCarx (2012-08-06 03:43:47) ]

Renegade Ops
Wednesday, September 14, 2011 | Permalink

Today we're launching another game, Renegade Ops just went live for consoles, and the PC version is coming to Steam shortly. And by "we" I mean my fellow colleagues here at Avalanche Studios. I am not and have not been part of the Renegade Ops team, so my main contribution has been my constant "is it done yet?" nagging and dropping a few puns on occasion at their desks. Despite not being on the team I'm very excited about this title. It's just plainly a cool game. I'll have to wait for another little while though, because I'll be playing on the PC. The game was developed by a small team with a small budget and shorter development time than usual, so I'm impressed with what they have been able to accomplish. And best of all is that it also comes at a small price tag. 13 on Steam, or 25 for a pack of 4 for those of you who want to play online co-op.

[ 5 comments | Last comment by Bjorke (2011-09-30 17:06:39) ]

DirectX 11.1 documentation online
Wednesday, September 14, 2011 | Permalink

With the public release of the Windows 8 Developer Preview the documentation for the upcoming DirectX 11.1 API has made it online as well. It's preliminary and subject to change of course, but likely the changes won't be too dramatic. The list of new features and additions is pretty long for a mere ".1" update.

[ 2 comments | Last comment by Humus (2011-09-19 23:16:26) ]

New gallery
Sunday, September 4, 2011 | Permalink

I have added a new gallery to my pictures. These are pictures of my pregnant wife from her 7th month. Now we're in the final month with just over two weeks left to the projected birth date, so it's time I put these pictures up before mini-Humus arrives.

[ 1 comments | Last comment by Me (2011-09-12 21:49:02) ]

Yet another AA technique - SDAA
Sunday, August 28, 2011 | Permalink

I have just posted another demo of yet another anti-aliasing technique. I call it Second-Depth Anti-Aliasing (SDAA) since it requires the second depths in the scene, i.e. the depths of the backfaces. Quality-wise it rivals that of GPAA/GBAA and is easier to integrate into an existing engine.

[ 9 comments | Last comment by Ray-Ban Sunglasses (2016-06-06 01:38:31) ]

GBAA demo updated
Monday, August 22, 2011 | Permalink

I have updated the GBAA demo with a few fixes to performance and image quality. The most glaring oversight I did in the previous version was that I made a copy of the backbuffer for the last resolve pass to read. I tend to copy an old demo and start from that rather than setting up everything from scratch. In this case I copied the GPAA demo and it didn't pass my mind that the backbuffer copy that was necessary for GPAA is not necessary when you have a final fullscreen pass like in GBAA. Instead you can just render to a temporary render target and read that while writing to the backbuffer in the end. This buffer copy was nearly half the cost of the resolve process, so eliminating this is significant win. The other thing I did was to only clear the buffers that need it, i.e. the depth buffer and geometry buffer. I could have removed the geometry buffer clear too, but felt it was good for educational purposes to leave it there, plus I would have had to change the skybox pass to accommodate the change, so it wouldn't necessarily be a win in all cases. For image quality I changed the unused component to be 0.5 instead of 0. This is to avoid the case where the distance computation landed exactly on zero, which would be interpreted as "no edge here" rather than edge cutting through pixel center. This resulted in some rare single pixel errors, especially for lower precision formats like RG8S. This demo is still using RG16F though because I saw nearly no performance gain to go down to RG8S.

[ 0 comments ]

Geometry Buffer Anti-Aliasing
Monday, July 18, 2011 | Permalink

There is a new demo up demonstrating another anti-aliasing technique called GBAA (Geometry Buffer Anti-Aliasing). Like GPAA it uses actual geometry information, but stores it in a fullscreen buffer. This should scale better with dense geometry and additionally allows alpha-tested edges to be anti-aliased.

[ 9 comments | Last comment by Yours3!f (2012-03-04 22:17:17) ]

More pages: 1 2 3 4 5 6 7 8 9 10 ... 21 ... 31 ... 41 ... 47