From da0469f19016aad5439baf76736bc1e029bbdbf9 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 26 Sep 2024 14:52:11 +0200 Subject: [PATCH] vkd3d-shader/fx: Handle the 'half' type in fx_4+. Signed-off-by: Nikolay Sivov --- libs/vkd3d-shader/fx.c | 9 +++++++++ tests/hlsl/effect-initial-values-fx_4.shader_test | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 7d4a9d2e..7a7631b3 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -467,6 +467,7 @@ static uint32_t get_fx_4_type_size(const struct hlsl_type *type) static const uint32_t fx_4_numeric_base_type[] = { + [HLSL_TYPE_HALF] = 1, [HLSL_TYPE_FLOAT] = 1, [HLSL_TYPE_INT ] = 2, [HLSL_TYPE_UINT ] = 3, @@ -503,6 +504,7 @@ static uint32_t get_fx_4_numeric_type_description(const struct hlsl_type *type, switch (type->e.numeric.type) { case HLSL_TYPE_FLOAT: + case HLSL_TYPE_HALF: case HLSL_TYPE_INT: case HLSL_TYPE_UINT: case HLSL_TYPE_BOOL: @@ -579,6 +581,12 @@ static const char * get_fx_4_type_name(const struct hlsl_type *type) case HLSL_CLASS_STRING: return "String"; + case HLSL_CLASS_SCALAR: + case HLSL_CLASS_VECTOR: + case HLSL_CLASS_MATRIX: + if (type->e.numeric.type == HLSL_TYPE_HALF) + return "float"; + /* fall-through */ default: return type->name; } @@ -1267,6 +1275,7 @@ static uint32_t write_fx_4_default_value(struct hlsl_type *value_type, struct hl switch (type->e.numeric.type) { case HLSL_TYPE_FLOAT: + case HLSL_TYPE_HALF: case HLSL_TYPE_INT: case HLSL_TYPE_UINT: case HLSL_TYPE_BOOL: diff --git a/tests/hlsl/effect-initial-values-fx_4.shader_test b/tests/hlsl/effect-initial-values-fx_4.shader_test index 591304bd..6321c59d 100644 --- a/tests/hlsl/effect-initial-values-fx_4.shader_test +++ b/tests/hlsl/effect-initial-values-fx_4.shader_test @@ -2,7 +2,7 @@ shader model >= 4.0 shader model < 6.0 -[effect todo] +[effect] float var1 = 0.1f; float2 var2 = {0.2f,0.3f}; float2x4 var3 = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0};