Jump to content
  • Advertisement

Archived

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

randomseed

Vertex Shader Question

This topic is 5630 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
Advertisement
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
www.creative-asylum.com

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!