Jump to content
  • Advertisement

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

Recommended Posts

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?




struct MyStruct {
	int a;
	float4 n;

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

MyStruct s2 = s1;

Is the above code usable?

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!