Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Question about Textures and GPU memory  (Read 939 times)

0 Members and 1 Guest are viewing this topic.

Sunflower

  • Newbie
  • *
  • Posts: 2
    • View Profile
Question about Textures and GPU memory
« on: June 04, 2013, 05:13:40 pm »
Hello there!

I'm using SFML for C# and I was wondering if using Texture class comes with risk of it being unusable due to clearing of GPU memory or something; I remember that somewhere texture-like object had to be checked if it wasn't wiped from GPU memory before drawing, so I would like to make sure if it isn't the case here.

And if actually Texture *might* be lost forever from GPU memory (and if so, how to find out that?), is having some emergency Image connected with that texture (so that texture would be created anew from that image) be a good strategy, knowing that Texture would be unlikely to change often?

Thanks for help!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Question about Textures and GPU memory
« Reply #1 on: June 04, 2013, 05:27:19 pm »
Why should a texture mysteriously disappear from video memory?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Sunflower

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Question about Textures and GPU memory
« Reply #2 on: June 04, 2013, 09:37:39 pm »
Well, I don't know why it would suddenly disappear from video memory, but in some game-creation software there was something analogical to RenderTexture, probably, called "surface". Here is an extract from its documentation:
Quote
First, you should realise that surfaces are "volatile". This means that if the device or window loses focus or is minimised (good examples are when a screensaver comes up in Windows, or on an Android device when the app loses focus due to a call) then the surface may be destroyed. This is because it is stored in the vRam and may be overwritten when the target platform needs that memory for something else which means that you should always have some type of fail-safe code in place, usually with the surface_exists function.

I'm quite new to SFML and have rather vague understanding of what is happening behind the scenes (I'm rather a high-level person, probably; and no, by "high-level" I don't mean how amazing I am), so I can't really tell whether there is room for similar problem as described for "surfaces" above, or textures (and overlying RenderTextures) are handled in a way that properly working computer shouldn't allow problems like that to happen. I figured that if surfaces have problem because of existing in video memory, and textures exist in there as well, then maybe SFML Textures would be as volatile as that program's surfaces.

So yes, can I be rest assured that properly written program won't experience mysterious exodus of textures? And that the reasons of problems with "surfaces' don't apply to Textures? I'm not really into technical details, but I'd like to be sure that my application won't suddenly get all white without any apparent reason, so to speak. ^^"

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Question about Textures and GPU memory
« Reply #3 on: June 04, 2013, 09:42:52 pm »
I such an issue existed in SFML, it would at least be properly documented ;)
Laurent Gomila - SFML developer

 

anything