Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: shader and texture simple question

  1. #1
    Intern Contributor
    Join Date
    Jul 2014
    Location
    Italy, Lissone
    Posts
    50

    shader and texture simple question

    hi all,
    my question is simple but very important i think:

    for example i'm using the gouraud shader files then i load and use phong shader files, then if i want to use gouraud again, which is better? delete the shader if not used anymore it and then load the shader again when i want to use it or use a vector which occupies ram memory?

    same thing for texture, consider if i turn the camera and the texture is not drawn anymore, should i delete it and then reload it from file or should i "save" it in the RAM?

    thanks advance

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    786
    Hmm, I'd say the principle of 'avoid doing unnecessary work' applies and boils down to:
    If you do not need the resources occupied by shaders/textures/buffer objects/whatever for something else and there is even a remote chance you may need them again, don't destroy them. If you need the resources for something else, destroy those objects first that are least likely to be needed again in the future. If you are certain you won't need an object again, free its resources.
    In particular compiling and linking shaders is not a cheap operation, the driver is running a rather powerful optimizing compiler for a non-trivial language. On the other hand compared to texture or vertex data they consume tiny amounts of memory, so they are unlikely to make a difference with respect to resource usage.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Dec 2010
    Location
    Oakville, ON, CA
    Posts
    107
    Me Hmm also - for some reason I think that the driver tosses resources between RAM and CPU memory to make a space in RAM for those only which are in use. Therefore if some resource is not used and RAM overfills, the driver deletes unused resources from RAM leaving their single copies in CPU memory only. If this is true, then there is nothing to worry about having redundant resources...

  4. #4
    Intern Contributor
    Join Date
    Jul 2014
    Location
    Italy, Lissone
    Posts
    50
    ok, i get the idea, thanks guys for the answer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •