Feature level shaders...

Started by
3 comments, last by DavidGallagher1 9 years, 7 months ago

Was recently think of adding feature level support to my dx11 engine and was wondering if feature level 9_3 supports shader model 2_a or 2_b. I see that it doesn't support 3_0 but couldn't find info of what shader model 2_x shaders are supported. Also do I write the shaders just like shader model 5_0 as far as data sent to the shaders and just limit them to the limits from my dx9 engine (supporting 2_b and 3_0).thanks for any help in this matter would just be nice to combine both my engines if possible.

Advertisement

Always read the footnotes: http://msdn.microsoft.com/en-us/library/windows/desktop/ff476876%28v=vs.85%29.aspx


Also do I write the shaders just like shader model 5_0 as far as data sent to the shaders and just limit them to the limits from my dx9 engine (supporting 2_b and 3_0).

You don't have to implement any such limiting. The DX11 API enforces the feature levels for you, so for example, if you try to set a shader that is not supported by the feature level in use, it won't set it. You can use the debug layer to check if the shader was set successfully, or if there were compatibility errors. As for the shader input data, you'll get errors if try to use a shader-input format that doesn't match the input fromat of the compiled shader. The shader compiler will also give you errors if you use features (like data formats) that aren't compatible with the shader model specified during compilation.

If you want to support multiple feature levels, and use the shader features supported by newer shader models with the newer feature levels, you'll have to write (or use #ifdefs extensively) and copile the shaders separately, for each shader model... And if all your shaders are going to use only the shader models supported by the lowest feature level, then you can still use them with the newer feature levels, but then I think there's no point in using the higher feature levels - the higher feature levels are only useful if you actually use the new shader features.

So no, you can't just write your shaders with SM5.0 features and compile them for lower SM targets (unless you can #ifdef-out the use of the SM5.0 features).

I probably didn't explain myself that well, I didn't mean use my sm_5_0 directly (as I have already compiled them all I just wanted to add a new rendering pipeline that would use the dx9 features instead).

I meant, being I have a list of shader model 2_x shaders could I just add them to the dx11 engine and run them instead, as my sm 5 shaders use mrt's but of coarse i can't do that in dx9 I just wanted to use the shaders from my older engine in my new dx 11 engine as a seperate pipeline if dx11 isn't supported and was wondering if they still needed to be in the fx shader format or the new hlsl format where vertex and pixel shaders are separate and using cBuffers etc, so compiling a seperate shader frame work is fine with me I just wondered if there was any voodoo I had to perform in porting them, as in do I write the shaders like the .fx files or the same as hlsl 5_0 with seperate vs and ps files if that makes sense. thanks for the link, I'm assuming 2_x is the equivelant to 2_a/2_b based on dx9_b and dx9_c.

The Effects framework is no longer part of DirectX SDK (since DX10 even).

You could also still use Effects in DirectX11, as Microsoft provides it as source-code, but they also said that it will be completely removed in a future DirectX version, along with the rest of the D3DX functions (they will probably not be supported starting with DX12).

The hlsl format hasn't changed though... You just can't use Effects techniques and shader passes in your shaders anymore. You don't have to remove the techniques, because the compiler will just ignore them, but you still can't use them without the Effects framework.

You have to compile and load each shader separately now, along with setting constant buffers and sampler states (if you used to set them from hlsl before) - this would be the same as not using the Effects framework in DX9.

And sadly, you also cannot use preshaders anymore: http://msdn.microsoft.com/en-us/library/windows/desktop/bb206299%28v=vs.85%29.aspx#PreShaders_Improve_Performance so you have to be a lot more careful about what calculations you put in your shaders - if they are better done on the CPU, you have to move them out of your shaders manually now if you want to improve performance.

But I think this is exactly what you wanted (no Effects), right?

2_x refers to all of the shader model 2 shaders (2_a, 2_b etc...) except 2.0.

I also found another footnote, which may be of interest to you:

(from http://msdn.microsoft.com/en-us/library/windows/desktop/jj215820%28v=vs.85%29.aspx#direct3d_9.1__9.2__and_9.3_feature_levels)

Feature level 9.3 effectively requires hardware that complies with the requirements for legacy Direct3D 9 shader model 3.0, but this feature level does not make use of vs_3_0 or ps_3_0 targets

Thanks a bunch for all the info, yeah that helps fill the gaps up in my understanding of it. appreciate it.

This topic is closed to new replies.

Advertisement