diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 97713343..5dbdaf7e 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1861,6 +1861,20 @@ const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type) return names[type]; } +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", + }; + + assert(type < ARRAY_SIZE(names)); + return names[type]; +} + static void dump_instr(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct hlsl_ir_node *instr); static void dump_instr_list(struct hlsl_ctx *ctx, struct vkd3d_string_buffer *buffer, const struct list *list) diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 53b47e40..81b1a61d 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -1003,6 +1003,8 @@ struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name); struct hlsl_type *hlsl_get_element_type_from_path_index(struct hlsl_ctx *ctx, const struct hlsl_type *type, struct hlsl_ir_node *idx); +const char *hlsl_jump_type_to_string(enum hlsl_ir_jump_type type); + 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); diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 2e7c101f..10bb1e3d 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -2118,6 +2118,28 @@ static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf write_sm4_instruction(buffer, &instr); } +static void write_sm4_jump(struct hlsl_ctx *ctx, + struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_jump *jump) +{ + struct sm4_instruction instr = {0}; + + switch (jump->type) + { + case HLSL_IR_JUMP_BREAK: + instr.opcode = VKD3D_SM4_OP_BREAK; + break; + + case HLSL_IR_JUMP_RETURN: + vkd3d_unreachable(); + + default: + hlsl_fixme(ctx, &jump->node.loc, "Jump type %s.\n", hlsl_jump_type_to_string(jump->type)); + return; + } + + write_sm4_instruction(buffer, &instr); +} + static void write_sm4_load(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_load *load) { @@ -2375,6 +2397,10 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer * write_sm4_if(ctx, buffer, hlsl_ir_if(instr)); break; + case HLSL_IR_JUMP: + write_sm4_jump(ctx, buffer, hlsl_ir_jump(instr)); + break; + case HLSL_IR_LOAD: write_sm4_load(ctx, buffer, hlsl_ir_load(instr)); break; diff --git a/tests/function-return.shader_test b/tests/function-return.shader_test index 7d411998..cbd29749 100644 --- a/tests/function-return.shader_test +++ b/tests/function-return.shader_test @@ -145,7 +145,7 @@ uniform 0 float 0.9 draw quad probe all rgba (1.0, 0.9, 1.0, 0.6) 1 -[pixel shader todo] +[pixel shader] float func(out float o) { @@ -184,10 +184,10 @@ float4 main() : sv_target } [test] -todo draw quad +draw quad probe all rgba (0.4, 0.3, 0.3, 0.9) 1 -[pixel shader todo] +[pixel shader] uniform float f; @@ -239,23 +239,23 @@ float4 main() : sv_target [test] uniform 0 float 0.0 -todo draw quad +draw quad probe all rgba (0.3, 0.2, 0.3, 0.3) 1 uniform 0 float 0.1 -todo draw quad +draw quad probe all rgba (0.3, 0.3, 0.3, 0.3) 1 uniform 0 float 0.3 -todo draw quad +draw quad probe all rgba (0.3, 0.5, 0.3, 0.3) 1 uniform 0 float 0.7 -todo draw quad +draw quad probe all rgba (0.3, 0.9, 0.7, 0.6) 1 uniform 0 float 0.9 -todo draw quad +draw quad probe all rgba (0.4, 0.1, 0.7, 0.6) 1 [pixel shader todo] diff --git a/tests/return.shader_test b/tests/return.shader_test index 2660c6dd..3c9ea611 100644 --- a/tests/return.shader_test +++ b/tests/return.shader_test @@ -128,7 +128,7 @@ uniform 0 float 0.9 draw quad probe all rgba (0.4, 0.5, 0.6, 0.7) 1 -[pixel shader todo] +[pixel shader] void main(out float4 ret : sv_target) { @@ -143,10 +143,10 @@ void main(out float4 ret : sv_target) } [test] -todo draw quad -todo probe all rgba (0.2, 0.4, 0.6, 0.8) +draw quad +probe all rgba (0.2, 0.4, 0.6, 0.8) -[pixel shader todo] +[pixel shader] uniform float f; @@ -166,26 +166,26 @@ void main(out float4 ret : sv_target) [test] uniform 0 float 0.0 -todo draw quad -todo probe all rgba (0.1, 0.1, 0.1, 0.1) 1 +draw quad +probe all rgba (0.1, 0.1, 0.1, 0.1) 1 uniform 0 float 0.1 -todo draw quad -todo probe all rgba (0.2, 0.2, 0.2, 0.2) 1 +draw quad +probe all rgba (0.2, 0.2, 0.2, 0.2) 1 uniform 0 float 0.3 -todo draw quad +draw quad todo probe all rgba (0.4, 0.4, 0.4, 0.4) 1 uniform 0 float 0.7 -todo draw quad +draw quad todo probe all rgba (0.8, 0.8, 0.8, 0.8) 1 uniform 0 float 0.9 -todo draw quad +draw quad todo probe all rgba (0.9, 0.9, 0.9, 0.9) 1 -[pixel shader todo] +[pixel shader] uniform float f; @@ -211,10 +211,10 @@ void main(out float4 ret : sv_target) [test] uniform 0 float 0.2 -todo draw quad -todo probe all rgba (0.2, 0.2, 0.2, 0.2) +draw quad +probe all rgba (0.2, 0.2, 0.2, 0.2) uniform 0 float 0.8 -todo draw quad +draw quad probe all rgba (0.5, 0.5, 0.5, 0.5) [pixel shader todo]