vkd3d-shader/fx: Handle nameless structure types.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov
2025-05-22 18:06:03 +02:00
committed by Henri Verbeet
parent a4e43402e5
commit 11d4fcff46
Notes: Henri Verbeet 2025-05-24 21:48:21 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1510
3 changed files with 42 additions and 10 deletions

View File

@@ -369,6 +369,10 @@ static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context
name = get_fx_4_type_name(element_type);
modifiers = element_type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK;
/* We don't try to reuse nameless types; they will get the same
* "<unnamed>" name, but are not available for the type cache. */
if (name)
{
LIST_FOR_EACH_ENTRY(type_entry, &fx->types, struct type_entry, entry)
{
if (strcmp(type_entry->name, name))
@@ -382,6 +386,7 @@ static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context
return type_entry->offset;
}
}
if (!(type_entry = hlsl_alloc(fx->ctx, sizeof(*type_entry))))
return 0;
@@ -391,6 +396,7 @@ static uint32_t write_type(const struct hlsl_type *type, struct fx_write_context
type_entry->elements_count = elements_count;
type_entry->modifiers = modifiers;
if (name)
list_add_tail(&fx->types, &type_entry->entry);
return type_entry->offset;
@@ -1238,7 +1244,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
name = get_fx_4_type_name(element_type);
name_offset = write_string(name, fx);
name_offset = write_string(name ? name : "<unnamed>", fx);
if (element_type->class == HLSL_CLASS_STRUCT)
{
if (!(field_offsets = hlsl_calloc(ctx, element_type->e.record.field_count, sizeof(*field_offsets))))

View File

@@ -56,6 +56,19 @@ BlendState bs
BlendOpAlpha = add;
};
[effect]
cbuffer cb1
{
float a1;
};
cbuffer cb2
{
struct
{
float a2;
} s1;
};
[effect fail]
BlendState bs
{

View File

@@ -58,6 +58,19 @@ BlendState bs
BlendOpAlpha[4] = add;
};
[effect]
cbuffer cb1
{
float a1;
};
cbuffer cb2
{
struct
{
float a2;
} s1;
};
[effect]
BlendState bs
{