mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Parse function call syntax on state blocks.
This commit is contained in:
committed by
Henri Verbeet
parent
f15d8dc9e9
commit
b5f2e7daeb
Notes:
Henri Verbeet
2024-07-09 21:10:32 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/915
@@ -1290,6 +1290,9 @@ static bool state_block_contains_state(const char *name, unsigned int start, str
|
||||
|
||||
for (i = start; i < block->count; ++i)
|
||||
{
|
||||
if (block->entries[i]->is_function_call)
|
||||
continue;
|
||||
|
||||
if (!ascii_strcasecmp(block->entries[i]->name, name))
|
||||
return true;
|
||||
}
|
||||
|
@@ -507,22 +507,31 @@ struct hlsl_ir_var
|
||||
* name[lhs_index] = args[0]
|
||||
* - or -
|
||||
* name[lhs_index] = {args[0], args[1], ...};
|
||||
*
|
||||
* This struct also represents function call syntax:
|
||||
* name(args[0], args[1], ...)
|
||||
*/
|
||||
struct hlsl_state_block_entry
|
||||
{
|
||||
/* For assignments, the name in the lhs. */
|
||||
/* Whether this entry is a function call. */
|
||||
bool is_function_call;
|
||||
|
||||
/* For assignments, the name in the lhs.
|
||||
* For functions, the name of the function. */
|
||||
char *name;
|
||||
/* Resolved format-specific property identifier. */
|
||||
unsigned int name_id;
|
||||
|
||||
/* Whether the lhs in the assignment is indexed and, in that case, its index. */
|
||||
/* For assignments, whether the lhs of an assignment is indexed and, in
|
||||
* that case, its index. */
|
||||
bool lhs_has_index;
|
||||
unsigned int lhs_index;
|
||||
|
||||
/* Instructions present in the rhs. */
|
||||
/* Instructions present in the rhs or the function arguments. */
|
||||
struct hlsl_block *instrs;
|
||||
|
||||
/* For assignments, arguments of the rhs initializer. */
|
||||
/* For assignments, arguments of the rhs initializer.
|
||||
* For function calls, the arguments themselves. */
|
||||
struct hlsl_src *args;
|
||||
unsigned int args_count;
|
||||
};
|
||||
|
@@ -7379,6 +7379,32 @@ state_block:
|
||||
hlsl_src_from_node(&entry->args[i], $5.args[i]);
|
||||
vkd3d_free($5.args);
|
||||
|
||||
$$ = $1;
|
||||
state_block_add_entry($$, entry);
|
||||
}
|
||||
| state_block any_identifier '(' func_arguments ')' ';'
|
||||
{
|
||||
struct hlsl_state_block_entry *entry;
|
||||
unsigned int i;
|
||||
|
||||
if (!(entry = hlsl_alloc(ctx, sizeof(*entry))))
|
||||
YYABORT;
|
||||
|
||||
entry->is_function_call = true;
|
||||
|
||||
entry->name = $2;
|
||||
entry->lhs_has_index = false;
|
||||
entry->lhs_index = 0;
|
||||
|
||||
entry->instrs = $4.instrs;
|
||||
|
||||
entry->args_count = $4.args_count;
|
||||
if (!(entry->args = hlsl_alloc(ctx, sizeof(*entry->args) * entry->args_count)))
|
||||
YYABORT;
|
||||
for (i = 0; i < entry->args_count; ++i)
|
||||
hlsl_src_from_node(&entry->args[i], $4.args[i]);
|
||||
vkd3d_free($4.args);
|
||||
|
||||
$$ = $1;
|
||||
state_block_add_entry($$, entry);
|
||||
}
|
||||
|
Reference in New Issue
Block a user