Sign in to follow this  

Shader language type

This topic is 4412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

This topic is 4412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this