From 0b989c9f377289f0dc989f0b32a94cd385362392 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Tue, 1 Oct 2024 11:36:56 -0300 Subject: [PATCH] vkd3d-shader/hlsl: Fix the conditions to discard default values. Otherwise default_values for strings are lost. Thanks to Nikolay Sivov for pointing this out. --- libs/vkd3d-shader/hlsl.y | 22 +++++++++---------- .../hlsl/effect-annotations-fx_4.shader_test | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ef37eb75..962ca175 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2366,9 +2366,9 @@ static void initialize_var_components(struct hlsl_ctx *ctx, struct hlsl_block *i { struct hlsl_default_value default_value = {0}; - if (hlsl_is_numeric_type(dst_comp_type)) + if (src->type == HLSL_IR_COMPILE || src->type == HLSL_IR_SAMPLER_STATE) { - if (src->type == HLSL_IR_COMPILE || src->type == HLSL_IR_SAMPLER_STATE) + if (hlsl_is_numeric_type(dst_comp_type)) { /* Default values are discarded if they contain an object * literal expression for a numeric component. */ @@ -2381,17 +2381,17 @@ static void initialize_var_components(struct hlsl_ctx *ctx, struct hlsl_block *i dst->default_values = NULL; } } - else - { - if (!hlsl_clone_block(ctx, &block, instrs)) - return; - default_value = evaluate_static_expression(ctx, &block, dst_comp_type, &src->loc); + } + else + { + if (!hlsl_clone_block(ctx, &block, instrs)) + return; + default_value = evaluate_static_expression(ctx, &block, dst_comp_type, &src->loc); - if (dst->default_values) - dst->default_values[*store_index] = default_value; + if (dst->default_values) + dst->default_values[*store_index] = default_value; - hlsl_block_cleanup(&block); - } + hlsl_block_cleanup(&block); } } else diff --git a/tests/hlsl/effect-annotations-fx_4.shader_test b/tests/hlsl/effect-annotations-fx_4.shader_test index 3884cd42..8289807d 100644 --- a/tests/hlsl/effect-annotations-fx_4.shader_test +++ b/tests/hlsl/effect-annotations-fx_4.shader_test @@ -86,7 +86,7 @@ technique10 // Without initializer technique10 < int a; > {} -[effect fail todo] +[effect fail] // Only numeric types and strings are allowed technique10 < DepthStencilState ds = { 0 }; > {}