short question about hlsl

Started by
4 comments, last by cgrant 14 years, 1 month ago
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?
Advertisement
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.
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.
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.
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 outfloat 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 //datadef r1, 1.0f //addressmova a0.x, r1.x //load address registermov 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.

Niko Suni

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.

This topic is closed to new replies.

Advertisement