mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Add a helper to create constants of arbitrary type.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Francisco Casas <fcasas@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
39bd9b0943
commit
5b24f7a06c
@ -563,15 +563,31 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir
|
|||||||
return hlsl_new_store(ctx, lhs, NULL, rhs, 0, rhs->loc);
|
return hlsl_new_store(ctx, lhs, NULL, rhs, 0, rhs->loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type,
|
||||||
|
const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_constant *c;
|
||||||
|
|
||||||
|
assert(type->type <= HLSL_CLASS_VECTOR);
|
||||||
|
|
||||||
|
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
init_node(&c->node, HLSL_IR_CONSTANT, type, *loc);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
|
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
|
||||||
const struct vkd3d_shader_location *loc)
|
const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
struct hlsl_ir_constant *c;
|
struct hlsl_ir_constant *c;
|
||||||
|
|
||||||
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc);
|
||||||
return NULL;
|
|
||||||
init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc);
|
if (c)
|
||||||
c->value[0].i = n;
|
c->value[0].i = n;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,10 +596,11 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i
|
|||||||
{
|
{
|
||||||
struct hlsl_ir_constant *c;
|
struct hlsl_ir_constant *c;
|
||||||
|
|
||||||
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
|
||||||
return NULL;
|
|
||||||
init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc);
|
if (c)
|
||||||
c->value[0].u = n;
|
c->value[0].u = n;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,6 +734,8 @@ struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type
|
|||||||
const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc);
|
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,
|
struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||||
const struct vkd3d_shader_location *loc);
|
const struct vkd3d_shader_location *loc);
|
||||||
|
struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type,
|
||||||
|
const struct vkd3d_shader_location *loc);
|
||||||
struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node);
|
struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node);
|
||||||
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
|
struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
|
||||||
struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc);
|
struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user