[PATCH vkd3d 6/6] vkd3d-shader/hlsl: Parse state blocks in variable definitions.

Zebediah Figura (she/her) zfigura at codeweavers.com
Mon Sep 27 20:22:43 CDT 2021


On 9/25/21 07:09, Matteo Bruni wrote:
> On Thu, Sep 23, 2021 at 11:47 PM Zebediah Figura
> <zfigura at codeweavers.com> wrote:
>>
>> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
>> ---
>>   Makefile.am                               |   1 +
>>   libs/vkd3d-shader/hlsl.h                  |   2 +
>>   libs/vkd3d-shader/hlsl.y                  |  64 +++++++-
>>   tests/hlsl-state-block-syntax.shader_test | 173 ++++++++++++++++++++++
>>   4 files changed, 235 insertions(+), 5 deletions(-)
>>   create mode 100644 tests/hlsl-state-block-syntax.shader_test
> 
>> diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
>> index 19745e725..420156e66 100644
>> --- a/libs/vkd3d-shader/hlsl.y
>> +++ b/libs/vkd3d-shader/hlsl.y
> 
>> @@ -2878,6 +2909,29 @@ primary_expr:
>>               if (!($$ = add_call(ctx, $1, &$3, @1)))
>>                   YYABORT;
>>           }
>> +    | NEW_IDENTIFIER
>> +        {
>> +            if (ctx->in_state_block)
>> +            {
>> +                struct hlsl_ir_load *load;
>> +                struct hlsl_ir_var *var;
>> +
>> +                if (!(var = hlsl_new_var(ctx, $1, ctx->builtin_types.scalar[HLSL_TYPE_INT], @1, NULL, 0, NULL)))
>> +                    YYABORT;
>> +                if (!(load = hlsl_new_var_load(ctx, var, @1)))
>> +                    YYABORT;
>> +                if (!($$ = make_list(ctx, &load->node)))
>> +                {
>> +                    hlsl_free_instr(&load->node);
>> +                    YYABORT;
>> +                }
>> +            }
> 
> This leaks var on error.
> Actually, does it also leak it on success? We usually store the
> variables into scopes and go through the scopes when we want to free
> them, but that's not the case here.

Indeed; I think this should be hlsl_new_synthetic_var(). Not sure what I 
was doing here...



More information about the wine-devel mailing list