Jump to content

Less memory usage by using OpenGL


Eisfunke

Recommended Posts

The Story


In the KSP 64-bit thread, where Lilleman showed us how to use KSP with 64-bit, gpisic noticed that when forcing the game into using OpenGL instead of the standart Direct3D as rendering system, KSP uses significantly less memory.

For example, I use 70 mods, resulting in a 2GiB GameData folder, and normal 32-bit, and get the following memory usages:

Direct3D: Crashes while loading at about 3,223,600K ≈ 3.07GiB

OpenGL: 2,266,200K ≈ 2.16 GiB

Difference: 0.91GiB

You see: By switching to OpenGL I could save almost a whole GiB of memory and get my KSP to start with all my mods!

In the following Instructions I explain how you can switch to OpenGL too and play KSP with all your mods, without the still quite buggy 64-bit, compressing your textures to the point where they look utterly ugly, or installing Linux (well, you should do that anyway :P)!

Instructions


If you use Steam, simply right-click Kerbal Space Program in your Library, click "Set launch options..." and put in "-force-opengl". You have to start the game out of steam (or the start menu) for this to work, if you start the KSP.exe manually it will ignore your Steam launch options!

Otherwise, or if you don't want to start through Steam, open your Kerbal Space Program folder, right-click KSP.exe, select "Create shortcut", and put "-force-opengl" in the "Target" field after the quotation marks, with a blank in between. You can now put that shortcut where you need it, e.g. onto your desktop.

Alternatively, if you want to start KSP through the start menu, right-click on Kerbal Space Program in there, and put the "-force-opengl" at the end of the "target"-field, again with a blank in between. (This does not work if you have the Steam version, as the start menu link then links to Steam)

Survey


I made a survey where you can tell us about your OpenGL experience using Google Forms. If I get enough answers I will put some graphics here to show how well (or badly) OpenGL works.

Click here to take the survey. Please try to fill in as many questions as you can. If you save the link you get after sending your answers you can edit them afterwards, but please don't do it more than once!

Click here to see the results of the survey.

Thanks


Thanks to gpisic for noticing this and Lilleman for the 64-bit hack!
Link to comment
Share on other sites

My FPS tanks when using OpenGL. Not the same for other games, either.

That's odd, as this isn't the case for me and OpenGL generally performs just as good as D3D in benchmarks (or even better). What graphics card do you use?

Hm, just searched and found that Unity generally performs worse with OpenGL. I never noticed, probably because I have a really beefy GPU and my only bottleneck are the physics, but for many players that might be a problem. Pity!

Edited by Eisfunke
Link to comment
Share on other sites

