Shader language type

Started by
1 comment, last by jollyjeffers 18 years, 5 months ago
Is there any difference in the method of writing a shader file? There seems to be 2 method, one is written something like C with struct and a function. The other is very like assembly. Is there any benefit over another? Which should i go for?
Advertisement
Quote:
Is there any difference in the method of writing a shader file? There seems to be 2 method, one is written something like C with struct and a function.

In DirectX8, shaders were written in a low-level shader assembly language. We no longer have to write shaders in assembly language. DirectX9 has supplied a High-Level Shading Language that we can use to write shaders (C-style).

I hope this helps.
Quote:Original post by littlekid
Is there any benefit over another? Which should i go for?

HLSL (the c-style one!) is just a different representation of the Assembly shaders - the actual Direct3D runtime will use the ASM code and the HLSL is pretty much just for us developers. For the most part they are identical.

The only exception to this is if you're targetting the low-end shader profiles (ps_1_x and vs_1_x) as the HLSL compiler often can't generate ASM code that fits within the shader profile's restrictions. You'll see a lot of graphics programmers using assembly directly for such tasks...

For the higher profiles (SM2 and SM3) the restrictions are less of a problem, and you'd have to be a pretty good assembly-level programmer to beat the HLSL compiler [smile]

Bottom line is that if you're particularly interested in the low-end hardware/profiles you'll want to look at the ASM route. For everything else I'd recommend HLSL, but it's pretty much up to you to choose whichever one you prefer...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement