From a882d60534fc6574ac48430b0da4eedbdddc1d20 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Tue, 9 Apr 2024 18:12:48 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Map HLSL_TYPE_DOUBLE to D3DXPT_FLOAT. --- libs/vkd3d-shader/d3dbc.c | 9 +++++++++ libs/vkd3d-shader/fx.c | 1 + 2 files changed, 10 insertions(+) diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index 97650942..1ad97add 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -1526,6 +1526,15 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type) { case HLSL_TYPE_BOOL: return D3DXPT_BOOL; + /* Actually double behaves differently depending on DLL version: + * For <= 36, it maps to D3DXPT_FLOAT. + * For 37-40, it maps to zero (D3DXPT_VOID). + * For >= 41, it maps to 39, which is D3D_SVT_DOUBLE (note D3D_SVT_* + * values are mostly compatible with D3DXPT_*). + * However, the latter two cases look like bugs, and a reasonable + * application certainly wouldn't know what to do with them. + * For fx_2_0 it's always D3DXPT_FLOAT regardless of DLL version. */ + case HLSL_TYPE_DOUBLE: case HLSL_TYPE_FLOAT: case HLSL_TYPE_HALF: return D3DXPT_FLOAT; diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 5bed9c7e..406e938d 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -648,6 +648,7 @@ static uint32_t write_fx_2_parameter(const struct hlsl_type *type, const char *n switch (type->base_type) { + case HLSL_TYPE_DOUBLE: case HLSL_TYPE_HALF: case HLSL_TYPE_FLOAT: case HLSL_TYPE_BOOL: