mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Parse clip() function.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
6ef0213135
commit
8d84e206ab
Notes:
Alexandre Julliard
2023-06-27 23:33:42 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/211
@ -2147,10 +2147,11 @@ const char *hlsl_jump_type_to_string(enum hlsl_ir_jump_type type)
|
||||
{
|
||||
static const char * const names[] =
|
||||
{
|
||||
"HLSL_IR_JUMP_BREAK",
|
||||
"HLSL_IR_JUMP_CONTINUE",
|
||||
"HLSL_IR_JUMP_DISCARD",
|
||||
"HLSL_IR_JUMP_RETURN",
|
||||
[HLSL_IR_JUMP_BREAK] = "HLSL_IR_JUMP_BREAK",
|
||||
[HLSL_IR_JUMP_CONTINUE] = "HLSL_IR_JUMP_CONTINUE",
|
||||
[HLSL_IR_JUMP_DISCARD_NEG] = "HLSL_IR_JUMP_DISCARD_NEG",
|
||||
[HLSL_IR_JUMP_DISCARD_NZ] = "HLSL_IR_JUMP_DISCARD_NZ",
|
||||
[HLSL_IR_JUMP_RETURN] = "HLSL_IR_JUMP_RETURN",
|
||||
};
|
||||
|
||||
assert(type < ARRAY_SIZE(names));
|
||||
@ -2419,8 +2420,12 @@ static void dump_ir_jump(struct vkd3d_string_buffer *buffer, const struct hlsl_i
|
||||
vkd3d_string_buffer_printf(buffer, "continue");
|
||||
break;
|
||||
|
||||
case HLSL_IR_JUMP_DISCARD:
|
||||
vkd3d_string_buffer_printf(buffer, "discard");
|
||||
case HLSL_IR_JUMP_DISCARD_NEG:
|
||||
vkd3d_string_buffer_printf(buffer, "discard_neg");
|
||||
break;
|
||||
|
||||
case HLSL_IR_JUMP_DISCARD_NZ:
|
||||
vkd3d_string_buffer_printf(buffer, "discard_nz");
|
||||
break;
|
||||
|
||||
case HLSL_IR_JUMP_RETURN:
|
||||
|
@ -558,7 +558,8 @@ enum hlsl_ir_jump_type
|
||||
{
|
||||
HLSL_IR_JUMP_BREAK,
|
||||
HLSL_IR_JUMP_CONTINUE,
|
||||
HLSL_IR_JUMP_DISCARD,
|
||||
HLSL_IR_JUMP_DISCARD_NEG,
|
||||
HLSL_IR_JUMP_DISCARD_NZ,
|
||||
HLSL_IR_JUMP_RETURN,
|
||||
};
|
||||
|
||||
@ -566,7 +567,7 @@ struct hlsl_ir_jump
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
enum hlsl_ir_jump_type type;
|
||||
/* Argument used for HLSL_IR_JUMP_DISCARD. */
|
||||
/* Argument used for HLSL_IR_JUMP_DISCARD_NZ and HLSL_IR_JUMP_DISCARD_NEG. */
|
||||
struct hlsl_src condition;
|
||||
};
|
||||
|
||||
|
@ -2544,6 +2544,34 @@ static bool intrinsic_clamp(struct hlsl_ctx *ctx,
|
||||
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MIN, max, params->args[2], loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_clip(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_node *condition, *jump;
|
||||
|
||||
if (!elementwise_intrinsic_float_convert_args(ctx, params, loc))
|
||||
return false;
|
||||
|
||||
condition = params->args[0];
|
||||
|
||||
if (ctx->profile->major_version < 4 && hlsl_type_component_count(condition->data_type) > 4)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
|
||||
if ((string = hlsl_type_to_string(ctx, condition->data_type)))
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"Argument type cannot exceed 4 components, got type \"%s\".", string->buffer);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(jump = hlsl_new_jump(ctx, HLSL_IR_JUMP_DISCARD_NEG, condition, loc)))
|
||||
return false;
|
||||
list_add_tail(params->instrs, &jump->entry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool intrinsic_cos(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@ -3482,6 +3510,7 @@ intrinsic_functions[] =
|
||||
{"asfloat", 1, true, intrinsic_asfloat},
|
||||
{"asuint", -1, true, intrinsic_asuint},
|
||||
{"clamp", 3, true, intrinsic_clamp},
|
||||
{"clip", 1, true, intrinsic_clip},
|
||||
{"cos", 1, true, intrinsic_cos},
|
||||
{"cross", 2, true, intrinsic_cross},
|
||||
{"ddx", 1, true, intrinsic_ddx},
|
||||
@ -5745,7 +5774,7 @@ discard_statement:
|
||||
return false;
|
||||
list_add_tail($$, &c->entry);
|
||||
|
||||
if (!(discard = hlsl_new_jump(ctx, HLSL_IR_JUMP_DISCARD, c, &@1)))
|
||||
if (!(discard = hlsl_new_jump(ctx, HLSL_IR_JUMP_DISCARD_NZ, c, &@1)))
|
||||
return false;
|
||||
list_add_tail($$, &discard->entry);
|
||||
}
|
||||
|
@ -4780,7 +4780,7 @@ static void write_sm4_jump(struct hlsl_ctx *ctx,
|
||||
instr.opcode = VKD3D_SM4_OP_BREAK;
|
||||
break;
|
||||
|
||||
case HLSL_IR_JUMP_DISCARD:
|
||||
case HLSL_IR_JUMP_DISCARD_NZ:
|
||||
{
|
||||
instr.opcode = VKD3D_SM4_OP_DISCARD | VKD3D_SM4_CONDITIONAL_NZ;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user