mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/spirv: Handle "IdRef" operands.
This commit is contained in:
Notes:
Henri Verbeet
2025-03-10 15:22:45 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1382
@@ -27,6 +27,16 @@ sub opcode_id($)
|
||||
sprintf "0x%04x", shift;
|
||||
}
|
||||
|
||||
sub fix_name($)
|
||||
{
|
||||
shift =~ s/([A-Z]+)/_$1/rg;
|
||||
}
|
||||
|
||||
sub operand_type_name(_)
|
||||
{
|
||||
"SPIRV_PARSER_OPERAND_TYPE${\uc fix_name shift}";
|
||||
}
|
||||
|
||||
sub grammar_version($)
|
||||
{
|
||||
my ($grammar) = @_;
|
||||
@@ -34,17 +44,37 @@ sub grammar_version($)
|
||||
"$grammar->{major_version}.$grammar->{minor_version}.$grammar->{revision}";
|
||||
}
|
||||
|
||||
sub instruction_operand(_)
|
||||
{
|
||||
my ($operand) = @_;
|
||||
|
||||
"{${\operand_type_name $operand->{kind}}" . (defined $operand->{quantifier} ? ", '$operand->{quantifier}'}" : "}");
|
||||
}
|
||||
|
||||
sub print_opcode_info(_)
|
||||
{
|
||||
my ($instruction) = @_;
|
||||
my $operand_count = @{$instruction->{operands} // []};
|
||||
|
||||
print " {${\opcode_id $instruction->{opcode}}, \"$instruction->{opname}\", $operand_count},\n";
|
||||
if (!$operand_count)
|
||||
{
|
||||
print " {${\opcode_id $instruction->{opcode}}, \"$instruction->{opname}\"},\n";
|
||||
return;
|
||||
}
|
||||
|
||||
print " {\n";
|
||||
print " ${\opcode_id $instruction->{opcode}}, \"$instruction->{opname}\", $operand_count,\n";
|
||||
print " (struct spirv_parser_instruction_operand[])\n";
|
||||
print " {\n";
|
||||
print " ${\instruction_operand},\n" foreach @{$instruction->{operands}};
|
||||
print " }\n";
|
||||
print " },\n";
|
||||
}
|
||||
|
||||
sub print_header($)
|
||||
{
|
||||
my ($grammar) = @_;
|
||||
my @operand_types = sort {$a->{kind} cmp $b->{kind}} @{$grammar->{operand_kinds}};
|
||||
|
||||
print "/* This file is automatically generated from version ${\grammar_version $grammar} of the\n";
|
||||
print " * machine-readable SPIR-V grammar.\n";
|
||||
@@ -54,11 +84,30 @@ sub print_header($)
|
||||
print map {" * $_" =~ s/ +$//r . "\n"} @{$grammar->{copyright}};
|
||||
print " */\n\n";
|
||||
|
||||
print "enum spirv_parser_operand_type\n";
|
||||
print "{\n";
|
||||
print " ${\operand_type_name $_->{kind}},\n" foreach @operand_types;
|
||||
print "};\n\n";
|
||||
|
||||
print "static const struct spirv_parser_operand_type_info\n";
|
||||
print "{\n";
|
||||
print " const char *name;\n";
|
||||
print "}\n";
|
||||
print "spirv_parser_operand_type_info[] =\n";
|
||||
print "{\n";
|
||||
print " [${\operand_type_name $_->{kind}}] = {\"$_->{kind}\"},\n" foreach @operand_types;
|
||||
print "};\n\n";
|
||||
|
||||
print "static const struct spirv_parser_opcode_info\n";
|
||||
print "{\n";
|
||||
print " uint16_t op;\n";
|
||||
print " const char *name;\n";
|
||||
print " size_t operand_count;\n";
|
||||
print " const struct spirv_parser_instruction_operand\n";
|
||||
print " {\n";
|
||||
print " enum spirv_parser_operand_type type;\n";
|
||||
print " char quantifier;\n";
|
||||
print " } *operands;\n";
|
||||
print "}\n";
|
||||
print "spirv_parser_opcode_info[] =\n";
|
||||
print "{\n";
|
||||
|
Reference in New Issue
Block a user