How to copy an array in HLSL?
Asked Answered
D

1

6

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?

Dulaney answered 4/1, 2019 at 15:21 Comment(0)
H
0

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.

Hypethral answered 21/7, 2022 at 9:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.