From ae27fded1a039fda84b526cd9bd7b64aeb5573b5 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Wed, 2 Oct 2024 09:48:02 +0200 Subject: [PATCH] vkd3d-shader/spirv: Handle all possible destination modifiers. Historically the SPIR-V backend was only fed by the TPF parser, which only generates _sat destination modifiers. Now it is fed by the D3DBC parser too (among others), so it mustn't assert on other modifiers. Modifier _pp can be trivially ignored. Modifier _centroid would probably require some handling, but I'm not immediately sure of what should happen and it doesn't look like a very urgent thing anyway, so I'm degrading the assertion to FIXME(). --- libs/vkd3d-shader/spirv.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 37415597..140a8cd0 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -4544,9 +4544,24 @@ static uint32_t spirv_compiler_emit_sat(struct spirv_compiler *compiler, static void spirv_compiler_emit_store_dst(struct spirv_compiler *compiler, const struct vkd3d_shader_dst_param *dst, uint32_t val_id) { - VKD3D_ASSERT(!(dst->modifiers & ~VKD3DSPDM_SATURATE)); - if (dst->modifiers & VKD3DSPDM_SATURATE) + uint32_t modifiers = dst->modifiers; + + /* It is always legitimate to ignore _pp. */ + modifiers &= ~VKD3DSPDM_PARTIALPRECISION; + + if (modifiers & VKD3DSPDM_SATURATE) + { val_id = spirv_compiler_emit_sat(compiler, &dst->reg, dst->write_mask, val_id); + modifiers &= ~VKD3DSPDM_SATURATE; + } + + if (dst->modifiers & VKD3DSPDM_MSAMPCENTROID) + { + FIXME("Ignoring _centroid modifier.\n"); + modifiers &= ~VKD3DSPDM_MSAMPCENTROID; + } + + VKD3D_ASSERT(!modifiers); spirv_compiler_emit_store_reg(compiler, &dst->reg, dst->write_mask, val_id); }