On Mon, Mar 28, 2022 at 10:59 AM Giovanni Mascellani gmascellani@codeweavers.com wrote:
With this change it is possible to store booleans as 0xffffffff, similarly as what happens at runtime.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
v2:
- New
libs/vkd3d-shader/hlsl.c | 2 +- libs/vkd3d-shader/hlsl.h | 1 - libs/vkd3d-shader/hlsl.y | 4 ++-- libs/vkd3d-shader/hlsl_codegen.c | 2 +- libs/vkd3d-shader/hlsl_constant_ops.c | 20 ++++++++++---------- 5 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 664f7813..eabe189f 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1168,7 +1168,7 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl switch (type->base_type) { case HLSL_TYPE_BOOL:
vkd3d_string_buffer_printf(buffer, "%s ", value->b ? "true" : "false");
vkd3d_string_buffer_printf(buffer, "%s ", value->u ? "true" : "false"); break; case HLSL_TYPE_DOUBLE:
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e4db386f..6b00d117 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -415,7 +415,6 @@ struct hlsl_ir_constant int32_t i; float f; double d;
} value[4]; struct hlsl_reg reg;bool b;
}; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 41fa7df4..481347ee 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -842,7 +842,7 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node) case HLSL_TYPE_DOUBLE: return value->d; case HLSL_TYPE_BOOL:
return value->b;
return !!value->u; default: assert(0); return 0;
@@ -3394,7 +3394,7 @@ primary_expr: if (!(c = hlsl_alloc(ctx, sizeof(*c)))) YYABORT; init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), @1);
c->value[0].b = $1;
c->value[0].u = $1 ? ~0u : 0; if (!($$ = make_list(ctx, &c->node))) YYABORT; }
I think I would have slightly preferred if this change (together with the similar one in fold_cast()) was in a separate patch. This works though.