High VRAM demand but in fact verly low GPU requirements

Post all other topics which do not belong to any other category.
KingChris
Manual Inserter
Manual Inserter
Posts: 4
Joined: Tue Mar 06, 2018 9:01 pm
Contact:

High VRAM demand but in fact verly low GPU requirements

Post by KingChris »

As many of you may know HD sprites need a very high amount of VRAM with about 3 GB. Until some days before I played on normal detail level and it was ok for me. But HD would be a really cool feature. In fact I tried the setting and it is running good even on my notebook with integrated graphics and only 4 GB of shared DDR3.

The game is running even with HD graphics with about 20 FPS in the worst case (zoomed out) and normally with almost 60 FPS.
So if I would buy a new notebook with a dedicated graphics card the game surely would run with 60 FPS, but 2GB VRAM would be less than required. Will it be enough for the final version of Factorio? I don't need a GTX 1050 or something like that and other graphic cards don't have more than 2 GB.

What is the background that so much VRAM iss needed and why are sprites not stored in the RAM on any device? I didn't see very much frame drops which could result from loading sprites.
Another point is that I want to know the difference between the "Low VRAM mode" which runs really bad for me and the normal setting where you can choose how much VRAM should be used. Isn't it in fact the same thing?

Some more technical background:
As far as I know it is really strange that everything has to be stored to the VRAM because nowadays the connection to the GPU memory is very good. With Dual Channel RAM you are able to work very well with no dedicatated graphics memory at all so why don't load big data packs to the VRAM only when needed?

Koub
Global Moderator
Global Moderator
Posts: 6797
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by Koub »

