From: "Francisco Casas" Subject: Re: [PATCH vkd3d v2 07/10] vkd3d-shader/hlsl: Support complex numeric initializers. Message-Id: <8da891aed9c8cab91cae6d046e41dba7@codeweavers.com> Date: Thu, 13 Jan 2022 14:17:16 +0000 In-Reply-To: <46c051e79b7a419cbb77ba2ac6b005c3@codeweavers.com> References: <46c051e79b7a419cbb77ba2ac6b005c3@codeweavers.com> <20220110193318.267854-7-fcasas@codeweavers.com> <7ddb2af1-3120-cafd-337f-1e414fc8a25b@codeweavers.com> Sorry, I was flying low when I wrote my previous answer, so I will correct some things: January 12, 2022 2:15 PM, "Francisco Casas" wrote: > January 12, 2022 1:48 PM, "Giovanni Mascellani" wrote: > >> Hi again, >> >> On 12/01/22 17:35, Giovanni Mascellani wrote: >> >>> In other words, it seems that here you have to test for > "v->initializer.args_count == 1", not >>> "size == 1". But do your own > research. >> This was correct, **I** was thinking on the single numeric initializer case, but replacing "size == 1" with "v->initializer.args_count == 1", besides preempting the regression, covers this case. >> Actually, I noticed that this shader does not compile on native: >> >> --- >> float4 main() : SV_TARGET >> { >> float3 x = {float4(71, 72, 73, 74)}; >> return float4(x, 74); >> } >> --- >> >> (the only difference with my previous email is the pair of braces around the initializer) >> >> So it seems that the condition you want to discriminate on is whether the initializer is specified >> as a list (in which case you have to fully unpack and match in order) or as a single object (in >> which case you treat it as an assignment). I guess, at least. > > No, I think that the original purpose of doing an assignment when "v->initializer.args_count == 1" > is to cover the cases for when numeric variables are initialized with a single numerical constant. > I correct myself, you were right in that that was the condition that was tested here. Regarding the compilation of that shader, yes, I hope it is acceptable to be permissive for those cases for now. Maybe this can be treated when we implement the "flattening" of initializers: --- float4 main() : SV_TARGET { float4 aa = {{1, 2}, 3, {{{4}}}} return aa } --- > For instance, this shader: > > --- > float4 main() : sv_target > { > float3 aa = 3; > float4 bb = {aa.x, aa.y, aa.z, 4.0}; > return bb; > } > --- > > Retrieves (3.0, 3.0, 3.0, 4.0) with the native compiler. > > If I am not mistaken, initializers like float4(1 ,2 ,3 ,4) are treated the same as > {1, 2, 3, 4} in the code. > I was mistaken, no, they aren't, obviously, sorry. > Still, I will add these tests in v3.