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.
This commit is contained in:
Francisco Casas 2024-10-01 11:36:56 -03:00 committed by Henri Verbeet
parent b7314e2438
commit 0b989c9f37
Notes: Henri Verbeet 2024-10-07 17:52:25 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1137
2 changed files with 12 additions and 12 deletions

View File

@ -2366,9 +2366,9 @@ static void initialize_var_components(struct hlsl_ctx *ctx, struct hlsl_block *i
{ {
struct hlsl_default_value default_value = {0}; 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 /* Default values are discarded if they contain an object
* literal expression for a numeric component. */ * 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; dst->default_values = NULL;
} }
} }
else }
{ else
if (!hlsl_clone_block(ctx, &block, instrs)) {
return; if (!hlsl_clone_block(ctx, &block, instrs))
default_value = evaluate_static_expression(ctx, &block, dst_comp_type, &src->loc); return;
default_value = evaluate_static_expression(ctx, &block, dst_comp_type, &src->loc);
if (dst->default_values) if (dst->default_values)
dst->default_values[*store_index] = default_value; dst->default_values[*store_index] = default_value;
hlsl_block_cleanup(&block); hlsl_block_cleanup(&block);
}
} }
} }
else else

View File

@ -86,7 +86,7 @@ technique10
// Without initializer // Without initializer
technique10 < int a; > {} technique10 < int a; > {}
[effect fail todo] [effect fail]
// Only numeric types and strings are allowed // Only numeric types and strings are allowed
technique10 < DepthStencilState ds = { 0 }; > {} technique10 < DepthStencilState ds = { 0 }; > {}