How to copy an array in HLSL?

Viewed 385

In HLSL I have two arrays:

int arr1[2]; 
int arr2[2];

I need to copy contents of arr1 to arr2.

Should I iterate through every element?

arr2[0] = arr1[0]; 
arr2[1] = arr1[1];

Is there any specific HLSL tool (like memcpy() in C/C++)?

Or could I just write arr2 = arr1; and that will work for me?

1 Answers

arr2 = arr1 works fine. There is no reason to go through every element and it could add quite a bit of time depending on the number of array elements or their size.

Related