Prevents a non-zero value at or above bit 14 from causing abs/negate values to be skipped, and emits proper warning and fixme messages.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 53 ++++++++++++++++++++++++---------------- libs/vkd3d-shader/sm4.h | 22 +++++++++++++---- 2 files changed, 49 insertions(+), 26 deletions(-)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 83f91960..8bb07a2b 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -1188,8 +1188,10 @@ static bool shader_sm4_read_param(struct vkd3d_sm4_data *priv, const DWORD **ptr } param->data_type = data_type;
- if (token & VKD3D_SM4_REGISTER_MODIFIER) + *modifier = VKD3DSPSM_NONE; + if (token & VKD3D_SM4_EXTENDED_OPERAND) { + enum vkd3d_sm4_extended_operand_type type; DWORD m;
if (*ptr >= end) @@ -1198,32 +1200,41 @@ static bool shader_sm4_read_param(struct vkd3d_sm4_data *priv, const DWORD **ptr return false; } m = *(*ptr)++; + type = m & VKD3D_SM4_EXTENDED_OPERAND_TYPE_MASK;
- switch (m) + if (type == VKD3D_SM4_EXTENDED_OPERAND_MODIFIER) { - case VKD3D_SM4_REGISTER_MODIFIER_NEGATE: - *modifier = VKD3DSPSM_NEG; - break; + unsigned int op_modifier = (m & VKD3D_SM4_REGISTER_MODIFIER_MASK) >> VKD3D_SM4_REGISTER_MODIFIER_SHIFT;
- case VKD3D_SM4_REGISTER_MODIFIER_ABS: - *modifier = VKD3DSPSM_ABS; - break; + switch (op_modifier & VKD3D_SM4_REGISTER_MODIFIER_ABS_NEGATE) + { + case VKD3D_SM4_REGISTER_MODIFIER_NEGATE: + *modifier = VKD3DSPSM_NEG; + break;
- case VKD3D_SM4_REGISTER_MODIFIER_ABS_NEGATE: - *modifier = VKD3DSPSM_ABSNEG; - break; + case VKD3D_SM4_REGISTER_MODIFIER_ABS: + *modifier = VKD3DSPSM_ABS; + break;
- default: - FIXME("Skipping modifier 0x%08x.\n", m); - /* fall-through */ - case VKD3D_SM4_REGISTER_MODIFIER_NONE: - *modifier = VKD3DSPSM_NONE; - break; + case VKD3D_SM4_REGISTER_MODIFIER_ABS_NEGATE: + *modifier = VKD3DSPSM_ABSNEG; + break; + + default: + break; + } + op_modifier &= ~VKD3D_SM4_REGISTER_MODIFIER_ABS_NEGATE; + if (op_modifier) + FIXME("Skipping modifier flags %#x.\n", op_modifier); } - } - else - { - *modifier = VKD3DSPSM_NONE; + else if (type) + { + FIXME("Unhandled extended operand type %#x.\n", type); + } + + m &= ~0u << VKD3D_SM4_REGISTER_MIN_PRECIS_SHIFT; + if (m) + FIXME("Skipping modifier 0x%08x.\n", m); }
order = (token & VKD3D_SM4_REGISTER_ORDER_MASK) >> VKD3D_SM4_REGISTER_ORDER_SHIFT; diff --git a/libs/vkd3d-shader/sm4.h b/libs/vkd3d-shader/sm4.h index b4dd1632..8dd00590 100644 --- a/libs/vkd3d-shader/sm4.h +++ b/libs/vkd3d-shader/sm4.h @@ -94,7 +94,14 @@
#define VKD3D_SM4_OPCODE_MASK 0xff
-#define VKD3D_SM4_REGISTER_MODIFIER (0x1u << 31) +#define VKD3D_SM4_EXTENDED_OPERAND (0x1u << 31) + +#define VKD3D_SM4_EXTENDED_OPERAND_TYPE_MASK 0x1fu + +#define VKD3D_SM4_REGISTER_MODIFIER_SHIFT 6 +#define VKD3D_SM4_REGISTER_MODIFIER_MASK (0xffu << VKD3D_SM4_REGISTER_MODIFIER_SHIFT) + +#define VKD3D_SM4_REGISTER_MIN_PRECIS_SHIFT 14
#define VKD3D_SM4_ADDRESSING_SHIFT2 28 #define VKD3D_SM4_ADDRESSING_MASK2 (0x3u << VKD3D_SM4_ADDRESSING_SHIFT2) @@ -388,12 +395,17 @@ enum vkd3d_sm4_register_type VKD3D_SM5_RT_DEPTHOUT_LESS_EQUAL = 0x27, };
+enum vkd3d_sm4_extended_operand_type +{ + VKD3D_SM4_EXTENDED_OPERAND_NONE = 0x0, + VKD3D_SM4_EXTENDED_OPERAND_MODIFIER = 0x1, +}; + enum vkd3d_sm4_register_modifier { - VKD3D_SM4_REGISTER_MODIFIER_NONE = 0x01, - VKD3D_SM4_REGISTER_MODIFIER_NEGATE = 0x41, - VKD3D_SM4_REGISTER_MODIFIER_ABS = 0x81, - VKD3D_SM4_REGISTER_MODIFIER_ABS_NEGATE = 0xc1, + VKD3D_SM4_REGISTER_MODIFIER_NEGATE = 0x1, + VKD3D_SM4_REGISTER_MODIFIER_ABS = 0x2, + VKD3D_SM4_REGISTER_MODIFIER_ABS_NEGATE = 0x3, };
enum vkd3d_sm4_output_primitive_type