Jump to content
  • Advertisement
Sign in to follow this  
Mercenarey

HLSL - can it match FFP speedwise?

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

I am working on my shaders atm, and after some tests, I noticed a significant dip in performance from my shader to the Fixed-Function-Pipeline (FFP). I lost around 15-20 FPS (from 192 to 175). Even with the most basic shader possible, that just passed on the vertex in the VS and made the pixel black in the PS, I couldn't reach the FFP. I even tried to run the FFP at the highest sampling (Anisotropic) and running the shader with the lowest (Linear), and still the closest I can ever get no matter what I try, is the shader is 10 slower than the FFP. Am I doing something wrong? Can I specify some flags to optimize the compilation of the shader? (I have Flags in the D3DXCreateEffectFromFile() function set to 0, since I don't see any optimization flags). Can you match or beat the FFP? And how do you do it?

Share this post


Link to post
Share on other sites
Advertisement

If your shaders are trivial, then you're going to be bottlenecked by graphics driver overhead, not shader processing. What you're seeing indicates that the driver is simply better optimized in the fixed-function path than the shader path. If you were running more expensive shaders, you probably wouldn't notice any difference.

All of the modern GPUs now (e.g. ATI Radeon 9xx and up) convert fixed-function commands into shaders in the driver anyway.

JB

Share this post


Link to post
Share on other sites
Remember that 192 to 175 is a differences of 500 microseconds (~9%), it might not be that significant. That is easily in the realms of timer (in)accuracy.

The second thing to appreciate is that the general style of programming differs with shaders; given you have more control over what you can/can't do there are many more possible combinations. You might want to look at how your application is using shaders to see if you can tune the app rather than look at just the HLSL.

Also, it's generally agreed (although fact is hard to find) that the IHV's have been implementing the FFP via shaders "under the covers" for a while now.

hth
Jack

Share this post


Link to post
Share on other sites
jbarcz1:
Your explanation sounds very plausible. I tested some more, and discovered that a big part of the difference lay in the setting of the effect.

And my shader IS very simple for now (very basic, moves the vector to projection space, and uses one light (directional with only diffuse) only.

So I am content with your explanation for now - at least until I make more advanced shaders I can test with, hehe.

jollyjeffers:
I don't buy the timer inaccuracy should be the explanation. I tested many times back and forth with FFP and shader, and the result was more or less the same all the time.
If it was an inaccuracy, why wouldn't some of the tests fall out to the shader's advantage?
Furthermore, Im using the performance timer which is very accurate.

Share this post


Link to post
Share on other sites
Older cards had dedicated fixed function hardware along side the programmable shader hardware (the GeForce 3 and 4, GeForce FX and Radeon 8500) and were often faster when using the fixed function pipe than when running a shader of similar complexity. Newer cards like the Radeon 9000 series and up and the GeForce 6 series and up have no fixed function hardware and convert fixed function calls to shaders internally so generally shaders should be just as efficent and usually more efficient since they don't need to handle all the different fixed function options in many cases.

The problem here is more likely to be in the way you are measuring performance though as pointed out. In order to be sure you're measuring mostly GPU performance and not API or driver overhead you should be using a moderately complex shader with a large amount of geometry in a single draw call.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mercenarey
I am working on my shaders atm, and after some tests, I noticed a significant dip in performance from my shader to the Fixed-Function-Pipeline (FFP). I lost around 15-20 FPS (from 192 to 175).

Even with the most basic shader possible, that just passed on the vertex in the VS and made the pixel black in the PS, I couldn't reach the FFP.

I even tried to run the FFP at the highest sampling (Anisotropic) and running the shader with the lowest (Linear), and still the closest I can ever get no matter what I try, is the shader is 10 slower than the FFP.

Am I doing something wrong? Can I specify some flags to optimize the compilation of the shader? (I have Flags in the D3DXCreateEffectFromFile() function set to 0, since I don't see any optimization flags).

Can you match or beat the FFP? And how do you do it?


This really depends on the part. All modern video cards don't actually have a fixed function unit - they are really using shaders under the covers. Now, there are a few hardwarish features that exist that aren't exposed in shaders to make this a bit faster. They tend to do things like turn down precision and other tricks. More or less, however, its the same.

Share this post


Link to post
Share on other sites
Just something nobody mentioned, when using shader, you have a small (sometime big if you change shaders too often) overhead caused by setting all the constants, and shaders themselves. Whereas with the FFP, you don't have that.
And even with newer cards where FFP is converted into shaders, it's done by the driver (I assume) and so it's probably a lot more optimized than setting your own shaders.

Share this post


Link to post
Share on other sites
"I lost around 15-20 FPS" is a meaningless statistic, because frames per second is not an important measurement for performance. What is an important measurement for performance is time per frame. And as JJ pointed out, 500 microseconds is an insignificant performance difference. For comparison, an extra 500 microseconds would change a framerate of 60 FPS to a framerate of 58 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!