A typical mid-end (GTX 1050) video card memory will have 112 GBps bandwidth VRAM.
DDR4 4000 (which is very high end RAM) will have in the 35GBps ("average DDR4 2400 will be more in the 20s).
Both memories are just not comparable. VRAM is designed for one thing : providing the GPU with all the data it needs real time so that it's not data starved.

[Edit] : it was obviously GBps, not MBps, thanks for pointing it out.
Koub - Please consider English is not my native language.

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 950
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by ratchetfreak »

The bottleneck for factorio is not the gpu, it is instead the CPU and memory latency. Upgrading gpu beyond the minimal required will do nothing to improve performance because the slowdown is elsewhere. Kinda like getting a new 10Gb network card even though your router is ancient and can only support 100Mb max.

Adding pressure to the RAM will negatively affect performance because now the RAM is occupied by other memory actions and cannot be used for the main processing.

KingChris
Manual Inserter
Manual Inserter
Posts: 4
Joined: Tue Mar 06, 2018 9:01 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by KingChris »

@Koub:

There is a litte mistake in your example. We are in the range of Gigabyte/s and not only MB. But I fully agree that RAM is slower.
But I don't unterstand why for example 20 GB/s shouldn't be enough because Factorio doesn't have sprites with some GB if all sprites together count 2.x GB. What should a situation in Factorio look like where all sprites are needed at one time?

Loading of 2 GB maybe would cause a Framedrop beacuse it needs 0.1 s in which nothing can be calculated. This would be surely annoying in other games where the player enters a new area.

@ratchetfreak:
I have constant 60 UPS so that's not the problem. Maybe in some Megabase it would be a problem but I think this is because of the non-optimized multithreading and not caused by the RAM. What I am wondering about that Factorio says it needs >3 GB VRAM but the games runs quite ok on my old notebook. I'm going to test the game with HD settings on a newer notebook but also with an integrated graphics and therfore shared memory, too.
If this runs smooth at 60 FPS the VRAM thing is pure nonsense, because in fact you don't really need it. But I think there are some programming issues as the low VRAM mode works very bad for me.

Koub
Global Moderator
Global Moderator
Posts: 6797
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by Koub »

Well atually, I remember several topics where this was brought (the fact that Factorio needed very high end video card VRAM, not related to GPU needs).
And I do agree : what's the point in having low end requirements for most of the machine, but guge requirement for VRAM ? I'd rather have a more coherent requirement.
Koub - Please consider English is not my native language.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by DaveMcW »

KingChris wrote:I have constant 60 UPS so that's not the problem. Maybe in some Megabase it would be a problem but I think this is because of the non-optimized multithreading and not caused by the RAM.
The devs made an optimized multithreading build, and it instantly hit a wall of RAM latency. RAM is the real bottleneck.

KingChris
Manual Inserter
Manual Inserter
Posts: 4
Joined: Tue Mar 06, 2018 9:01 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by KingChris »

DaveMcW wrote:
KingChris wrote:I have constant 60 UPS so that's not the problem. Maybe in some Megabase it would be a problem but I think this is because of the non-optimized multithreading and not caused by the RAM.
The devs made an optimized multithreading build, and it instantly hit a wall of RAM latency. RAM is the real bottleneck.
I read the thread about multithreading and it said that more than 2 cores don't have such a big effect. So probably you are right that the RAM can be a bottleneck.

But in the given situation that you don't have a megabase and stable 60 UPS the FPS become more important. And here there are in my opinon some problems and too much settings.

- The Low VRAM mode works bad on my device. And I'm sure some people will try to activate it when they want to choose HD graphics and there it says "You can't choose them because of <3GB VRAM"
- Choosing Low VRAM usage is ok for me but can't there be an automated VRAM allocation? Why does the user has to choose here something?
- In fact I am able to play with HD graphics even if it always said I can't

posila
Factorio Staff
Factorio Staff
Posts: 5154
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by posila »

In 0.16.28, I added some tooltips to graphics settings to give people idea what they do and what might be their impact on performance.

High-res sprites were always intended for top 20% gaming computers, but I can see why people with older or lower-end HW want to use them too. Also some high-end configurations don't run the game smoothly so we will work on improving how we utilize VRAM in the new rendering framework in 0.17.

"Low VRAM mode" depends on "Video memory usage" setting. "Video memory usage" is kind of bad name for that setting, because it controls what kind of sprite will be included in sprite atlases. For example, if you set it to "High", low priority sprites (trains, radars, explosions) will be excluded from the atlases. The more sprites we can fit into single atlas, the better we can utilize sprite batching. But drivers/GPUs don't seem to be fond of huge textures we are creating nowadays, so we exposed some options to control atlas size.

Atlases are supposed to be always be in VRAM (but we have no direct control over that, graphics driver might decide to not put an atlas to VRAM). "Low VRAM mode" controls what happens with free floating sprites (the ones the were not put to any atlas). If disabled, they are created as textures, so it's up to a driver to shuffle textures between VRAM and RAM as they are being used in rendering. If enabled, they are kept in RAM as blob of data and converted to textures only when needed in rendering. Currently we have structure that we call Bitmap Cache, that manages all these conversions and releases textures that were not used for some period of time. It was in the code since ever, but was not used, I enabled it for 0.16 as an experiment.

I thought "Low VRAM mode" performs much better than expected. I do have some framedrops from time to time, but the game is still playable for me. Can you elaborate on effects it has on performance on your computer?

So ... why does "Low VRAM mode" causes framedrops and why I expected it to be much worse? It is true there PCI-e has huge memory bandwidth, but every CPU<->GPU communication has huge latency (in context of real-time rendering). So if I ask it to upload a chunk of memory to a texture, it won't happen immediately, but some time in the near future. And if I try to render such texture, it will stall whole rendering pipeline. There are ways how to mitigate this, but it is not trivial problem to solve, and it is impossible with our current rendering framework.

Also, please don't buy laptop to play games :( it's just trouble ... from power and cooling issues, to driver problems, because every laptop with dedicated GPU has some technology for switching between integrated and dedicated GPU, which requires drivers from two graphics vendors to cooperate on some level... just no.

@Koub: I believe you can run the game on very wide range of PCs, and I try to make it so that on configuration that we have listed in minimum requirements (512MB Video Memory, 4GB RAM) you can play with normal sprite quality. We never default sprite quality setting to lower than normal.

Ubertwink
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Sun Oct 18, 2015 5:47 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by Ubertwink »

posila wrote:Also, please don't buy laptop to play games :( it's just trouble ...
While this is true for playing stuff like Witcher on ultra with hairworks enabled, Factorio at a glimpse looks like a pretty light game in terms of system requirements, and a lot of people expect it to run well ("well" as in stable 60 fps) even with some of graphic settings tuned up a bit.

Fractaliste
Inserter
Inserter
Posts: 28
Joined: Wed Dec 06, 2017 9:20 am
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by Fractaliste »

posila wrote: Also, please don't buy laptop to play games :( it's just trouble ...
Factorio is one of the unusual game I can play in my bed with my 5 years old laptop without decent graphics card, do not kill it!

KingChris
Manual Inserter
Manual Inserter
Posts: 4
Joined: Tue Mar 06, 2018 9:01 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by KingChris »

posila wrote: I thought "Low VRAM mode" performs much better than expected. I do have some framedrops from time to time, but the game is still playable for me. Can you elaborate on effects it has on performance on your computer?
I'm not sure if I understood it the right way. But if the question was how the behaviour is on my Laptop, when I check or uncheck the "Low VRAM box" than the issue is following.
With the box unchecked I can play the game stable and I have only smaller framedrops. When I check the box the framedrops are much bigger and go even under 10 FPS and the game really stucks for some seconds from time to time and it also hang up.

But what about my key question from this topic. If even on my old notebook without dedicated VRAM and with old DDR3-RAM the game is running in HD (with 25-60 FPS) I'm pretty sure that with a newer iGPU and enough DDR4 in DualChannel mode the game would run very smooth. Maybe I can test it on such a notebook this weekend.
So maybe there isn't any bottenleck regarding to graphics even in HD mode? A text like "You need 3GB of VRAM" causes panic and I'm sure some people buy a better graphics card only for playing Factorio but maybe it wouldn't be necessary at all.

User avatar
Krazykrl
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Tue May 02, 2017 11:08 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by Krazykrl »

KingChris wrote:So maybe there isn't any bottenleck regarding to graphics even in HD mode? A text like "You need 3GB of VRAM" causes panic and I'm sure some people buy a better graphics card only for playing Factorio but maybe it wouldn't be necessary at all.
Well, in my case... If I use All VRAM mode, I get almost unnoticeable stutters every few seconds at normal texture quality. If I additionally turn on HD textures, Factorio freezes for about 300ms every 5 seconds or so. I am using a dedicated GPU though (a 4 year old GTX 760 2GB.)

HurkWurk
Filter Inserter
Filter Inserter
Posts: 258
Joined: Mon Nov 14, 2016 4:55 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by HurkWurk »

Ubertwink wrote:
posila wrote:Also, please don't buy laptop to play games :( it's just trouble ...
While this is true for playing stuff like Witcher on ultra with hairworks enabled, Factorio at a glimpse looks like a pretty light game in terms of system requirements, and a lot of people expect it to run well ("well" as in stable 60 fps) even with some of graphic settings tuned up a bit.
you are misunderstanding what hes talking about. its not performance, its compatibility. many people have already ran into this similar issue with HDMI audio.

example, I have an MSI gaming laptop. it uses both the internal intel GPU and a dedicated SLI 1050 pair of cards as well. some games however, start running on the intel GPU. because they arent "aware" of the SLI pair at the time they launch. so in cases like that, you have to mess with settings to do things like force the graphics cards to load the game and/or disable the Intel card through keyboard shortcuts before launching the game, etc.

posila
Factorio Staff
Factorio Staff
Posts: 5154
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by posila »

KingChris wrote:With the box unchecked I can play the game stable and I have only smaller framedrops. When I check the box the framedrops are much bigger and go even under 10 FPS and the game really stucks for some seconds from time to time and it also hang up.
Interesting, thanks for the information.
KingChris wrote:But what about my key question from this topic. If even on my old notebook without dedicated VRAM and with old DDR3-RAM the game is running in HD (with 25-60 FPS) I'm pretty sure that with a newer iGPU and enough DDR4 in DualChannel mode the game would run very smooth. Maybe I can test it on such a notebook this weekend. So maybe there isn't any bottenleck regarding to graphics even in HD mode? A text like "You need 3GB of VRAM" causes panic and I'm sure some people buy a better graphics card only for playing Factorio but maybe it wouldn't be necessary at all.
The bottleneck regarding so graphics in HD mode is real, but the minimum requirements for HD graphics can't be defined exactly. For example the game runs perfectly fine for me on 2GB GTX 750Ti, no matter what settings in game I choose, but can run really poorly on 2GB Radeon R7 360 with high quality sprites, or people can have problems with GTX 980 and 4K screen. The purpose of 3GB VRAM warning is to let people know, the game may perform poorly if high resolution sprites are used on their PC. If they still choose to try it out and it works perfectly, great. If the FPS tanks, it's not a bug.
HurkWurk wrote:example, I have an MSI gaming laptop. it uses both the internal intel GPU and a dedicated SLI 1050 pair of cards as well. some games however, start running on the intel GPU. because they arent "aware" of the SLI pair at the time they launch. so in cases like that, you have to mess with settings to do things like force the graphics cards to load the game and/or disable the Intel card through keyboard shortcuts before launching the game, etc.
The saddest part is that this is completely invisible to DirectX or OpenGL. The game can't force itself to be initialized on the high performance card, drivers decide on which GPU given application should run. So when you say "[games] aren't aware of the SLI pair" it's acctually graphics driver, that decided those games don't need to be run on dedicated GPUs. And understandably people will go complain to the game developers, not graphics vendors or laptop manufacturers.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by eradicator »

posila wrote:Also, please don't buy laptop to play games :( it's just trouble ... from power and cooling issues, to driver problems, because every laptop with dedicated GPU has some technology for switching between integrated and dedicated GPU, which requires drivers from two graphics vendors to cooperate on some level... just no.
My laptop is my main system. Since i need to frequently carry it around it's not feasible to own a non-laptop for me. So i play games on it too. 2G VRAM btw, and using high textures at 40fps during full zoom-out and 60fps with normal zoom.

Back to topic... knowing next to nothing about how gpus internally manage vram i vaguely remember they can do some sort of texture compression. So my question is: would it be feasible to make textures more compressible by using image quantization similar to what pngquant does?

Also i recently noticed during modding that mod guis with many elements seem to use a lot more vram than i expected, even if they're invisible. My reasoning: After creating a large gui i noticed weird framerate drops even when the gui wasn't visible, and changing my sprite settings to normal made the drops much less noticible.

You can simulate the effect with something like this (creates an invisible gui with about 180k sprite buttons):

Code: Select all

/c
local cycles = 200
local g = game.player.gui.center
g.clear()
local f = g.add{type='scroll-pane',name = 'test'}
f.style.height = 800
f.style.visible = false
f = f.add{type='table',column_count = 1}
local k = #game.item_prototypes
for i=0,4*cycles do
  local j = 0
  local y = f.add{type='frame'}
  y = y.add{type='table',column_count = 30}
  for n,p in pairs(game.item_prototypes) do
    local x = y.add{type='flow'}
    x.add{type='sprite-button',sprite='item/'..n,number=(i*k)+j,tooltip = p.localised_name}
    j = j+1
    end
  end
This slows down my vanilla game to 30fps and creates very ugly micro-freezes regularly, which i assume is texture shuffling between VRAM and RAM. Removing the gui immediately brings back normal framerates:

Code: Select all

/c game.player.gui.center.clear()

bobucles
Smart Inserter
Smart Inserter
Posts: 1657
Joined: Wed Jun 10, 2015 10:37 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by bobucles »

Don't more recent video cards have some sort of automatic texture compression? 2GB on one card may be very different than 2GB on another card.

Zeblote
Filter Inserter
Filter Inserter
Posts: 972
Joined: Fri Oct 31, 2014 11:55 am
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by Zeblote »

posila wrote:The saddest part is that this is completely invisible to DirectX or OpenGL. The game can't force itself to be initialized on the high performance card, drivers decide on which GPU given application should run. So when you say "[games] aren't aware of the SLI pair" it's acctually graphics driver, that decided those games don't need to be run on dedicated GPUs. And understandably people will go complain to the game developers, not graphics vendors or laptop manufacturers.
The game can export 2 variables to hint the drivers that it requires high performance. For example, this is found in unreal engine:

Code: Select all

// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
// The following line is to favor the high performance NVIDIA GPU if there are multiple GPUs
// Has to be .exe module to be correctly detected.
extern "C" { _declspec(dllexport) uint32 NvOptimusEnablement = 0x00000001; }

// And the AMD equivalent
// Also has to be .exe module to be correctly detected.
extern "C" { _declspec(dllexport) uint32 AmdPowerXpressRequestHighPerformance = 0x00000001; }
But it looks like factorio already does this, so it's strange that it isn't working.

posila
Factorio Staff
Factorio Staff
Posts: 5154
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by posila »

eradicator wrote:Back to topic... knowing next to nothing about how gpus internally manage vram i vaguely remember they can do some sort of texture compression. So my question is: would it be feasible to make textures more compressible by using image quantization similar to what pngquant does?
GPU use lossy block compression algorithms (I think all of them work on 4x4 pixel blocks) and they have constant compression ratio independent on content of a compressed texture. Reason for this is that GPU needs to be able to do fast random-memory access into textures, so it needs to be able to calculate memory offset from pixel position. That's not possible in formats like PNG or JPEG, where you have no way of getting value of specific pixel without decompressing whole image.
eradicator wrote:Also i recently noticed during modding that mod guis with many elements seem to use a lot more vram than i expected, even if they're invisible. My reasoning: After creating a large gui i noticed weird framerate drops even when the gui wasn't visible, and changing my sprite settings to normal made the drops much less noticible.
That doesn't seem like VRAM problem to me. Might be something in-optimal in GUI logic or in LUA, might be worth separate bug report, even thought I am not sure if 180k gui elements is something we want to support.
bobucles wrote:Don't more recent video cards have some sort of automatic texture compression? 2GB on one card may be very different than 2GB on another card.
It sounds plausible, but I don't know.

posila
Factorio Staff
Factorio Staff
Posts: 5154
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by posila »

Zeblote wrote:The game can export 2 variables to hint the drivers that it requires high performance.
...
But it looks like factorio already does this, so it's strange that it isn't working.
I don't know if it's working or not for Factorio, not many people complain about it being launched on wrong GPU nowadays. But it's just a hint, driver can do whatever it wants. I was talking about general case ... if these problems on "gaming" laptops would be isolated to Factorio, than it's obvious we are doing something wrong. But if these problems are common across several games and mostly don't happen on desktops, I don't think the issues are cause by games being buggy.

I am just not fan of switchable graphics technology in gaming laptops, that's all.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5202
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: High VRAM demand but in fact verly low GPU requirements

Post by eradicator »

posila wrote: GPU use lossy block compression algorithms (I think all of them work on 4x4 pixel blocks) and they have constant compression ratio independent on content of a compressed texture. Reason for this is that GPU needs to be able to do fast random-memory access into textures, so it needs to be able to calculate memory offset from pixel position. That's not possible in formats like PNG or JPEG, where you have no way of getting value of specific pixel without decompressing whole image.
Ah. That makes sense. I knew GPUs don't handle precompressed formats, but didn't know constant-factor compression even existed :D.
posila wrote:That doesn't seem like VRAM problem to me. Might be something in-optimal in GUI logic or in LUA, might be worth separate bug report, even thought I am not sure if 180k gui elements is something we want to support.
The actual count i need is more like 10k for vanilla (recipe count * 20 ish?, so rapidly rises with mods), which i could probably reduce to 3-4k if i knew it's just the number of elements that needs to be optimized. The main reason i wanted to keep that many elements is because i had to balance them against the creation cost (the freeze that happens when the gui is created for the first time). And i had no idea what part of the gui subsystem was causing the slowdown, so in turn i had no idea where to optimize (still don't know if empty things like flows are less expensive than i.e. sprite buttons). I guess i'll post a formal report when i have time if there's at least a chance for it to get optimized :). Not sure what i'd name that "bug" though without having it instantly moved to the "don't do that" section ^^.
Last edited by eradicator on Fri Mar 09, 2018 3:47 pm, edited 4 times in total.

Post Reply

Return to “General discussion”