Search code examples
shaderhlsldirectx-9

Should I favor a higher ShaderModel even if shader can be compiled with a lower version?


I have a lot of shaders compiling with ShaderModel vs_1_1 and ps_2_0 (using DirectX9). If I know that the hardware supports a higher shader model (probably most will support 3.0) should I compile with that higher shader model version? Is it more performant? Or is the lesser model version more effecient?


Solution

  • Easiest way to check is to use fxc with different profiles and check instruction count, in higher versions you can have new intrinsics that can reduce total instruction count.

    I remember struggling to fit within the 64 limitation in ps_2_0, whereas compiling in ps_3_0 gave me 63 instructions.

    I would (personal opinion here), use shader model 3 tho, even phones support the feature set nowadays.

    As per performance indicator, you have different things to take into account of course, since you need to balance between arithmetic/texture fetch/fill rate.

    Of course the lower the better in general, but 1 less arithmetic will not make you system much faster if you're draw call bound.

    For profiling, if you don't already use this feature yet, I strongly recommend to implement Queries , in your case TimeStamp is the most useful one. It allows you to measure shader execution time. Occlusion is also very useful for measure overdraw in the forward pass (fill rate).