Results 1 to 4 of 4

Thread: shader and texture simple question

  1. #1
    Member Contributor
    Join Date
    Jul 2014
    Italy, Lissone

    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
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    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
    Senior Member Regular Contributor
    Join Date
    Dec 2010
    Oakville, ON, CA
    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
    Member Contributor
    Join Date
    Jul 2014
    Italy, Lissone
    ok, i get the idea, thanks guys for the answer

Similar Threads

  1. Simple question about geometry shader
    By nicolas in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-11-2012, 03:09 AM
  2. Question of texture coordinates in shader
    By SagoO in forum OpenGL: GLSL
    Replies: 1
    Last Post: 04-05-2011, 02:55 AM
  3. Simple texture wrapping question
    By chronophile in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-03-2010, 01:05 AM
  4. HLSL simple Texture Shader
    By Matthias Thurau in forum OpenGL: GLSL
    Replies: 2
    Last Post: 01-05-2008, 01:24 PM
  5. simple texture question
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-04-2003, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean