If you recall the ball demo in v1.x of Gorgon, it’s a stupid bouncing ball simulation with rotating, translating, scaling and fading balls bouncing around the screen. It’s been my testbed for a long, long time. And it still is (yes, it’ll be in the examples for Gorgon v2). Anyway, I ran that old v1.x version of the ball demo running on Direct3D 9, pumped the thing up to 65536 balls and on my Radeon 6870 (on a Core i7 machine) it got an unhealthy 15-16 FPS (~60 msec of draw time). So, I compared it against the new version running under Direct3D 11 and got 35 FPS (~28 msec of draw time). That’s 263,184 vertices being transformed, coloured, blended, etc… running at above 30 FPS. The older version had some text being displayed on a render target, so that may account for the difference, but with a difference of 32 milliseconds, it’s unlikely. Still, I’m impressed with Direct3D 11. On a lesser video card, performance seems to be on par with the Direct 3D 9 version (sometimes it’s faster, sometimes it’s slower depending on the card).
It’s been a major pain learning the changes to this API. Especially when I want to structure it in a certain way. States are set differently, shaders are required, data is uploaded in various ways, etc… But those changes seem to improve the performance. I also can’t forget that I’m using SharpDX instead of SlimDX and there’s definitely a performance boost there.
When I initially transitioned over to SharpDX I was shocked to see how much faster it was when rendering thousands of draw calls in comparison to SlimDX. However, Gorgon batches things internally so the draw calls are kept to a minimum so it’s only a part of the performance boost. Still, I’m very pleased and I’d like to thank Alexandre Mutel for all of his hard and amazing work on SharpDX (dude is farking brilliant, seriously).
Now, if anyone is actually reading this, I’d like to point out some of the MAJOR differences between v1.x and 2.0:
Gorgon is no longer (just) a graphics library:
Yep. That’s right, it’s now a big set of libraries which you can add or not add your leisure. There’s a graphics library in there, it’s just not the primary thing anymore. The libraries are:
- Gorgon.Common.dll – This is shared amongst all the other libraries and contains utility code like base collection objects, specialized collections, diagnostic information (e.g. frame rate), a new data stream object, the plug-in management, extensions for IntPtr, numeric types, string formatting, and hash code generation. It’s required to use any other component.
- Gorgon.Filesystem.dll – This is a file system object. It’s not even remotely close to what was in the previous version.
- Gorgon.Input.dll – This is the input library. It handles input from joysticks, keyboards, mice and even has rudimentary support for custom human interface devices.
- Gorgon.Graphics.dll – This is what you’ve likely come here for. This is the base graphics API. It does nothing fancy, it provides you the same things that Direct3D 11 would provide you, except it’s wrapped up in my own functionality (and simplified where I could do it).
- Gorgon.Graphics.2DRenderer.dll (this is what the name might be, I’m still working on it) – This is the functionality for the 2D stuff in Gorgon. Sprites, text, etc… are all here.
Basically, it works more like PhysFS in that it mounts directories or packed files (zip and gorgon bzip from v1 are included through plug-ins) into a unified file system. So you could mount C:Folder into / and D:BigZip.zip into / and you can access data from each file system as though they were in the same area. Unified. Hot. It’s good for rounding up resources into a virtualized central location.
More input plug-ins:
All of the input management is done through plug-ins (like the previous version), however now there are more plug-ins to choose from such as raw input (like v1), windows forms (basically a pass through) and xinput (this is new and for xbox game devices only – Microsoft’s limitation, not mine). You can load all of these plug-ins at the same time and use keyboard from the windows forms plug-in, the mouse from the raw input plug-in and the xinput gamepad interface.
Graphics are split up into multiple components:
This is the big one. Basically I wanted to separate the API from the renderer. The previous version kind of did this under the hood but you weren’t given any access to it. So, for this version I split it out so that a user could write their own 3D library, 2D library, or whatever away from the 2D renderer. It’s also the object that gives access to the 2D renderer and the swap chains you’ll need to draw into (or any other render target). Aside from that, some notable improvements are the ability to use anti-aliasing, full screen on multi-monitor setups with multiple swap chains and it does caching of state objects so you don’t have to (this is a big thing in Direct 3D 11, and VERY different from Direct 3D 9).
The 2D renderer is still being fleshed out, so I don’t want to comment on it yet (mostly so I don’t make promises I can’t keep).
The idle loop is decoupled from the graphics:
Yeah, this might be a pain in the ass, but it allows the use of the idle loop without requiring graphics (you know, because there are other application types out there) and it allows the ability to swap out idle loops at will. The down side is that instead of doing the page flip for you at the end of the loop, you’ll be required to call the Render() method of the 2D interface or Flip() on the current swap chain before seeing any graphics. However, think of it this way: You now have complete control over when your graphics get displayed with this.
The down side to these massive changes is that if you’re looking convert to version 2, you’ve got your work cut out for you. For example, in Gorgon v1 you called Gorgon.Initialize and Gorgon.SetMode and off to the races you go. Not so with the new version. As it stands, you call Gorgon.Run(<form>, <idle function>) to start the application (it replaces Application.Run in Program.cs). This gives the advantage of being able to run the application outside of the form. Traditionally you would do all the initialization from OnLoad of the form, and you still can, but now you can also do it outside if you so choose.
To set the video mode (which is actually just a swap chain), you create the graphics object and call the CreateSwapchain method. You can then pass the resulting swap chain to the 2D renderer and start working Gorgon like you normally would (well, more on that at another time).
So, that’s a summary of what’s going on. I hope it’s not too painful for most people (fark, who am I kidding? It’ll be painful I’m sure). I hoped to make Gorgon more generalized, and it looks like that’s what I’m getting. It’s more work to initialize it, but in the end I think the flexibility will be worth it.