Sign in to follow this  
Dwood

short question about hlsl

Recommended Posts

Okay so I have these decompiled shaders in sasm (vs_1_1) and while trying to upconvert them to vs_2_0 I came across the mov a0.x, <some register here> in the sasm. In the dx sdk it mentions that I can use mova a0 to access the register//write to it in vs2... looking around further about that address register it mentions that I have to initialize it before I can modify it...? or can I just type mova(a0.x, blah) ? Basically how do I work with that address register properly in hlsl?

Share this post


Link to post
Share on other sites
a mov asm instruction is just an assign. ex

if the value 2.0f was in register c0 and we want to assign it to a variable say temp which is in c1 then :
[HLSL]
temp = 2.0f;

[asm]
mov c1, c0;

would be equivalent.
The mov instruction just copy data into a destination register from the source register.

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
You don't work with registers at all in HLSL, you just work with variables. This means there is no "mova" intrinsic or anything like that.


So when I'm trying to convert them to hlsl I just ignore such sasm lines?

edit: cgrant, I know the mov command and all that. I'm just curious what I should do when I see an address register, basically.

Share this post


Link to post
Share on other sites
I haven't tried this, but I believe that the address register gets used if you refer to vector elements by the array operator using a dynamic index. If you use a constant index to address the array, the HLSL compiler will likely optimize it off and writes a standard swizzle instead.

Example HLSL:


float4 data = {1.0f, 2.0f, 3.0f, 4.0f};
float address = 1; //should not be constant if you don't want to optimize mova out
float fetchedData = data[address]; //dynamic indexing to float4 register


If I understand the spec correctly, this would result in following asm (if isolated):



def r0 1.0f, 2.0f, 3.0f, 4.0f //data
def r1, 1.0f //address
mova a0.x, r1.x //load address register
mov r2, r0[a0.x]; //r2 = fetchedData = 2.0f = r0[1]



Again, this is untested! If you are going to use this as a basis for further work, be sure to verify it.

Share this post


Link to post
Share on other sites
To the op, I didn't mean to insult your intelligence, sorry. Anyways, whenever you see a mov instruction you just have to trace source register and then assign the value that was place in it to some HLSL variable. Its probably going to be tedious since the source register may be used in several places.

Share this post


Link to post
Share on other sites

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