mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Add a hlsl_block_add_int_constant() helper.
This commit is contained in:
committed by
Henri Verbeet
parent
992d20def3
commit
d5a2ff5c12
Notes:
Henri Verbeet
2025-02-20 16:07:11 +01:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Francisco Casas (@fcasas) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1370
@@ -1590,7 +1590,8 @@ struct hlsl_ir_node *hlsl_new_float_constant(struct hlsl_ctx *ctx, float f,
|
||||
return hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_FLOAT), &value, loc);
|
||||
}
|
||||
|
||||
struct hlsl_ir_node *hlsl_new_int_constant(struct hlsl_ctx *ctx, int32_t n, const struct vkd3d_shader_location *loc)
|
||||
static struct hlsl_ir_node *hlsl_new_int_constant(struct hlsl_ctx *ctx, int32_t n,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_constant_value value;
|
||||
|
||||
@@ -1598,6 +1599,12 @@ struct hlsl_ir_node *hlsl_new_int_constant(struct hlsl_ctx *ctx, int32_t n, cons
|
||||
return hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), &value, loc);
|
||||
}
|
||||
|
||||
struct hlsl_ir_node *hlsl_block_add_int_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
int32_t n, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
return append_new_instr(ctx, block, hlsl_new_int_constant(ctx, n, loc));
|
||||
}
|
||||
|
||||
struct hlsl_ir_node *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
|
@@ -1505,6 +1505,8 @@ struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_bloc
|
||||
void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl);
|
||||
void hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl);
|
||||
|
||||
struct hlsl_ir_node *hlsl_block_add_int_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
int32_t n, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_block_add_uint_constant(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
unsigned int n, const struct vkd3d_shader_location *loc);
|
||||
void hlsl_block_cleanup(struct hlsl_block *block);
|
||||
@@ -1588,7 +1590,6 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
|
||||
const struct hlsl_semantic *semantic, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition,
|
||||
struct hlsl_block *then_block, struct hlsl_block *else_block, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_new_int_constant(struct hlsl_ctx *ctx, int32_t n, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_ir_node *hlsl_new_jump(struct hlsl_ctx *ctx,
|
||||
enum hlsl_ir_jump_type type, struct hlsl_ir_node *condition, const struct vkd3d_shader_location *loc);
|
||||
struct hlsl_type *hlsl_new_stream_output_type(struct hlsl_ctx *ctx,
|
||||
|
@@ -2328,9 +2328,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct hlsl_block *block, bool d
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST,
|
||||
"Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
|
||||
|
||||
if (!(one = hlsl_new_int_constant(ctx, 1, loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(block, one);
|
||||
one = hlsl_block_add_int_constant(ctx, block, 1, loc);
|
||||
|
||||
if (!add_assignment(ctx, block, lhs, decrement ? ASSIGN_OP_SUB : ASSIGN_OP_ADD, one, false))
|
||||
return false;
|
||||
@@ -9376,12 +9374,9 @@ primary_expr:
|
||||
}
|
||||
| C_INTEGER
|
||||
{
|
||||
struct hlsl_ir_node *c;
|
||||
|
||||
if (!(c = hlsl_new_int_constant(ctx, $1, &@1)))
|
||||
YYABORT;
|
||||
if (!($$ = make_block(ctx, c)))
|
||||
if (!($$ = make_empty_block(ctx)))
|
||||
YYABORT;
|
||||
hlsl_block_add_int_constant(ctx, $$, $1, &@1);
|
||||
}
|
||||
| C_UNSIGNED
|
||||
{
|
||||
|
Reference in New Issue
Block a user