Skip to main content
GameDev.net gamedev.net
🔒 Locked

Basic Shader Optimisations

Started by Krakken Oct 31, 2005 at 4:51 AM 1 replies 700+ views
Original Post
Krakken
Krakken
Hi, I'd like some advice on some basic HLSL shader optimisations I can make. At the moment, I have a three pass post-filter which drops the game frame-rate to about 20-fps regardless of my previous frame rate. I'd also like to know if it's possible to do one calculation on certain things per frame to save re-calculating per-pixel? Also, is one pass faster than three passes? Any info to help would be great. I noticed in rendermonkey that putting it into ps_2_a added on about 10-fps over ps_2_0. Thanks, Nat.
Muhammad Haggag
Muhammad Haggag
Quote:
Original post by Krakken
I'd like some advice on some basic HLSL shader optimisations I can make. At the moment, I have a three pass post-filter which drops the game frame-rate to about 20-fps regardless of my previous frame rate.

- Postprocessing effects are greatly affected by the resolution of your render target. You can do your postfiltering on a smaller render target, then stretch it to the backbuffer. IIRC F.E.A.R does something like this, where it renders to a target that is half the backbuffer in width and height (Pixel doubling).

- The HLSL compiler is pretty smart when it comes to assembly-level/register-level optimization, so don't bother going this direction unless you're doing pre ps2.0 shaders.

- If you show us your code or give us an idea what you're trying to achieve, perhaps we can point out optimization opportunities.

Quote:
I'd also like to know if it's possible to do one calculation on certain things per frame to save re-calculating per-pixel?

Well, it depends on what you're doing. If something is constant throughout the frame, then not calculating it in the shader will definitely save you some cycles.

Quote:
Also, is one pass faster than three passes?

Assuming the "single" pass does the same calculations as the other 3 passes, then yes, it'll be faster. If it does things differently, then it depends on its complexity and length versus those of the 3 passes.

Quote:
Any info to help would be great. I noticed in rendermonkey that putting it into ps_2_a added on about 10-fps over ps_2_0.

ps_2_a exposes additional features (e.g. more temporary registers) and instructions, which enables the compiler to output more optimal code. Check: "DirectX Graphics->Reference->Asm Shader Reference->Pixel Shaders->Pixel Shader Differences" in the documentation.

Krakken
Krakken
Thanks very much. I'll go through, fix up what I got and if I still have problems i'll post the code.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.