I can report the same savings Eisfunke, By forcing opengl, i seem to save well over a gig of RAM, From 3.4gb down to about 2.2gb using OpenGL, it does not seem to affect performance on my machine, (And like you i am using a pretty beefy desktop.

Running about 40 mods with a 2.5gb GameDATA folder, on the 32bit client.

Link to comment
Share on other sites

I've filled out the survey as well.

Running 70+ add-ons (2.13 GB) on the 32-bit client, I used 3.11 GB of RAM under Direct3D, but only 1.73 GB of RAM under OpenGL - around 1.38 GB's worth of savings.

PC Specs:

Win 7 64-bit

Intel® Core i7-2600 CPU @ 3.40GHz

16 GB RAM

NVIDIA Quadro 600

Link to comment
Share on other sites

That's odd, as this isn't the case for me and OpenGL generally performs just as good as D3D in benchmarks (or even better). What graphics card do you use?

Hm, just searched and found that Unity generally performs worse with OpenGL. I never noticed, probably because I have a really beefy GPU and my only bottleneck are the physics, but for many players that might be a problem. Pity!

750ti rig and a 780ti rig, they have extremely similar i5 processors on them, and they get extremely similar FPS in KSP. The 750ti seems to really struggle with OpenGL on KSP, however seems fine on others.

The 780ti is of course completely overkill and could render it in vb paint.

Edited by Linear
Link to comment
Share on other sites

It's interesting that on Windows that you get so much savings by using OpenGL...

In my case I use a Mac and the difference between launching the game on Windows (DX) vs. OSX (OpenGL) is around a ~400 MB savings, in favor of DX on Windows. It's just surprising to me that you guys are seeing such a large reduction in memory usage by using OpenGL considering how much more mature and memory-optimized DirectX is.

Link to comment
Share on other sites

It's interesting that on Windows that you get so much savings by using OpenGL...

In my case I use a Mac and the difference between launching the game on Windows (DX) vs. OSX (OpenGL) is around a ~400 MB savings, in favor of DX on Windows. It's just surprising to me that you guys are seeing such a large reduction in memory usage by using OpenGL considering how much more mature and memory-optimized DirectX is.

It is strange. It really shouldn't be happening. However, with all the bugs that are happening, it's worth the extra RAM.

Link to comment
Share on other sites

I did some tests with a vanilla install, using the rocket from this thread: http://forum.kerbalspaceprogram.com/threads/42877-CPU-Performance-Database

DX11 cause awful glitches, and Ram consumption was about the same as DX9 (default) KSP. Maybe 200Mb less.

But it went from 1.9GB RAM consumption with DX9 to 1.1GB with OpenGL, about 800MB saved!

That's interesting, because the number of mods don't seems to have influence on this.

I didn't even noticed the missing shadows before, that's the only minor glitch compared to DX9.

About framerate, this is what I got with my gaming rig:

API | Frames rendered | Min | Max | Average

DX9 | 9941 | 16 | 146 | 55.228

OGL | 7122 | 13 | 99 | 39.567

http://image.noelshack.com/fichiers/2014/26/1403877678-dx9oglcomp1.png

http://image.noelshack.com/fichiers/2014/26/1403877683-dx9oglcomp2.png

[TABLE]

<tbody>[TR]

[/TR]

[TR]

[TD][/TD]

[TD][/TD]

[TD][/TD]

[TD][/TD]

[/TR]

[TR]

[TD][/TD]

[TD][/TD]

[TD][/TD]

[TD][TABLE]

<tbody>[TR]

[/TR]

[TR]

[TD][/TD]

[/TR]

</tbody>[/TABLE]

[/TD]

[/TR]

</tbody>[/TABLE]

I would say the gaming experience is similar, the framerate does not have a huge impact. It's only slower when both DX and OGL display 40+fps.

Link to comment
Share on other sites

I haven't tested it thoroughly yet, but I see some improvements on my pretty low end PC.

My config:

CPU: Intel Core 2 Duo 1,8GHz

Memory: 2GB DDR2

Graphics: AMD Radeon HD 5450 1GB DDR3

Before forcing openGL I was barely able to run the game with those mods:

Active Texture Manager

Deadly Reentry

Docking Port Alignment Indicatpr

Enhanced Navball

Ferram Aerospace Research

Infernal Robotics

Kerbal Alarm Clock

Kerbal Attachment System

Kerbal Engineer Redux

Kerbal Joint Reinforcement

KOS 2.08

KW Rocketry

Mk2 Cockpit Internals

RealChute Parachute System

TAC Life Support

Vanguard Technologies EVA Parachutes

After forcing openGL I have updated KOS to v3.08 and have installed Near Future Technologies, Spaceplane Plus, Tantares, FASA launch tower

So, I will be continuing to use openGL. Seems to me that sounds are a bit lower in quality though, but I can live with that.

Link to comment
Share on other sites

Been messing with OpenGL all weekend (and I think a bit of last week too) after giving up on getting 64 to work nicely with my setup (system and mods). Cut the memory usage in half upon startup and reduced memory related crashes to 0 (down from 1 every 20-30 minutes or so, depending on what I was doing).

Textures look the same, though I lost one of my EVE settings somewhere in my tweaking (I again have the white horizon...maybe when I dropped RSPC?).

Checked via launching the exe directly rather than through Steam. ~3.1GB usage via DX, ~1.7GB usage via OpenGL.

Mods Installed (at least partially, I do tend to edit the mods a touch to fit what I need, either removing parts that I don't use or writing a patch to update/edit something using Module Manager (e.g. Interstellar's science equipment which only half works.))

Toolbar

Active Texture Management

B9 (Flat RCS tanks, Aerobrakes, and Omni Lights only)

Distant Object Enhancement

DMagic Orbital Science (with Universal Storage pieces removed)

