Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index e597425a..c56a74d4 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1446,11 +1446,14 @@ static void write_sm4_if(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf
write_sm4_block(ctx, buffer, &iff->then_instrs);
- instr.opcode = VKD3D_SM4_OP_ELSE; - instr.src_count = 0; - write_sm4_instruction(buffer, &instr); + if (!list_empty(&iff->else_instrs.instrs)) + { + instr.opcode = VKD3D_SM4_OP_ELSE; + instr.src_count = 0; + write_sm4_instruction(buffer, &instr);
- write_sm4_block(ctx, buffer, &iff->else_instrs); + write_sm4_block(ctx, buffer, &iff->else_instrs); + }
instr.opcode = VKD3D_SM4_OP_ENDIF; write_sm4_instruction(buffer, &instr);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c56a74d4..9b48aa8b 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1166,7 +1166,7 @@ static void write_sm4_constant(struct hlsl_ctx *ctx, { const unsigned int dimx = constant->node.data_type->dimx; struct sm4_instruction instr; - unsigned int i; + struct sm4_register *reg = &instr.srcs[0].reg;
memset(&instr, 0, sizeof(instr)); instr.opcode = VKD3D_SM4_OP_MOV; @@ -1174,10 +1174,23 @@ static void write_sm4_constant(struct hlsl_ctx *ctx, sm4_register_from_node(&instr.dsts[0].reg, &instr.dsts[0].writemask, &constant->node); instr.dst_count = 1;
- instr.srcs[0].reg.dim = (dimx > 1) ? VKD3D_SM4_DIMENSION_VEC4 : VKD3D_SM4_DIMENSION_SCALAR; - instr.srcs[0].reg.type = VKD3D_SM4_RT_IMMCONST; - for (i = 0; i < dimx; ++i) - instr.srcs[0].reg.immconst_uint[i] = constant->value[i].u; + reg->type = VKD3D_SM4_RT_IMMCONST; + if (dimx == 1) + { + reg->dim = VKD3D_SM4_DIMENSION_SCALAR; + reg->immconst_uint[0] = constant->value[0].u; + } + else + { + unsigned int i, j = 0; + + reg->dim = VKD3D_SM4_DIMENSION_VEC4; + for (i = 0; i < 4; ++i) + { + if (instr.dsts[0].writemask & (1u << i)) + reg->immconst_uint[i] = constant->value[j++].u; + } + } instr.src_count = 1,
write_sm4_instruction(buffer, &instr);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 2120b26f..b7e0409d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2529,6 +2529,10 @@ type:
$$ = hlsl_get_vector_type(ctx, $3->base_type, $5); } + | KW_VECTOR + { + $$ = hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 4); + } | KW_MATRIX '<' type ',' C_INTEGER ',' C_INTEGER '>' { if ($3->type != HLSL_CLASS_SCALAR) @@ -2557,6 +2561,10 @@ type:
$$ = hlsl_get_matrix_type(ctx, $3->base_type, $7, $5); } + | KW_MATRIX + { + $$ = hlsl_get_matrix_type(ctx, HLSL_TYPE_FLOAT, 4, 4); + } | KW_VOID { $$ = ctx->builtin_types.Void;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- Makefile.am | 2 + tests/hlsl-numeric-types.shader_test | 102 +++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 tests/hlsl-numeric-types.shader_test
diff --git a/Makefile.am b/Makefile.am index d6e14cf1..3e083b0a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,6 +71,7 @@ vkd3d_shader_tests = \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-nested-arrays.shader_test \ + tests/hlsl-numeric-types.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ tests/hlsl-shape.shader_test \ @@ -294,6 +295,7 @@ XFAIL_TESTS = \ tests/hlsl-majority-pragma.shader_test \ tests/hlsl-majority-typedef.shader_test \ tests/hlsl-nested-arrays.shader_test \ + tests/hlsl-numeric-types.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ tests/hlsl-return-void.shader_test \ tests/hlsl-shape.shader_test \ diff --git a/tests/hlsl-numeric-types.shader_test b/tests/hlsl-numeric-types.shader_test new file mode 100644 index 00000000..7504f95a --- /dev/null +++ b/tests/hlsl-numeric-types.shader_test @@ -0,0 +1,102 @@ +[pixel shader] +vector main() : sv_target +{ + float4 ret = vector(1.0, 2.0, 3.0, 4.0); + return ret; +} + +[test] +draw quad +probe all rgba (1.0, 2.0, 3.0, 4.0) + +[pixel shader] +float4 main() : sv_target +{ + vector<float, 4> ret = float4(1.0, 2.0, 3.0, 4.0); + return ret; +} + +[test] +draw quad +probe all rgba (1.0, 2.0, 3.0, 4.0) + +[pixel shader] +float4 main() : sv_target +{ + vector<float, 3> ret = vector<float, 3>(1.0, 2.0, 3.0); + return vector(ret, 0.0); +} + +[test] +draw quad +probe all rgba (1.0, 2.0, 3.0, 0.0) + +[pixel shader fail] +vector main() : sv_target +{ + vector ret = vector(1.0, 2.0, 3.0); + return ret; +} + +[pixel shader fail] +vector main() : sv_target +{ + vector<float> ret = vector(1.0, 2.0, 3.0, 4.0); + return ret; +} + +[pixel shader] +float4 main() : sv_target +{ + matrix m = matrix<float, 4, 4>(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, + 13.0, 14.0, 15.0, 16.0); + return m[1]; +} + +[test] +draw quad +probe all rgba (5.0, 6.0, 7.0, 8.0) + +[pixel shader] +float4 main() : sv_target +{ + matrix<float, 2, 3> m = float2x3(1.0, 2.0, 3.0, + 5.0, 6.0, 7.0); + return float4(m[1], 0.0); +} + +[test] +draw quad +probe all rgba (5.0, 6.0, 7.0, 0.0) + +[pixel shader fail] +float4 main() : sv_target +{ + matrix m = matrix<float>(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, + 13.0, 14.0, 15.0, 16.0); + return m[1]; +} + +[pixel shader fail] +float4 main() : sv_target +{ + matrix m = matrix<float, 4>(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, + 13.0, 14.0, 15.0, 16.0); + return m[1]; +} + +[pixel shader fail] +float4 main() : sv_target +{ + matrix m = matrix(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, + 13.0, 14.0, 15.0); + return m[1]; +}
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com