Jump to content
  • Advertisement
Sign in to follow this  
yadango

HLSL Assembly Question

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

Hello,
I'm trying to learn HLSL assembly, using MSDN as a guide and a book or two. Most swizzle examples given are kind of simple and I saw some code that looked like this and wondered what the equivalent statements were.
[source]mova a0.w, r4.x
mul r4.yzw, v0.y, c0[a0.w].xxyz
[/source]
is the equivalent expression
[source]a0.w = r4.x
r4.y = v0.y * c0[a0.w].x
r4.z = v0.y * c0[a0.w].x
r4.w = v0.y * c0[a0.w].y[/source]
or this?
[source]a0.w = r4.x
r4.y = v0.y * c0[a0.w].x
r4.z = v0.y * c0[a0.w].x
r4.w = v0.y * c0[a0.w].y
r4.w = v0.y * c0[a0.w].z[/source]
Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Cool, thanks, makes sense now! The repeat rule only applies to the source register and not the dest.

Share this post


Link to post
Share on other sites
I'm not sure.. but I would guess neither.. and that r4.yzw = v0.y * c0[a0.w].xyz
The docs http://msdn.microsoft.com/en-us/library/windows/desktop/hh447193(v=vs.85).aspx says the destination register has a writemask.. which is not the same as a swizzle. I interpret it as that the calculation is done on 4 components and the components of the result is written to the destination register or skipped depending on the mask..
That is, xxyz * v0.y is calculated to a temporary result xyzw, and the x is skipped on write to destination since it's not in the mask.

Share this post


Link to post
Share on other sites
so maybe something like this? smile.png that's why the mask has to be in order...

[source lang="cpp"]// mova a0.w, r4.x
temp.x = r4.x
temp.y = r4.x
temp.z = r4.x
temp.w = r4.x
a0.x = unchanged
a0.y = unchanged
a0.z = unchanged
a0.w = temp.w

// mul r4.yzw, v0.y, c0[a0.w].xxyz
temp1.x = v0.y
temp1.y = v0.y
temp1.z = v0.y
temp1.w = v0.y
temp2.x = c0[a0.w].x
temp2.y = c0[a0.w].x
temp2.z = c0[a0.w].y
temp2.w = c0[a0.w].z
r4.x = unchanged
r4.y = temp1.y * temp2.y
r4.z = temp1.z * temp2.z
r4.w = temp1.w * temp2.w[/source] Edited by yadango

Share this post


Link to post
Share on other sites
The internal steps will differ from platform to platform, HLSL ASM is an intermediate format, but the end result is most likely like that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!