Jump to content
  • Advertisement
Sign in to follow this  
funkeejeffounet

[GLSL]Varrying array question and discard weird thing...

This topic is 4975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I was wondering if we could have varying arrays(of floats) in vertex/fragment shaders. How does the vertex shader interpolates in this case? Also, I have a program running at 5FPS whith a lot of rendering. When discarding all my fragments(just to estimate the cost of my shaders), I only have 10FPS, wich is illogical cause my fragment shaders have big loops with atan in it... Is discard something costy and should be avoided? Cheers, Jeff.

Share this post


Link to post
Share on other sites
Advertisement
what card at you using?

In theory, an array of varying data, if it can be done i've never tried, each array element will be dumpped into its own interpolater per vertex

Share this post


Link to post
Share on other sites
thats why i asked about the card.
I assume you discard without performing any other fragment operations? I dont belive its that expensive on your hardware, however I cant find out anything to confirm it.
The only other thing I can think is that when you kill the fragments you shift the bottleneck else where...

Share this post


Link to post
Share on other sites
What is really weird is that when rendering my geometry I achieve between 2 and 10 frames per seconds, but when discarding in my fragment shader I always get 2 FPS. How can such a thing be possible?
Can it be a driver issue?

And for the varrying array, if my vertex shader code is something like this :

varrying float tab[100];

void main (void)
{
//Transforming the vertice in screen space
gl_Position = ftransform();
//Two texture fetches depending on my transformed vertice coordinates x and y
position_1 = vec3(texture2D(texture_1, vec2(gl_Position)));
position_2 = vec3(texture2D(texture_2, vec2(gl_Position)));

//The texture texels R component are used here
for (i=position_1.x; i<position_2.x; i++)
{
tab = position_1.y + position_2.y + position_1.z + position_2.z;
}


In this case, will the array for each fragment be the result of the interpolated gl_Position between vertices, so that texture fetches will be the right ones?

Thansk phantom for helping me out,
Cheers, Jeff.

[Edited by - _the_phantom_ on March 31, 2005 1:48:32 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by funkeejeffounet
In this case, will the array for each fragment be the result of the interpolated gl_Position between vertices, so that texture fetches will be the right ones?


No. For that the texture lookups would be using the gl_Position for whichever vertex is currently being processed. To use the interpolated position at each fragment you would need to hold off on the texture lookups until the fragment program.

I don't know what could be wrong with discarding the fragments though.

Share this post


Link to post
Share on other sites
Quote:
Original post by funkeejeffounet
What is really weird is that when rendering my geometry I achieve between 2 and 10 frames per seconds, but when discarding in my fragment shader I always get 2 FPS. How can such a thing be possible?
Can it be a driver issue?


Hmmm that could be related to the zbuffer, if your not changing the z-coords of your fragments in the fragment shader then you could be getting a speed up due to early z-rejection, however when you dump the fragments you are processing all the fragments and not writing and z-values thus the speed up due to early z-rejection goes away

Share this post


Link to post
Share on other sites
Well I don't use a zbuffer in this pass :), so I guess the bottleneck is elsewhere.

I've just added in my code a "varying vec3 tab[128]" but the driver gives me a linker error. The shaders compiles fine though, I guess it is a problem coming from my uniforms or the array but I cannot guess why.

I declared the varrying array in both my vertex shader and my fragment shader.
I declared two sampler2D as uniform in my vertex shader only.
I declared a sampler1D and a sampler3D as uniforms in my fragment shader only.

From the GLSL spec it should work cause the only errors we can get are when using unifoms sharing a same name but different types. Also, if I remember correctly, I can have up to 8 uniforms on my GF6600.

Someone has a thought on this linker error? I really hope it is not the driver(I'm currently using beta 76.41).

Cheers, Jeff.

Share this post


Link to post
Share on other sites
"I've just added in my code a "varying vec3 tab[128]" but the driver gives me a linker error. The shaders compiles fine though, I guess it is a problem coming from my uniforms or the array but I cannot guess why."

You are exceeding the hardware limits and if you have software emulation turned on, it exceeds the emulators limits.
Most hw have about 16 interpolators (varyings)
There is a glGet for this. Use it!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!