mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Introduce a hlsl_new_bool_constant() helper.
This commit is contained in:
parent
4c5fd9c7b9
commit
3fc2fdc37f
Notes:
Alexandre Julliard
2022-10-18 00:13:00 +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/22
@ -915,6 +915,16 @@ struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_typ
|
||||
return c;
|
||||
}
|
||||
|
||||
struct hlsl_ir_constant *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_constant *c;
|
||||
|
||||
if ((c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), loc)))
|
||||
c->value[0].u = b ? ~0u : 0;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
struct hlsl_ir_constant *hlsl_new_float_constant(struct hlsl_ctx *ctx, float f,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
|
@ -751,6 +751,7 @@ struct hlsl_type *hlsl_get_element_type_from_path_index(struct hlsl_ctx *ctx, co
|
||||
struct hlsl_type *hlsl_new_array_type(struct hlsl_ctx *ctx, struct hlsl_type *basic_type, unsigned int array_size);
|
||||
struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg1,
|
||||
struct hlsl_ir_node *arg2);
|
||||
struct hlsl_ir_constant *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name,
|
||||
const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc);
|
||||
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||
|
@ -2800,7 +2800,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
|
||||
struct hlsl_type *type;
|
||||
INT intval;
|
||||
FLOAT floatval;
|
||||
BOOL boolval;
|
||||
bool boolval;
|
||||
char *name;
|
||||
DWORD modifiers;
|
||||
struct hlsl_ir_node *instr;
|
||||
@ -3857,11 +3857,11 @@ initializer_expr_list:
|
||||
boolean:
|
||||
KW_TRUE
|
||||
{
|
||||
$$ = TRUE;
|
||||
$$ = true;
|
||||
}
|
||||
| KW_FALSE
|
||||
{
|
||||
$$ = FALSE;
|
||||
$$ = false;
|
||||
}
|
||||
|
||||
statement_list:
|
||||
@ -4001,13 +4001,14 @@ primary_expr:
|
||||
{
|
||||
struct hlsl_ir_constant *c;
|
||||
|
||||
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
||||
if (!(c = hlsl_new_bool_constant(ctx, $1, &@1)))
|
||||
YYABORT;
|
||||
init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), @1);
|
||||
c->value[0].u = $1 ? ~0u : 0;
|
||||
if (!($$ = make_list(ctx, &c->node)))
|
||||
{
|
||||
hlsl_free_instr(&c->node);
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
| VAR_IDENTIFIER
|
||||
{
|
||||
struct hlsl_ir_load *load;
|
||||
|
Loading…
x
Reference in New Issue
Block a user