Jump to content
  • Advertisement
Sign in to follow this  
RPTD

Using GLSL brings app to a crawl

This topic is 4232 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

This is a rather strange problem that I ran into today. In my engine currently there is 2D render part which does not use shaders and 3D render part which uses shaders. Now the idea has been to make the 2D part also with shaders as this way enabling and disabling shaders can be spared. Furthermore some additional tricks would be possible if required. Now comes the big problem. The 2D part consists currently mainly of many line draws and some quads ( images and text ). Hence for testing purpose I took the line only shader and draw only the lines ( should be roughly 90% of the workload ). If I use no shaders like before then I have 160 FPS in the 2D menu. If I though use the line shader all crawls down to horrible 16 FPS (!). The shaders used are dead simple.
// vertex program
void main( void ){
	gl_FrontColor = gl_Color;
	gl_Position = gl_ModelViewProjectionMatrix * vec4( gl_Vertex.xyz, 1.0 );
}
// fragement program
void main( void ){
	gl_FragColor = gl_Color;
}
Those shaders reduce the calculations per pixel done even more than what the fixed pipeline would perform. Still I'm punished with 90% drop in framerate. I assume from this behaviour that somewhere the pipeline has to be stalled but I have not the slightest clue what could cause this slowdown. The test system has been a Radeon 9700 Mobility on my Laptop.

Share this post


Link to post
Share on other sites
Advertisement
Check the error log output of the compilation / linking of the shader, maybe it fallsback to software emulation.

Share this post


Link to post
Share on other sites
Everything compiles without an error. There are also no OpenGL errors during rendering with the shaders.

Share this post


Link to post
Share on other sites
a 9700 should have no problems with that (dont know about laptops though but i assume theyre pretty much standard 9700s)
perhaps try glintercept or gldebugger + see whats happening,
do other glsl apps run fine eg rendermonkey

Share this post


Link to post
Share on other sites
I read on OpenGL.org that Radeons sometimes fall back to SW rendering with lines and shaders, mostly when any primitive smoothing is enabled.
Here's one link
http://www.opengl.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic;f=11;t=000956

If you don't send some fancy gl_Vertex.w from the app the even simpler shader would use gl_Position = ftransform();

Share this post


Link to post
Share on other sites
ATI cards don't return an error code if they fall back to software mode. you have to check the shader info log after compiling and linking if it says something about falling back to software mode.

[edit]Hm, and Maddi already wrote that ... sorry for the repetition[/edit]

Share this post


Link to post
Share on other sites
@zedzeek:
I'm on a linux machine hence those windows tools are to no use to me. Otherwise though the drawing works. I use the same line shader for drawing debug output ( like bounding boxes or entitiy connections ) and there it doesn't slow down that much ( just slowdown from non optimized rendering which not required for debug output ).

@Metalcore:
Thanks for the link. I disable LINE_SMOOTH and indeed the framrate climbed back up. This though astonishes me a lot. Why does it kill the framerate with the shader? Should LINE_SMOOTH not simpy prevent the bluring? Should this be less workload on the the graphic board?

With that I have now though still a slowdown but this is most probably caused by something else. I'll once try to wrap the entire 2d drawing into shader code ( with two shaders: lines and images/text ) and fiddle with the parameters. Maybe I find something there that pushes me up to where I had been before.

without line shader: 160 fps
with line shader: ~108 fps

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!