Jump to content
  • Advertisement


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


Vertex Shader Question

This topic is 5714 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

Hey all, just some stupid questions about vertex shader programming. vs.1.1 dcl_position v0 mov r0.xy, v0 this little code fragment...what is ment by r0.xy, in this case does it mean only move the x and y component of v0 to r0? Say I do something like: vs.1.1 dcl_position v0 mul oPos, v0, c0 //where c0 is world*view*proj This seems to take care of all the basic transforms you normally have with D3DTS_VIEW, D3DTS_PROJECTION and D3DTS_WORLD. Well I guess I want to know is this faster then using the device to set transforms? does it depend on the hardware? Ok last question, say I have 2 vertex shaders like in the dolphin sample, and as in the sample I assemble the shaders during init time, do I get a preformance hit if I switch back and forth at render time?

Share this post

Link to post
Share on other sites
1) Yes. "Write Masking"
Docs ->
DirectX Graphics ->
Reference ->
Shader Reference ->
Vertex Shader 1_1 ->
Masking (Vertex Shader)

2a) The "mul" instruction is only a vector multiply - i.e. multiply a 4D vector by a 4D vector giving a 4D vector as a result. To multiply the 4D position vector by a 4x4 transformation matrix you need a few "mad" instructions or a "m4x4" instruction.

2b) The D3D fixed function pipeline concatenates the D3DTS_WORLD, D3DTS_VIEW and D3DTS_PROJECTION matrices into single transforms internally too (and a few of the other hidden "internal" matrices).

3) On newer shader capable hardware the fixed function pipe is apparently implemented internally using shaders. Shaders are the way all the manufacturers are going so are likely to be the fastest path. Everything in D3D always depends on the specific hardware though.

4) Switching shaders is relatively expensive, though not as expensive as stuff like uploading textures.

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites
Thanx for the info and answers. Ohh and I ment to say:

m4x4 oPos, v0, c0

but as you can see from the time it was pretty early in the morning. Thanx again

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!