Get available video memory value

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Get available video memory value

Post 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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Get available video memory value

Post 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.
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Get available video memory value

Post 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:
Attachments
vram-no-limit.png
vram-no-limit.png (42.17 KiB) Viewed 5595 times
vram-limit.png
vram-limit.png (41.32 KiB) Viewed 5596 times
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Get available video memory value

Post 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.
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Get available video memory value

Post by Sasha264 »

There are compressed texture formats btw.
Can I apply compressed texture formats to canvases somehow?
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Get available video memory value

Post 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.
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: Get available video memory value

Post 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
Post Reply

Who is online

Users browsing this forum: sbr2729 and 81 guests