Advertisement

Can we use a struct variable to initialize another one in HLSL?

Started by May 28, 2019 04:49 AM
1 comment, last by Adam Miles 5 years, 8 months ago

I'm new to HLSL programming and I want to use a struct variable to init another one, i.e. to use a "copy constructor" in C++.

Since struct is customized data structure, I wonder if we can use a "=" to do the copy initialization?

 

e.g.

 


struct MyStruct {
	int a;
	float4 n;
}

MyStruct s1;
s1.a = 1;
s1.b = float4(1.f);

MyStruct s2 = s1;

Is the above code usable?

Yes

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

This topic is closed to new replies.

Advertisement