Jump to content

View more

Image of the Day

雑魚は多めにして、爽快感重視にしつつ・・・(´・ω・`)
早いとこ、ベースを作って、完成にもっていかないとね。
タイトルもまだ迷ってるだよなぁ。 
#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

HLSL Assembly Question

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
5 replies to this topic

#1 yadango   Members   

567
Like
0Likes
Like

Posted 03 August 2012 - 04:01 AM

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.
mova a0.w, r4.x

mul r4.yzw, v0.y, c0[a0.w].xxyz


is the equivalent expression
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

or this?
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

Thanks!

#2 Digitalfragment   Members   

1486
Like
1Likes
Like

Posted 05 August 2012 - 05:36 PM

The first. the z in c0[a0.w].xxyz would get dropped as it doesn't have a corresponding output in r4.yzw

#3 yadango   Members   

567
Like
0Likes
Like

Posted 05 August 2012 - 05:57 PM

Cool, thanks, makes sense now! The repeat rule only applies to the source register and not the dest.

#4 Erik Rufelt   Members   

5901
Like
1Likes
Like

Posted 05 August 2012 - 06:41 PM

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.

#5 yadango   Members   

567
Like
0Likes
Like

Posted 05 August 2012 - 07:24 PM

so maybe something like this? Posted Image that's why the mask has to be in order...

[source lang="cpp"]// mova a0.w, r4.xtemp.x = r4.xtemp.y = r4.xtemp.z = r4.xtemp.w = r4.xa0.x = unchangeda0.y = unchangeda0.z = unchangeda0.w = temp.w// mul r4.yzw, v0.y, c0[a0.w].xxyztemp1.x = v0.ytemp1.y = v0.ytemp1.z = v0.ytemp1.w = v0.ytemp2.x = c0[a0.w].xtemp2.y = c0[a0.w].xtemp2.z = c0[a0.w].ytemp2.w = c0[a0.w].zr4.x = unchangedr4.y = temp1.y * temp2.yr4.z = temp1.z * temp2.zr4.w = temp1.w * temp2.w[/source]

Edited by yadango, 05 August 2012 - 07:29 PM.


#6 Erik Rufelt   Members   

5901
Like
0Likes
Like

Posted 06 August 2012 - 03:41 AM

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




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.