vkd3d-shader/dxil: Read DXIL metadata kinds.

This commit is contained in:
Conor McCarthy 2023-09-29 11:56:35 +10:00 committed by Alexandre Julliard
parent cba3e18c45
commit 4ac201788d
Notes: Alexandre Julliard 2023-10-12 23:35:11 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/372

View File

@ -295,6 +295,7 @@ struct dxil_block
enum sm6_metadata_type
{
VKD3D_METADATA_KIND,
VKD3D_METADATA_NODE,
VKD3D_METADATA_STRING,
VKD3D_METADATA_VALUE,
@ -307,6 +308,12 @@ struct sm6_metadata_node
struct sm6_metadata_value *operands[];
};
struct sm6_metadata_kind
{
uint64_t id;
char *name;
};
struct sm6_metadata_value
{
enum sm6_metadata_type type;
@ -316,6 +323,7 @@ struct sm6_metadata_value
char *string_value;
const struct sm6_value *value;
struct sm6_metadata_node *node;
struct sm6_metadata_kind kind;
} u;
};
@ -2977,6 +2985,19 @@ static enum vkd3d_result sm6_parser_metadata_init(struct sm6_parser *sm6, const
return ret;
break;
case METADATA_KIND:
if (!dxil_record_validate_operand_min_count(record, 2, sm6))
return VKD3D_ERROR_INVALID_SHADER;
m->type = VKD3D_METADATA_KIND;
m->u.kind.id = record->operands[0];
if (!(m->u.kind.name = dxil_record_to_string(record, 1, sm6)))
{
ERR("Failed to allocate name of a kind.\n");
return VKD3D_ERROR_OUT_OF_MEMORY;
}
break;
case METADATA_STRING:
/* LLVM allows an empty string here. */
m->type = VKD3D_METADATA_STRING;
@ -3039,6 +3060,9 @@ static void sm6_metadata_value_destroy(struct sm6_metadata_value *m)
case VKD3D_METADATA_NODE:
vkd3d_free(m->u.node);
break;
case VKD3D_METADATA_KIND:
vkd3d_free(m->u.kind.name);
break;
case VKD3D_METADATA_STRING:
vkd3d_free(m->u.string_value);
break;