Page 1 of 1

Get available video memory value

Posted: Wed Jul 31, 2019 12:37 pm
by Sasha264
Good day! :ultrahappy:

https://love2d.org/wiki/love.graphics.getStats

Code: Select all

love.graphics.getStats( )
Returnes size of currently used video memory in texturememory field.

Is here a way to somehow get total video memory value?
Or maybe available | free value?

I have some data in canvases that can be stored for future use, or can be dropped and calculated again in future.
Actual used video memory can be 1-2 GB for me, so not all video cards have such amount.
And I want to drop the memory usage. But only in the case of "small" amount of available video memory.

Re: Get available video memory value

Posted: Wed Jul 31, 2019 10:09 pm
by raidho36
Existence of threads like these in 2018 tells me, there isn't a simple way to do this.

https://stackoverflow.com/questions/484 ... ics-memory

Texture creation will fail if you exceed VRAM limits, so you will know if it runs out. The to-go way of handling this type of problem is to have graphics settings where particular switches control how much memory the graphical assets will take, most notably the texture quality dropdown. This way users will be able to configure the right settings for their machine. You can target typical memory values with any particular setting: 1 GB, 2, 3, 4, 6, 8, 11 (oddball but nVidia has it), 16 GB.

Re: Get available video memory value

Posted: Wed Jul 31, 2019 10:39 pm
by Sasha264
Thank you!
For the reply.. and for the link :3

Ok, handle it by user efforts is a way :megagrin:
Maybe I can suggest default limit by the table, contains video card names and available vram values... :ehem:

Did not checked the texture creation fail, but canvas creation works "fine" when the limit is exceeded. But cpu memory consumption is increasing and fps drops to ~5 or something:

Re: Get available video memory value

Posted: Thu Aug 01, 2019 11:41 am
by grump
Sasha264 wrote: Wed Jul 31, 2019 10:39 pm Did not checked the texture creation fail, but canvas creation works "fine" when the limit is exceeded. But cpu memory consumption is increasing and fps drops to ~5 or something:
(Some) GPU drivers implement memory swapping between GPU and main RAM, so you can use more GPU memory than available at the expense of speed when swapping occurs.

There are compressed texture formats btw.

Re: Get available video memory value

Posted: Sat Aug 10, 2019 11:51 am
by Sasha264
There are compressed texture formats btw.
Can I apply compressed texture formats to canvases somehow?

Re: Get available video memory value

Posted: Sat Aug 10, 2019 12:11 pm
by slime
Unfortunately you can't.

What sort of thing are these large cached Canvases used for, specifically? Maybe there's a different way to accomplish your goal which uses less VRAM.

Re: Get available video memory value

Posted: Sat Aug 10, 2019 1:34 pm
by Sasha264
Hello! :nyu:
What sort of thing are these large cached Canvases used for, specifically? Maybe there's a different way to accomplish your goal which uses less VRAM.
I have a (potentially) unlimited grid that contains objects which are affecting each other with shadows and lights and some other static shader effects. Player can scroll visible window around the world. The basic implementation is to calculate every effect in realtime just for visible window.

Then a thought came to me: why do I need to calculate some channels of lighting every frame while they are static? So I divided entire world with squares NxN pixels with some overlap, calculate lighting only for visible squares and store it in canvases pool. So, if player will navigate to area A then to area B then again to area A => lighting will be calculated once for area A and once for area B. Because the world is potentially unlimited, I can not cover it by the squares entirely, so here is the restriction to number of stored canvases. Like a cache pattern. The question is how many canvases can I alow to be in the pool?

Maybe this is a bad idea initially, because it entails a bunch of problems and has questionable profit. Just trying :3