Editor Extensions

Enhanced Nav Ball

Environmental Visual Enhancements (with Astronomer's pack)

Firespitter (removed Bi-Plane and Oblong fuselage parts)

Hooligan Labs - Airships

KAS

KSO

KSPX - I think I may have dropped some parts out of here too

KW Rocketry

MechJeb2

Hot Rockets

Near Future - Electrical, Propulsion, Solar

Final Frontier

Panda Jager Labs

Part Highlighter

Procedural Wings

Procedural Fairings

RLA_Stockalike - LV-T5 small and NERVA small only

SCANsat

Science Alert

Mk2 Cockpit internals

Texture Replacer

TAC Fuel Balancer

Kerbal Alarm Clock

KSP Alternate Resource Panel

Tweakable Everything

KSP Interstellar

Link to comment
Share on other sites

Same here. Works really good, with ATM basic its fast and good looking. And... crashes are really rare, and performance is around 90% of directx9 for me.

Been messing with OpenGL all weekend (and I think a bit of last week too) after giving up on getting 64 to work nicely with my setup (system and mods). Cut the memory usage in half upon startup and reduced memory related crashes to 0 (down from 1 every 20-30 minutes or so, depending on what I was doing).

Textures look the same, though I lost one of my EVE settings somewhere in my tweaking (I again have the white horizon...maybe when I dropped RSPC?).

Checked via launching the exe directly rather than through Steam. ~3.1GB usage via DX, ~1.7GB usage via OpenGL.

Mods Installed (at least partially, I do tend to edit the mods a touch to fit what I need, either removing parts that I don't use or writing a patch to update/edit something using Module Manager (e.g. Interstellar's science equipment which only half works.))

Toolbar

Active Texture Management

B9 (Flat RCS tanks, Aerobrakes, and Omni Lights only)

Distant Object Enhancement

DMagic Orbital Science (with Universal Storage pieces removed)

Editor Extensions

Enhanced Nav Ball

