[PATCH vkd3d v2 07/10] vkd3d-shader/hlsl: Support complex numeric initializers.

Francisco Casas fcasas at codeweavers.com
Thu Jan 13 08:17:16 CST 2022


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" <fcasas at codeweavers.com> wrote:

> January 12, 2022 1:48 PM, "Giovanni Mascellani" <gmascellani at codeweavers.com> 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.



More information about the wine-devel mailing list