Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Test Builds => Topic started by: Swifty on March 27, 2012, 03:29:18 am

Title: Optimization: GPU-based Submodel Transforms
Post by: Swifty on March 27, 2012, 03:29:18 am
I'm always working on a lot of optimizations but I feel that this one is ready to be tested by the community. This feature speeds up rendering by merging all submodels into one big model while letting the GPU do all the work into positioning and orienting them for the final render. This cuts down CPU overhead by significantly reducing the number of draw calls needed to render a model, especially if the model has a lot of submodels.

This shifts a bit of extra overhead on the GPU though. I'm essentially communicating with the video card through floating point textures and constantly have to update those textures per frame. Also, there's an additional cost in the vertex shader of having to fetch the necessary transform data from those textures and doing an extra matrix multiply. Your mileage may vary with this build.

This requires an OpenGL 3.0 compliant card. I should mention that this build is based off of Trunk Revision 8627.

To switch on and off this feature, load up the builds using the Launcher, go to the "Features" tab, open the "Experimental" drop down selection, and enable "Enable merged index buffers"

Please give feedback of what your performance is with and without this feature enabled. Also be sure to indicate what CPU and GPU you're running on.

EDIT: Please make sure you don't have any *.sdr files in your "effects" folder! This test build has new shader files built to get this working.

http://www.mediafire.com/?mv9gfwq50by8zgg
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Sushi on March 27, 2012, 09:56:00 am
Got a patchfile too?
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: General Battuta on March 27, 2012, 10:21:24 am
Every time I read about Swifty optimizations I get that flippy floppy feeling in my stomach like a pretty girl walked by
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: The E on March 27, 2012, 10:22:02 am
Got a patchfile too?
It's in the archive.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Rga_Noris on March 27, 2012, 10:32:51 am
Link doesnt work for me.

EDIT: Got it working by adding it to my account and then downloading. If I try to D/L from your mediafire account, it just says OOPS! Restarting your download! And then it doesnt.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Sushi on March 27, 2012, 10:36:10 am
Ugh, can we get a mirror? Mediafire has apparently decided to go full sucktastic. It keeps shoveling ads at me while telling me "there was a problem with your download, click here to retry" (and get more ads shoveled in my face).
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Rga_Noris on March 27, 2012, 10:37:27 am
Try it from my MediaFire account... worked for me.

http://www.mediafire.com/?w8bogu5teko8i42
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: mjn.mixael on March 27, 2012, 10:39:08 am
Did my tests on a BtA mission with an intro cutscene that features the HTL Arcadia and a lot of other ships flying around. Some with rotating submodels, some with stationary submodels. Pretty busy scene.

GPU: GeForce GTX 550 Ti
CPU: Intel Core i7 970 3.2Ghz

Regular Trunk
FPS: 38 - 40
CPU Load: 100%
GPU Load: 13-30%

Optimized Build
FPS: 40-42
CPU Load: 100%
GPU Load: 20-40%
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Swifty on March 27, 2012, 10:38:04 pm
There seem to be a major bug with this build preventing submodels from being rendered (defeating almost the whole purpose of this optimization). I'll upload a new build ASAP.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Reprobator on March 28, 2012, 11:23:37 am
I'll try it!
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Swifty on March 30, 2012, 12:48:24 pm
Hmm, I can't get a hold of the bug that Axem and mjn.mixael had reported. Can more people please try out this build and tell me the results? I've only got feedback from like, two people.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Angelus on March 30, 2012, 01:43:23 pm
the build crashes the game right after the splashscreen, with and without the new flag.

Intel Xeon 2.4 and a ATI Radeon 2600HD ( AGP )
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Swifty on March 30, 2012, 05:21:11 pm
Try running the debug build and nail your fs2_open.log file here.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Swifty on March 30, 2012, 06:21:03 pm
alright, so some of the problems with this build has been due to old shaders lingering in the "effects" folder. More people should continue testing this build.

On another note, Axem has given me some interesting data when looking at a scene with three FSU Sathanas.

(http://lazymodders.fsmods.net/axemart/FreeSpace/Debug/3sathtest.jpg)

Swifty is victorious against RC5! :)
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Echelon9 on March 30, 2012, 09:04:28 pm
There seem to be a major bug with this build preventing submodels from being rendered (defeating almost the whole purpose of this optimization). I'll upload a new build ASAP.
I'll test, but wanted to make sure the newer, fixed build was the one linked to in original post?
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Swifty on March 30, 2012, 09:41:04 pm
There didn't need to be a new build actually. The bugs that were reported were due to old shader files.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Darius on March 30, 2012, 10:03:24 pm
Haven't got any objective testing done yet, but subjectively I'm noticing a huge increase in framerate in ship-heavy scenes. It's almost like getting a CPU upgrade.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Fury on March 31, 2012, 02:35:34 am
Even though Swifty included updated shaders in the executables themselves, any mods bundling shaders in their vp files will override Swifty's shaders. Such mods include BP2 which are great for testing. So I took the liberty of uploading BP2 shaders which do not have this missing submodel problem: http://www.mediafire.com/?1vf1z9mh2f9p220

However, Kyad pointed out an issue with these shaders. See following two pics:
http://img826.imageshack.us/img826/8545/screen0003q.jpg
http://img835.imageshack.us/img835/7223/screen0002l.jpg
The transport seen in these pics is rotated 90 degrees, with glowpoints still in their original place. Weird issue, which I can also confirm. I do not know how much these shaders differ from the ones included in the executables.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: MetalDestroyer on March 31, 2012, 04:44:32 am
Does that mean, FSO support Tesselation features ? :)
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: The E on March 31, 2012, 04:58:17 am
No. Tesselation is a very different beast. This code just moves part of the work associated with setting up a model for rendering from the CPU to the GPU.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Macfie on March 31, 2012, 07:18:39 am
Where does the patch file go?
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Fury on March 31, 2012, 08:08:51 am
Nowhere, it just contains changed code base on some revision of the FSO trunk. It's meant for coders only.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Bobboau on March 31, 2012, 05:24:41 pm
ohhhh, nice! I'm assuming you basically used a similar technique that is used for skeletal deformation?

with this in place model instancing becomes a lot easier.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Swifty on April 01, 2012, 01:05:42 am
Yup, that's pretty much it. :D

As for model instancing, perhaps it's feasible but I've given it cursory thought for now. Right now I have rotation and position info stored in a floating point texture per ship which is then bound in a texture unit before draw. Not very scalable for instanced drawing. Perhaps I could have a transformation texture per ship class which will store the data that the shader can rely on when getting per instance data. Or I can use array textures.

I'll think about it fully when this gets stable.
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Spoon on April 14, 2012, 11:11:24 am
Swifty is super cool
Title: Re: Optimization: GPU-based Submodel Transforms
Post by: Bobboau on April 18, 2012, 05:48:14 pm
Yup, that's pretty much it. :D

As for model instancing, perhaps it's feasible but I've given it cursory thought for now. Right now I have rotation and position info stored in a floating point texture per ship

is this a 1D texture? can it be made into a 1D texture, if so then you can use the second dimension for more than one ship. or make a 3d texture.
and you wouldn't even need to do this per class, you could just put everything into one texture, use the ship class index as the offset in one dimension.