mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Parse "if" statement attributes.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
9605993af3
commit
1153f6bb34
Notes:
Alexandre Julliard
2023-08-24 23:11:51 +02:00
Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/303
@ -6108,19 +6108,39 @@ jump_statement:
|
||||
}
|
||||
|
||||
selection_statement:
|
||||
KW_IF '(' expr ')' if_body
|
||||
attribute_list_optional KW_IF '(' expr ')' if_body
|
||||
{
|
||||
struct hlsl_ir_node *condition = node_from_block($3);
|
||||
struct hlsl_ir_node *condition = node_from_block($4);
|
||||
const struct parse_attribute_list *attributes = &$1;
|
||||
struct hlsl_ir_node *instr;
|
||||
unsigned int i;
|
||||
|
||||
if (!(instr = hlsl_new_if(ctx, condition, $5.then_block, $5.else_block, &@1)))
|
||||
if (attribute_list_has_duplicates(attributes))
|
||||
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Found duplicate attribute.");
|
||||
|
||||
for (i = 0; i < attributes->count; ++i)
|
||||
{
|
||||
destroy_block($5.then_block);
|
||||
destroy_block($5.else_block);
|
||||
const struct hlsl_attribute *attr = attributes->attrs[i];
|
||||
|
||||
if (!strcmp(attr->name, "branch")
|
||||
|| !strcmp(attr->name, "flatten"))
|
||||
{
|
||||
hlsl_warning(ctx, &@1, VKD3D_SHADER_WARNING_HLSL_IGNORED_ATTRIBUTE, "Unhandled attribute '%s'.", attr->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
hlsl_warning(ctx, &@1, VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE, "Unrecognized attribute '%s'.", attr->name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(instr = hlsl_new_if(ctx, condition, $6.then_block, $6.else_block, &@2)))
|
||||
{
|
||||
destroy_block($6.then_block);
|
||||
destroy_block($6.else_block);
|
||||
YYABORT;
|
||||
}
|
||||
destroy_block($5.then_block);
|
||||
destroy_block($5.else_block);
|
||||
destroy_block($6.then_block);
|
||||
destroy_block($6.else_block);
|
||||
if (condition->data_type->dimx > 1 || condition->data_type->dimy > 1)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
@ -6130,7 +6150,7 @@ selection_statement:
|
||||
"if condition type %s is not scalar.", string->buffer);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
}
|
||||
$$ = $3;
|
||||
$$ = $4;
|
||||
hlsl_block_add_instr($$, instr);
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,7 @@ enum vkd3d_shader_error
|
||||
VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE = 5302,
|
||||
VKD3D_SHADER_WARNING_HLSL_IMAGINARY_NUMERIC_RESULT = 5303,
|
||||
VKD3D_SHADER_WARNING_HLSL_NON_FINITE_RESULT = 5304,
|
||||
VKD3D_SHADER_WARNING_HLSL_IGNORED_ATTRIBUTE = 5305,
|
||||
|
||||
VKD3D_SHADER_ERROR_GLSL_INTERNAL = 6000,
|
||||
|
||||
|
@ -15,7 +15,7 @@ uniform 0 float4 0.1 0.0 0.0 0.0
|
||||
draw quad
|
||||
probe all rgba (0.1, 0.2, 0.3, 0.4)
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
float4 main(uniform float4 u) : sv_target
|
||||
{
|
||||
[attr1]
|
||||
@ -25,7 +25,7 @@ float4 main(uniform float4 u) : sv_target
|
||||
return float4(0.9, 0.8, 0.7, 0.6);
|
||||
}
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
float4 main(uniform float4 u) : sv_target
|
||||
{
|
||||
[flatten]
|
||||
@ -37,8 +37,8 @@ float4 main(uniform float4 u) : sv_target
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.0 0.0 0.0 0.0
|
||||
todo draw quad
|
||||
todo probe all rgba (0.9, 0.8, 0.7, 0.6)
|
||||
draw quad
|
||||
probe all rgba (0.9, 0.8, 0.7, 0.6)
|
||||
|
||||
[pixel shader fail]
|
||||
float4 u;
|
||||
@ -52,7 +52,7 @@ float main() : sv_target
|
||||
return float4(0.9, 0.8, 0.7, 0.6);
|
||||
}
|
||||
|
||||
[pixel shader fail]
|
||||
[pixel shader fail todo]
|
||||
float4 u;
|
||||
|
||||
float main() : sv_target
|
||||
@ -68,7 +68,7 @@ float main() : sv_target
|
||||
[require]
|
||||
shader model >= 3.0
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
float4 main(uniform float4 u) : sv_target
|
||||
{
|
||||
[branch]
|
||||
@ -80,5 +80,5 @@ float4 main(uniform float4 u) : sv_target
|
||||
|
||||
[test]
|
||||
uniform 0 float4 0.0 0.0 0.0 0.0
|
||||
todo draw quad
|
||||
todo probe all rgba (0.9, 0.8, 0.7, 0.6)
|
||||
draw quad
|
||||
probe all rgba (0.9, 0.8, 0.7, 0.6)
|
||||
|
Loading…
x
Reference in New Issue
Block a user