From 6b8d4cca7e2d2ae304cf5dc305dd5ae18648c9be Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 23 Nov 2024 18:10:53 -0500 Subject: [PATCH] hk: be robust against invalid MSAA inputs fixes vkd3d-proton test_multisample_rendering Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/vulkan/hk_cmd_draw.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/asahi/vulkan/hk_cmd_draw.c b/src/asahi/vulkan/hk_cmd_draw.c index c5e6a8debfc..5881e340520 100644 --- a/src/asahi/vulkan/hk_cmd_draw.c +++ b/src/asahi/vulkan/hk_cmd_draw.c @@ -2968,12 +2968,16 @@ hk_flush_dynamic_state(struct hk_cmd_buffer *cmd, struct hk_cs *cs, /* With attachmentless rendering, we don't know the sample count until draw * time, so we do a late tilebuffer fix up. But with rasterizer discard, * rasterization_samples might be 0. + * + * Note that we ignore dyn->ms.rasterization_samples when we do have a sample + * count from an attachment. In Vulkan, these have to match anyway, but DX12 + * drivers are robust against this scenarios and vkd3d-proton will go out of + * spec here. No reason we can't be robust here too. */ - if (dyn->ms.rasterization_samples && - gfx->render.tilebuffer.nr_samples != dyn->ms.rasterization_samples) { + if (dyn->ms.rasterization_samples && !gfx->render.tilebuffer.nr_samples) { + agx_tilebuffer_set_samples(&gfx->render.tilebuffer, + dyn->ms.rasterization_samples); - unsigned nr_samples = MAX2(dyn->ms.rasterization_samples, 1); - agx_tilebuffer_set_samples(&gfx->render.tilebuffer, nr_samples); cs->tib = gfx->render.tilebuffer; }