HLSL, VS, CG confusion

Started by
2 comments, last by NiteLordz 20 years ago
Hi, i was just wondering which one is the best to implement. I remember reading somewhere that one should use the lowest version ( VS 1.0 opposed to VS 2.0 ) if the effect can be done the same way. Well my ? is, is this true. Also should i use the VS 1.0 if the same effect is done in HLSL. i am assuming that the HLSL is just an easier interface to use, that it compiles down to the same Vertex Shader. Well appreciate any information on this topic.
Code makes the man
Advertisement
Generally, you want to use the highest shader version that the card your program is running on will allow. If you have a vertex shader that can be compiled to use 1.0 or 1.1, then do so on cards that only support those versions. If the card supports vs 2.0, then use 2.0 because the driver and the runtime will have a greater ability to optimize the shader.

You''re right about HLSL being basically a layer on top of the standard assembly shaders. HLSL will be compiled into standard assembly shaders by D3DX. It allows developers to write their shaders in a much more readable and maintainable C++-like language and insulates the developer from having to worry about things like co-issue of instructions and how to write something like if/elseif/elseif/elseif/else in assembly (I''ve actually tried that, its horrible!).

neneboricua
yeah also with HLSL, it gets compiled down into the most appropreate version of asm code for the card its running on.
quote:Original post by hlivingstone
yeah also with HLSL, it gets compiled down into the most appropreate version of asm code for the card its running on.

Well, not necessarily. Which shader version the HLSL code will be compiled to pretty much depends on how you call D3DXCompileShaderFromFile. If you''re using the Effect interface, you have to decide while you''re writing your shader what shader versions your system will support. You can use different Techniques to get your shader to compile to different versions.

neneboricua

This topic is closed to new replies.

Advertisement