Open devshgraphicsprogramming opened 1 year ago
TL;DR Basically https://github.com/microsoft/hlsl-specs/blob/main/proposals/0005-strict-initializer-lists.md but with being able to write out names of members to initialize (less error prone)
C-style aggregate designated initializers would be interesting too!
C-style aggregate designated initializers would be interesting too!
yeah exactly what I'm looking for, definitely not the C++ style because then your designators need to match order of declaration in struct.
I'd rather have that be a warning than an error.
Re: designated initializers, I'd love for the following to compile and work:
struct Varying {
float4 position: SV_Position;
float2 uv: TEXCOORD0;
};
Varying VSMain(
float3 position: POSITION,
float2 uv: TEXCOORD0
) {
return {
.position = mul(constant.combined_matrix, float4(position, 1.0)),
.uv = uv
};
}
Is your feature request related to a problem? Please describe.
Its okay to not want to implement constructors and destructors because they come with a whole host of issues.
But not having to make a
static create
for every struct would be nice.Describe the solution you'd like
Aggregate initialization
{}
and initialization with named members to avoid the razorsharp knife I could cut myself with.Describe alternatives you've considered
Static factory functions.
They're really verbose, got to repeat all members as parameters, and typename of the struct, and remember about assignments.
Its a lot of code to hand-write.