Jump to content

  • Log In with Google      Sign In   
  • Create Account

GLSL Texture and variables


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 me_here_me   Members   -  Reputation: 102

Like
0Likes
Like

Posted 01 January 2007 - 04:39 AM

I m using GLSL for rendering a 3D texture. I am new to GLSL and i feel that i am performing the operaations in not a very efficient manner. I am binding a texture everytime when a display function is called which i feel can be made more efficient. can i activate and bind a texture once and use it everytime the display function is called. void display() { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, txVolume); // txVolume is already loaded glUniform1iARB(glGetUniformLocation(p, "txVolume"), 0); int minX, maxX, minY, maxY, minZ, maxZ = 0; determineCorners(&Ddim,&matrixMVFinalTemp, &minX, &maxX, &minY, &maxY, &minZ, &maxZ); // a method that determines values for its arguments locminX = glGetUniformLocationARB(p, "minX"); locmaxX = glGetUniformLocationARB(p, "maxX"); locminY = glGetUniformLocationARB(p, "minY"); locmaxY = glGetUniformLocationARB(p, "maxY"); locminZ = glGetUniformLocationARB(p, "minZ"); locmaxZ = glGetUniformLocationARB(p, "maxZ"); glUniform1iARB(locminX, minX); glUniform1iARB(locmaxX, maxX); glUniform1iARB(locminY, minY); glUniform1iARB(locmaxY, maxY); glUniform1iARB(locminZ, minZ); glUniform1iARB(locmaxZ, maxZ); glBegin(GL_POLYGON); glVertex2d(-50.0,-50.0); glVertex2d(-50.0,50.0); glVertex2d(9.0,50.0); glVertex2d(9.0,-50.0); glEnd(); } thanks in advance

Sponsor:

#2 RichardS   Members   -  Reputation: 298

Like
0Likes
Like

Posted 01 January 2007 - 06:02 AM

I wouldn't worry about 1 texture bind.

You may want to try to entirely eliminate redundant state changes, but in general, it's much better for your sanity to just set it up at the begining of a frame, rather than trying to track state across frames (for a program this small it probably does not matter, but as they get larger...)

However, the glGetUniformLocation calls might actually be a performance issue. They exist so OpenGL doesn't have to do string comparisions and table lookups every time you load a new uniform. Using the API in this way negates that advantage.

Query the uniform locations once during setup, and cache the values. It'll have far more of an effect than removing the BindTexture.

#3 zedzeek   Members   -  Reputation: 528

Like
0Likes
Like

Posted 01 January 2007 - 07:52 AM

in addition to what richard saiz (without seeing the shader)
u have 6 different variables minX minY minZ max
now im guessing u do perhaps something like
valX = max( minX, 0.0 );
valY = max( minY, 0.0 );

but cause of the way graphic hardware works on vectors youll get much better performance bby working on all at once
uniform vec3 min_vec;

val = max( min_vec, vec3(0) );

#4 me_here_me   Members   -  Reputation: 102

Like
0Likes
Like

Posted 04 January 2007 - 02:56 AM

thanks for the valuable input :)


#5 me_here_me   Members   -  Reputation: 102

Like
0Likes
Like

Posted 04 January 2007 - 02:56 AM

thanks for the valuable input :)





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS