Archived

This topic is now archived and is closed to further replies.

NiteLordz

HLSL, VS, CG confusion

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites