Not known to occur anywhere, but it is a regression from release 1.7. We need a test for SV_ClipDistance in a pixel shader, but it's a bit late to add that before the release.
From: Conor McCarthy cmccarthy@codeweavers.com
Clip/cull distance can appear as input in pixel shaders, and the array size must not be forced to zero. --- libs/vkd3d-shader/spirv.c | 5 ++++- libs/vkd3d-shader/vkd3d_shader_private.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 2197b74dd..f72875e1a 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -4714,8 +4714,11 @@ static uint32_t spirv_compiler_emit_input(struct spirv_compiler *compiler,
array_sizes[0] = (reg->type == VKD3DSPR_PATCHCONST ? 0 : compiler->input_control_point_count); array_sizes[1] = signature_element->register_count; - if (array_sizes[1] == 1 && !vsir_sysval_semantic_is_tess_factor(signature_element->sysval_semantic)) + if (array_sizes[1] == 1 && !vsir_sysval_semantic_is_tess_factor(signature_element->sysval_semantic) + && (!vsir_sysval_semantic_is_clip_cull(signature_element->sysval_semantic) || array_sizes[0])) + { array_sizes[1] = 0; + }
write_mask = signature_element->mask;
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index d3989672b..267b467ee 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -980,6 +980,11 @@ static inline bool vsir_sysval_semantic_is_tess_factor(enum vkd3d_shader_sysval_ && sysval_semantic <= VKD3D_SHADER_SV_TESS_FACTOR_LINEDEN; }
+static inline bool vsir_sysval_semantic_is_clip_cull(enum vkd3d_shader_sysval_semantic sysval_semantic) +{ + return sysval_semantic == VKD3D_SHADER_SV_CLIP_DISTANCE || sysval_semantic == VKD3D_SHADER_SV_CULL_DISTANCE; +} + struct signature_element *vsir_signature_find_element_for_reg(const struct shader_signature *signature, unsigned int reg_idx, unsigned int write_mask); void shader_signature_cleanup(struct shader_signature *signature);
More accurately, not known to occur in any game supported upstream, but some Diablo IV SM 6 shaders have this issue.
Oops. Good catch.
We need a test for SV_ClipDistance in a pixel shader, but it's a bit late to add that before the release.
Is this on your list then? If not I can try to write one myself.
On Thu Dec 7 01:33:54 2023 +0000, Zebediah Figura wrote:
Oops. Good catch.
We need a test for SV_ClipDistance in a pixel shader, but it's a bit
late to add that before the release. Is this on your list then? If not I can try to write one myself.
It's a "when I get around to it" item, so please feel free to write one.
This merge request was closed by Conor McCarthy.
Went upstream with the release MR.