Shaders slower than FFP

Started by
9 comments, last by Metron 17 years, 3 months ago
Hi, I recently have switched my engine from FFP to shaders. Using a simple scene (a couple of hundred line + some text) I get a really bad speed when using shaders. Basically, I draw some lines and make debug output. I measure my FPS by averaging the last 100 frames. When using the FFP I get ~1700 FPS (when displaying the FPS). Using the shader pipe, I "barely" get 350 FPS. Actually, since I display the average of the last 100 frames, I see my FPS dropping from 600 to 350 only because I display some more text. This wasn't my expected behaviour. Can anyone give me a hint where this performance drop my come from? Have fun, Metron
----------------------------------------http://www.sidema.be----------------------------------------
Advertisement
Firstly - that drop is nothing! Think about what FPS means - its not a linear scale. Useing FPS is actually a pretty bad way to measure performance. Try useing miliseconds per render or something as a better alternative. Think of this:

FPS = 1700, means 0.6ms render time
FPX = 350, means 2.8ms render time

So with a fps drop of 1350fps you add 2.2ms to your render time. Now consider this:

FPS = 60, means 16.6ms render time
FPS = 50, means 20.0ms render time

So with a fps drop of 10, you now add 3.6ms to your render time. See why FPS is a bad measure of performance? A 10 fps drop from 60 to 50 means double the difference in render times between 1700 and 350. Honestly any change when your fps is higher than 120 means practically nothing!
At those framerates, you might be CPU limited. Using shaders instead of FF may cause you to make calls to DirectX a lot more, incurring greater overhead. This is just a wild guess, though.
NextWar: The Quest for Earth available now for Windows Phone 7.

A little question,

How do you set your shader constants ? Do you use handles ? Do you pass more data than is necessary ? Do you switch shader very often ?

Cheers!
Maybe you're on Software VertexProcessing? Maybe you use some other commands that you didn't use on FFP before?

For some simple letters, you're definitly CPU bound and the gfx board is idling around most of the time. So it must be either some additional overhead for setting up shaders and such or you're not doing the same as you have done on the FFP.

Bye, Thomas
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
When you've got FPS that high comparisons between various ways of rendering the scene are rather meaningless. Try adding more stuff to the scene so the FPS is more like 30 or 40, and then try your comparisons.

Also consider that if your card has a seperate FF pipeline and shader pipeline (modern cards tend to emulate FF using the shader pipeline), the FF pipeline may actually be faster than the shader one. Also if you have an integrated graphics card vertex shaders may actually be executed on the CPU.
If you provide more details, it might make more sense.

What card are you using? Some older cards were more efficient at FFP.

When you say FFP, do you mean vertex shaders, or pixel shaders, or both?

Are you doing the same calculation in both? What is it?
Since the above posters have done a suitable job tossing out some questions you'll need to answer for diagnostic purposes, I'll just chime in to mention two things:

(1) depending on your card, the FFP might be a "shader" itself anyway, and
(2) the point of shaders is not to, neccessarily, provide more speed than the fixed-function pipeline, but rather to provide a greater range of control.
Here we go ;)

FPS is not a valid measurement, I agree. But they reflect a tendency wihtin my code that I don't like.

My card is a 8800GTX, the cpu is a E6400.

As I said, the scene is very simple. Just some lines and some text.

I set vertex- and pixelshaders. I set the constants using handles. I switch the shaders 2 times : one for rendering the lines and one for the 2D text (thus I set 4 shaders: 2 vertex and 2 pixelshaders). I don't think that I pass too much data because I filter the needed data once the shader has been compiled and I only set that data.

I've thought of the software vertexshaders but I've hardcoded the hardware usage.

Well... I'll have to dig into this some more.
----------------------------------------http://www.sidema.be----------------------------------------
8800GTX is a very powerful card, and thus some lines and some text are not making it work very hard, so any slow down is going to be a bottleneck in some other part of the system. As I stated before you'll need a scene that's more complex that actually taxes your card to make a valid performance comparison e.g. you could render a couple of million cubes with some lighting, and then try doing that with FFP and then shaders. You may find that emulating what the FFP does with shaders will actually go slower than just using the FFP, even though the FFP is actually being emulated with shaders under the hood. However the shaders that do that are going to be written by the people who make the hardware and thus may be written in card specific code and will be highly optimized and thus you probably won't be able to out perform them.

As jpetrie said shaders are about more control of rendering rather than speed of rendering, so don't worry about this too much. If you find the FFP goes more quickly and you don't need more than the FFP provides then use the FFP.

This topic is closed to new replies.

Advertisement