vkd3d-shader/fx: Use a switch in write_fx_2_initial_value().

This commit is contained in:
Zebediah Figura 2024-04-09 19:01:34 -05:00 committed by Alexandre Julliard
parent 6c6106f780
commit 280bea9033
Notes: Alexandre Julliard 2024-04-11 17:04:58 -05: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/775

View File

@ -733,7 +733,7 @@ static uint32_t write_fx_2_initial_value(const struct hlsl_ir_var *var, struct f
{
struct vkd3d_bytecode_buffer *buffer = &fx->unstructured;
const struct hlsl_type *type = var->data_type;
uint32_t i, offset, size, elements_count = 1;
uint32_t offset, size, elements_count = 1;
size = get_fx_2_type_size(type);
@ -743,20 +743,27 @@ static uint32_t write_fx_2_initial_value(const struct hlsl_ir_var *var, struct f
type = hlsl_get_multiarray_element_type(type);
}
if (type->class == HLSL_CLASS_OBJECT)
/* Note that struct fields must all be numeric;
* this was validated in check_invalid_object_fields(). */
switch (type->class)
{
/* Objects are given sequential ids. */
offset = put_u32(buffer, fx->object_variable_count++);
for (i = 1; i < elements_count; ++i)
put_u32(buffer, fx->object_variable_count++);
}
else
{
/* FIXME: write actual initial value */
offset = put_u32(buffer, 0);
case HLSL_CLASS_SCALAR:
case HLSL_CLASS_VECTOR:
case HLSL_CLASS_MATRIX:
case HLSL_CLASS_STRUCT:
/* FIXME: write actual initial value */
offset = put_u32(buffer, 0);
for (i = 1; i < size / sizeof(uint32_t); ++i)
put_u32(buffer, 0);
for (uint32_t i = 1; i < size / sizeof(uint32_t); ++i)
put_u32(buffer, 0);
break;
default:
/* Objects are given sequential ids. */
offset = put_u32(buffer, fx->object_variable_count++);
for (uint32_t i = 1; i < elements_count; ++i)
put_u32(buffer, fx->object_variable_count++);
break;
}
return offset;