mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Use a switch in hlsl_types_are_equal().
This commit is contained in:
parent
d9f7a88329
commit
4fd3f46109
Notes:
Alexandre Julliard
2024-05-06 22:37:26 +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/831
@ -979,55 +979,73 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
|
|||||||
|
|
||||||
if (t1->class != t2->class)
|
if (t1->class != t2->class)
|
||||||
return false;
|
return false;
|
||||||
if (t1->base_type != t2->base_type)
|
|
||||||
return false;
|
switch (t1->class)
|
||||||
if (t1->class == HLSL_CLASS_SAMPLER || t1->class == HLSL_CLASS_TEXTURE || t1->class == HLSL_CLASS_UAV)
|
|
||||||
{
|
{
|
||||||
if (t1->sampler_dim != t2->sampler_dim)
|
case HLSL_CLASS_SCALAR:
|
||||||
return false;
|
case HLSL_CLASS_VECTOR:
|
||||||
if ((t1->class == HLSL_CLASS_TEXTURE || t1->class == HLSL_CLASS_UAV)
|
case HLSL_CLASS_MATRIX:
|
||||||
&& t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC
|
if (t1->base_type != t2->base_type)
|
||||||
&& !hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format))
|
return false;
|
||||||
return false;
|
if ((t1->modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
||||||
if (t1->class == HLSL_CLASS_UAV && t1->e.resource.rasteriser_ordered != t2->e.resource.rasteriser_ordered)
|
!= (t2->modifiers & HLSL_MODIFIER_ROW_MAJOR))
|
||||||
return false;
|
return false;
|
||||||
}
|
if (t1->dimx != t2->dimx)
|
||||||
if ((t1->modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
return false;
|
||||||
!= (t2->modifiers & HLSL_MODIFIER_ROW_MAJOR))
|
if (t1->dimy != t2->dimy)
|
||||||
return false;
|
return false;
|
||||||
if (t1->dimx != t2->dimx)
|
return true;
|
||||||
return false;
|
|
||||||
if (t1->dimy != t2->dimy)
|
|
||||||
return false;
|
|
||||||
if (t1->class == HLSL_CLASS_STRUCT)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if (t1->e.record.field_count != t2->e.record.field_count)
|
case HLSL_CLASS_UAV:
|
||||||
return false;
|
if (t1->e.resource.rasteriser_ordered != t2->e.resource.rasteriser_ordered)
|
||||||
|
return false;
|
||||||
|
/* fall through */
|
||||||
|
case HLSL_CLASS_TEXTURE:
|
||||||
|
if (t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC
|
||||||
|
&& !hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format))
|
||||||
|
return false;
|
||||||
|
/* fall through */
|
||||||
|
case HLSL_CLASS_SAMPLER:
|
||||||
|
if (t1->sampler_dim != t2->sampler_dim)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
for (i = 0; i < t1->e.record.field_count; ++i)
|
case HLSL_CLASS_STRUCT:
|
||||||
{
|
if (t1->e.record.field_count != t2->e.record.field_count)
|
||||||
const struct hlsl_struct_field *field1 = &t1->e.record.fields[i];
|
|
||||||
const struct hlsl_struct_field *field2 = &t2->e.record.fields[i];
|
|
||||||
|
|
||||||
if (!hlsl_types_are_equal(field1->type, field2->type))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (strcmp(field1->name, field2->name))
|
for (size_t i = 0; i < t1->e.record.field_count; ++i)
|
||||||
return false;
|
{
|
||||||
}
|
const struct hlsl_struct_field *field1 = &t1->e.record.fields[i];
|
||||||
}
|
const struct hlsl_struct_field *field2 = &t2->e.record.fields[i];
|
||||||
if (t1->class == HLSL_CLASS_ARRAY)
|
|
||||||
return t1->e.array.elements_count == t2->e.array.elements_count
|
if (!hlsl_types_are_equal(field1->type, field2->type))
|
||||||
&& hlsl_types_are_equal(t1->e.array.type, t2->e.array.type);
|
return false;
|
||||||
if (t1->class == HLSL_CLASS_TECHNIQUE)
|
|
||||||
{
|
if (strcmp(field1->name, field2->name))
|
||||||
if (t1->e.version != t2->e.version)
|
return false;
|
||||||
return false;
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case HLSL_CLASS_ARRAY:
|
||||||
|
return t1->e.array.elements_count == t2->e.array.elements_count
|
||||||
|
&& hlsl_types_are_equal(t1->e.array.type, t2->e.array.type);
|
||||||
|
|
||||||
|
case HLSL_CLASS_TECHNIQUE:
|
||||||
|
return t1->e.version == t2->e.version;
|
||||||
|
|
||||||
|
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||||
|
case HLSL_CLASS_EFFECT_GROUP:
|
||||||
|
case HLSL_CLASS_PASS:
|
||||||
|
case HLSL_CLASS_PIXEL_SHADER:
|
||||||
|
case HLSL_CLASS_RENDER_TARGET_VIEW:
|
||||||
|
case HLSL_CLASS_STRING:
|
||||||
|
case HLSL_CLASS_VERTEX_SHADER:
|
||||||
|
case HLSL_CLASS_VOID:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
vkd3d_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
|
struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user