Environmental Visual Enhancements (with Astronomer's pack)

Firespitter (removed Bi-Plane and Oblong fuselage parts)

Hooligan Labs - Airships

KAS

KSO

KSPX - I think I may have dropped some parts out of here too

KW Rocketry

MechJeb2

Hot Rockets

Near Future - Electrical, Propulsion, Solar

Final Frontier

Panda Jager Labs

Part Highlighter

Procedural Wings

Procedural Fairings

RLA_Stockalike - LV-T5 small and NERVA small only

SCANsat

Science Alert

Mk2 pit internals

Texture Replacer

TAC Fuel Balancer

Kerbal Alarm Clock

KSP Alternate Resource Panel

Tweakable Everything

KSP Interstellar

Link to comment
Share on other sites

Saved a little over 1GB of memory using OpenGL. Game is more stable. Don't think I've had a single crash since doing this - probably because I'm not running close to the memory limit now.

Only glitch is that when I alt-tab away from KSP in fullscreen and return, the Windows border stays and things are a little screwy in KSP. Pressing Alt-Enter fixes things.

Link to comment
Share on other sites

[...]It's just surprising to me that you guys are seeing such a large reduction in memory usage by using OpenGL considering how much more mature and memory-optimized DirectX is.

Where did you get that claim from? OpenGL generally doesn't perform any worse, rather better, than DirectX, the problem is that Unity is sadly not as optimized on it as on the (sadly) generally more often used Direct3D, that is why you get the framerate losses. That's important to me as I'm a proponent of open-source and therefore generally favor OpenGL and don't like if it's called worse just because it's younger and free.

<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>OpenGL performance will depend on the graphics card and CPU. In a large majority of cases, DirectX performs better. Which is exactly the reason it is used as standard in pretty much every graphics-intensive game that is not still in the dark ages.

Same thing I said to Jason Cox. While NVidia cards perform a bit better on DirectX, AMDs perform better on OpenGL. See, I have a AMD R9 290, and a benchmark with Unigine Heaven (Unigine is a engine optimized for both rendering frameworks) gives me these results:

OpenGL: 34.9 FPS, 878 Points

Direct3D 11: 30.9 FPS, 779 Points

See? OpenGL isn't commonly used because it's inferior (even on nVidia cards the difference is small), it's due to Windows' market leadership and DirectX being Microsofts own thing.

Stop judging OpenGL. It's Unity's fault, not OpenGL's.

<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>Opengl makes me lag as i have a amd graphic card

Huh? As i said above, on an AMD card it should run better than on a nVidia.

I can't run KSP with openGL ,it always hang:(

More information would be great. What mods, when does it hang, GPU...

Only glitch is that when I alt-tab away from KSP in fullscreen and return, the Windows border stays and things are a little screwy in KSP. Pressing Alt-Enter fixes things.

I have that problem too. I will try Alt-Enter, thanks!

http://i.imgur.com/TB1RJlM.png

So much for that.

Well, it seems that I should remove Better Atmospheres V5. I can't launch game since I installed that version of mod.

I suppose it works with Direct3D? It yes, try OpenGL without BA5, and please post the logfiles that were produced (like your picture shows).

In conclusion you could say that KSP generally runs smoother on Direct3D and has a few glitches. Its usage only pays off if you really use enough mods for it to matter as a memory reduction method and your hardware can handle it, but if it can, it does its job quite well. If there are no objections I will write this in the OP soon.

Link to comment
Share on other sites

Tryed forcing both DX11 and OpenGL

Packed some mods:

Standart KSP (ATM 3.1 , Dx9c) = 3.2 GB ram usage at startup

DX11 (same ATM 3.1) = 2.1 GB , problems with switching to fullscreen and borderless window , texture and font glitching

OpenGL (same ATM 3.1) = 1.4g GB at startup. Smooth , no crashes yet , fonts are normal

This is really amazing , will continue play on OpenGL to check any bugs.

http://i.imgur.com/QeehU4d.jpg

Specs:

Win 7 x64

i5 2500

GeForce 650 ti

8 gb 1333 ram

Link to comment
Share on other sites

tried forcing DX11,

lazor's docking camera doesnt work.

and the game goes "null reference exception" very frequently and it seems the framerate drops a little bit (not sure, but my perception tells me so)

using a 7850 on phenom2 955

Link to comment
Share on other sites

opengl was introduced in early 1990 directx was introduced in 95 alot of games at that time wouldn't touch it with a 10 foot pole microsoft spent tons of money on developers to see it even get started. Even then the better programmers of the time still stuck with opengl. See Carmack's stuff ie anything from id software. So I'm interested as to why anyone thinks that opengl is the newbie here?

Link to comment
Share on other sites

opengl was introduced in early 1990 directx was introduced in 95 alot of games at that time wouldn't touch it with a 10 foot pole microsoft spent tons of money on developers to see it even get started. Even then the better rogrammers of the time still stuck with opengl. See Carmack's stuff ie anything from id software. So I'm interested as to why anyone thinks that opengl is the newbie here?

not really...

i recalled DX became the industry standard very soon after its launch, like... a couple years later when 3dfx was going downhill and eventually became a goner

i still recalled if you want to play games those days, you probably need a Voodoo or those kind of addon cards...and games supported 3dfx's Glide instead of opengl and d3d

(i always wanted to see if it would work plugging the voodoo2 out to another voodoo2's in, but then i was in junior high that time, didnt have much spare money to do that...)

and i always have this thought that opengl has never been the mainstream in games, they are mainly used by rendering softwares like AutoCAD and those kind of stuff

Edited by lammatt
Link to comment
Share on other sites

not really...

i recalled DX became the industry standard very soon after its launch, like... a couple years later when 3dfx was going downhill and eventually became a goner

i still recalled if you want to play games those days, you probably need a Voodoo or those kind of addon cards...and games supported 3dfx's Glide instead of opengl and d3d

and i always have this thought that opengl has never been the mainstream in games, they are mainly used by rendering softwares like AutoCAD and those kind of stuff

glide was simply a modified version of opengl. This was done because it took a while for stuff to be integrated into the released version of opengl and 3dfx wanted the features faster. 3dfx was a member of the opengl standards committee. Directx did become standard quickly, because, as I said microsoft poured virtually unlimited funds into helping game developers write games for directx. directx became standard because of microsofts marketing and co development programs not because it was any better. In my opinion it didn't even reach parity untill around directx 8.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...