vkd3d-shader/tpf: Write default values for SM4.

This commit is contained in:
Francisco Casas 2024-04-09 13:07:54 -04:00 committed by Henri Verbeet
parent b44a25ce19
commit 253c994155
Notes: Henri Verbeet 2024-06-11 16:55:09 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/787
3 changed files with 33 additions and 3 deletions

View File

@ -1744,6 +1744,8 @@ static void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffe
} }
put_u32(buffer, 0); /* type */ put_u32(buffer, 0); /* type */
put_u32(buffer, 0); /* FIXME: default value */ put_u32(buffer, 0); /* FIXME: default value */
if (var->default_values)
FIXME("Write SM1 default values.\n");
} }
} }

View File

@ -3522,7 +3522,7 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
put_u32(&buffer, var->data_type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float)); put_u32(&buffer, var->data_type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float));
put_u32(&buffer, flags); put_u32(&buffer, flags);
put_u32(&buffer, 0); /* type */ put_u32(&buffer, 0); /* type */
put_u32(&buffer, 0); /* FIXME: default value */ put_u32(&buffer, 0); /* default value */
if (profile->major_version >= 5) if (profile->major_version >= 5)
{ {
@ -3546,6 +3546,34 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
set_u32(&buffer, var_offset, string_offset); set_u32(&buffer, var_offset, string_offset);
write_sm4_type(ctx, &buffer, var->data_type); write_sm4_type(ctx, &buffer, var->data_type);
set_u32(&buffer, var_offset + 4 * sizeof(uint32_t), var->data_type->bytecode_offset); set_u32(&buffer, var_offset + 4 * sizeof(uint32_t), var->data_type->bytecode_offset);
if (var->default_values)
{
unsigned int reg_size = var->data_type->reg_size[HLSL_REGSET_NUMERIC];
unsigned int comp_count = hlsl_type_component_count(var->data_type);
unsigned int default_value_offset;
unsigned int k;
default_value_offset = bytecode_reserve_bytes(&buffer, reg_size * sizeof(uint32_t));
set_u32(&buffer, var_offset + 5 * sizeof(uint32_t), default_value_offset);
for (k = 0; k < comp_count; ++k)
{
struct hlsl_type *comp_type = hlsl_type_get_component_type(ctx, var->data_type, k);
unsigned int comp_offset;
enum hlsl_regset regset;
comp_offset = hlsl_type_get_component_offset(ctx, var->data_type, k, &regset);
if (regset == HLSL_REGSET_NUMERIC)
{
if (comp_type->e.numeric.type == HLSL_TYPE_DOUBLE)
hlsl_fixme(ctx, &var->loc, "Write double default values.");
set_u32(&buffer, default_value_offset + comp_offset * sizeof(uint32_t),
var->default_values[k].value.u);
}
}
}
++j; ++j;
} }
} }

View File

@ -1863,7 +1863,7 @@ static void test_default_values_reflection(void)
if (expect->var_desc.DefaultValue) if (expect->var_desc.DefaultValue)
{ {
todo ok(var_desc.DefaultValue, "Didn't get default value.\n"); ok(var_desc.DefaultValue, "Didn't get default value.\n");
if (var_desc.DefaultValue && var_desc.Size == expect->var_desc.Size) if (var_desc.DefaultValue && var_desc.Size == expect->var_desc.Size)
{ {
@ -1872,7 +1872,7 @@ static void test_default_values_reflection(void)
unsigned int var_val = *((unsigned int *)var_desc.DefaultValue + k); unsigned int var_val = *((unsigned int *)var_desc.DefaultValue + k);
unsigned int expect_val = *((unsigned int *)expect->var_desc.DefaultValue + k); unsigned int expect_val = *((unsigned int *)expect->var_desc.DefaultValue + k);
ok(var_val == expect_val, "Expected default value 0x%08x, but got 0x%08x, at offset %u.\n", todo_if(var_val != expect_val) ok(var_val == expect_val, "Expected default value 0x%08x, but got 0x%08x, at offset %u.\n",
expect_val, var_val, 4 * k); expect_val, var_val, 4 * k);
} }
} }